]>
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 | |
3eeb4801 | 512 | -gcodeview |
43b72ede AA |
513 | -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 |
514 | -gstatement-frontiers -gno-statement-frontiers | |
515 | -gvariable-location-views -gno-variable-location-views | |
516 | -ginternal-reset-location-views -gno-internal-reset-location-views | |
517 | -ginline-points -gno-inline-points | |
518 | -gvms -gz@r{[}=@var{type}@r{]} | |
519 | -gsplit-dwarf -gdescribe-dies -gno-describe-dies | |
520 | -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section | |
521 | -fno-eliminate-unused-debug-types | |
522 | -femit-struct-debug-baseonly -femit-struct-debug-reduced | |
523 | -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} | |
524 | -fno-eliminate-unused-debug-symbols -femit-class-debug-always | |
525 | -fno-merge-debug-strings -fno-dwarf2-cfi-asm | |
d77de738 ML |
526 | -fvar-tracking -fvar-tracking-assignments} |
527 | ||
528 | @item Optimization Options | |
529 | @xref{Optimize Options,,Options that Control Optimization}. | |
43b72ede AA |
530 | @gccoptlist{-faggressive-loop-optimizations |
531 | -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
532 | -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
533 | -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
534 | -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
535 | -fno-allocation-dce -fallow-store-data-races | |
536 | -fassociative-math -fauto-profile -fauto-profile[=@var{path}] | |
537 | -fauto-inc-dec -fbranch-probabilities | |
538 | -fcaller-saves | |
539 | -fcombine-stack-adjustments -fconserve-stack | |
540 | -fcompare-elim -fcprop-registers -fcrossjumping | |
541 | -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules | |
542 | -fcx-limited-range | |
543 | -fdata-sections -fdce -fdelayed-branch | |
544 | -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively | |
545 | -fdevirtualize-at-ltrans -fdse | |
546 | -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects | |
547 | -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} | |
548 | -ffinite-loops | |
549 | -fforward-propagate -ffp-contract=@var{style} -ffunction-sections | |
550 | -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity | |
551 | -fgcse-sm -fhoist-adjacent-loads -fif-conversion | |
552 | -fif-conversion2 -findirect-inlining | |
553 | -finline-functions -finline-functions-called-once -finline-limit=@var{n} | |
554 | -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone | |
555 | -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const | |
556 | -fipa-reference -fipa-reference-addressable | |
557 | -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} | |
558 | -flive-patching=@var{level} | |
559 | -fira-region=@var{region} -fira-hoist-pressure | |
560 | -fira-loop-pressure -fno-ira-share-save-slots | |
561 | -fno-ira-share-spill-slots | |
562 | -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute | |
563 | -fivopts -fkeep-inline-functions -fkeep-static-functions | |
564 | -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage | |
565 | -floop-block -floop-interchange -floop-strip-mine | |
566 | -floop-unroll-and-jam -floop-nest-optimize | |
567 | -floop-parallelize-all -flra-remat -flto -flto-compression-level | |
568 | -flto-partition=@var{alg} -fmerge-all-constants | |
569 | -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves | |
570 | -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg | |
571 | -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse | |
572 | -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole | |
573 | -fno-peephole2 -fno-printf-return-value -fno-sched-interblock | |
574 | -fno-sched-spec -fno-signed-zeros | |
575 | -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss | |
576 | -fomit-frame-pointer -foptimize-sibling-calls | |
577 | -fpartial-inlining -fpeel-loops -fpredictive-commoning | |
578 | -fprefetch-loop-arrays | |
579 | -fprofile-correction | |
580 | -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training | |
581 | -fprofile-values -fprofile-reorder-functions | |
582 | -freciprocal-math -free -frename-registers -freorder-blocks | |
583 | -freorder-blocks-algorithm=@var{algorithm} | |
584 | -freorder-blocks-and-partition -freorder-functions | |
585 | -frerun-cse-after-loop -freschedule-modulo-scheduled-loops | |
586 | -frounding-math -fsave-optimization-record | |
587 | -fsched2-use-superblocks -fsched-pressure | |
588 | -fsched-spec-load -fsched-spec-load-dangerous | |
589 | -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] | |
590 | -fsched-group-heuristic -fsched-critical-path-heuristic | |
591 | -fsched-spec-insn-heuristic -fsched-rank-heuristic | |
592 | -fsched-last-insn-heuristic -fsched-dep-count-heuristic | |
593 | -fschedule-fusion | |
594 | -fschedule-insns -fschedule-insns2 -fsection-anchors | |
595 | -fselective-scheduling -fselective-scheduling2 | |
596 | -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops | |
597 | -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate | |
598 | -fsignaling-nans | |
599 | -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops | |
600 | -fsplit-paths | |
601 | -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt | |
602 | -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing | |
603 | -fthread-jumps -ftracer -ftree-bit-ccp | |
604 | -ftree-builtin-call-dce -ftree-ccp -ftree-ch | |
605 | -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts | |
606 | -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting | |
607 | -ftree-loop-if-convert -ftree-loop-im | |
608 | -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns | |
609 | -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize | |
610 | -ftree-loop-vectorize | |
611 | -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta | |
612 | -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra | |
613 | -ftree-switch-conversion -ftree-tail-merge | |
614 | -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init | |
615 | -funconstrained-commons -funit-at-a-time -funroll-all-loops | |
616 | -funroll-loops -funsafe-math-optimizations -funswitch-loops | |
617 | -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt | |
618 | -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs | |
d77de738 ML |
619 | --param @var{name}=@var{value} |
620 | -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz} | |
621 | ||
622 | @item Program Instrumentation Options | |
623 | @xref{Instrumentation Options,,Program Instrumentation Options}. | |
43b72ede AA |
624 | @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage |
625 | -fprofile-abs-path | |
626 | -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} | |
627 | -fprofile-info-section -fprofile-info-section=@var{name} | |
628 | -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} | |
629 | -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} | |
630 | -fprofile-exclude-files=@var{regex} | |
631 | -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} | |
632 | -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} | |
633 | -fsanitize-trap -fsanitize-trap=@var{style} | |
634 | -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... | |
635 | -fsanitize-undefined-trap-on-error -fbounds-check | |
636 | -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} | |
637 | -fharden-compares -fharden-conditional-branches | |
638 | -fstack-protector -fstack-protector-all -fstack-protector-strong | |
639 | -fstack-protector-explicit -fstack-check | |
640 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} | |
641 | -fno-stack-limit -fsplit-stack | |
642 | -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} | |
643 | -fvtv-counts -fvtv-debug | |
644 | -finstrument-functions -finstrument-functions-once | |
645 | -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} | |
646 | -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} | |
647 | -fprofile-prefix-map=@var{old}=@var{new}} | |
d77de738 ML |
648 | |
649 | @item Preprocessor Options | |
650 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
43b72ede AA |
651 | @gccoptlist{-A@var{question}=@var{answer} |
652 | -A-@var{question}@r{[}=@var{answer}@r{]} | |
653 | -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} | |
654 | -dD -dI -dM -dN -dU | |
655 | -fdebug-cpp -fdirectives-only -fdollars-in-identifiers | |
656 | -fexec-charset=@var{charset} -fextended-identifiers | |
657 | -finput-charset=@var{charset} -flarge-source-files | |
658 | -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} | |
659 | -fno-canonical-system-headers -fpch-deps -fpch-preprocess | |
660 | -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion | |
661 | -fwide-exec-charset=@var{charset} -fworking-directory | |
662 | -H -imacros @var{file} -include @var{file} | |
663 | -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules | |
664 | -no-integrated-cpp -P -pthread -remap | |
665 | -traditional -traditional-cpp -trigraphs | |
666 | -U@var{macro} -undef | |
d77de738 ML |
667 | -Wp,@var{option} -Xpreprocessor @var{option}} |
668 | ||
669 | @item Assembler Options | |
670 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
671 | @gccoptlist{-Wa,@var{option} -Xassembler @var{option}} | |
672 | ||
673 | @item Linker Options | |
674 | @xref{Link Options,,Options for Linking}. | |
43b72ede AA |
675 | @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} |
676 | -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ | |
677 | -e @var{entry} --entry=@var{entry} | |
678 | -pie -pthread -r -rdynamic | |
679 | -s -static -static-pie -static-libgcc -static-libstdc++ | |
680 | -static-libasan -static-libtsan -static-liblsan -static-libubsan | |
681 | -shared -shared-libgcc -symbolic | |
682 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} | |
d77de738 ML |
683 | -u @var{symbol} -z @var{keyword}} |
684 | ||
685 | @item Directory Options | |
686 | @xref{Directory Options,,Options for Directory Search}. | |
43b72ede AA |
687 | @gccoptlist{-B@var{prefix} -I@var{dir} -I- |
688 | -idirafter @var{dir} | |
689 | -imacros @var{file} -imultilib @var{dir} | |
690 | -iplugindir=@var{dir} -iprefix @var{file} | |
691 | -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} | |
692 | -iwithprefix @var{dir} -iwithprefixbefore @var{dir} | |
693 | -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix | |
d77de738 ML |
694 | -nostdinc -nostdinc++ --sysroot=@var{dir}} |
695 | ||
696 | @item Code Generation Options | |
697 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
43b72ede AA |
698 | @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} |
699 | -ffixed-@var{reg} -fexceptions | |
700 | -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables | |
701 | -fasynchronous-unwind-tables | |
702 | -fno-gnu-unique | |
703 | -finhibit-size-directive -fcommon -fno-ident | |
704 | -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt | |
705 | -fno-jump-tables -fno-bit-tests | |
706 | -frecord-gcc-switches | |
707 | -freg-struct-return -fshort-enums -fshort-wchar | |
708 | -fverbose-asm -fpack-struct[=@var{n}] | |
709 | -fleading-underscore -ftls-model=@var{model} | |
710 | -fstack-reuse=@var{reuse_level} | |
711 | -ftrampolines -ftrapv -fwrapv | |
712 | -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} | |
d77de738 ML |
713 | -fstrict-volatile-bitfields -fsync-libcalls} |
714 | ||
715 | @item Developer Options | |
716 | @xref{Developer Options,,GCC Developer Options}. | |
43b72ede | 717 | @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion |
d77de738 | 718 | -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]} |
43b72ede AA |
719 | -fchecking -fchecking=@var{n} |
720 | -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} | |
721 | -fdisable-ipa-@var{pass_name} | |
722 | -fdisable-rtl-@var{pass_name} | |
723 | -fdisable-rtl-@var{pass-name}=@var{range-list} | |
724 | -fdisable-tree-@var{pass_name} | |
725 | -fdisable-tree-@var{pass-name}=@var{range-list} | |
726 | -fdump-debug -fdump-earlydebug | |
727 | -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links | |
728 | -fdump-final-insns@r{[}=@var{file}@r{]} | |
729 | -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline | |
730 | -fdump-lang-all | |
731 | -fdump-lang-@var{switch} | |
732 | -fdump-lang-@var{switch}-@var{options} | |
733 | -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
734 | -fdump-passes | |
735 | -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} | |
736 | -fdump-statistics | |
737 | -fdump-tree-all | |
738 | -fdump-tree-@var{switch} | |
739 | -fdump-tree-@var{switch}-@var{options} | |
740 | -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
741 | -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second | |
742 | -fenable-@var{kind}-@var{pass} | |
743 | -fenable-@var{kind}-@var{pass}=@var{range-list} | |
744 | -fira-verbose=@var{n} | |
745 | -flto-report -flto-report-wpa -fmem-report-wpa | |
746 | -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report | |
747 | -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} | |
748 | -fmultiflags -fprofile-report | |
749 | -frandom-seed=@var{string} -fsched-verbose=@var{n} | |
750 | -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose | |
751 | -fstats -fstack-usage -ftime-report -ftime-report-details | |
752 | -fvar-tracking-assignments-toggle -gtoggle | |
753 | -print-file-name=@var{library} -print-libgcc-file-name | |
754 | -print-multi-directory -print-multi-lib -print-multi-os-directory | |
755 | -print-prog-name=@var{program} -print-search-dirs -Q | |
756 | -print-sysroot -print-sysroot-headers-suffix | |
d77de738 ML |
757 | -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}} |
758 | ||
759 | @item Machine-Dependent Options | |
760 | @xref{Submodel Options,,Machine-Dependent Options}. | |
761 | @c This list is ordered alphanumerically by subsection name. | |
762 | @c Try and put the significant identifier (CPU or system) first, | |
763 | @c so users have a clue at guessing where the ones they want will be. | |
764 | ||
765 | @emph{AArch64 Options} | |
43b72ede AA |
766 | @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian |
767 | -mgeneral-regs-only | |
768 | -mcmodel=tiny -mcmodel=small -mcmodel=large | |
769 | -mstrict-align -mno-strict-align | |
770 | -momit-leaf-frame-pointer | |
771 | -mtls-dialect=desc -mtls-dialect=traditional | |
772 | -mtls-size=@var{size} | |
773 | -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 | |
774 | -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div | |
775 | -mpc-relative-literal-loads | |
776 | -msign-return-address=@var{scope} | |
d77de738 | 777 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf} |
43b72ede AA |
778 | +@var{b-key}]|@var{bti} |
779 | -mharden-sls=@var{opts} | |
780 | -march=@var{name} -mcpu=@var{name} -mtune=@var{name} | |
781 | -moverride=@var{string} -mverbose-cost-dump | |
782 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} | |
783 | -mstack-protector-guard-offset=@var{offset} -mtrack-speculation | |
d77de738 ML |
784 | -moutline-atomics } |
785 | ||
786 | @emph{Adapteva Epiphany Options} | |
43b72ede AA |
787 | @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs |
788 | -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf | |
789 | -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} | |
790 | -mround-nearest -mlong-calls -mshort-calls -msmall16 | |
791 | -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} | |
d77de738 ML |
792 | -msplit-vecmove-early -m1reg-@var{reg}} |
793 | ||
794 | @emph{AMD GCN Options} | |
795 | @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}} | |
796 | ||
797 | @emph{ARC Options} | |
43b72ede AA |
798 | @gccoptlist{-mbarrel-shifter -mjli-always |
799 | -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 | |
800 | -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr | |
801 | -mea -mno-mpy -mmul32x16 -mmul64 -matomic | |
802 | -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap | |
803 | -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape | |
804 | -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof | |
805 | -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved | |
806 | -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} | |
807 | -mvolatile-cache -mtp-regno=@var{regno} | |
808 | -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc | |
809 | -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi | |
810 | -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none | |
811 | -mlra-priority-compact -mlra-priority-noncompact -mmillicode | |
812 | -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} | |
813 | -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame | |
814 | -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} | |
d77de738 ML |
815 | -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index} |
816 | ||
817 | @emph{ARM Options} | |
43b72ede AA |
818 | @gccoptlist{-mapcs-frame -mno-apcs-frame |
819 | -mabi=@var{name} | |
820 | -mapcs-stack-check -mno-apcs-stack-check | |
821 | -mapcs-reentrant -mno-apcs-reentrant | |
822 | -mgeneral-regs-only | |
823 | -msched-prolog -mno-sched-prolog | |
824 | -mlittle-endian -mbig-endian | |
825 | -mbe8 -mbe32 | |
826 | -mfloat-abi=@var{name} | |
d77de738 | 827 | -mfp16-format=@var{name} |
43b72ede AA |
828 | -mthumb-interwork -mno-thumb-interwork |
829 | -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} | |
830 | -mtune=@var{name} -mprint-tune-info | |
831 | -mstructure-size-boundary=@var{n} | |
832 | -mabort-on-noreturn | |
833 | -mlong-calls -mno-long-calls | |
834 | -msingle-pic-base -mno-single-pic-base | |
835 | -mpic-register=@var{reg} | |
836 | -mnop-fun-dllimport | |
837 | -mpoke-function-name | |
838 | -mthumb -marm -mflip-thumb | |
839 | -mtpcs-frame -mtpcs-leaf-frame | |
840 | -mcaller-super-interworking -mcallee-super-interworking | |
841 | -mtp=@var{name} -mtls-dialect=@var{dialect} | |
842 | -mword-relocations | |
843 | -mfix-cortex-m3-ldrd | |
844 | -mfix-cortex-a57-aes-1742098 | |
845 | -mfix-cortex-a72-aes-1655431 | |
846 | -munaligned-access | |
847 | -mneon-for-64bits | |
848 | -mslow-flash-data | |
849 | -masm-syntax-unified | |
850 | -mrestrict-it | |
851 | -mverbose-cost-dump | |
852 | -mpure-code | |
853 | -mcmse | |
854 | -mfix-cmse-cve-2021-35465 | |
855 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} | |
856 | -mfdpic | |
14fab5fb AC |
857 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] |
858 | [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} | |
d77de738 ML |
859 | |
860 | @emph{AVR Options} | |
43b72ede AA |
861 | @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args |
862 | -mbranch-cost=@var{cost} | |
863 | -mcall-prologues -mgas-isr-prologues -mint8 | |
864 | -mdouble=@var{bits} -mlong-double=@var{bits} | |
865 | -mn_flash=@var{size} -mno-interrupts | |
866 | -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack | |
867 | -mfract-convert-truncate | |
868 | -mshort-calls -nodevicelib -nodevicespecs | |
d77de738 ML |
869 | -Waddr-space-convert -Wmisspelled-isr} |
870 | ||
871 | @emph{Blackfin Options} | |
43b72ede AA |
872 | @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
873 | -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer | |
874 | -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly | |
875 | -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library | |
876 | -mno-id-shared-library -mshared-library-id=@var{n} | |
877 | -mleaf-id-shared-library -mno-leaf-id-shared-library | |
878 | -msep-data -mno-sep-data -mlong-calls -mno-long-calls | |
879 | -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram | |
d77de738 ML |
880 | -micplb} |
881 | ||
882 | @emph{C6X Options} | |
43b72ede | 883 | @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} |
d77de738 ML |
884 | -msim -msdata=@var{sdata-type}} |
885 | ||
886 | @emph{CRIS Options} | |
887 | @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} | |
43b72ede AA |
888 | -mtune=@var{cpu} -mmax-stack-frame=@var{n} |
889 | -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects | |
890 | -mstack-align -mdata-align -mconst-align | |
891 | -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue | |
892 | -melf -maout -sim -sim2 | |
d77de738 ML |
893 | -mmul-bug-workaround -mno-mul-bug-workaround} |
894 | ||
895 | @emph{C-SKY Options} | |
43b72ede AA |
896 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} |
897 | -mbig-endian -EB -mlittle-endian -EL | |
898 | -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu | |
899 | -mfloat-abi=@var{name} | |
900 | -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust | |
901 | -mdsp -medsp -mvdsp | |
902 | -mdiv -msmart -mhigh-registers -manchor | |
903 | -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt | |
d77de738 ML |
904 | -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim} |
905 | ||
906 | @emph{Darwin Options} | |
43b72ede AA |
907 | @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal |
908 | -arch_only -bind_at_load -bundle -bundle_loader | |
909 | -client_name -compatibility_version -current_version | |
910 | -dead_strip | |
911 | -dependency-file -dylib_file -dylinker_install_name | |
912 | -dynamic -dynamiclib -exported_symbols_list | |
913 | -filelist -flat_namespace -force_cpusubtype_ALL | |
914 | -force_flat_namespace -headerpad_max_install_names | |
915 | -iframework | |
916 | -image_base -init -install_name -keep_private_externs | |
917 | -multi_module -multiply_defined -multiply_defined_unused | |
918 | -noall_load -no_dead_strip_inits_and_terms | |
919 | -nofixprebinding -nomultidefs -noprebind -noseglinkedit | |
920 | -pagezero_size -prebind -prebind_all_twolevel_modules | |
921 | -private_bundle -read_only_relocs -sectalign | |
922 | -sectobjectsymbols -whyload -seg1addr | |
923 | -sectcreate -sectobjectsymbols -sectorder | |
924 | -segaddr -segs_read_only_addr -segs_read_write_addr | |
925 | -seg_addr_table -seg_addr_table_filename -seglinkedit | |
926 | -segprot -segs_read_only_addr -segs_read_write_addr | |
927 | -single_module -static -sub_library -sub_umbrella | |
928 | -twolevel_namespace -umbrella -undefined | |
929 | -unexported_symbols_list -weak_reference_mismatches | |
930 | -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} | |
d77de738 ML |
931 | -mkernel -mone-byte-bool} |
932 | ||
933 | @emph{DEC Alpha Options} | |
43b72ede AA |
934 | @gccoptlist{-mno-fp-regs -msoft-float |
935 | -mieee -mieee-with-inexact -mieee-conformant | |
936 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} | |
937 | -mtrap-precision=@var{mode} -mbuild-constants | |
938 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} | |
939 | -mbwx -mmax -mfix -mcix | |
940 | -mfloat-vax -mfloat-ieee | |
941 | -mexplicit-relocs -msmall-data -mlarge-data | |
942 | -msmall-text -mlarge-text | |
d77de738 ML |
943 | -mmemory-latency=@var{time}} |
944 | ||
945 | @emph{eBPF Options} | |
946 | @gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version} | |
947 | -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re | |
948 | -mjmpext -mjmp32 -malu32 -mcpu=@var{version}} | |
949 | ||
950 | @emph{FR30 Options} | |
951 | @gccoptlist{-msmall-model -mno-lsim} | |
952 | ||
953 | @emph{FT32 Options} | |
954 | @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm} | |
955 | ||
956 | @emph{FRV Options} | |
43b72ede AA |
957 | @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 |
958 | -mhard-float -msoft-float | |
959 | -malloc-cc -mfixed-cc -mdword -mno-dword | |
960 | -mdouble -mno-double | |
961 | -mmedia -mno-media -mmuladd -mno-muladd | |
962 | -mfdpic -minline-plt -mgprel-ro -multilib-library-pic | |
963 | -mlinked-fp -mlong-calls -malign-labels | |
964 | -mlibrary-pic -macc-4 -macc-8 | |
965 | -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move | |
966 | -moptimize-membar -mno-optimize-membar | |
967 | -mscc -mno-scc -mcond-exec -mno-cond-exec | |
968 | -mvliw-branch -mno-vliw-branch | |
969 | -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec | |
970 | -mno-nested-cond-exec -mtomcat-stats | |
971 | -mTLS -mtls | |
d77de738 ML |
972 | -mcpu=@var{cpu}} |
973 | ||
974 | @emph{GNU/Linux Options} | |
43b72ede | 975 | @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid |
d77de738 ML |
976 | -tno-android-cc -tno-android-ld} |
977 | ||
978 | @emph{H8/300 Options} | |
979 | @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300} | |
980 | ||
981 | @emph{HPPA Options} | |
43b72ede AA |
982 | @gccoptlist{-march=@var{architecture-type} |
983 | -matomic-libcalls -mbig-switch | |
984 | -mcaller-copies -mdisable-fpregs -mdisable-indexing | |
985 | -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld | |
986 | -mfixed-range=@var{register-range} | |
987 | -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls | |
988 | -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs | |
989 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
990 | -mno-jump-in-delay -mno-long-load-store | |
991 | -mno-portable-runtime -mno-soft-float | |
992 | -mno-space-regs -msoft-float -mpa-risc-1-0 | |
993 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime | |
994 | -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio | |
d77de738 ML |
995 | -munix=@var{unix-std} -nolibdld -static -threads} |
996 | ||
997 | @emph{IA-64 Options} | |
43b72ede AA |
998 | @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic |
999 | -mvolatile-asm-stop -mregister-names -msdata -mno-sdata | |
1000 | -mconstant-gp -mauto-pic -mfused-madd | |
1001 | -minline-float-divide-min-latency | |
1002 | -minline-float-divide-max-throughput | |
1003 | -mno-inline-float-divide | |
1004 | -minline-int-divide-min-latency | |
1005 | -minline-int-divide-max-throughput | |
1006 | -mno-inline-int-divide | |
1007 | -minline-sqrt-min-latency -minline-sqrt-max-throughput | |
1008 | -mno-inline-sqrt | |
1009 | -mdwarf2-asm -mearly-stop-bits | |
1010 | -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} | |
1011 | -mtune=@var{cpu-type} -milp32 -mlp64 | |
1012 | -msched-br-data-spec -msched-ar-data-spec -msched-control-spec | |
1013 | -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec | |
1014 | -msched-spec-ldc -msched-spec-control-ldc | |
1015 | -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns | |
1016 | -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path | |
1017 | -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost | |
d77de738 ML |
1018 | -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}} |
1019 | ||
1020 | @emph{LM32 Options} | |
43b72ede | 1021 | @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled |
d77de738 ML |
1022 | -msign-extend-enabled -muser-enabled} |
1023 | ||
1024 | @emph{LoongArch Options} | |
43b72ede AA |
1025 | @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} |
1026 | -mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float | |
1027 | -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division | |
1028 | -mcond-move-int -mno-cond-move-int | |
1029 | -mcond-move-float -mno-cond-move-float | |
1030 | -memcpy -mno-memcpy -mstrict-align -mno-strict-align | |
1031 | -mmax-inline-memcpy-size=@var{n} | |
1032 | -mexplicit-relocs -mno-explicit-relocs | |
1033 | -mdirect-extern-access -mno-direct-extern-access | |
d77de738 ML |
1034 | -mcmodel=@var{code-model}} |
1035 | ||
1036 | @emph{M32R/D Options} | |
43b72ede AA |
1037 | @gccoptlist{-m32r2 -m32rx -m32r |
1038 | -mdebug | |
1039 | -malign-loops -mno-align-loops | |
1040 | -missue-rate=@var{number} | |
1041 | -mbranch-cost=@var{number} | |
1042 | -mmodel=@var{code-size-model-type} | |
1043 | -msdata=@var{sdata-type} | |
1044 | -mno-flush-func -mflush-func=@var{name} | |
1045 | -mno-flush-trap -mflush-trap=@var{number} | |
d77de738 ML |
1046 | -G @var{num}} |
1047 | ||
1048 | @emph{M32C Options} | |
1049 | @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}} | |
1050 | ||
1051 | @emph{M680x0 Options} | |
43b72ede AA |
1052 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} |
1053 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 | |
1054 | -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 | |
1055 | -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 | |
1056 | -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort | |
1057 | -mno-short -mhard-float -m68881 -msoft-float -mpcrel | |
1058 | -malign-int -mstrict-align -msep-data -mno-sep-data | |
1059 | -mshared-library-id=n -mid-shared-library -mno-id-shared-library | |
d77de738 ML |
1060 | -mxgot -mno-xgot -mlong-jump-table-offsets} |
1061 | ||
1062 | @emph{MCore Options} | |
43b72ede AA |
1063 | @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates |
1064 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields | |
1065 | -m4byte-functions -mno-4byte-functions -mcallgraph-data | |
1066 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim | |
d77de738 ML |
1067 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} |
1068 | ||
d77de738 | 1069 | @emph{MicroBlaze Options} |
43b72ede AA |
1070 | @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} |
1071 | -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift | |
1072 | -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss | |
1073 | -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt | |
1074 | -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} | |
d77de738 ML |
1075 | -mpic-data-is-text-relative} |
1076 | ||
1077 | @emph{MIPS Options} | |
43b72ede AA |
1078 | @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} |
1079 | -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 | |
1080 | -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 | |
1081 | -mips16 -mno-mips16 -mflip-mips16 | |
1082 | -minterlink-compressed -mno-interlink-compressed | |
1083 | -minterlink-mips16 -mno-interlink-mips16 | |
1084 | -mabi=@var{abi} -mabicalls -mno-abicalls | |
1085 | -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot | |
1086 | -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float | |
1087 | -mno-float -msingle-float -mdouble-float | |
1088 | -modd-spreg -mno-odd-spreg | |
1089 | -mabs=@var{mode} -mnan=@var{encoding} | |
1090 | -mdsp -mno-dsp -mdspr2 -mno-dspr2 | |
1091 | -mmcu -mmno-mcu | |
1092 | -meva -mno-eva | |
1093 | -mvirt -mno-virt | |
1094 | -mxpa -mno-xpa | |
1095 | -mcrc -mno-crc | |
1096 | -mginv -mno-ginv | |
1097 | -mmicromips -mno-micromips | |
1098 | -mmsa -mno-msa | |
1099 | -mloongson-mmi -mno-loongson-mmi | |
1100 | -mloongson-ext -mno-loongson-ext | |
1101 | -mloongson-ext2 -mno-loongson-ext2 | |
1102 | -mfpu=@var{fpu-type} | |
1103 | -msmartmips -mno-smartmips | |
1104 | -mpaired-single -mno-paired-single -mdmx -mno-mdmx | |
1105 | -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc | |
1106 | -mlong64 -mlong32 -msym32 -mno-sym32 | |
1107 | -G@var{num} -mlocal-sdata -mno-local-sdata | |
1108 | -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt | |
1109 | -membedded-data -mno-embedded-data | |
1110 | -muninit-const-in-rodata -mno-uninit-const-in-rodata | |
1111 | -mcode-readable=@var{setting} | |
1112 | -msplit-addresses -mno-split-addresses | |
1113 | -mexplicit-relocs -mno-explicit-relocs | |
1114 | -mcheck-zero-division -mno-check-zero-division | |
1115 | -mdivide-traps -mdivide-breaks | |
1116 | -mload-store-pairs -mno-load-store-pairs | |
1117 | -munaligned-access -mno-unaligned-access | |
1118 | -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls | |
1119 | -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp | |
1120 | -mfix-24k -mno-fix-24k | |
1121 | -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 | |
1122 | -mfix-r5900 -mno-fix-r5900 | |
1123 | -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 | |
1124 | -mfix-vr4120 -mno-fix-vr4120 | |
1125 | -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 | |
1126 | -mflush-func=@var{func} -mno-flush-func | |
1127 | -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely | |
1128 | -mcompact-branches=@var{policy} | |
1129 | -mfp-exceptions -mno-fp-exceptions | |
1130 | -mvr4130-align -mno-vr4130-align -msynci -mno-synci | |
1131 | -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 | |
1132 | -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address | |
d77de738 ML |
1133 | -mframe-header-opt -mno-frame-header-opt} |
1134 | ||
1135 | @emph{MMIX Options} | |
43b72ede AA |
1136 | @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu |
1137 | -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols | |
1138 | -melf -mbranch-predict -mno-branch-predict -mbase-addresses | |
d77de738 ML |
1139 | -mno-base-addresses -msingle-exit -mno-single-exit} |
1140 | ||
1141 | @emph{MN10300 Options} | |
43b72ede AA |
1142 | @gccoptlist{-mmult-bug -mno-mult-bug |
1143 | -mno-am33 -mam33 -mam33-2 -mam34 | |
1144 | -mtune=@var{cpu-type} | |
1145 | -mreturn-pointer-on-d0 | |
d77de738 ML |
1146 | -mno-crt0 -mrelax -mliw -msetlb} |
1147 | ||
1148 | @emph{Moxie Options} | |
1149 | @gccoptlist{-meb -mel -mmul.x -mno-crt0} | |
1150 | ||
1151 | @emph{MSP430 Options} | |
43b72ede AA |
1152 | @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax |
1153 | -mwarn-mcu | |
1154 | -mcode-region= -mdata-region= | |
1155 | -msilicon-errata= -msilicon-errata-warn= | |
d77de738 ML |
1156 | -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=} |
1157 | ||
1158 | @emph{NDS32 Options} | |
43b72ede AA |
1159 | @gccoptlist{-mbig-endian -mlittle-endian |
1160 | -mreduced-regs -mfull-regs | |
1161 | -mcmov -mno-cmov | |
1162 | -mext-perf -mno-ext-perf | |
1163 | -mext-perf2 -mno-ext-perf2 | |
1164 | -mext-string -mno-ext-string | |
1165 | -mv3push -mno-v3push | |
1166 | -m16bit -mno-16bit | |
1167 | -misr-vector-size=@var{num} | |
1168 | -mcache-block-size=@var{num} | |
1169 | -march=@var{arch} | |
1170 | -mcmodel=@var{code-model} | |
d77de738 ML |
1171 | -mctor-dtor -mrelax} |
1172 | ||
1173 | @emph{Nios II Options} | |
43b72ede AA |
1174 | @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt |
1175 | -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} | |
1176 | -mel -meb | |
1177 | -mno-bypass-cache -mbypass-cache | |
1178 | -mno-cache-volatile -mcache-volatile | |
1179 | -mno-fast-sw-div -mfast-sw-div | |
1180 | -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div | |
1181 | -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} | |
1182 | -mcustom-fpu-cfg=@var{name} | |
1183 | -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} | |
d77de738 ML |
1184 | -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx} |
1185 | ||
1186 | @emph{Nvidia PTX Options} | |
1187 | @gccoptlist{-m64 -mmainkernel -moptimize} | |
1188 | ||
1189 | @emph{OpenRISC Options} | |
43b72ede AA |
1190 | @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div |
1191 | -msoft-mul -msoft-div | |
1192 | -msoft-float -mhard-float -mdouble-float -munordered-float | |
1193 | -mcmov -mror -mrori -msext -msfimm -mshftimm | |
d77de738 ML |
1194 | -mcmodel=@var{code-model}} |
1195 | ||
1196 | @emph{PDP-11 Options} | |
43b72ede AA |
1197 | @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 |
1198 | -mint32 -mno-int16 -mint16 -mno-int32 | |
d77de738 ML |
1199 | -msplit -munix-asm -mdec-asm -mgnu-asm -mlra} |
1200 | ||
d77de738 ML |
1201 | @emph{PowerPC Options} |
1202 | See RS/6000 and PowerPC Options. | |
1203 | ||
1204 | @emph{PRU Options} | |
43b72ede | 1205 | @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop |
f58e6d42 | 1206 | -mabi=@var{variant}} |
d77de738 ML |
1207 | |
1208 | @emph{RISC-V Options} | |
43b72ede AA |
1209 | @gccoptlist{-mbranch-cost=@var{N-instruction} |
1210 | -mplt -mno-plt | |
1211 | -mabi=@var{ABI-string} | |
1212 | -mfdiv -mno-fdiv | |
1213 | -mdiv -mno-div | |
1214 | -misa-spec=@var{ISA-spec-string} | |
1215 | -march=@var{ISA-string} | |
1216 | -mtune=@var{processor-string} | |
1217 | -mpreferred-stack-boundary=@var{num} | |
1218 | -msmall-data-limit=@var{N-bytes} | |
1219 | -msave-restore -mno-save-restore | |
1220 | -mshorten-memrefs -mno-shorten-memrefs | |
1221 | -mstrict-align -mno-strict-align | |
1222 | -mcmodel=medlow -mcmodel=medany | |
1223 | -mexplicit-relocs -mno-explicit-relocs | |
1224 | -mrelax -mno-relax | |
1225 | -mriscv-attribute -mno-riscv-attribute | |
1226 | -malign-data=@var{type} | |
1227 | -mbig-endian -mlittle-endian | |
1228 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1229 | -mstack-protector-guard-offset=@var{offset} | |
f797260a PN |
1230 | -mcsr-check -mno-csr-check |
1231 | -minline-atomics -mno-inline-atomics} | |
d77de738 ML |
1232 | |
1233 | @emph{RL78 Options} | |
43b72ede AA |
1234 | @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs |
1235 | -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 | |
d77de738 ML |
1236 | -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts} |
1237 | ||
1238 | @emph{RS/6000 and PowerPC Options} | |
43b72ede AA |
1239 | @gccoptlist{-mcpu=@var{cpu-type} |
1240 | -mtune=@var{cpu-type} | |
1241 | -mcmodel=@var{code-model} | |
1242 | -mpowerpc64 | |
1243 | -maltivec -mno-altivec | |
1244 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
1245 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
1246 | -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd | |
1247 | -mfprnd -mno-fprnd | |
1248 | -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp | |
1249 | -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc | |
1250 | -m64 -m32 -mxl-compat -mno-xl-compat -mpe | |
1251 | -malign-power -malign-natural | |
1252 | -msoft-float -mhard-float -mmultiple -mno-multiple | |
1253 | -mupdate -mno-update | |
1254 | -mavoid-indexed-addresses -mno-avoid-indexed-addresses | |
1255 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
1256 | -mstrict-align -mno-strict-align -mrelocatable | |
1257 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
1258 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian | |
1259 | -mdynamic-no-pic -mswdiv -msingle-pic-base | |
1260 | -mprioritize-restricted-insns=@var{priority} | |
1261 | -msched-costly-dep=@var{dependence_type} | |
1262 | -minsert-sched-nops=@var{scheme} | |
1263 | -mcall-aixdesc -mcall-eabi -mcall-freebsd | |
1264 | -mcall-linux -mcall-netbsd -mcall-openbsd | |
1265 | -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi | |
1266 | -mtraceback=@var{traceback_type} | |
1267 | -maix-struct-return -msvr4-struct-return | |
1268 | -mabi=@var{abi-type} -msecure-plt -mbss-plt | |
1269 | -mlongcall -mno-longcall -mpltseq -mno-pltseq | |
1270 | -mblock-move-inline-limit=@var{num} | |
1271 | -mblock-compare-inline-limit=@var{num} | |
1272 | -mblock-compare-inline-loop-limit=@var{num} | |
1273 | -mno-block-ops-unaligned-vsx | |
1274 | -mstring-compare-inline-limit=@var{num} | |
1275 | -misel -mno-isel | |
1276 | -mvrsave -mno-vrsave | |
1277 | -mmulhw -mno-mulhw | |
1278 | -mdlmzb -mno-dlmzb | |
1279 | -mprototype -mno-prototype | |
1280 | -msim -mmvme -mads -myellowknife -memb -msdata | |
1281 | -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} | |
1282 | -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision | |
1283 | -mno-recip-precision | |
1284 | -mveclibabi=@var{type} -mfriz -mno-friz | |
1285 | -mpointers-to-nested-functions -mno-pointers-to-nested-functions | |
1286 | -msave-toc-indirect -mno-save-toc-indirect | |
1287 | -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector | |
1288 | -mcrypto -mno-crypto -mhtm -mno-htm | |
1289 | -mquad-memory -mno-quad-memory | |
1290 | -mquad-memory-atomic -mno-quad-memory-atomic | |
1291 | -mcompat-align-parm -mno-compat-align-parm | |
1292 | -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware | |
1293 | -mgnu-attribute -mno-gnu-attribute | |
1294 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1295 | -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed | |
1296 | -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect | |
d77de738 ML |
1297 | -mprivileged -mno-privileged} |
1298 | ||
1299 | @emph{RX Options} | |
43b72ede AA |
1300 | @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu |
1301 | -mcpu= | |
1302 | -mbig-endian-data -mlittle-endian-data | |
1303 | -msmall-data | |
1304 | -msim -mno-sim | |
1305 | -mas100-syntax -mno-as100-syntax | |
1306 | -mrelax | |
1307 | -mmax-constant-size= | |
1308 | -mint-register= | |
1309 | -mpid | |
1310 | -mallow-string-insns -mno-allow-string-insns | |
1311 | -mjsr | |
1312 | -mno-warn-multiple-fast-interrupts | |
d77de738 ML |
1313 | -msave-acc-in-interrupts} |
1314 | ||
1315 | @emph{S/390 and zSeries Options} | |
43b72ede AA |
1316 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1317 | -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp | |
1318 | -mlong-double-64 -mlong-double-128 | |
1319 | -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack | |
1320 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle | |
1321 | -m64 -m31 -mdebug -mno-debug -mesa -mzarch | |
1322 | -mhtm -mvx -mzvector | |
1323 | -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip | |
1324 | -mfused-madd -mno-fused-madd | |
1325 | -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard | |
d77de738 ML |
1326 | -mhotpatch=@var{halfwords},@var{halfwords}} |
1327 | ||
d77de738 | 1328 | @emph{SH Options} |
43b72ede AA |
1329 | @gccoptlist{-m1 -m2 -m2e |
1330 | -m2a-nofpu -m2a-single-only -m2a-single -m2a | |
1331 | -m3 -m3e | |
1332 | -m4-nofpu -m4-single-only -m4-single -m4 | |
1333 | -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al | |
1334 | -mb -ml -mdalign -mrelax | |
1335 | -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave | |
1336 | -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct | |
1337 | -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} | |
1338 | -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} | |
1339 | -maccumulate-outgoing-args | |
1340 | -matomic-model=@var{atomic-model} | |
1341 | -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch | |
1342 | -mcbranch-force-delay-slot | |
1343 | -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra | |
d77de738 ML |
1344 | -mpretend-cmove -mtas} |
1345 | ||
1346 | @emph{Solaris 2 Options} | |
43b72ede | 1347 | @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text |
d77de738 ML |
1348 | -pthreads} |
1349 | ||
1350 | @emph{SPARC Options} | |
43b72ede AA |
1351 | @gccoptlist{-mcpu=@var{cpu-type} |
1352 | -mtune=@var{cpu-type} | |
1353 | -mcmodel=@var{code-model} | |
1354 | -mmemory-model=@var{mem-model} | |
1355 | -m32 -m64 -mapp-regs -mno-app-regs | |
1356 | -mfaster-structs -mno-faster-structs -mflat -mno-flat | |
1357 | -mfpu -mno-fpu -mhard-float -msoft-float | |
1358 | -mhard-quad-float -msoft-quad-float | |
1359 | -mstack-bias -mno-stack-bias | |
1360 | -mstd-struct-return -mno-std-struct-return | |
1361 | -munaligned-doubles -mno-unaligned-doubles | |
1362 | -muser-mode -mno-user-mode | |
1363 | -mv8plus -mno-v8plus -mvis -mno-vis | |
1364 | -mvis2 -mno-vis2 -mvis3 -mno-vis3 | |
1365 | -mvis4 -mno-vis4 -mvis4b -mno-vis4b | |
1366 | -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld | |
1367 | -mpopc -mno-popc -msubxc -mno-subxc | |
1368 | -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc | |
d77de738 ML |
1369 | -mlra -mno-lra} |
1370 | ||
1371 | @emph{System V Options} | |
1372 | @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}} | |
1373 | ||
1374 | @emph{V850 Options} | |
43b72ede AA |
1375 | @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep |
1376 | -mprolog-function -mno-prolog-function -mspace | |
1377 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
1378 | -mapp-regs -mno-app-regs | |
1379 | -mdisable-callt -mno-disable-callt | |
1380 | -mv850e2v3 -mv850e2 -mv850e1 -mv850es | |
1381 | -mv850e -mv850 -mv850e3v5 | |
1382 | -mloop | |
1383 | -mrelax | |
1384 | -mlong-jumps | |
1385 | -msoft-float | |
1386 | -mhard-float | |
1387 | -mgcc-abi | |
1388 | -mrh850-abi | |
d77de738 ML |
1389 | -mbig-switch} |
1390 | ||
1391 | @emph{VAX Options} | |
1392 | @gccoptlist{-mg -mgnu -munix -mlra} | |
1393 | ||
1394 | @emph{Visium Options} | |
43b72ede | 1395 | @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float |
d77de738 ML |
1396 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode} |
1397 | ||
1398 | @emph{VMS Options} | |
43b72ede | 1399 | @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 |
d77de738 ML |
1400 | -mpointer-size=@var{size}} |
1401 | ||
1402 | @emph{VxWorks Options} | |
43b72ede | 1403 | @gccoptlist{-mrtp -non-static -Bstatic -Bdynamic |
d77de738 ML |
1404 | -Xbind-lazy -Xbind-now} |
1405 | ||
1406 | @emph{x86 Options} | |
43b72ede AA |
1407 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1408 | -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default | |
1409 | -mfpmath=@var{unit} | |
1410 | -masm=@var{dialect} -mno-fancy-math-387 | |
1411 | -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float | |
1412 | -mno-wide-multiply -mrtd -malign-double | |
1413 | -mpreferred-stack-boundary=@var{num} | |
1414 | -mincoming-stack-boundary=@var{num} | |
1415 | -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait | |
1416 | -mrecip -mrecip=@var{opt} | |
1417 | -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} | |
1418 | -mmove-max=@var{bits} -mstore-max=@var{bits} | |
1419 | -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx | |
1420 | -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl | |
1421 | -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes | |
1422 | -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd | |
1423 | -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves | |
1424 | -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop | |
1425 | -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp | |
1426 | -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg | |
1427 | -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call | |
1428 | -mavx512vbmi2 -mavx512bf16 -menqcmd | |
1429 | -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq | |
1430 | -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid | |
1431 | -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk | |
1432 | -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni | |
1433 | -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 | |
efa6a82b | 1434 | -mprefetchi -mraoint -mamx-complex |
43b72ede AA |
1435 | -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops |
1436 | -minline-stringops-dynamically -mstringop-strategy=@var{alg} | |
1437 | -mkl -mwidekl | |
1438 | -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} | |
1439 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double | |
1440 | -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 | |
1441 | -mregparm=@var{num} -msseregparm | |
1442 | -mveclibabi=@var{type} -mvect8-ret-in-mem | |
1443 | -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign | |
1444 | -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs | |
1445 | -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} | |
1446 | -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} | |
1447 | -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv | |
1448 | -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} | |
1449 | -mavx256-split-unaligned-load -mavx256-split-unaligned-store | |
1450 | -malign-data=@var{type} -mstack-protector-guard=@var{guard} | |
1451 | -mstack-protector-guard-reg=@var{reg} | |
1452 | -mstack-protector-guard-offset=@var{offset} | |
1453 | -mstack-protector-guard-symbol=@var{symbol} | |
1454 | -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop | |
1455 | -mindirect-branch=@var{choice} -mfunction-return=@var{choice} | |
1456 | -mindirect-branch-register -mharden-sls=@var{choice} | |
1457 | -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access | |
bb576017 | 1458 | -munroll-only-small-loops -mlam=@var{choice}} |
d77de738 ML |
1459 | |
1460 | @emph{x86 Windows Options} | |
43b72ede AA |
1461 | @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll |
1462 | -mnop-fun-dllimport -mthread | |
d77de738 ML |
1463 | -municode -mwin32 -mwindows -fno-set-stack-executable} |
1464 | ||
1465 | @emph{Xstormy16 Options} | |
1466 | @gccoptlist{-msim} | |
1467 | ||
1468 | @emph{Xtensa Options} | |
43b72ede AA |
1469 | @gccoptlist{-mconst16 -mno-const16 |
1470 | -mfused-madd -mno-fused-madd | |
1471 | -mforce-no-pic | |
1472 | -mserialize-volatile -mno-serialize-volatile | |
1473 | -mtext-section-literals -mno-text-section-literals | |
1474 | -mauto-litpools -mno-auto-litpools | |
1475 | -mtarget-align -mno-target-align | |
1476 | -mlongcalls -mno-longcalls | |
1477 | -mabi=@var{abi-type} | |
675b390e MF |
1478 | -mextra-l32r-costs=@var{cycles} |
1479 | -mstrict-align -mno-strict-align} | |
d77de738 ML |
1480 | |
1481 | @emph{zSeries Options} | |
1482 | See S/390 and zSeries Options. | |
1483 | @end table | |
1484 | ||
1485 | ||
1486 | @node Overall Options | |
1487 | @section Options Controlling the Kind of Output | |
1488 | ||
1489 | Compilation can involve up to four stages: preprocessing, compilation | |
1490 | proper, assembly and linking, always in that order. GCC is capable of | |
1491 | preprocessing and compiling several files either into several | |
1492 | assembler input files, or into one assembler input file; then each | |
1493 | assembler input file produces an object file, and linking combines all | |
1494 | the object files (those newly compiled, and those specified as input) | |
1495 | into an executable file. | |
1496 | ||
1497 | @cindex file name suffix | |
1498 | For any given input file, the file name suffix determines what kind of | |
1499 | compilation is done: | |
1500 | ||
1501 | @table @gcctabopt | |
1502 | @item @var{file}.c | |
1503 | C source code that must be preprocessed. | |
1504 | ||
1505 | @item @var{file}.i | |
1506 | C source code that should not be preprocessed. | |
1507 | ||
1508 | @item @var{file}.ii | |
1509 | C++ source code that should not be preprocessed. | |
1510 | ||
1511 | @item @var{file}.m | |
1512 | Objective-C source code. Note that you must link with the @file{libobjc} | |
1513 | library to make an Objective-C program work. | |
1514 | ||
1515 | @item @var{file}.mi | |
1516 | Objective-C source code that should not be preprocessed. | |
1517 | ||
1518 | @item @var{file}.mm | |
1519 | @itemx @var{file}.M | |
1520 | Objective-C++ source code. Note that you must link with the @file{libobjc} | |
1521 | library to make an Objective-C++ program work. Note that @samp{.M} refers | |
1522 | to a literal capital M@. | |
1523 | ||
1524 | @item @var{file}.mii | |
1525 | Objective-C++ source code that should not be preprocessed. | |
1526 | ||
1527 | @item @var{file}.h | |
1528 | C, C++, Objective-C or Objective-C++ header file to be turned into a | |
1529 | precompiled header (default), or C, C++ header file to be turned into an | |
1530 | Ada spec (via the @option{-fdump-ada-spec} switch). | |
1531 | ||
1532 | @item @var{file}.cc | |
1533 | @itemx @var{file}.cp | |
1534 | @itemx @var{file}.cxx | |
1535 | @itemx @var{file}.cpp | |
1536 | @itemx @var{file}.CPP | |
1537 | @itemx @var{file}.c++ | |
1538 | @itemx @var{file}.C | |
1539 | C++ source code that must be preprocessed. Note that in @samp{.cxx}, | |
1540 | the last two letters must both be literally @samp{x}. Likewise, | |
1541 | @samp{.C} refers to a literal capital C@. | |
1542 | ||
1543 | @item @var{file}.mm | |
1544 | @itemx @var{file}.M | |
1545 | Objective-C++ source code that must be preprocessed. | |
1546 | ||
1547 | @item @var{file}.mii | |
1548 | Objective-C++ source code that should not be preprocessed. | |
1549 | ||
1550 | @item @var{file}.hh | |
1551 | @itemx @var{file}.H | |
1552 | @itemx @var{file}.hp | |
1553 | @itemx @var{file}.hxx | |
1554 | @itemx @var{file}.hpp | |
1555 | @itemx @var{file}.HPP | |
1556 | @itemx @var{file}.h++ | |
1557 | @itemx @var{file}.tcc | |
1558 | C++ header file to be turned into a precompiled header or Ada spec. | |
1559 | ||
1560 | @item @var{file}.f | |
1561 | @itemx @var{file}.for | |
1562 | @itemx @var{file}.ftn | |
1563 | Fixed form Fortran source code that should not be preprocessed. | |
1564 | ||
1565 | @item @var{file}.F | |
1566 | @itemx @var{file}.FOR | |
1567 | @itemx @var{file}.fpp | |
1568 | @itemx @var{file}.FPP | |
1569 | @itemx @var{file}.FTN | |
1570 | Fixed form Fortran source code that must be preprocessed (with the traditional | |
1571 | preprocessor). | |
1572 | ||
1573 | @item @var{file}.f90 | |
1574 | @itemx @var{file}.f95 | |
1575 | @itemx @var{file}.f03 | |
1576 | @itemx @var{file}.f08 | |
1577 | Free form Fortran source code that should not be preprocessed. | |
1578 | ||
1579 | @item @var{file}.F90 | |
1580 | @itemx @var{file}.F95 | |
1581 | @itemx @var{file}.F03 | |
1582 | @itemx @var{file}.F08 | |
1583 | Free form Fortran source code that must be preprocessed (with the | |
1584 | traditional preprocessor). | |
1585 | ||
1586 | @item @var{file}.go | |
1587 | Go source code. | |
1588 | ||
1589 | @item @var{file}.d | |
1590 | D source code. | |
1591 | ||
1592 | @item @var{file}.di | |
1593 | D interface file. | |
1594 | ||
1595 | @item @var{file}.dd | |
1596 | D documentation code (Ddoc). | |
1597 | ||
1598 | @item @var{file}.ads | |
1599 | Ada source code file that contains a library unit declaration (a | |
1600 | declaration of a package, subprogram, or generic, or a generic | |
1601 | instantiation), or a library unit renaming declaration (a package, | |
1602 | generic, or subprogram renaming declaration). Such files are also | |
1603 | called @dfn{specs}. | |
1604 | ||
1605 | @item @var{file}.adb | |
1606 | Ada source code file containing a library unit body (a subprogram or | |
1607 | package body). Such files are also called @dfn{bodies}. | |
1608 | ||
1609 | @c GCC also knows about some suffixes for languages not yet included: | |
1610 | @c Ratfor: | |
1611 | @c @var{file}.r | |
1612 | ||
1613 | @item @var{file}.s | |
1614 | Assembler code. | |
1615 | ||
1616 | @item @var{file}.S | |
1617 | @itemx @var{file}.sx | |
1618 | Assembler code that must be preprocessed. | |
1619 | ||
1620 | @item @var{other} | |
1621 | An object file to be fed straight into linking. | |
1622 | Any file name with no recognized suffix is treated this way. | |
1623 | @end table | |
1624 | ||
1625 | @opindex x | |
1626 | You can specify the input language explicitly with the @option{-x} option: | |
1627 | ||
1628 | @table @gcctabopt | |
1629 | @item -x @var{language} | |
1630 | Specify explicitly the @var{language} for the following input files | |
1631 | (rather than letting the compiler choose a default based on the file | |
1632 | name suffix). This option applies to all following input files until | |
1633 | the next @option{-x} option. Possible values for @var{language} are: | |
1634 | @smallexample | |
1635 | c c-header cpp-output | |
1636 | c++ c++-header c++-system-header c++-user-header c++-cpp-output | |
1637 | objective-c objective-c-header objective-c-cpp-output | |
1638 | objective-c++ objective-c++-header objective-c++-cpp-output | |
1639 | assembler assembler-with-cpp | |
1640 | ada | |
1641 | d | |
1642 | f77 f77-cpp-input f95 f95-cpp-input | |
1643 | go | |
1644 | @end smallexample | |
1645 | ||
1646 | @item -x none | |
1647 | Turn off any specification of a language, so that subsequent files are | |
1648 | handled according to their file name suffixes (as they are if @option{-x} | |
1649 | has not been used at all). | |
1650 | @end table | |
1651 | ||
1652 | If you only want some of the stages of compilation, you can use | |
1653 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and | |
1654 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
1655 | @command{gcc} is to stop. Note that some combinations (for example, | |
1656 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
1657 | ||
1658 | @table @gcctabopt | |
d77de738 | 1659 | @opindex c |
ddf6fe37 | 1660 | @item -c |
d77de738 ML |
1661 | Compile or assemble the source files, but do not link. The linking |
1662 | stage simply is not done. The ultimate output is in the form of an | |
1663 | object file for each source file. | |
1664 | ||
1665 | By default, the object file name for a source file is made by replacing | |
1666 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
1667 | ||
1668 | Unrecognized input files, not requiring compilation or assembly, are | |
1669 | ignored. | |
1670 | ||
d77de738 | 1671 | @opindex S |
ddf6fe37 | 1672 | @item -S |
d77de738 ML |
1673 | Stop after the stage of compilation proper; do not assemble. The output |
1674 | is in the form of an assembler code file for each non-assembler input | |
1675 | file specified. | |
1676 | ||
1677 | By default, the assembler file name for a source file is made by | |
1678 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
1679 | ||
1680 | Input files that don't require compilation are ignored. | |
1681 | ||
d77de738 | 1682 | @opindex E |
ddf6fe37 | 1683 | @item -E |
d77de738 ML |
1684 | Stop after the preprocessing stage; do not run the compiler proper. The |
1685 | output is in the form of preprocessed source code, which is sent to the | |
1686 | standard output. | |
1687 | ||
1688 | Input files that don't require preprocessing are ignored. | |
1689 | ||
1690 | @cindex output file option | |
d77de738 | 1691 | @opindex o |
ddf6fe37 | 1692 | @item -o @var{file} |
d77de738 ML |
1693 | Place the primary output in file @var{file}. This applies to whatever |
1694 | sort of output is being produced, whether it be an executable file, an | |
1695 | object file, an assembler file or preprocessed C code. | |
1696 | ||
1697 | If @option{-o} is not specified, the default is to put an executable | |
1698 | file in @file{a.out}, the object file for | |
1699 | @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its | |
1700 | assembler file in @file{@var{source}.s}, a precompiled header file in | |
1701 | @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on | |
1702 | standard output. | |
1703 | ||
1704 | Though @option{-o} names only the primary output, it also affects the | |
1705 | naming of auxiliary and dump outputs. See the examples below. Unless | |
1706 | overridden, both auxiliary outputs and dump outputs are placed in the | |
1707 | same directory as the primary output. In auxiliary outputs, the suffix | |
1708 | of the input file is replaced with that of the auxiliary output file | |
1709 | type; in dump outputs, the suffix of the dump file is appended to the | |
1710 | input file suffix. In compilation commands, the base name of both | |
1711 | auxiliary and dump outputs is that of the primary output; in compile and | |
1712 | link commands, the primary output name, minus the executable suffix, is | |
1713 | combined with the input file name. If both share the same base name, | |
1714 | disregarding the suffix, the result of the combination is that base | |
1715 | name, otherwise, they are concatenated, separated by a dash. | |
1716 | ||
1717 | @smallexample | |
1718 | gcc -c foo.c ... | |
1719 | @end smallexample | |
1720 | ||
1721 | will use @file{foo.o} as the primary output, and place aux outputs and | |
1722 | dumps next to it, e.g., aux file @file{foo.dwo} for | |
1723 | @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for | |
1724 | @option{-fdump-rtl-final}. | |
1725 | ||
1726 | If a non-linker output file is explicitly specified, aux and dump files | |
1727 | by default take the same base name: | |
1728 | ||
1729 | @smallexample | |
1730 | gcc -c foo.c -o dir/foobar.o ... | |
1731 | @end smallexample | |
1732 | ||
1733 | will name aux outputs @file{dir/foobar.*} and dump outputs | |
1734 | @file{dir/foobar.c.*}. | |
1735 | ||
1736 | A linker output will instead prefix aux and dump outputs: | |
1737 | ||
1738 | @smallexample | |
1739 | gcc foo.c bar.c -o dir/foobar ... | |
1740 | @end smallexample | |
1741 | ||
1742 | will generally name aux outputs @file{dir/foobar-foo.*} and | |
1743 | @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and | |
1744 | @file{dir/foobar-bar.c.*}. | |
1745 | ||
1746 | The one exception to the above is when the executable shares the base | |
1747 | name with the single input: | |
1748 | ||
1749 | @smallexample | |
1750 | gcc foo.c -o dir/foo ... | |
1751 | @end smallexample | |
1752 | ||
1753 | in which case aux outputs are named @file{dir/foo.*} and dump outputs | |
1754 | named @file{dir/foo.c.*}. | |
1755 | ||
1756 | The location and the names of auxiliary and dump outputs can be adjusted | |
1757 | by the options @option{-dumpbase}, @option{-dumpbase-ext}, | |
1758 | @option{-dumpdir}, @option{-save-temps=cwd}, and | |
1759 | @option{-save-temps=obj}. | |
1760 | ||
1761 | ||
d77de738 | 1762 | @opindex dumpbase |
ddf6fe37 | 1763 | @item -dumpbase @var{dumpbase} |
d77de738 ML |
1764 | This option sets the base name for auxiliary and dump output files. It |
1765 | does not affect the name of the primary output file. Intermediate | |
1766 | outputs, when preserved, are not regarded as primary outputs, but as | |
1767 | auxiliary outputs: | |
1768 | ||
1769 | @smallexample | |
1770 | gcc -save-temps -S foo.c | |
1771 | @end smallexample | |
1772 | ||
1773 | saves the (no longer) temporary preprocessed file in @file{foo.i}, and | |
1774 | then compiles to the (implied) output file @file{foo.s}, whereas: | |
1775 | ||
1776 | @smallexample | |
1777 | gcc -save-temps -dumpbase save-foo -c foo.c | |
1778 | @end smallexample | |
1779 | ||
1780 | preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now | |
1781 | an intermediate, thus auxiliary output), and then assembles to the | |
1782 | (implied) output file @file{foo.o}. | |
1783 | ||
1784 | Absent this option, dump and aux files take their names from the input | |
1785 | file, or from the (non-linker) output file, if one is explicitly | |
1786 | specified: dump output files (e.g. those requested by @option{-fdump-*} | |
1787 | options) with the input name suffix, and aux output files (those | |
1788 | requested by other non-dump options, e.g. @code{-save-temps}, | |
1789 | @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it. | |
1790 | ||
1791 | Similar suffix differentiation of dump and aux outputs can be attained | |
1792 | for explicitly-given @option{-dumpbase basename.suf} by also specifying | |
1793 | @option{-dumpbase-ext .suf}. | |
1794 | ||
1795 | If @var{dumpbase} is explicitly specified with any directory component, | |
1796 | any @var{dumppfx} specification (e.g. @option{-dumpdir} or | |
1797 | @option{-save-temps=*}) is ignored, and instead of appending to it, | |
1798 | @var{dumpbase} fully overrides it: | |
1799 | ||
1800 | @smallexample | |
1801 | gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \ | |
1802 | -dumpdir pfx- -save-temps=cwd ... | |
1803 | @end smallexample | |
1804 | ||
1805 | creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding | |
1806 | @file{dir/} in @option{-o}, the @file{./} prefix implied by | |
1807 | @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}. | |
1808 | ||
1809 | When @option{-dumpbase} is specified in a command that compiles multiple | |
1810 | inputs, or that compiles and then links, it may be combined with | |
1811 | @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input | |
1812 | file is compiled using the combined @var{dumppfx}, and default values | |
1813 | for @var{dumpbase} and @var{auxdropsuf} are computed for each input | |
1814 | file: | |
1815 | ||
1816 | @smallexample | |
1817 | gcc foo.c bar.c -c -dumpbase main ... | |
1818 | @end smallexample | |
1819 | ||
1820 | creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids | |
1821 | overwriting the auxiliary and dump outputs by using the @var{dumpbase} | |
1822 | as a prefix, creating auxiliary and dump outputs named @file{main-foo.*} | |
1823 | and @file{main-bar.*}. | |
1824 | ||
1825 | An empty string specified as @var{dumpbase} avoids the influence of the | |
1826 | output basename in the naming of auxiliary and dump outputs during | |
1827 | compilation, computing default values : | |
1828 | ||
1829 | @smallexample | |
1830 | gcc -c foo.c -o dir/foobar.o -dumpbase '' ... | |
1831 | @end smallexample | |
1832 | ||
1833 | will name aux outputs @file{dir/foo.*} and dump outputs | |
1834 | @file{dir/foo.c.*}. Note how their basenames are taken from the input | |
1835 | name, but the directory still defaults to that of the output. | |
1836 | ||
1837 | The empty-string dumpbase does not prevent the use of the output | |
1838 | basename for outputs during linking: | |
1839 | ||
1840 | @smallexample | |
1841 | gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ... | |
1842 | @end smallexample | |
1843 | ||
1844 | The compilation of the source files will name auxiliary outputs | |
1845 | @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs | |
1846 | @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during | |
1847 | linking will use @file{dir/foobar.} as the prefix for dumps and | |
1848 | auxiliary files. | |
1849 | ||
1850 | ||
d77de738 | 1851 | @opindex dumpbase-ext |
ddf6fe37 | 1852 | @item -dumpbase-ext @var{auxdropsuf} |
d77de738 ML |
1853 | When forming the name of an auxiliary (but not a dump) output file, drop |
1854 | trailing @var{auxdropsuf} from @var{dumpbase} before appending any | |
1855 | suffixes. If not specified, this option defaults to the suffix of a | |
1856 | default @var{dumpbase}, i.e., the suffix of the input file when | |
1857 | @option{-dumpbase} is not present in the command line, or @var{dumpbase} | |
1858 | is combined with @var{dumppfx}. | |
1859 | ||
1860 | @smallexample | |
1861 | gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ... | |
1862 | @end smallexample | |
1863 | ||
1864 | creates @file{dir/foo.o} as the main output, and generates auxiliary | |
1865 | outputs in @file{dir/x-foo.*}, taking the location of the primary | |
1866 | output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump | |
1867 | outputs retain the suffix: @file{dir/x-foo.c.*}. | |
1868 | ||
1869 | This option is disregarded if it does not match the suffix of a | |
1870 | specified @var{dumpbase}, except as an alternative to the executable | |
1871 | suffix when appending the linker output base name to @var{dumppfx}, as | |
1872 | specified below: | |
1873 | ||
1874 | @smallexample | |
1875 | gcc foo.c bar.c -o main.out -dumpbase-ext .out ... | |
1876 | @end smallexample | |
1877 | ||
1878 | creates @file{main.out} as the primary output, and avoids overwriting | |
1879 | the auxiliary and dump outputs by using the executable name minus | |
1880 | @var{auxdropsuf} as a prefix, creating auxiliary outputs named | |
1881 | @file{main-foo.*} and @file{main-bar.*} and dump outputs named | |
1882 | @file{main-foo.c.*} and @file{main-bar.c.*}. | |
1883 | ||
1884 | ||
d77de738 | 1885 | @opindex dumpdir |
ddf6fe37 | 1886 | @item -dumpdir @var{dumppfx} |
d77de738 ML |
1887 | When forming the name of an auxiliary or dump output file, use |
1888 | @var{dumppfx} as a prefix: | |
1889 | ||
1890 | @smallexample | |
1891 | gcc -dumpdir pfx- -c foo.c ... | |
1892 | @end smallexample | |
1893 | ||
1894 | creates @file{foo.o} as the primary output, and auxiliary outputs named | |
1895 | @file{pfx-foo.*}, combining the given @var{dumppfx} with the default | |
1896 | @var{dumpbase} derived from the default primary output, derived in turn | |
1897 | from the input name. Dump outputs also take the input name suffix: | |
1898 | @file{pfx-foo.c.*}. | |
1899 | ||
1900 | If @var{dumppfx} is to be used as a directory name, it must end with a | |
1901 | directory separator: | |
1902 | ||
1903 | @smallexample | |
1904 | gcc -dumpdir dir/ -c foo.c -o obj/bar.o ... | |
1905 | @end smallexample | |
1906 | ||
1907 | creates @file{obj/bar.o} as the primary output, and auxiliary outputs | |
1908 | named @file{dir/bar.*}, combining the given @var{dumppfx} with the | |
1909 | default @var{dumpbase} derived from the primary output name. Dump | |
1910 | outputs also take the input name suffix: @file{dir/bar.c.*}. | |
1911 | ||
1912 | It defaults to the location of the output file, unless the output | |
1913 | file is a special file like @code{/dev/null}. Options | |
1914 | @option{-save-temps=cwd} and @option{-save-temps=obj} override this | |
1915 | default, just like an explicit @option{-dumpdir} option. In case | |
1916 | multiple such options are given, the last one prevails: | |
1917 | ||
1918 | @smallexample | |
1919 | gcc -dumpdir pfx- -c foo.c -save-temps=obj ... | |
1920 | @end smallexample | |
1921 | ||
1922 | outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because | |
1923 | @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier | |
1924 | @option{-dumpdir} option. It does not matter that @option{=obj} is the | |
1925 | default for @option{-save-temps}, nor that the output directory is | |
1926 | implicitly the current directory. Dump outputs are named | |
1927 | @file{foo.c.*}. | |
1928 | ||
1929 | When compiling from multiple input files, if @option{-dumpbase} is | |
1930 | specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash | |
1931 | are appended to (or override, if containing any directory components) an | |
1932 | explicit or defaulted @var{dumppfx}, so that each of the multiple | |
1933 | compilations gets differently-named aux and dump outputs. | |
1934 | ||
1935 | @smallexample | |
1936 | gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1937 | @end smallexample | |
1938 | ||
1939 | outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and | |
1940 | @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}. | |
1941 | Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*} | |
1942 | and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the | |
1943 | single-input compilation: | |
1944 | ||
1945 | @smallexample | |
1946 | gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1947 | @end smallexample | |
1948 | ||
1949 | that, applying @option{-dumpbase} to a single source, does not compute | |
1950 | and append a separate @var{dumpbase} per input file. Its auxiliary and | |
1951 | dump outputs go in @file{dir/pfx-main.*}. | |
1952 | ||
1953 | When compiling and then linking from multiple input files, a defaulted | |
1954 | or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}- | |
1955 | transformation above (e.g. the compilation of @file{foo.c} and | |
1956 | @file{bar.c} above, but without @option{-c}). If neither | |
1957 | @option{-dumpdir} nor @option{-dumpbase} are given, the linker output | |
1958 | base name, minus @var{auxdropsuf}, if specified, or the executable | |
1959 | suffix otherwise, plus a dash is appended to the default @var{dumppfx} | |
1960 | instead. Note, however, that unlike earlier cases of linking: | |
1961 | ||
1962 | @smallexample | |
1963 | gcc foo.c bar.c -dumpdir dir/pfx- -o main ... | |
1964 | @end smallexample | |
1965 | ||
1966 | does not append the output name @file{main} to @var{dumppfx}, because | |
1967 | @option{-dumpdir} is explicitly specified. The goal is that the | |
1968 | explicitly-specified @var{dumppfx} may contain the specified output name | |
1969 | as part of the prefix, if desired; only an explicitly-specified | |
1970 | @option{-dumpbase} would be combined with it, in order to avoid simply | |
1971 | discarding a meaningful option. | |
1972 | ||
1973 | When compiling and then linking from a single input file, the linker | |
1974 | output base name will only be appended to the default @var{dumppfx} as | |
1975 | above if it does not share the base name with the single input file | |
1976 | name. This has been covered in single-input linking cases above, but | |
1977 | not with an explicit @option{-dumpdir} that inhibits the combination, | |
1978 | even if overridden by @option{-save-temps=*}: | |
1979 | ||
1980 | @smallexample | |
1981 | gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ... | |
1982 | @end smallexample | |
1983 | ||
1984 | Auxiliary outputs are named @file{foo.*}, and dump outputs | |
1985 | @file{foo.c.*}, in the current working directory as ultimately requested | |
1986 | by @option{-save-temps=cwd}. | |
1987 | ||
1988 | Summing it all up for an intuitive though slightly imprecise data flow: | |
1989 | the primary output name is broken into a directory part and a basename | |
1990 | part; @var{dumppfx} is set to the former, unless overridden by | |
1991 | @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set | |
1992 | to the latter, unless overriden by @option{-dumpbase}. If there are | |
1993 | multiple inputs or linking, this @var{dumpbase} may be combined with | |
1994 | @var{dumppfx} and taken from each input file. Auxiliary output names | |
1995 | for each input are formed by combining @var{dumppfx}, @var{dumpbase} | |
1996 | minus suffix, and the auxiliary output suffix; dump output names are | |
1997 | only different in that the suffix from @var{dumpbase} is retained. | |
1998 | ||
1999 | When it comes to auxiliary and dump outputs created during LTO | |
2000 | recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as | |
2001 | given or as derived from the linker output name but not from inputs, | |
2002 | even in cases in which this combination would not otherwise be used as | |
2003 | such, is passed down with a trailing period replacing the compiler-added | |
2004 | dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper}; | |
2005 | being involved in linking, this program does not normally get any | |
2006 | @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them. | |
2007 | ||
2008 | When running sub-compilers, @command{lto-wrapper} appends LTO stage | |
2009 | names to the received @var{dumppfx}, ensures it contains a directory | |
2010 | component so that it overrides any @option{-dumpdir}, and passes that as | |
2011 | @option{-dumpbase} to sub-compilers. | |
2012 | ||
d77de738 | 2013 | @opindex v |
ddf6fe37 | 2014 | @item -v |
d77de738 ML |
2015 | Print (on standard error output) the commands executed to run the stages |
2016 | of compilation. Also print the version number of the compiler driver | |
2017 | program and of the preprocessor and the compiler proper. | |
2018 | ||
d77de738 | 2019 | @opindex ### |
ddf6fe37 | 2020 | @item -### |
d77de738 ML |
2021 | Like @option{-v} except the commands are not executed and arguments |
2022 | are quoted unless they contain only alphanumeric characters or @code{./-_}. | |
2023 | This is useful for shell scripts to capture the driver-generated command lines. | |
2024 | ||
d77de738 | 2025 | @opindex help |
ddf6fe37 | 2026 | @item --help |
d77de738 ML |
2027 | Print (on the standard output) a description of the command-line options |
2028 | understood by @command{gcc}. If the @option{-v} option is also specified | |
2029 | then @option{--help} is also passed on to the various processes | |
2030 | invoked by @command{gcc}, so that they can display the command-line options | |
2031 | they accept. If the @option{-Wextra} option has also been specified | |
2032 | (prior to the @option{--help} option), then command-line options that | |
2033 | have no documentation associated with them are also displayed. | |
2034 | ||
d77de738 | 2035 | @opindex target-help |
ddf6fe37 | 2036 | @item --target-help |
d77de738 ML |
2037 | Print (on the standard output) a description of target-specific command-line |
2038 | options for each tool. For some targets extra target-specific | |
2039 | information may also be printed. | |
2040 | ||
2041 | @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]} | |
2042 | Print (on the standard output) a description of the command-line | |
2043 | options understood by the compiler that fit into all specified classes | |
2044 | and qualifiers. These are the supported classes: | |
2045 | ||
2046 | @table @asis | |
2047 | @item @samp{optimizers} | |
2048 | Display all of the optimization options supported by the | |
2049 | compiler. | |
2050 | ||
2051 | @item @samp{warnings} | |
2052 | Display all of the options controlling warning messages | |
2053 | produced by the compiler. | |
2054 | ||
2055 | @item @samp{target} | |
2056 | Display target-specific options. Unlike the | |
2057 | @option{--target-help} option however, target-specific options of the | |
2058 | linker and assembler are not displayed. This is because those | |
2059 | tools do not currently support the extended @option{--help=} syntax. | |
2060 | ||
2061 | @item @samp{params} | |
2062 | Display the values recognized by the @option{--param} | |
2063 | option. | |
2064 | ||
2065 | @item @var{language} | |
2066 | Display the options supported for @var{language}, where | |
2067 | @var{language} is the name of one of the languages supported in this | |
2068 | version of GCC@. If an option is supported by all languages, one needs | |
2069 | to select @samp{common} class. | |
2070 | ||
2071 | @item @samp{common} | |
2072 | Display the options that are common to all languages. | |
2073 | @end table | |
2074 | ||
2075 | These are the supported qualifiers: | |
2076 | ||
2077 | @table @asis | |
2078 | @item @samp{undocumented} | |
2079 | Display only those options that are undocumented. | |
2080 | ||
2081 | @item @samp{joined} | |
2082 | Display options taking an argument that appears after an equal | |
2083 | sign in the same continuous piece of text, such as: | |
2084 | @samp{--help=target}. | |
2085 | ||
2086 | @item @samp{separate} | |
2087 | Display options taking an argument that appears as a separate word | |
2088 | following the original option, such as: @samp{-o output-file}. | |
2089 | @end table | |
2090 | ||
2091 | Thus for example to display all the undocumented target-specific | |
2092 | switches supported by the compiler, use: | |
2093 | ||
2094 | @smallexample | |
2095 | --help=target,undocumented | |
2096 | @end smallexample | |
2097 | ||
2098 | The sense of a qualifier can be inverted by prefixing it with the | |
2099 | @samp{^} character, so for example to display all binary warning | |
2100 | options (i.e., ones that are either on or off and that do not take an | |
2101 | argument) that have a description, use: | |
2102 | ||
2103 | @smallexample | |
2104 | --help=warnings,^joined,^undocumented | |
2105 | @end smallexample | |
2106 | ||
2107 | The argument to @option{--help=} should not consist solely of inverted | |
2108 | qualifiers. | |
2109 | ||
2110 | Combining several classes is possible, although this usually | |
2111 | restricts the output so much that there is nothing to display. One | |
2112 | case where it does work, however, is when one of the classes is | |
2113 | @var{target}. For example, to display all the target-specific | |
2114 | optimization options, use: | |
2115 | ||
2116 | @smallexample | |
2117 | --help=target,optimizers | |
2118 | @end smallexample | |
2119 | ||
2120 | The @option{--help=} option can be repeated on the command line. Each | |
2121 | successive use displays its requested class of options, skipping | |
2122 | those that have already been displayed. If @option{--help} is also | |
2123 | specified anywhere on the command line then this takes precedence | |
2124 | over any @option{--help=} option. | |
2125 | ||
2126 | If the @option{-Q} option appears on the command line before the | |
2127 | @option{--help=} option, then the descriptive text displayed by | |
2128 | @option{--help=} is changed. Instead of describing the displayed | |
2129 | options, an indication is given as to whether the option is enabled, | |
2130 | disabled or set to a specific value (assuming that the compiler | |
2131 | knows this at the point where the @option{--help=} option is used). | |
2132 | ||
2133 | Here is a truncated example from the ARM port of @command{gcc}: | |
2134 | ||
2135 | @smallexample | |
2136 | % gcc -Q -mabi=2 --help=target -c | |
2137 | The following options are target specific: | |
2138 | -mabi= 2 | |
2139 | -mabort-on-noreturn [disabled] | |
2140 | -mapcs [disabled] | |
2141 | @end smallexample | |
2142 | ||
2143 | The output is sensitive to the effects of previous command-line | |
2144 | options, so for example it is possible to find out which optimizations | |
2145 | are enabled at @option{-O2} by using: | |
2146 | ||
2147 | @smallexample | |
2148 | -Q -O2 --help=optimizers | |
2149 | @end smallexample | |
2150 | ||
2151 | Alternatively you can discover which binary optimizations are enabled | |
2152 | by @option{-O3} by using: | |
2153 | ||
2154 | @smallexample | |
2155 | gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts | |
2156 | gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts | |
2157 | diff /tmp/O2-opts /tmp/O3-opts | grep enabled | |
2158 | @end smallexample | |
2159 | ||
d77de738 | 2160 | @opindex version |
ddf6fe37 | 2161 | @item --version |
d77de738 ML |
2162 | Display the version number and copyrights of the invoked GCC@. |
2163 | ||
d77de738 | 2164 | @opindex pass-exit-codes |
ddf6fe37 | 2165 | @item -pass-exit-codes |
d77de738 ML |
2166 | Normally the @command{gcc} program exits with the code of 1 if any |
2167 | phase of the compiler returns a non-success return code. If you specify | |
2168 | @option{-pass-exit-codes}, the @command{gcc} program instead returns with | |
2169 | the numerically highest error produced by any phase returning an error | |
2170 | indication. The C, C++, and Fortran front ends return 4 if an internal | |
2171 | compiler error is encountered. | |
2172 | ||
d77de738 | 2173 | @opindex pipe |
ddf6fe37 | 2174 | @item -pipe |
d77de738 ML |
2175 | Use pipes rather than temporary files for communication between the |
2176 | various stages of compilation. This fails to work on some systems where | |
2177 | the assembler is unable to read from a pipe; but the GNU assembler has | |
2178 | no trouble. | |
2179 | ||
d77de738 | 2180 | @opindex specs |
ddf6fe37 | 2181 | @item -specs=@var{file} |
d77de738 ML |
2182 | Process @var{file} after the compiler reads in the standard @file{specs} |
2183 | file, in order to override the defaults which the @command{gcc} driver | |
2184 | program uses when determining what switches to pass to @command{cc1}, | |
2185 | @command{cc1plus}, @command{as}, @command{ld}, etc. More than one | |
2186 | @option{-specs=@var{file}} can be specified on the command line, and they | |
2187 | are processed in order, from left to right. @xref{Spec Files}, for | |
2188 | information about the format of the @var{file}. | |
2189 | ||
d77de738 | 2190 | @opindex wrapper |
ddf6fe37 | 2191 | @item -wrapper |
d77de738 ML |
2192 | Invoke all subcommands under a wrapper program. The name of the |
2193 | wrapper program and its parameters are passed as a comma separated | |
2194 | list. | |
2195 | ||
2196 | @smallexample | |
2197 | gcc -c t.c -wrapper gdb,--args | |
2198 | @end smallexample | |
2199 | ||
2200 | @noindent | |
2201 | This invokes all subprograms of @command{gcc} under | |
2202 | @samp{gdb --args}, thus the invocation of @command{cc1} is | |
2203 | @samp{gdb --args cc1 @dots{}}. | |
2204 | ||
d77de738 | 2205 | @opindex ffile-prefix-map |
ddf6fe37 | 2206 | @item -ffile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
2207 | When compiling files residing in directory @file{@var{old}}, record |
2208 | any references to them in the result of the compilation as if the | |
2209 | files resided in directory @file{@var{new}} instead. Specifying this | |
2210 | option is equivalent to specifying all the individual | |
2211 | @option{-f*-prefix-map} options. This can be used to make reproducible | |
11543b27 | 2212 | builds that are location independent. Directories referenced by |
2eb0191a JJ |
2213 | directives are not affected by these options. See also |
2214 | @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map}, | |
2215 | @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}. | |
2216 | ||
2eb0191a | 2217 | @opindex fcanon-prefix-map |
e54b01a1 | 2218 | @item -fcanon-prefix-map |
2eb0191a JJ |
2219 | For the @option{-f*-prefix-map} options normally comparison |
2220 | of @file{@var{old}} prefix against the filename that would be normally | |
2221 | referenced in the result of the compilation is done using textual | |
2222 | comparison of the prefixes, or ignoring character case for case insensitive | |
2223 | filesystems and considering slashes and backslashes as equal on DOS based | |
2224 | filesystems. The @option{-fcanon-prefix-map} causes such comparisons | |
2225 | to be done on canonicalized paths of @file{@var{old}} | |
2226 | and the referenced filename. | |
d77de738 | 2227 | |
d77de738 | 2228 | @opindex fplugin |
ddf6fe37 | 2229 | @item -fplugin=@var{name}.so |
d77de738 ML |
2230 | Load the plugin code in file @var{name}.so, assumed to be a |
2231 | shared object to be dlopen'd by the compiler. The base name of | |
2232 | the shared object file is used to identify the plugin for the | |
2233 | purposes of argument parsing (See | |
2234 | @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below). | |
2235 | Each plugin should define the callback functions specified in the | |
2236 | Plugins API. | |
2237 | ||
d77de738 | 2238 | @opindex fplugin-arg |
ddf6fe37 | 2239 | @item -fplugin-arg-@var{name}-@var{key}=@var{value} |
d77de738 ML |
2240 | Define an argument called @var{key} with a value of @var{value} |
2241 | for the plugin called @var{name}. | |
2242 | ||
d77de738 | 2243 | @opindex fdump-ada-spec |
ddf6fe37 | 2244 | @item -fdump-ada-spec@r{[}-slim@r{]} |
d77de738 ML |
2245 | For C and C++ source and include files, generate corresponding Ada specs. |
2246 | @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn, | |
2247 | GNAT User's Guide}, which provides detailed documentation on this feature. | |
2248 | ||
d77de738 | 2249 | @opindex fada-spec-parent |
ddf6fe37 | 2250 | @item -fada-spec-parent=@var{unit} |
d77de738 ML |
2251 | In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate |
2252 | Ada specs as child units of parent @var{unit}. | |
2253 | ||
d77de738 | 2254 | @opindex fdump-go-spec |
ddf6fe37 | 2255 | @item -fdump-go-spec=@var{file} |
d77de738 ML |
2256 | For input files in any language, generate corresponding Go |
2257 | declarations in @var{file}. This generates Go @code{const}, | |
2258 | @code{type}, @code{var}, and @code{func} declarations which may be a | |
2259 | useful way to start writing a Go interface to code written in some | |
2260 | other language. | |
2261 | ||
2262 | @include @value{srcdir}/../libiberty/at-file.texi | |
2263 | @end table | |
2264 | ||
2265 | @node Invoking G++ | |
2266 | @section Compiling C++ Programs | |
2267 | ||
2268 | @cindex suffixes for C++ source | |
2269 | @cindex C++ source file suffixes | |
2270 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
2271 | @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or | |
2272 | @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp}, | |
2273 | @samp{.H}, or (for shared template code) @samp{.tcc}; and | |
2274 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes | |
2275 | files with these names and compiles them as C++ programs even if you | |
2276 | call the compiler the same way as for compiling C programs (usually | |
2277 | with the name @command{gcc}). | |
2278 | ||
2279 | @findex g++ | |
2280 | @findex c++ | |
2281 | However, the use of @command{gcc} does not add the C++ library. | |
2282 | @command{g++} is a program that calls GCC and automatically specifies linking | |
2283 | against the C++ library. It treats @samp{.c}, | |
2284 | @samp{.h} and @samp{.i} files as C++ source files instead of C source | |
2285 | files unless @option{-x} is used. This program is also useful when | |
2286 | precompiling a C header file with a @samp{.h} extension for use in C++ | |
2287 | compilations. On many systems, @command{g++} is also installed with | |
2288 | the name @command{c++}. | |
2289 | ||
2290 | @cindex invoking @command{g++} | |
2291 | When you compile C++ programs, you may specify many of the same | |
2292 | command-line options that you use for compiling programs in any | |
2293 | language; or command-line options meaningful for C and related | |
2294 | languages; or options that are meaningful only for C++ programs. | |
2295 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
2296 | explanations of options for languages related to C@. | |
2297 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
2298 | explanations of options that are meaningful only for C++ programs. | |
2299 | ||
2300 | @node C Dialect Options | |
2301 | @section Options Controlling C Dialect | |
2302 | @cindex dialect options | |
2303 | @cindex language dialect options | |
2304 | @cindex options, dialect | |
2305 | ||
2306 | The following options control the dialect of C (or languages derived | |
2307 | from C, such as C++, Objective-C and Objective-C++) that the compiler | |
2308 | accepts: | |
2309 | ||
2310 | @table @gcctabopt | |
2311 | @cindex ANSI support | |
2312 | @cindex ISO support | |
d77de738 | 2313 | @opindex ansi |
ddf6fe37 | 2314 | @item -ansi |
d77de738 ML |
2315 | In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is |
2316 | equivalent to @option{-std=c++98}. | |
2317 | ||
2318 | This turns off certain features of GCC that are incompatible with ISO | |
2319 | C90 (when compiling C code), or of standard C++ (when compiling C++ code), | |
2320 | such as the @code{asm} and @code{typeof} keywords, and | |
2321 | predefined macros such as @code{unix} and @code{vax} that identify the | |
2322 | type of system you are using. It also enables the undesirable and | |
2323 | rarely used ISO trigraph feature. For the C compiler, | |
2324 | it disables recognition of C++ style @samp{//} comments as well as | |
2325 | the @code{inline} keyword. | |
2326 | ||
2327 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
2328 | @code{__inline__} and @code{__typeof__} continue to work despite | |
2329 | @option{-ansi}. You would not want to use them in an ISO C program, of | |
2330 | course, but it is useful to put them in header files that might be included | |
2331 | in compilations done with @option{-ansi}. Alternate predefined macros | |
2332 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
2333 | without @option{-ansi}. | |
2334 | ||
2335 | The @option{-ansi} option does not cause non-ISO programs to be | |
2336 | rejected gratuitously. For that, @option{-Wpedantic} is required in | |
2337 | addition to @option{-ansi}. @xref{Warning Options}. | |
2338 | ||
2339 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} | |
2340 | option is used. Some header files may notice this macro and refrain | |
2341 | from declaring certain functions or defining certain macros that the | |
2342 | ISO standard doesn't call for; this is to avoid interfering with any | |
2343 | programs that might use these names for other things. | |
2344 | ||
2345 | Functions that are normally built in but do not have semantics | |
2346 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
2347 | functions when @option{-ansi} is used. @xref{Other Builtins,,Other | |
2348 | built-in functions provided by GCC}, for details of the functions | |
2349 | affected. | |
2350 | ||
d77de738 | 2351 | @opindex std |
ddf6fe37 | 2352 | @item -std= |
d77de738 ML |
2353 | Determine the language standard. @xref{Standards,,Language Standards |
2354 | Supported by GCC}, for details of these standard versions. This option | |
2355 | is currently only supported when compiling C or C++. | |
2356 | ||
2357 | The compiler can accept several base standards, such as @samp{c90} or | |
2358 | @samp{c++98}, and GNU dialects of those standards, such as | |
2359 | @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the | |
2360 | compiler accepts all programs following that standard plus those | |
2361 | using GNU extensions that do not contradict it. For example, | |
2362 | @option{-std=c90} turns off certain features of GCC that are | |
2363 | incompatible with ISO C90, such as the @code{asm} and @code{typeof} | |
2364 | keywords, but not other GNU extensions that do not have a meaning in | |
2365 | ISO C90, such as omitting the middle term of a @code{?:} | |
2366 | expression. On the other hand, when a GNU dialect of a standard is | |
2367 | specified, all features supported by the compiler are enabled, even when | |
2368 | those features change the meaning of the base standard. As a result, some | |
2369 | strict-conforming programs may be rejected. The particular standard | |
2370 | is used by @option{-Wpedantic} to identify which features are GNU | |
2371 | extensions given that version of the standard. For example | |
2372 | @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//} | |
2373 | comments, while @option{-std=gnu99 -Wpedantic} does not. | |
2374 | ||
2375 | A value for this option must be provided; possible values are | |
2376 | ||
2377 | @table @samp | |
2378 | @item c90 | |
2379 | @itemx c89 | |
2380 | @itemx iso9899:1990 | |
2381 | Support all ISO C90 programs (certain GNU extensions that conflict | |
2382 | with ISO C90 are disabled). Same as @option{-ansi} for C code. | |
2383 | ||
2384 | @item iso9899:199409 | |
2385 | ISO C90 as modified in amendment 1. | |
2386 | ||
2387 | @item c99 | |
2388 | @itemx c9x | |
2389 | @itemx iso9899:1999 | |
2390 | @itemx iso9899:199x | |
2391 | ISO C99. This standard is substantially completely supported, modulo | |
2392 | bugs and floating-point issues | |
2393 | (mainly but not entirely relating to optional C99 features from | |
2394 | Annexes F and G). See | |
2395 | @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The | |
2396 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
2397 | ||
2398 | @item c11 | |
2399 | @itemx c1x | |
2400 | @itemx iso9899:2011 | |
2401 | ISO C11, the 2011 revision of the ISO C standard. This standard is | |
2402 | substantially completely supported, modulo bugs, floating-point issues | |
2403 | (mainly but not entirely relating to optional C11 features from | |
2404 | Annexes F and G) and the optional Annexes K (Bounds-checking | |
2405 | interfaces) and L (Analyzability). The name @samp{c1x} is deprecated. | |
2406 | ||
2407 | @item c17 | |
2408 | @itemx c18 | |
2409 | @itemx iso9899:2017 | |
2410 | @itemx iso9899:2018 | |
2411 | ISO C17, the 2017 revision of the ISO C standard | |
2412 | (published in 2018). This standard is | |
2413 | same as C11 except for corrections of defects (all of which are also | |
2414 | applied with @option{-std=c11}) and a new value of | |
2415 | @code{__STDC_VERSION__}, and so is supported to the same extent as C11. | |
2416 | ||
2417 | @item c2x | |
2418 | The next version of the ISO C standard, still under development. The | |
2419 | support for this version is experimental and incomplete. | |
2420 | ||
2421 | @item gnu90 | |
2422 | @itemx gnu89 | |
2423 | GNU dialect of ISO C90 (including some C99 features). | |
2424 | ||
2425 | @item gnu99 | |
2426 | @itemx gnu9x | |
2427 | GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated. | |
2428 | ||
2429 | @item gnu11 | |
2430 | @itemx gnu1x | |
2431 | GNU dialect of ISO C11. | |
2432 | The name @samp{gnu1x} is deprecated. | |
2433 | ||
2434 | @item gnu17 | |
2435 | @itemx gnu18 | |
2436 | GNU dialect of ISO C17. This is the default for C code. | |
2437 | ||
2438 | @item gnu2x | |
2439 | The next version of the ISO C standard, still under development, plus | |
2440 | GNU extensions. The support for this version is experimental and | |
2441 | incomplete. | |
2442 | ||
2443 | @item c++98 | |
2444 | @itemx c++03 | |
2445 | The 1998 ISO C++ standard plus the 2003 technical corrigendum and some | |
2446 | additional defect reports. Same as @option{-ansi} for C++ code. | |
2447 | ||
2448 | @item gnu++98 | |
2449 | @itemx gnu++03 | |
2450 | GNU dialect of @option{-std=c++98}. | |
2451 | ||
2452 | @item c++11 | |
2453 | @itemx c++0x | |
2454 | The 2011 ISO C++ standard plus amendments. | |
2455 | The name @samp{c++0x} is deprecated. | |
2456 | ||
2457 | @item gnu++11 | |
2458 | @itemx gnu++0x | |
2459 | GNU dialect of @option{-std=c++11}. | |
2460 | The name @samp{gnu++0x} is deprecated. | |
2461 | ||
2462 | @item c++14 | |
2463 | @itemx c++1y | |
2464 | The 2014 ISO C++ standard plus amendments. | |
2465 | The name @samp{c++1y} is deprecated. | |
2466 | ||
2467 | @item gnu++14 | |
2468 | @itemx gnu++1y | |
2469 | GNU dialect of @option{-std=c++14}. | |
2470 | The name @samp{gnu++1y} is deprecated. | |
2471 | ||
2472 | @item c++17 | |
2473 | @itemx c++1z | |
2474 | The 2017 ISO C++ standard plus amendments. | |
2475 | The name @samp{c++1z} is deprecated. | |
2476 | ||
2477 | @item gnu++17 | |
2478 | @itemx gnu++1z | |
2479 | GNU dialect of @option{-std=c++17}. | |
2480 | This is the default for C++ code. | |
2481 | The name @samp{gnu++1z} is deprecated. | |
2482 | ||
2483 | @item c++20 | |
2484 | @itemx c++2a | |
2485 | The 2020 ISO C++ standard plus amendments. | |
2486 | Support is experimental, and could change in incompatible ways in | |
2487 | future releases. | |
2488 | The name @samp{c++2a} is deprecated. | |
2489 | ||
2490 | @item gnu++20 | |
2491 | @itemx gnu++2a | |
2492 | GNU dialect of @option{-std=c++20}. | |
2493 | Support is experimental, and could change in incompatible ways in | |
2494 | future releases. | |
2495 | The name @samp{gnu++2a} is deprecated. | |
2496 | ||
2497 | @item c++2b | |
2498 | @itemx c++23 | |
2499 | The next revision of the ISO C++ standard, planned for | |
2500 | 2023. Support is highly experimental, and will almost certainly | |
2501 | change in incompatible ways in future releases. | |
2502 | ||
2503 | @item gnu++2b | |
2504 | @itemx gnu++23 | |
2505 | GNU dialect of @option{-std=c++2b}. Support is highly experimental, | |
2506 | and will almost certainly change in incompatible ways in future | |
2507 | releases. | |
2508 | @end table | |
2509 | ||
d77de738 | 2510 | @opindex aux-info |
ddf6fe37 | 2511 | @item -aux-info @var{filename} |
d77de738 ML |
2512 | Output to the given filename prototyped declarations for all functions |
2513 | declared and/or defined in a translation unit, including those in header | |
2514 | files. This option is silently ignored in any language other than C@. | |
2515 | ||
2516 | Besides declarations, the file indicates, in comments, the origin of | |
2517 | each declaration (source file and line), whether the declaration was | |
2518 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
2519 | @samp{O} for old, respectively, in the first character after the line | |
2520 | number and the colon), and whether it came from a declaration or a | |
2521 | definition (@samp{C} or @samp{F}, respectively, in the following | |
2522 | character). In the case of function definitions, a K&R-style list of | |
2523 | arguments followed by their declarations is also provided, inside | |
2524 | comments, after the declaration. | |
2525 | ||
d77de738 ML |
2526 | @opindex fno-asm |
2527 | @opindex fasm | |
ddf6fe37 | 2528 | @item -fno-asm |
d77de738 ML |
2529 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
2530 | keyword, so that code can use these words as identifiers. You can use | |
2531 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
2532 | instead. In C, @option{-ansi} implies @option{-fno-asm}. | |
2533 | ||
2534 | In C++, @code{inline} is a standard keyword and is not affected by | |
2535 | this switch. You may want to use the @option{-fno-gnu-keywords} flag | |
2536 | instead, which disables @code{typeof} but not @code{asm} and | |
2537 | @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), | |
2538 | this switch only affects the @code{asm} and @code{typeof} keywords, | |
2539 | since @code{inline} is a standard keyword in ISO C99. In C2X mode | |
2540 | (@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects | |
2541 | the @code{asm} keyword, since @code{typeof} is a standard keyword in | |
2542 | ISO C2X. | |
2543 | ||
d77de738 ML |
2544 | @opindex fno-builtin |
2545 | @opindex fbuiltin | |
f33d7a88 | 2546 | @cindex built-in functions |
ddf6fe37 AA |
2547 | @item -fno-builtin |
2548 | @itemx -fno-builtin-@var{function} | |
d77de738 ML |
2549 | Don't recognize built-in functions that do not begin with |
2550 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in | |
2551 | functions provided by GCC}, for details of the functions affected, | |
2552 | including those which are not built-in functions when @option{-ansi} or | |
2553 | @option{-std} options for strict ISO C conformance are used because they | |
2554 | do not have an ISO standard meaning. | |
2555 | ||
2556 | GCC normally generates special code to handle certain built-in functions | |
2557 | more efficiently; for instance, calls to @code{alloca} may become single | |
2558 | instructions which adjust the stack directly, and calls to @code{memcpy} | |
2559 | may become inline copy loops. The resulting code is often both smaller | |
2560 | and faster, but since the function calls no longer appear as such, you | |
2561 | cannot set a breakpoint on those calls, nor can you change the behavior | |
2562 | of the functions by linking with a different library. In addition, | |
2563 | when a function is recognized as a built-in function, GCC may use | |
2564 | information about that function to warn about problems with calls to | |
2565 | that function, or to generate more efficient code, even if the | |
2566 | resulting code still contains calls to that function. For example, | |
2567 | warnings are given with @option{-Wformat} for bad calls to | |
2568 | @code{printf} when @code{printf} is built in and @code{strlen} is | |
2569 | known not to modify global memory. | |
2570 | ||
2571 | With the @option{-fno-builtin-@var{function}} option | |
2572 | only the built-in function @var{function} is | |
2573 | disabled. @var{function} must not begin with @samp{__builtin_}. If a | |
2574 | function is named that is not built-in in this version of GCC, this | |
2575 | option is ignored. There is no corresponding | |
2576 | @option{-fbuiltin-@var{function}} option; if you wish to enable | |
2577 | built-in functions selectively when using @option{-fno-builtin} or | |
2578 | @option{-ffreestanding}, you may define macros such as: | |
2579 | ||
2580 | @smallexample | |
2581 | #define abs(n) __builtin_abs ((n)) | |
2582 | #define strcpy(d, s) __builtin_strcpy ((d), (s)) | |
2583 | @end smallexample | |
2584 | ||
d77de738 | 2585 | @opindex fcond-mismatch |
ddf6fe37 | 2586 | @item -fcond-mismatch |
d77de738 ML |
2587 | Allow conditional expressions with mismatched types in the second and |
2588 | third arguments. The value of such an expression is void. This option | |
2589 | is not supported for C++. | |
2590 | ||
d77de738 ML |
2591 | @opindex ffreestanding |
2592 | @cindex hosted environment | |
f33d7a88 | 2593 | @item -ffreestanding |
d77de738 ML |
2594 | |
2595 | Assert that compilation targets a freestanding environment. This | |
2596 | implies @option{-fno-builtin}. A freestanding environment | |
2597 | is one in which the standard library may not exist, and program startup may | |
2598 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
2599 | This is equivalent to @option{-fno-hosted}. | |
2600 | ||
2601 | @xref{Standards,,Language Standards Supported by GCC}, for details of | |
2602 | freestanding and hosted environments. | |
2603 | ||
d77de738 | 2604 | @opindex fgimple |
ddf6fe37 | 2605 | @item -fgimple |
d77de738 ML |
2606 | |
2607 | Enable parsing of function definitions marked with @code{__GIMPLE}. | |
2608 | This is an experimental feature that allows unit testing of GIMPLE | |
2609 | passes. | |
2610 | ||
d77de738 | 2611 | @opindex fgnu-tm |
ddf6fe37 | 2612 | @item -fgnu-tm |
d77de738 ML |
2613 | When the option @option{-fgnu-tm} is specified, the compiler |
2614 | generates code for the Linux variant of Intel's current Transactional | |
2615 | Memory ABI specification document (Revision 1.1, May 6 2009). This is | |
2616 | an experimental feature whose interface may change in future versions | |
2617 | of GCC, as the official specification changes. Please note that not | |
2618 | all architectures are supported for this feature. | |
2619 | ||
2620 | For more information on GCC's support for transactional memory, | |
2621 | @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU | |
2622 | Transactional Memory Library}. | |
2623 | ||
2624 | Note that the transactional memory feature is not supported with | |
2625 | non-call exceptions (@option{-fnon-call-exceptions}). | |
2626 | ||
d77de738 | 2627 | @opindex fgnu89-inline |
ddf6fe37 | 2628 | @item -fgnu89-inline |
d77de738 ML |
2629 | The option @option{-fgnu89-inline} tells GCC to use the traditional |
2630 | GNU semantics for @code{inline} functions when in C99 mode. | |
2631 | @xref{Inline,,An Inline Function is As Fast As a Macro}. | |
2632 | Using this option is roughly equivalent to adding the | |
2633 | @code{gnu_inline} function attribute to all inline functions | |
2634 | (@pxref{Function Attributes}). | |
2635 | ||
2636 | The option @option{-fno-gnu89-inline} explicitly tells GCC to use the | |
2637 | C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it | |
2638 | specifies the default behavior). | |
2639 | This option is not supported in @option{-std=c90} or | |
2640 | @option{-std=gnu90} mode. | |
2641 | ||
2642 | The preprocessor macros @code{__GNUC_GNU_INLINE__} and | |
2643 | @code{__GNUC_STDC_INLINE__} may be used to check which semantics are | |
2644 | in effect for @code{inline} functions. @xref{Common Predefined | |
2645 | Macros,,,cpp,The C Preprocessor}. | |
2646 | ||
d77de738 ML |
2647 | @opindex fhosted |
2648 | @cindex hosted environment | |
f33d7a88 | 2649 | @item -fhosted |
d77de738 ML |
2650 | |
2651 | Assert that compilation targets a hosted environment. This implies | |
2652 | @option{-fbuiltin}. A hosted environment is one in which the | |
2653 | entire standard library is available, and in which @code{main} has a return | |
2654 | type of @code{int}. Examples are nearly everything except a kernel. | |
2655 | This is equivalent to @option{-fno-freestanding}. | |
2656 | ||
d77de738 | 2657 | @opindex flax-vector-conversions |
ddf6fe37 | 2658 | @item -flax-vector-conversions |
d77de738 ML |
2659 | Allow implicit conversions between vectors with differing numbers of |
2660 | elements and/or incompatible element types. This option should not be | |
2661 | used for new code. | |
2662 | ||
d77de738 | 2663 | @opindex fms-extensions |
ddf6fe37 | 2664 | @item -fms-extensions |
d77de738 ML |
2665 | Accept some non-standard constructs used in Microsoft header files. |
2666 | ||
2667 | In C++ code, this allows member names in structures to be similar | |
2668 | to previous types declarations. | |
2669 | ||
2670 | @smallexample | |
2671 | typedef int UOW; | |
2672 | struct ABC @{ | |
2673 | UOW UOW; | |
2674 | @}; | |
2675 | @end smallexample | |
2676 | ||
2677 | Some cases of unnamed fields in structures and unions are only | |
2678 | accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union | |
2679 | fields within structs/unions}, for details. | |
2680 | ||
2681 | Note that this option is off for all targets except for x86 | |
2682 | targets using ms-abi. | |
2683 | ||
ddf6fe37 | 2684 | @opindex foffload |
d77de738 ML |
2685 | @cindex Offloading targets |
2686 | @cindex OpenACC offloading targets | |
2687 | @cindex OpenMP offloading targets | |
f33d7a88 AA |
2688 | @item -foffload=disable |
2689 | @itemx -foffload=default | |
2690 | @itemx -foffload=@var{target-list} | |
d77de738 ML |
2691 | Specify for which OpenMP and OpenACC offload targets code should be generated. |
2692 | The default behavior, equivalent to @option{-foffload=default}, is to generate | |
2693 | code for all supported offload targets. The @option{-foffload=disable} form | |
2694 | generates code only for the host fallback, while | |
2695 | @option{-foffload=@var{target-list}} generates code only for the specified | |
2696 | comma-separated list of offload targets. | |
2697 | ||
2698 | Offload targets are specified in GCC's internal target-triplet format. You can | |
2699 | run the compiler with @option{-v} to show the list of configured offload targets | |
2700 | under @code{OFFLOAD_TARGET_NAMES}. | |
2701 | ||
ddf6fe37 | 2702 | @opindex foffload-options |
d77de738 ML |
2703 | @cindex Offloading options |
2704 | @cindex OpenACC offloading options | |
2705 | @cindex OpenMP offloading options | |
f33d7a88 AA |
2706 | @item -foffload-options=@var{options} |
2707 | @itemx -foffload-options=@var{target-triplet-list}=@var{options} | |
d77de738 ML |
2708 | |
2709 | With @option{-foffload-options=@var{options}}, GCC passes the specified | |
2710 | @var{options} to the compilers for all enabled offloading targets. You can | |
2711 | specify options that apply only to a specific target or targets by using | |
2712 | the @option{-foffload-options=@var{target-list}=@var{options}} form. The | |
2713 | @var{target-list} is a comma-separated list in the same format as for the | |
2714 | @option{-foffload=} option. | |
2715 | ||
2716 | Typical command lines are | |
2717 | ||
2718 | @smallexample | |
2719 | -foffload-options=-lgfortran -foffload-options=-lm | |
2720 | -foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic | |
2721 | -foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm | |
2722 | @end smallexample | |
2723 | ||
d77de738 ML |
2724 | @opindex fopenacc |
2725 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2726 | @item -fopenacc |
d77de738 ML |
2727 | Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and |
2728 | @code{!$acc} in Fortran. When @option{-fopenacc} is specified, the | |
2729 | compiler generates accelerated code according to the OpenACC Application | |
2730 | Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option | |
2731 | implies @option{-pthread}, and thus is only supported on targets that | |
2732 | have support for @option{-pthread}. | |
2733 | ||
d77de738 ML |
2734 | @opindex fopenacc-dim |
2735 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2736 | @item -fopenacc-dim=@var{geom} |
d77de738 ML |
2737 | Specify default compute dimensions for parallel offload regions that do |
2738 | not explicitly specify. The @var{geom} value is a triple of | |
2739 | ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size | |
2740 | can be omitted, to use a target-specific default value. | |
2741 | ||
d77de738 ML |
2742 | @opindex fopenmp |
2743 | @cindex OpenMP parallel | |
f33d7a88 | 2744 | @item -fopenmp |
d77de738 ML |
2745 | Enable handling of OpenMP directives @code{#pragma omp} in C/C++, |
2746 | @code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and | |
2747 | @code{!$omp} in Fortran. When @option{-fopenmp} is specified, the | |
2748 | compiler generates parallel code according to the OpenMP Application | |
2749 | Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option | |
2750 | implies @option{-pthread}, and thus is only supported on targets that | |
2751 | have support for @option{-pthread}. @option{-fopenmp} implies | |
2752 | @option{-fopenmp-simd}. | |
2753 | ||
d77de738 ML |
2754 | @opindex fopenmp-simd |
2755 | @cindex OpenMP SIMD | |
2756 | @cindex SIMD | |
f33d7a88 | 2757 | @item -fopenmp-simd |
d77de738 ML |
2758 | Enable handling of OpenMP's @code{simd}, @code{declare simd}, |
2759 | @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}, | |
2760 | @code{loop} directives and combined or composite directives with | |
2761 | @code{simd} as constituent with @code{#pragma omp} in C/C++, | |
2762 | @code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ | |
2763 | and @code{!$omp} in Fortran. Other OpenMP directives are ignored. | |
2764 | ||
ddf6fe37 | 2765 | @opindex fopenmp-target-simd-clone |
f33d7a88 | 2766 | @cindex OpenMP target SIMD clone |
309e2d95 SL |
2767 | @item -fopenmp-target-simd-clone |
2768 | @item -fopenmp-target-simd-clone=@var{device-type} | |
309e2d95 SL |
2769 | In addition to generating SIMD clones for functions marked with the |
2770 | @code{declare simd} directive, GCC also generates clones | |
2771 | for functions marked with the OpenMP @code{declare target} directive | |
2772 | that are suitable for vectorization when this option is in effect. The | |
2773 | @var{device-type} may be one of @code{none}, @code{host}, @code{nohost}, | |
2774 | and @code{any}, which correspond to keywords for the @code{device_type} | |
2775 | clause of the @code{declare target} directive; clones are generated for | |
2776 | the intersection of devices specified. | |
2777 | @option{-fopenmp-target-simd-clone} is equivalent to | |
2778 | @option{-fopenmp-target-simd-clone=any} and | |
2779 | @option{-fno-openmp-target-simd-clone} is equivalent to | |
2780 | @option{-fopenmp-target-simd-clone=none}. | |
2781 | ||
2782 | At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this | |
2783 | optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise | |
2784 | it is disabled by default. | |
2785 | ||
d77de738 ML |
2786 | @opindex fpermitted-flt-eval-methods |
2787 | @opindex fpermitted-flt-eval-methods=c11 | |
2788 | @opindex fpermitted-flt-eval-methods=ts-18661-3 | |
ddf6fe37 | 2789 | @item -fpermitted-flt-eval-methods=@var{style} |
d77de738 ML |
2790 | ISO/IEC TS 18661-3 defines new permissible values for |
2791 | @code{FLT_EVAL_METHOD} that indicate that operations and constants with | |
2792 | a semantic type that is an interchange or extended format should be | |
2793 | evaluated to the precision and range of that type. These new values are | |
2794 | a superset of those permitted under C99/C11, which does not specify the | |
2795 | meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code | |
2796 | conforming to C11 may not have been written expecting the possibility of | |
2797 | the new values. | |
2798 | ||
2799 | @option{-fpermitted-flt-eval-methods} specifies whether the compiler | |
2800 | should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, | |
2801 | or the extended set of values specified in ISO/IEC TS 18661-3. | |
2802 | ||
2803 | @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. | |
2804 | ||
2805 | The default when in a standards compliant mode (@option{-std=c11} or similar) | |
2806 | is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU | |
2807 | dialect (@option{-std=gnu11} or similar) is | |
2808 | @option{-fpermitted-flt-eval-methods=ts-18661-3}. | |
2809 | ||
d77de738 | 2810 | @opindex fplan9-extensions |
ddf6fe37 | 2811 | @item -fplan9-extensions |
d77de738 ML |
2812 | Accept some non-standard constructs used in Plan 9 code. |
2813 | ||
2814 | This enables @option{-fms-extensions}, permits passing pointers to | |
2815 | structures with anonymous fields to functions that expect pointers to | |
2816 | elements of the type of the field, and permits referring to anonymous | |
2817 | fields declared using a typedef. @xref{Unnamed Fields,,Unnamed | |
2818 | struct/union fields within structs/unions}, for details. This is only | |
2819 | supported for C, not C++. | |
2820 | ||
d77de738 ML |
2821 | @opindex fsigned-bitfields |
2822 | @opindex funsigned-bitfields | |
2823 | @opindex fno-signed-bitfields | |
2824 | @opindex fno-unsigned-bitfields | |
ddf6fe37 AA |
2825 | @item -fsigned-bitfields |
2826 | @itemx -funsigned-bitfields | |
2827 | @itemx -fno-signed-bitfields | |
2828 | @itemx -fno-unsigned-bitfields | |
d77de738 ML |
2829 | These options control whether a bit-field is signed or unsigned, when the |
2830 | declaration does not use either @code{signed} or @code{unsigned}. By | |
2831 | default, such a bit-field is signed, because this is consistent: the | |
2832 | basic integer types such as @code{int} are signed types. | |
2833 | ||
d77de738 | 2834 | @opindex fsigned-char |
ddf6fe37 | 2835 | @item -fsigned-char |
d77de738 ML |
2836 | Let the type @code{char} be signed, like @code{signed char}. |
2837 | ||
2838 | Note that this is equivalent to @option{-fno-unsigned-char}, which is | |
2839 | the negative form of @option{-funsigned-char}. Likewise, the option | |
2840 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
2841 | ||
d77de738 | 2842 | @opindex funsigned-char |
ddf6fe37 | 2843 | @item -funsigned-char |
d77de738 ML |
2844 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
2845 | ||
2846 | Each kind of machine has a default for what @code{char} should | |
2847 | be. It is either like @code{unsigned char} by default or like | |
2848 | @code{signed char} by default. | |
2849 | ||
2850 | Ideally, a portable program should always use @code{signed char} or | |
2851 | @code{unsigned char} when it depends on the signedness of an object. | |
2852 | But many programs have been written to use plain @code{char} and | |
2853 | expect it to be signed, or expect it to be unsigned, depending on the | |
2854 | machines they were written for. This option, and its inverse, let you | |
2855 | make such a program work with the opposite default. | |
2856 | ||
2857 | The type @code{char} is always a distinct type from each of | |
2858 | @code{signed char} or @code{unsigned char}, even though its behavior | |
2859 | is always just like one of those two. | |
2860 | ||
d77de738 ML |
2861 | @opindex fstrict-flex-arrays |
2862 | @opindex fno-strict-flex-arrays | |
ddf6fe37 | 2863 | @item -fstrict-flex-arrays |
d77de738 ML |
2864 | Control when to treat the trailing array of a structure as a flexible array |
2865 | member for the purpose of accessing the elements of such an array. | |
2866 | The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the | |
2867 | strictest. A trailing array is treated as a flexible array member only when it | |
2868 | is declared as a flexible array member per C99 standard onwards. | |
2869 | The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the | |
2870 | least strict. All trailing arrays of structures are treated as flexible array | |
2871 | members. | |
2872 | ||
d77de738 | 2873 | @opindex fstrict-flex-arrays=@var{level} |
ddf6fe37 | 2874 | @item -fstrict-flex-arrays=@var{level} |
d77de738 ML |
2875 | Control when to treat the trailing array of a structure as a flexible array |
2876 | member for the purpose of accessing the elements of such an array. The value | |
2877 | of @var{level} controls the level of strictness. | |
2878 | ||
2879 | The possible values of @var{level} are the same as for the | |
2880 | @code{strict_flex_array} attribute (@pxref{Variable Attributes}). | |
2881 | ||
2882 | You can control this behavior for a specific trailing array field of a | |
2883 | structure by using the variable attribute @code{strict_flex_array} attribute | |
2884 | (@pxref{Variable Attributes}). | |
2885 | ||
d77de738 | 2886 | @opindex fsso-struct |
ddf6fe37 | 2887 | @item -fsso-struct=@var{endianness} |
d77de738 ML |
2888 | Set the default scalar storage order of structures and unions to the |
2889 | specified endianness. The accepted values are @samp{big-endian}, | |
2890 | @samp{little-endian} and @samp{native} for the native endianness of | |
2891 | the target (the default). This option is not supported for C++. | |
2892 | ||
2893 | @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate | |
2894 | code that is not binary compatible with code generated without it if the | |
2895 | specified endianness is not the native endianness of the target. | |
2896 | @end table | |
2897 | ||
2898 | @node C++ Dialect Options | |
2899 | @section Options Controlling C++ Dialect | |
2900 | ||
2901 | @cindex compiler options, C++ | |
2902 | @cindex C++ options, command-line | |
2903 | @cindex options, C++ | |
2904 | This section describes the command-line options that are only meaningful | |
2905 | for C++ programs. You can also use most of the GNU compiler options | |
2906 | regardless of what language your program is in. For example, you | |
2907 | might compile a file @file{firstClass.C} like this: | |
2908 | ||
2909 | @smallexample | |
2910 | g++ -g -fstrict-enums -O -c firstClass.C | |
2911 | @end smallexample | |
2912 | ||
2913 | @noindent | |
2914 | In this example, only @option{-fstrict-enums} is an option meant | |
2915 | only for C++ programs; you can use the other options with any | |
2916 | language supported by GCC@. | |
2917 | ||
2918 | Some options for compiling C programs, such as @option{-std}, are also | |
2919 | relevant for C++ programs. | |
2920 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
2921 | ||
2922 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
2923 | ||
2924 | @table @gcctabopt | |
2925 | ||
d77de738 | 2926 | @opindex fabi-version |
ddf6fe37 | 2927 | @item -fabi-version=@var{n} |
d77de738 ML |
2928 | Use version @var{n} of the C++ ABI@. The default is version 0. |
2929 | ||
2930 | Version 0 refers to the version conforming most closely to | |
2931 | the C++ ABI specification. Therefore, the ABI obtained using version 0 | |
2932 | will change in different versions of G++ as ABI bugs are fixed. | |
2933 | ||
2934 | Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. | |
2935 | ||
2936 | Version 2 is the version of the C++ ABI that first appeared in G++ | |
2937 | 3.4, and was the default through G++ 4.9. | |
2938 | ||
2939 | Version 3 corrects an error in mangling a constant address as a | |
2940 | template argument. | |
2941 | ||
2942 | Version 4, which first appeared in G++ 4.5, implements a standard | |
2943 | mangling for vector types. | |
2944 | ||
2945 | Version 5, which first appeared in G++ 4.6, corrects the mangling of | |
2946 | attribute const/volatile on function pointer types, decltype of a | |
2947 | plain decl, and use of a function parameter in the declaration of | |
2948 | another parameter. | |
2949 | ||
2950 | Version 6, which first appeared in G++ 4.7, corrects the promotion | |
2951 | behavior of C++11 scoped enums and the mangling of template argument | |
2952 | packs, const/static_cast, prefix ++ and --, and a class scope function | |
2953 | used as a template argument. | |
2954 | ||
2955 | Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a | |
2956 | builtin type and corrects the mangling of lambdas in default argument | |
2957 | scope. | |
2958 | ||
2959 | Version 8, which first appeared in G++ 4.9, corrects the substitution | |
2960 | behavior of function types with function-cv-qualifiers. | |
2961 | ||
2962 | Version 9, which first appeared in G++ 5.2, corrects the alignment of | |
2963 | @code{nullptr_t}. | |
2964 | ||
2965 | Version 10, which first appeared in G++ 6.1, adds mangling of | |
2966 | attributes that affect type identity, such as ia32 calling convention | |
2967 | attributes (e.g.@: @samp{stdcall}). | |
2968 | ||
2969 | Version 11, which first appeared in G++ 7, corrects the mangling of | |
2970 | sizeof... expressions and operator names. For multiple entities with | |
2971 | the same name within a function, that are declared in different scopes, | |
2972 | the mangling now changes starting with the twelfth occurrence. It also | |
2973 | implies @option{-fnew-inheriting-ctors}. | |
2974 | ||
2975 | Version 12, which first appeared in G++ 8, corrects the calling | |
2976 | conventions for empty classes on the x86_64 target and for classes | |
2977 | with only deleted copy/move constructors. It accidentally changes the | |
2978 | calling convention for classes with a deleted copy constructor and a | |
2979 | trivial move constructor. | |
2980 | ||
2981 | Version 13, which first appeared in G++ 8.2, fixes the accidental | |
2982 | change in version 12. | |
2983 | ||
2984 | Version 14, which first appeared in G++ 10, corrects the mangling of | |
2985 | the nullptr expression. | |
2986 | ||
2987 | Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI | |
2988 | tag regression. | |
2989 | ||
2990 | Version 16, which first appeared in G++ 11, changes the mangling of | |
2991 | @code{__alignof__} to be distinct from that of @code{alignof}, and | |
2992 | dependent operator names. | |
2993 | ||
2994 | Version 17, which first appeared in G++ 12, fixes layout of classes | |
2995 | that inherit from aggregate classes with default member initializers | |
2996 | in C++14 and up. | |
2997 | ||
2998 | Version 18, which first appeard in G++ 13, fixes manglings of lambdas | |
2999 | that have additional context. | |
3000 | ||
3001 | See also @option{-Wabi}. | |
3002 | ||
d77de738 | 3003 | @opindex fabi-compat-version |
ddf6fe37 | 3004 | @item -fabi-compat-version=@var{n} |
d77de738 ML |
3005 | On targets that support strong aliases, G++ |
3006 | works around mangling changes by creating an alias with the correct | |
3007 | mangled name when defining a symbol with an incorrect mangled name. | |
3008 | This switch specifies which ABI version to use for the alias. | |
3009 | ||
3010 | With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2 | |
3011 | compatibility). If another ABI version is explicitly selected, this | |
3012 | defaults to 0. For compatibility with GCC versions 3.2 through 4.9, | |
3013 | use @option{-fabi-compat-version=2}. | |
3014 | ||
3015 | If this option is not provided but @option{-Wabi=@var{n}} is, that | |
3016 | version is used for compatibility aliases. If this option is provided | |
3017 | along with @option{-Wabi} (without the version), the version from this | |
3018 | option is used for the warning. | |
3019 | ||
d77de738 ML |
3020 | @opindex fno-access-control |
3021 | @opindex faccess-control | |
ddf6fe37 | 3022 | @item -fno-access-control |
d77de738 ML |
3023 | Turn off all access checking. This switch is mainly useful for working |
3024 | around bugs in the access control code. | |
3025 | ||
d77de738 | 3026 | @opindex faligned-new |
ddf6fe37 | 3027 | @item -faligned-new |
d77de738 ML |
3028 | Enable support for C++17 @code{new} of types that require more |
3029 | alignment than @code{void* ::operator new(std::size_t)} provides. A | |
3030 | numeric argument such as @code{-faligned-new=32} can be used to | |
3031 | specify how much alignment (in bytes) is provided by that function, | |
3032 | but few users will need to override the default of | |
3033 | @code{alignof(std::max_align_t)}. | |
3034 | ||
3035 | This flag is enabled by default for @option{-std=c++17}. | |
3036 | ||
d77de738 ML |
3037 | @opindex fchar8_t |
3038 | @opindex fno-char8_t | |
ddf6fe37 AA |
3039 | @item -fchar8_t |
3040 | @itemx -fno-char8_t | |
d77de738 ML |
3041 | Enable support for @code{char8_t} as adopted for C++20. This includes |
3042 | the addition of a new @code{char8_t} fundamental type, changes to the | |
3043 | types of UTF-8 string and character literals, new signatures for | |
3044 | user-defined literals, associated standard library updates, and new | |
3045 | @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros. | |
3046 | ||
3047 | This option enables functions to be overloaded for ordinary and UTF-8 | |
3048 | strings: | |
3049 | ||
3050 | @smallexample | |
3051 | int f(const char *); // #1 | |
3052 | int f(const char8_t *); // #2 | |
3053 | int v1 = f("text"); // Calls #1 | |
3054 | int v2 = f(u8"text"); // Calls #2 | |
3055 | @end smallexample | |
3056 | ||
3057 | @noindent | |
3058 | and introduces new signatures for user-defined literals: | |
3059 | ||
3060 | @smallexample | |
3061 | int operator""_udl1(char8_t); | |
3062 | int v3 = u8'x'_udl1; | |
3063 | int operator""_udl2(const char8_t*, std::size_t); | |
3064 | int v4 = u8"text"_udl2; | |
3065 | template<typename T, T...> int operator""_udl3(); | |
3066 | int v5 = u8"text"_udl3; | |
3067 | @end smallexample | |
3068 | ||
3069 | @noindent | |
3070 | The change to the types of UTF-8 string and character literals introduces | |
3071 | incompatibilities with ISO C++11 and later standards. For example, the | |
3072 | following code is well-formed under ISO C++11, but is ill-formed when | |
3073 | @option{-fchar8_t} is specified. | |
3074 | ||
3075 | @smallexample | |
d77de738 ML |
3076 | const char *cp = u8"xx";// error: invalid conversion from |
3077 | // `const char8_t*' to `const char*' | |
3078 | int f(const char*); | |
3079 | auto v = f(u8"xx"); // error: invalid conversion from | |
3080 | // `const char8_t*' to `const char*' | |
3081 | std::string s@{u8"xx"@}; // error: no matching function for call to | |
3082 | // `std::basic_string<char>::basic_string()' | |
3083 | using namespace std::literals; | |
3084 | s = u8"xx"s; // error: conversion from | |
3085 | // `basic_string<char8_t>' to non-scalar | |
3086 | // type `basic_string<char>' requested | |
3087 | @end smallexample | |
3088 | ||
d77de738 | 3089 | @opindex fcheck-new |
ddf6fe37 | 3090 | @item -fcheck-new |
d77de738 ML |
3091 | Check that the pointer returned by @code{operator new} is non-null |
3092 | before attempting to modify the storage allocated. This check is | |
3093 | normally unnecessary because the C++ standard specifies that | |
3094 | @code{operator new} only returns @code{0} if it is declared | |
3095 | @code{throw()}, in which case the compiler always checks the | |
3096 | return value even without this option. In all other cases, when | |
3097 | @code{operator new} has a non-empty exception specification, memory | |
3098 | exhaustion is signalled by throwing @code{std::bad_alloc}. See also | |
3099 | @samp{new (nothrow)}. | |
3100 | ||
d77de738 ML |
3101 | @opindex fconcepts |
3102 | @opindex fconcepts-ts | |
ddf6fe37 AA |
3103 | @item -fconcepts |
3104 | @itemx -fconcepts-ts | |
d77de738 ML |
3105 | Enable support for the C++ Concepts feature for constraining template |
3106 | arguments. With @option{-std=c++20} and above, Concepts are part of | |
3107 | the language standard, so @option{-fconcepts} defaults to on. | |
3108 | ||
3109 | Some constructs that were allowed by the earlier C++ Extensions for | |
3110 | Concepts Technical Specification, ISO 19217 (2015), but didn't make it | |
3111 | into the standard, can additionally be enabled by | |
3112 | @option{-fconcepts-ts}. | |
3113 | ||
d77de738 | 3114 | @opindex fconstexpr-depth |
ddf6fe37 | 3115 | @item -fconstexpr-depth=@var{n} |
d77de738 ML |
3116 | Set the maximum nested evaluation depth for C++11 constexpr functions |
3117 | to @var{n}. A limit is needed to detect endless recursion during | |
3118 | constant expression evaluation. The minimum specified by the standard | |
3119 | is 512. | |
3120 | ||
d77de738 | 3121 | @opindex fconstexpr-cache-depth |
ddf6fe37 | 3122 | @item -fconstexpr-cache-depth=@var{n} |
d77de738 ML |
3123 | Set the maximum level of nested evaluation depth for C++11 constexpr |
3124 | functions that will be cached to @var{n}. This is a heuristic that | |
3125 | trades off compilation speed (when the cache avoids repeated | |
3126 | calculations) against memory consumption (when the cache grows very | |
3127 | large from highly recursive evaluations). The default is 8. Very few | |
3128 | users are likely to want to adjust it, but if your code does heavy | |
3129 | constexpr calculations you might want to experiment to find which | |
3130 | value works best for you. | |
3131 | ||
d77de738 | 3132 | @opindex fconstexpr-fp-except |
ddf6fe37 | 3133 | @item -fconstexpr-fp-except |
d77de738 ML |
3134 | Annex F of the C standard specifies that IEC559 floating point |
3135 | exceptions encountered at compile time should not stop compilation. | |
3136 | C++ compilers have historically not followed this guidance, instead | |
3137 | treating floating point division by zero as non-constant even though | |
3138 | it has a well defined value. This flag tells the compiler to give | |
3139 | Annex F priority over other rules saying that a particular operation | |
3140 | is undefined. | |
3141 | ||
3142 | @smallexample | |
3143 | constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except | |
3144 | @end smallexample | |
3145 | ||
d77de738 | 3146 | @opindex fconstexpr-loop-limit |
ddf6fe37 | 3147 | @item -fconstexpr-loop-limit=@var{n} |
d77de738 ML |
3148 | Set the maximum number of iterations for a loop in C++14 constexpr functions |
3149 | to @var{n}. A limit is needed to detect infinite loops during | |
3150 | constant expression evaluation. The default is 262144 (1<<18). | |
3151 | ||
d77de738 | 3152 | @opindex fconstexpr-ops-limit |
ddf6fe37 | 3153 | @item -fconstexpr-ops-limit=@var{n} |
d77de738 ML |
3154 | Set the maximum number of operations during a single constexpr evaluation. |
3155 | Even when number of iterations of a single loop is limited with the above limit, | |
3156 | if there are several nested loops and each of them has many iterations but still | |
3157 | smaller than the above limit, or if in a body of some loop or even outside | |
3158 | of a loop too many expressions need to be evaluated, the resulting constexpr | |
3159 | evaluation might take too long. | |
3160 | The default is 33554432 (1<<25). | |
3161 | ||
2efb237f | 3162 | @opindex fcontracts |
ddf6fe37 | 3163 | @item -fcontracts |
2efb237f JCI |
3164 | Enable experimental support for the C++ Contracts feature, as briefly |
3165 | added to and then removed from the C++20 working paper (N4820). The | |
3166 | implementation also includes proposed enhancements from papers P1290, | |
3167 | P1332, and P1429. This functionality is intended mostly for those | |
3168 | interested in experimentation towards refining the feature to get it | |
3169 | into shape for a future C++ standard. | |
3170 | ||
3171 | On violation of a checked contract, the violation handler is called. | |
3172 | Users can replace the violation handler by defining | |
3173 | @smallexample | |
4ace81b6 SL |
3174 | void |
3175 | handle_contract_violation (const std::experimental::contract_violation&); | |
2efb237f JCI |
3176 | @end smallexample |
3177 | ||
3178 | There are different sets of additional flags that can be used together | |
3179 | to specify which contracts will be checked and how, for N4820 | |
3180 | contracts, P1332 contracts, or P1429 contracts; these sets cannot be | |
3181 | used together. | |
3182 | ||
3183 | @table @gcctabopt | |
2efb237f | 3184 | @opindex fcontract-mode |
ddf6fe37 | 3185 | @item -fcontract-mode=[on|off] |
2efb237f JCI |
3186 | Control whether any contracts have any semantics at all. Defaults to on. |
3187 | ||
2efb237f | 3188 | @opindex fcontract-assumption-mode |
ddf6fe37 | 3189 | @item -fcontract-assumption-mode=[on|off] |
2efb237f JCI |
3190 | [N4820] Control whether contracts with level @samp{axiom} |
3191 | should have the assume semantic. Defaults to on. | |
3192 | ||
2efb237f | 3193 | @opindex fcontract-build-level |
ddf6fe37 | 3194 | @item -fcontract-build-level=[off|default|audit] |
2efb237f JCI |
3195 | [N4820] Specify which level of contracts to generate checks |
3196 | for. Defaults to @samp{default}. | |
3197 | ||
2efb237f | 3198 | @opindex fcontract-continuation-mode |
ddf6fe37 | 3199 | @item -fcontract-continuation-mode=[on|off] |
2efb237f JCI |
3200 | [N4820] Control whether to allow the program to continue executing |
3201 | after a contract violation. That is, do checked contracts have the | |
3202 | @samp{maybe} semantic described below rather than the @samp{never} | |
3203 | semantic. Defaults to off. | |
3204 | ||
2efb237f | 3205 | @opindex fcontract-role |
ddf6fe37 | 3206 | @item -fcontract-role=<name>:<default>,<audit>,<axiom> |
2efb237f JCI |
3207 | [P1332] Specify the concrete semantics for each contract level |
3208 | of a particular contract role. | |
3209 | ||
3210 | @item -fcontract-semantic=[default|audit|axiom]:<semantic> | |
3211 | [P1429] Specify the concrete semantic for a particular | |
3212 | contract level. | |
3213 | ||
2efb237f | 3214 | @opindex fcontract-strict-declarations |
ddf6fe37 | 3215 | @item -fcontract-strict-declarations=[on|off] |
2efb237f JCI |
3216 | Control whether to reject adding contracts to a function after its |
3217 | first declaration. Defaults to off. | |
3218 | @end table | |
3219 | ||
3220 | The possible concrete semantics for that can be specified with | |
3221 | @samp{-fcontract-role} or @samp{-fcontract-semantic} are: | |
3222 | ||
3223 | @table @code | |
3224 | @item ignore | |
3225 | This contract has no effect. | |
3226 | ||
3227 | @item assume | |
3228 | This contract is treated like C++23 @code{[[assume]]}. | |
3229 | ||
3230 | @item check_never_continue | |
3231 | @itemx never | |
3232 | @itemx abort | |
3233 | This contract is checked. If it fails, the violation handler is | |
3234 | called. If the handler returns, @code{std::terminate} is called. | |
3235 | ||
3236 | @item check_maybe_continue | |
3237 | @itemx maybe | |
3238 | This contract is checked. If it fails, the violation handler is | |
3239 | called. If the handler returns, execution continues normally. | |
3240 | @end table | |
3241 | ||
d77de738 | 3242 | @opindex fcoroutines |
ddf6fe37 | 3243 | @item -fcoroutines |
d77de738 ML |
3244 | Enable support for the C++ coroutines extension (experimental). |
3245 | ||
d77de738 ML |
3246 | @opindex fno-elide-constructors |
3247 | @opindex felide-constructors | |
ddf6fe37 | 3248 | @item -fno-elide-constructors |
d77de738 ML |
3249 | The C++ standard allows an implementation to omit creating a temporary |
3250 | that is only used to initialize another object of the same type. | |
3251 | Specifying this option disables that optimization, and forces G++ to | |
3252 | call the copy constructor in all cases. This option also causes G++ | |
3253 | to call trivial member functions which otherwise would be expanded inline. | |
3254 | ||
3255 | In C++17, the compiler is required to omit these temporaries, but this | |
3256 | option still affects trivial member functions. | |
3257 | ||
d77de738 ML |
3258 | @opindex fno-enforce-eh-specs |
3259 | @opindex fenforce-eh-specs | |
ddf6fe37 | 3260 | @item -fno-enforce-eh-specs |
d77de738 ML |
3261 | Don't generate code to check for violation of exception specifications |
3262 | at run time. This option violates the C++ standard, but may be useful | |
3263 | for reducing code size in production builds, much like defining | |
3264 | @code{NDEBUG}. This does not give user code permission to throw | |
3265 | exceptions in violation of the exception specifications; the compiler | |
3266 | still optimizes based on the specifications, so throwing an | |
3267 | unexpected exception results in undefined behavior at run time. | |
3268 | ||
d77de738 ML |
3269 | @opindex fextern-tls-init |
3270 | @opindex fno-extern-tls-init | |
ddf6fe37 AA |
3271 | @item -fextern-tls-init |
3272 | @itemx -fno-extern-tls-init | |
d77de738 ML |
3273 | The C++11 and OpenMP standards allow @code{thread_local} and |
3274 | @code{threadprivate} variables to have dynamic (runtime) | |
3275 | initialization. To support this, any use of such a variable goes | |
3276 | through a wrapper function that performs any necessary initialization. | |
3277 | When the use and definition of the variable are in the same | |
3278 | translation unit, this overhead can be optimized away, but when the | |
3279 | use is in a different translation unit there is significant overhead | |
3280 | even if the variable doesn't actually need dynamic initialization. If | |
3281 | the programmer can be sure that no use of the variable in a | |
3282 | non-defining TU needs to trigger dynamic initialization (either | |
3283 | because the variable is statically initialized, or a use of the | |
3284 | variable in the defining TU will be executed before any uses in | |
3285 | another TU), they can avoid this overhead with the | |
3286 | @option{-fno-extern-tls-init} option. | |
3287 | ||
3288 | On targets that support symbol aliases, the default is | |
3289 | @option{-fextern-tls-init}. On targets that do not support symbol | |
3290 | aliases, the default is @option{-fno-extern-tls-init}. | |
3291 | ||
d77de738 ML |
3292 | @opindex ffold-simple-inlines |
3293 | @opindex fno-fold-simple-inlines | |
ddf6fe37 AA |
3294 | @item -ffold-simple-inlines |
3295 | @itemx -fno-fold-simple-inlines | |
d77de738 ML |
3296 | Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward}, |
3297 | @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this | |
3298 | means no debug information will be generated for such calls. Since these | |
3299 | functions are rarely interesting to debug, this flag is enabled by default | |
3300 | unless @option{-fno-inline} is active. | |
3301 | ||
d77de738 ML |
3302 | @opindex fno-gnu-keywords |
3303 | @opindex fgnu-keywords | |
ddf6fe37 | 3304 | @item -fno-gnu-keywords |
d77de738 ML |
3305 | Do not recognize @code{typeof} as a keyword, so that code can use this |
3306 | word as an identifier. You can use the keyword @code{__typeof__} instead. | |
3307 | This option is implied by the strict ISO C++ dialects: @option{-ansi}, | |
3308 | @option{-std=c++98}, @option{-std=c++11}, etc. | |
3309 | ||
d77de738 | 3310 | @opindex fimplicit-constexpr |
ddf6fe37 | 3311 | @item -fimplicit-constexpr |
d77de738 ML |
3312 | Make inline functions implicitly constexpr, if they satisfy the |
3313 | requirements for a constexpr function. This option can be used in | |
3314 | C++14 mode or later. This can result in initialization changing from | |
3315 | dynamic to static and other optimizations. | |
3316 | ||
d77de738 ML |
3317 | @opindex fno-implicit-templates |
3318 | @opindex fimplicit-templates | |
ddf6fe37 | 3319 | @item -fno-implicit-templates |
d77de738 ML |
3320 | Never emit code for non-inline templates that are instantiated |
3321 | implicitly (i.e.@: by use); only emit code for explicit instantiations. | |
3322 | If you use this option, you must take care to structure your code to | |
3323 | include all the necessary explicit instantiations to avoid getting | |
3324 | undefined symbols at link time. | |
3325 | @xref{Template Instantiation}, for more information. | |
3326 | ||
d77de738 ML |
3327 | @opindex fno-implicit-inline-templates |
3328 | @opindex fimplicit-inline-templates | |
ddf6fe37 | 3329 | @item -fno-implicit-inline-templates |
d77de738 ML |
3330 | Don't emit code for implicit instantiations of inline templates, either. |
3331 | The default is to handle inlines differently so that compiles with and | |
3332 | without optimization need the same set of explicit instantiations. | |
3333 | ||
d77de738 ML |
3334 | @opindex fno-implement-inlines |
3335 | @opindex fimplement-inlines | |
ddf6fe37 | 3336 | @item -fno-implement-inlines |
d77de738 ML |
3337 | To save space, do not emit out-of-line copies of inline functions |
3338 | controlled by @code{#pragma implementation}. This causes linker | |
3339 | errors if these functions are not inlined everywhere they are called. | |
3340 | ||
d77de738 ML |
3341 | @opindex fmodules-ts |
3342 | @opindex fno-modules-ts | |
ddf6fe37 AA |
3343 | @item -fmodules-ts |
3344 | @itemx -fno-modules-ts | |
d77de738 ML |
3345 | Enable support for C++20 modules (@pxref{C++ Modules}). The |
3346 | @option{-fno-modules-ts} is usually not needed, as that is the | |
3347 | default. Even though this is a C++20 feature, it is not currently | |
3348 | implicitly enabled by selecting that standard version. | |
3349 | ||
ddf6fe37 | 3350 | @opindex fmodule-header |
d77de738 ML |
3351 | @item -fmodule-header |
3352 | @itemx -fmodule-header=user | |
3353 | @itemx -fmodule-header=system | |
d77de738 ML |
3354 | Compile a header file to create an importable header unit. |
3355 | ||
d77de738 | 3356 | @opindex fmodule-implicit-inline |
ddf6fe37 | 3357 | @item -fmodule-implicit-inline |
d77de738 ML |
3358 | Member functions defined in their class definitions are not implicitly |
3359 | inline for modular code. This is different to traditional C++ | |
3360 | behavior, for good reasons. However, it may result in a difficulty | |
3361 | during code porting. This option makes such function definitions | |
3362 | implicitly inline. It does however generate an ABI incompatibility, | |
3363 | so you must use it everywhere or nowhere. (Such definitions outside | |
3364 | of a named module remain implicitly inline, regardless.) | |
3365 | ||
d77de738 ML |
3366 | @opindex fno-module-lazy |
3367 | @opindex fmodule-lazy | |
ddf6fe37 | 3368 | @item -fno-module-lazy |
d77de738 ML |
3369 | Disable lazy module importing and module mapper creation. |
3370 | ||
f33d7a88 AA |
3371 | @vindex CXX_MODULE_MAPPER @r{environment variable} |
3372 | @opindex fmodule-mapper | |
d77de738 ML |
3373 | @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} |
3374 | @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...} | |
3375 | @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]} | |
3376 | @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]} | |
3377 | @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
3378 | @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]} | |
d77de738 ML |
3379 | An oracle to query for module name to filename mappings. If |
3380 | unspecified the @env{CXX_MODULE_MAPPER} environment variable is used, | |
3381 | and if that is unset, an in-process default is provided. | |
3382 | ||
d77de738 | 3383 | @opindex fmodule-only |
ddf6fe37 | 3384 | @item -fmodule-only |
d77de738 ML |
3385 | Only emit the Compiled Module Interface, inhibiting any object file. |
3386 | ||
d77de738 | 3387 | @opindex fms-extensions |
ddf6fe37 | 3388 | @item -fms-extensions |
d77de738 ML |
3389 | Disable Wpedantic warnings about constructs used in MFC, such as implicit |
3390 | int and getting a pointer to member function via non-standard syntax. | |
3391 | ||
d77de738 | 3392 | @opindex fnew-inheriting-ctors |
ddf6fe37 | 3393 | @item -fnew-inheriting-ctors |
d77de738 ML |
3394 | Enable the P0136 adjustment to the semantics of C++11 constructor |
3395 | inheritance. This is part of C++17 but also considered to be a Defect | |
3396 | Report against C++11 and C++14. This flag is enabled by default | |
3397 | unless @option{-fabi-version=10} or lower is specified. | |
3398 | ||
d77de738 | 3399 | @opindex fnew-ttp-matching |
ddf6fe37 | 3400 | @item -fnew-ttp-matching |
d77de738 ML |
3401 | Enable the P0522 resolution to Core issue 150, template template |
3402 | parameters and default arguments: this allows a template with default | |
3403 | template arguments as an argument for a template template parameter | |
3404 | with fewer template parameters. This flag is enabled by default for | |
3405 | @option{-std=c++17}. | |
3406 | ||
d77de738 ML |
3407 | @opindex fno-nonansi-builtins |
3408 | @opindex fnonansi-builtins | |
ddf6fe37 | 3409 | @item -fno-nonansi-builtins |
d77de738 ML |
3410 | Disable built-in declarations of functions that are not mandated by |
3411 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, | |
3412 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. | |
3413 | ||
d77de738 | 3414 | @opindex fnothrow-opt |
ddf6fe37 | 3415 | @item -fnothrow-opt |
d77de738 ML |
3416 | Treat a @code{throw()} exception specification as if it were a |
3417 | @code{noexcept} specification to reduce or eliminate the text size | |
3418 | overhead relative to a function with no exception specification. If | |
3419 | the function has local variables of types with non-trivial | |
3420 | destructors, the exception specification actually makes the | |
3421 | function smaller because the EH cleanups for those variables can be | |
3422 | optimized away. The semantic effect is that an exception thrown out of | |
3423 | a function with such an exception specification results in a call | |
3424 | to @code{terminate} rather than @code{unexpected}. | |
3425 | ||
d77de738 ML |
3426 | @opindex fno-operator-names |
3427 | @opindex foperator-names | |
ddf6fe37 | 3428 | @item -fno-operator-names |
d77de738 ML |
3429 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
3430 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
3431 | synonyms as keywords. | |
3432 | ||
d77de738 ML |
3433 | @opindex fno-optional-diags |
3434 | @opindex foptional-diags | |
ddf6fe37 | 3435 | @item -fno-optional-diags |
d77de738 ML |
3436 | Disable diagnostics that the standard says a compiler does not need to |
3437 | issue. Currently, the only such diagnostic issued by G++ is the one for | |
3438 | a name having multiple meanings within a class. | |
3439 | ||
d77de738 | 3440 | @opindex fpermissive |
ddf6fe37 | 3441 | @item -fpermissive |
d77de738 ML |
3442 | Downgrade some diagnostics about nonconformant code from errors to |
3443 | warnings. Thus, using @option{-fpermissive} allows some | |
3444 | nonconforming code to compile. | |
3445 | ||
d77de738 ML |
3446 | @opindex fno-pretty-templates |
3447 | @opindex fpretty-templates | |
ddf6fe37 | 3448 | @item -fno-pretty-templates |
d77de738 ML |
3449 | When an error message refers to a specialization of a function |
3450 | template, the compiler normally prints the signature of the | |
3451 | template followed by the template arguments and any typedefs or | |
3452 | typenames in the signature (e.g.@: @code{void f(T) [with T = int]} | |
3453 | rather than @code{void f(int)}) so that it's clear which template is | |
3454 | involved. When an error message refers to a specialization of a class | |
3455 | template, the compiler omits any template arguments that match | |
3456 | the default template arguments for that template. If either of these | |
3457 | behaviors make it harder to understand the error message rather than | |
3458 | easier, you can use @option{-fno-pretty-templates} to disable them. | |
3459 | ||
d77de738 ML |
3460 | @opindex fno-rtti |
3461 | @opindex frtti | |
ddf6fe37 | 3462 | @item -fno-rtti |
d77de738 ML |
3463 | Disable generation of information about every class with virtual |
3464 | functions for use by the C++ run-time type identification features | |
3465 | (@code{dynamic_cast} and @code{typeid}). If you don't use those parts | |
3466 | of the language, you can save some space by using this flag. Note that | |
3467 | exception handling uses the same information, but G++ generates it as | |
3468 | needed. The @code{dynamic_cast} operator can still be used for casts that | |
3469 | do not require run-time type information, i.e.@: casts to @code{void *} or to | |
3470 | unambiguous base classes. | |
3471 | ||
3472 | Mixing code compiled with @option{-frtti} with that compiled with | |
3473 | @option{-fno-rtti} may not work. For example, programs may | |
3474 | fail to link if a class compiled with @option{-fno-rtti} is used as a base | |
3475 | for a class compiled with @option{-frtti}. | |
3476 | ||
d77de738 | 3477 | @opindex fsized-deallocation |
ddf6fe37 | 3478 | @item -fsized-deallocation |
d77de738 ML |
3479 | Enable the built-in global declarations |
3480 | @smallexample | |
3481 | void operator delete (void *, std::size_t) noexcept; | |
3482 | void operator delete[] (void *, std::size_t) noexcept; | |
3483 | @end smallexample | |
3484 | as introduced in C++14. This is useful for user-defined replacement | |
3485 | deallocation functions that, for example, use the size of the object | |
3486 | to make deallocation faster. Enabled by default under | |
3487 | @option{-std=c++14} and above. The flag @option{-Wsized-deallocation} | |
3488 | warns about places that might want to add a definition. | |
3489 | ||
d77de738 | 3490 | @opindex fstrict-enums |
ddf6fe37 | 3491 | @item -fstrict-enums |
d77de738 ML |
3492 | Allow the compiler to optimize using the assumption that a value of |
3493 | enumerated type can only be one of the values of the enumeration (as | |
3494 | defined in the C++ standard; basically, a value that can be | |
3495 | represented in the minimum number of bits needed to represent all the | |
3496 | enumerators). This assumption may not be valid if the program uses a | |
3497 | cast to convert an arbitrary integer value to the enumerated type. | |
d8a656d5 JW |
3498 | This option has no effect for an enumeration type with a fixed underlying |
3499 | type. | |
d77de738 | 3500 | |
d77de738 | 3501 | @opindex fstrong-eval-order |
ddf6fe37 | 3502 | @item -fstrong-eval-order |
d77de738 ML |
3503 | Evaluate member access, array subscripting, and shift expressions in |
3504 | left-to-right order, and evaluate assignment in right-to-left order, | |
3505 | as adopted for C++17. Enabled by default with @option{-std=c++17}. | |
3506 | @option{-fstrong-eval-order=some} enables just the ordering of member | |
3507 | access and shift expressions, and is the default without | |
3508 | @option{-std=c++17}. | |
3509 | ||
d77de738 | 3510 | @opindex ftemplate-backtrace-limit |
ddf6fe37 | 3511 | @item -ftemplate-backtrace-limit=@var{n} |
d77de738 ML |
3512 | Set the maximum number of template instantiation notes for a single |
3513 | warning or error to @var{n}. The default value is 10. | |
3514 | ||
d77de738 | 3515 | @opindex ftemplate-depth |
ddf6fe37 | 3516 | @item -ftemplate-depth=@var{n} |
d77de738 ML |
3517 | Set the maximum instantiation depth for template classes to @var{n}. |
3518 | A limit on the template instantiation depth is needed to detect | |
3519 | endless recursions during template class instantiation. ANSI/ISO C++ | |
3520 | conforming programs must not rely on a maximum depth greater than 17 | |
3521 | (changed to 1024 in C++11). The default value is 900, as the compiler | |
3522 | can run out of stack space before hitting 1024 in some situations. | |
3523 | ||
d77de738 ML |
3524 | @opindex fno-threadsafe-statics |
3525 | @opindex fthreadsafe-statics | |
ddf6fe37 | 3526 | @item -fno-threadsafe-statics |
d77de738 ML |
3527 | Do not emit the extra code to use the routines specified in the C++ |
3528 | ABI for thread-safe initialization of local statics. You can use this | |
3529 | option to reduce code size slightly in code that doesn't need to be | |
3530 | thread-safe. | |
3531 | ||
d77de738 | 3532 | @opindex fuse-cxa-atexit |
ddf6fe37 | 3533 | @item -fuse-cxa-atexit |
d77de738 ML |
3534 | Register destructors for objects with static storage duration with the |
3535 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
3536 | This option is required for fully standards-compliant handling of static | |
3537 | destructors, but only works if your C library supports | |
3538 | @code{__cxa_atexit}. | |
3539 | ||
d77de738 ML |
3540 | @opindex fno-use-cxa-get-exception-ptr |
3541 | @opindex fuse-cxa-get-exception-ptr | |
ddf6fe37 | 3542 | @item -fno-use-cxa-get-exception-ptr |
d77de738 ML |
3543 | Don't use the @code{__cxa_get_exception_ptr} runtime routine. This |
3544 | causes @code{std::uncaught_exception} to be incorrect, but is necessary | |
3545 | if the runtime routine is not available. | |
3546 | ||
d77de738 | 3547 | @opindex fvisibility-inlines-hidden |
ddf6fe37 | 3548 | @item -fvisibility-inlines-hidden |
d77de738 ML |
3549 | This switch declares that the user does not attempt to compare |
3550 | pointers to inline functions or methods where the addresses of the two functions | |
3551 | are taken in different shared objects. | |
3552 | ||
3553 | The effect of this is that GCC may, effectively, mark inline methods with | |
3554 | @code{__attribute__ ((visibility ("hidden")))} so that they do not | |
3555 | appear in the export table of a DSO and do not require a PLT indirection | |
3556 | when used within the DSO@. Enabling this option can have a dramatic effect | |
3557 | on load and link times of a DSO as it massively reduces the size of the | |
3558 | dynamic export table when the library makes heavy use of templates. | |
3559 | ||
3560 | The behavior of this switch is not quite the same as marking the | |
3561 | methods as hidden directly, because it does not affect static variables | |
3562 | local to the function or cause the compiler to deduce that | |
3563 | the function is defined in only one shared object. | |
3564 | ||
3565 | You may mark a method as having a visibility explicitly to negate the | |
3566 | effect of the switch for that method. For example, if you do want to | |
3567 | compare pointers to a particular inline method, you might mark it as | |
3568 | having default visibility. Marking the enclosing class with explicit | |
3569 | visibility has no effect. | |
3570 | ||
3571 | Explicitly instantiated inline methods are unaffected by this option | |
3572 | as their linkage might otherwise cross a shared library boundary. | |
3573 | @xref{Template Instantiation}. | |
3574 | ||
d77de738 | 3575 | @opindex fvisibility-ms-compat |
ddf6fe37 | 3576 | @item -fvisibility-ms-compat |
d77de738 ML |
3577 | This flag attempts to use visibility settings to make GCC's C++ |
3578 | linkage model compatible with that of Microsoft Visual Studio. | |
3579 | ||
3580 | The flag makes these changes to GCC's linkage model: | |
3581 | ||
3582 | @enumerate | |
3583 | @item | |
3584 | It sets the default visibility to @code{hidden}, like | |
3585 | @option{-fvisibility=hidden}. | |
3586 | ||
3587 | @item | |
3588 | Types, but not their members, are not hidden by default. | |
3589 | ||
3590 | @item | |
3591 | The One Definition Rule is relaxed for types without explicit | |
3592 | visibility specifications that are defined in more than one | |
3593 | shared object: those declarations are permitted if they are | |
3594 | permitted when this option is not used. | |
3595 | @end enumerate | |
3596 | ||
3597 | In new code it is better to use @option{-fvisibility=hidden} and | |
3598 | export those classes that are intended to be externally visible. | |
3599 | Unfortunately it is possible for code to rely, perhaps accidentally, | |
3600 | on the Visual Studio behavior. | |
3601 | ||
3602 | Among the consequences of these changes are that static data members | |
3603 | of the same type with the same name but defined in different shared | |
3604 | objects are different, so changing one does not change the other; | |
3605 | and that pointers to function members defined in different shared | |
3606 | objects may not compare equal. When this flag is given, it is a | |
3607 | violation of the ODR to define types with the same name differently. | |
3608 | ||
d77de738 ML |
3609 | @opindex fno-weak |
3610 | @opindex fweak | |
ddf6fe37 | 3611 | @item -fno-weak |
d77de738 ML |
3612 | Do not use weak symbol support, even if it is provided by the linker. |
3613 | By default, G++ uses weak symbols if they are available. This | |
3614 | option exists only for testing, and should not be used by end-users; | |
3615 | it results in inferior code and has no benefits. This option may | |
3616 | be removed in a future release of G++. | |
3617 | ||
d77de738 ML |
3618 | @opindex fext-numeric-literals |
3619 | @opindex fno-ext-numeric-literals | |
ddf6fe37 | 3620 | @item -fext-numeric-literals @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3621 | Accept imaginary, fixed-point, or machine-defined |
3622 | literal number suffixes as GNU extensions. | |
3623 | When this option is turned off these suffixes are treated | |
3624 | as C++11 user-defined literal numeric suffixes. | |
3625 | This is on by default for all pre-C++11 dialects and all GNU dialects: | |
3626 | @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11}, | |
3627 | @option{-std=gnu++14}. | |
3628 | This option is off by default | |
3629 | for ISO C++11 onwards (@option{-std=c++11}, ...). | |
3630 | ||
d77de738 | 3631 | @opindex nostdinc++ |
ddf6fe37 | 3632 | @item -nostdinc++ |
d77de738 ML |
3633 | Do not search for header files in the standard directories specific to |
3634 | C++, but do still search the other standard directories. (This option | |
3635 | is used when building the C++ library.) | |
3636 | ||
ddf6fe37 AA |
3637 | @opindex flang-info-include-translate |
3638 | @opindex flang-info-include-translate-not | |
d77de738 ML |
3639 | @item -flang-info-include-translate |
3640 | @itemx -flang-info-include-translate-not | |
3641 | @itemx -flang-info-include-translate=@var{header} | |
d77de738 ML |
3642 | Inform of include translation events. The first will note accepted |
3643 | include translations, the second will note declined include | |
3644 | translations. The @var{header} form will inform of include | |
3645 | translations relating to that specific header. If @var{header} is of | |
3646 | the form @code{"user"} or @code{<system>} it will be resolved to a | |
3647 | specific user or system header using the include path. | |
3648 | ||
ddf6fe37 | 3649 | @opindex flang-info-module-cmi |
d77de738 ML |
3650 | @item -flang-info-module-cmi |
3651 | @itemx -flang-info-module-cmi=@var{module} | |
d77de738 ML |
3652 | Inform of Compiled Module Interface pathnames. The first will note |
3653 | all read CMI pathnames. The @var{module} form will not reading a | |
3654 | specific module's CMI. @var{module} may be a named module or a | |
3655 | header-unit (the latter indicated by either being a pathname containing | |
3656 | directory separators or enclosed in @code{<>} or @code{""}). | |
3657 | ||
d77de738 | 3658 | @opindex stdlib |
ddf6fe37 | 3659 | @item -stdlib=@var{libstdc++,libc++} |
d77de738 ML |
3660 | When G++ is configured to support this option, it allows specification of |
3661 | alternate C++ runtime libraries. Two options are available: @var{libstdc++} | |
3662 | (the default, native C++ runtime for G++) and @var{libc++} which is the | |
3663 | C++ runtime installed on some operating systems (e.g. Darwin versions from | |
3664 | Darwin11 onwards). The option switches G++ to use the headers from the | |
3665 | specified library and to emit @code{-lstdc++} or @code{-lc++} respectively, | |
3666 | when a C++ runtime is required for linking. | |
3667 | @end table | |
3668 | ||
3669 | In addition, these warning options have meanings only for C++ programs: | |
3670 | ||
3671 | @table @gcctabopt | |
d77de738 | 3672 | @opindex Wabi-tag |
ddf6fe37 | 3673 | @item -Wabi-tag @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3674 | Warn when a type with an ABI tag is used in a context that does not |
3675 | have that ABI tag. See @ref{C++ Attributes} for more information | |
3676 | about ABI tags. | |
3677 | ||
d77de738 ML |
3678 | @opindex Wcomma-subscript |
3679 | @opindex Wno-comma-subscript | |
ddf6fe37 | 3680 | @item -Wcomma-subscript @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3681 | Warn about uses of a comma expression within a subscripting expression. |
3682 | This usage was deprecated in C++20 and is going to be removed in C++23. | |
3683 | However, a comma expression wrapped in @code{( )} is not deprecated. Example: | |
3684 | ||
3685 | @smallexample | |
3686 | @group | |
3687 | void f(int *a, int b, int c) @{ | |
3688 | a[b,c]; // deprecated in C++20, invalid in C++23 | |
3689 | a[(b,c)]; // OK | |
3690 | @} | |
3691 | @end group | |
3692 | @end smallexample | |
3693 | ||
3694 | In C++23 it is valid to have comma separated expressions in a subscript | |
3695 | when an overloaded subscript operator is found and supports the right | |
3696 | number and types of arguments. G++ will accept the formerly valid syntax | |
3697 | for code that is not valid in C++23 but used to be valid but deprecated | |
3698 | in C++20 with a pedantic warning that can be disabled with | |
3699 | @option{-Wno-comma-subscript}. | |
3700 | ||
3701 | Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated}, | |
3702 | and with @option{-std=c++23} regardless of @option{-Wno-deprecated}. | |
3703 | ||
5fccebdb JM |
3704 | This warning is upgraded to an error by @option{-pedantic-errors} in |
3705 | C++23 mode or later. | |
3706 | ||
d77de738 ML |
3707 | @opindex Wctad-maybe-unsupported |
3708 | @opindex Wno-ctad-maybe-unsupported | |
ddf6fe37 | 3709 | @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3710 | Warn when performing class template argument deduction (CTAD) on a type with |
3711 | no explicitly written deduction guides. This warning will point out cases | |
3712 | where CTAD succeeded only because the compiler synthesized the implicit | |
3713 | deduction guides, which might not be what the programmer intended. Certain | |
3714 | style guides allow CTAD only on types that specifically "opt-in"; i.e., on | |
3715 | types that are designed to support CTAD. This warning can be suppressed with | |
3716 | the following pattern: | |
3717 | ||
3718 | @smallexample | |
3719 | struct allow_ctad_t; // any name works | |
3720 | template <typename T> struct S @{ | |
3721 | S(T) @{ @} | |
3722 | @}; | |
4ace81b6 SL |
3723 | // Guide with incomplete parameter type will never be considered. |
3724 | S(allow_ctad_t) -> S<void>; | |
d77de738 ML |
3725 | @end smallexample |
3726 | ||
d77de738 ML |
3727 | @opindex Wctor-dtor-privacy |
3728 | @opindex Wno-ctor-dtor-privacy | |
ddf6fe37 | 3729 | @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3730 | Warn when a class seems unusable because all the constructors or |
3731 | destructors in that class are private, and it has neither friends nor | |
3732 | public static member functions. Also warn if there are no non-private | |
3733 | methods, and there's at least one private member function that isn't | |
3734 | a constructor or destructor. | |
3735 | ||
d77de738 ML |
3736 | @opindex Wdangling-reference |
3737 | @opindex Wno-dangling-reference | |
ddf6fe37 | 3738 | @item -Wdangling-reference @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3739 | Warn when a reference is bound to a temporary whose lifetime has ended. |
3740 | For example: | |
3741 | ||
3742 | @smallexample | |
3743 | int n = 1; | |
3744 | const int& r = std::max(n - 1, n + 1); // r is dangling | |
3745 | @end smallexample | |
3746 | ||
3747 | In the example above, two temporaries are created, one for each | |
3748 | argument, and a reference to one of the temporaries is returned. | |
3749 | However, both temporaries are destroyed at the end of the full | |
3750 | expression, so the reference @code{r} is dangling. This warning | |
3751 | also detects dangling references in member initializer lists: | |
3752 | ||
3753 | @smallexample | |
3754 | const int& f(const int& i) @{ return i; @} | |
3755 | struct S @{ | |
3756 | const int &r; // r is dangling | |
3757 | S() : r(f(10)) @{ @} | |
3758 | @}; | |
3759 | @end smallexample | |
3760 | ||
3761 | Member functions are checked as well, but only their object argument: | |
3762 | ||
3763 | @smallexample | |
3764 | struct S @{ | |
3765 | const S& self () @{ return *this; @} | |
3766 | @}; | |
3767 | const S& s = S().self(); // s is dangling | |
3768 | @end smallexample | |
3769 | ||
3770 | Certain functions are safe in this respect, for example @code{std::use_facet}: | |
3771 | they take and return a reference, but they don't return one of its arguments, | |
3772 | which can fool the warning. Such functions can be excluded from the warning | |
3773 | by wrapping them in a @code{#pragma}: | |
3774 | ||
3775 | @smallexample | |
3776 | #pragma GCC diagnostic push | |
3777 | #pragma GCC diagnostic ignored "-Wdangling-reference" | |
3778 | const T& foo (const T&) @{ @dots{} @} | |
3779 | #pragma GCC diagnostic pop | |
3780 | @end smallexample | |
3781 | ||
ce51e843 ML |
3782 | @option{-Wdangling-reference} also warns about code like |
3783 | ||
3784 | @smallexample | |
3785 | auto p = std::minmax(1, 2); | |
3786 | @end smallexample | |
3787 | ||
3788 | where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and | |
3789 | both references dangle after the end of the full expression that contains | |
3790 | the call to @code{std::minmax}. | |
3791 | ||
d77de738 ML |
3792 | This warning is enabled by @option{-Wall}. |
3793 | ||
d77de738 ML |
3794 | @opindex Wdelete-non-virtual-dtor |
3795 | @opindex Wno-delete-non-virtual-dtor | |
ddf6fe37 | 3796 | @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3797 | Warn when @code{delete} is used to destroy an instance of a class that |
3798 | has virtual functions and non-virtual destructor. It is unsafe to delete | |
3799 | an instance of a derived class through a pointer to a base class if the | |
3800 | base class does not have a virtual destructor. This warning is enabled | |
3801 | by @option{-Wall}. | |
3802 | ||
d77de738 ML |
3803 | @opindex Wdeprecated-copy |
3804 | @opindex Wno-deprecated-copy | |
ddf6fe37 | 3805 | @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3806 | Warn that the implicit declaration of a copy constructor or copy |
3807 | assignment operator is deprecated if the class has a user-provided | |
3808 | copy constructor or copy assignment operator, in C++11 and up. This | |
3809 | warning is enabled by @option{-Wextra}. With | |
3810 | @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a | |
3811 | user-provided destructor. | |
3812 | ||
d77de738 ML |
3813 | @opindex Wdeprecated-enum-enum-conversion |
3814 | @opindex Wno-deprecated-enum-enum-conversion | |
ddf6fe37 | 3815 | @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3816 | Disable the warning about the case when the usual arithmetic conversions |
3817 | are applied on operands where one is of enumeration type and the other is | |
3818 | of a different enumeration type. This conversion was deprecated in C++20. | |
3819 | For example: | |
3820 | ||
3821 | @smallexample | |
3822 | enum E1 @{ e @}; | |
3823 | enum E2 @{ f @}; | |
3824 | int k = f - e; | |
3825 | @end smallexample | |
3826 | ||
3827 | @option{-Wdeprecated-enum-enum-conversion} is enabled by default with | |
3828 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3829 | by @option{-Wenum-conversion}. | |
3830 | ||
d77de738 ML |
3831 | @opindex Wdeprecated-enum-float-conversion |
3832 | @opindex Wno-deprecated-enum-float-conversion | |
ddf6fe37 | 3833 | @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3834 | Disable the warning about the case when the usual arithmetic conversions |
3835 | are applied on operands where one is of enumeration type and the other is | |
3836 | of a floating-point type. This conversion was deprecated in C++20. For | |
3837 | example: | |
3838 | ||
3839 | @smallexample | |
3840 | enum E1 @{ e @}; | |
3841 | enum E2 @{ f @}; | |
3842 | bool b = e <= 3.7; | |
3843 | @end smallexample | |
3844 | ||
3845 | @option{-Wdeprecated-enum-float-conversion} is enabled by default with | |
3846 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3847 | by @option{-Wenum-conversion}. | |
3848 | ||
d77de738 ML |
3849 | @opindex Winit-list-lifetime |
3850 | @opindex Wno-init-list-lifetime | |
ddf6fe37 | 3851 | @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3852 | Do not warn about uses of @code{std::initializer_list} that are likely |
3853 | to result in dangling pointers. Since the underlying array for an | |
3854 | @code{initializer_list} is handled like a normal C++ temporary object, | |
3855 | it is easy to inadvertently keep a pointer to the array past the end | |
3856 | of the array's lifetime. For example: | |
3857 | ||
3858 | @itemize @bullet | |
3859 | @item | |
3860 | If a function returns a temporary @code{initializer_list}, or a local | |
3861 | @code{initializer_list} variable, the array's lifetime ends at the end | |
3862 | of the return statement, so the value returned has a dangling pointer. | |
3863 | ||
3864 | @item | |
3865 | If a new-expression creates an @code{initializer_list}, the array only | |
3866 | lives until the end of the enclosing full-expression, so the | |
3867 | @code{initializer_list} in the heap has a dangling pointer. | |
3868 | ||
3869 | @item | |
3870 | When an @code{initializer_list} variable is assigned from a | |
3871 | brace-enclosed initializer list, the temporary array created for the | |
3872 | right side of the assignment only lives until the end of the | |
3873 | full-expression, so at the next statement the @code{initializer_list} | |
3874 | variable has a dangling pointer. | |
3875 | ||
3876 | @smallexample | |
3877 | // li's initial underlying array lives as long as li | |
3878 | std::initializer_list<int> li = @{ 1,2,3 @}; | |
3879 | // assignment changes li to point to a temporary array | |
3880 | li = @{ 4, 5 @}; | |
3881 | // now the temporary is gone and li has a dangling pointer | |
3882 | int i = li.begin()[0] // undefined behavior | |
3883 | @end smallexample | |
3884 | ||
3885 | @item | |
3886 | When a list constructor stores the @code{begin} pointer from the | |
3887 | @code{initializer_list} argument, this doesn't extend the lifetime of | |
3888 | the array, so if a class variable is constructed from a temporary | |
3889 | @code{initializer_list}, the pointer is left dangling by the end of | |
3890 | the variable declaration statement. | |
3891 | ||
3892 | @end itemize | |
3893 | ||
c85f8dbb MP |
3894 | @opindex Winvalid-constexpr |
3895 | @opindex Wno-invalid-constexpr | |
ddf6fe37 | 3896 | @item -Winvalid-constexpr |
c85f8dbb MP |
3897 | |
3898 | Warn when a function never produces a constant expression. In C++20 | |
3899 | and earlier, for every @code{constexpr} function and function template, | |
3900 | there must be at least one set of function arguments in at least one | |
3901 | instantiation such that an invocation of the function or constructor | |
3902 | could be an evaluated subexpression of a core constant expression. | |
3903 | C++23 removed this restriction, so it's possible to have a function | |
3904 | or a function template marked @code{constexpr} for which no invocation | |
3905 | satisfies the requirements of a core constant expression. | |
3906 | ||
3907 | This warning is enabled as a pedantic warning by default in C++20 and | |
3908 | earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in | |
3909 | which case it will be an ordinary warning. For example: | |
3910 | ||
3911 | @smallexample | |
3912 | void f (int& i); | |
3913 | constexpr void | |
3914 | g (int& i) | |
3915 | @{ | |
4ace81b6 SL |
3916 | // Warns by default in C++20, in C++23 only with -Winvalid-constexpr. |
3917 | f(i); | |
c85f8dbb MP |
3918 | @} |
3919 | @end smallexample | |
3920 | ||
d77de738 ML |
3921 | @opindex Winvalid-imported-macros |
3922 | @opindex Wno-invalid-imported-macros | |
ddf6fe37 | 3923 | @item -Winvalid-imported-macros |
d77de738 ML |
3924 | Verify all imported macro definitions are valid at the end of |
3925 | compilation. This is not enabled by default, as it requires | |
3926 | additional processing to determine. It may be useful when preparing | |
3927 | sets of header-units to ensure consistent macros. | |
3928 | ||
d77de738 ML |
3929 | @opindex Wliteral-suffix |
3930 | @opindex Wno-literal-suffix | |
ddf6fe37 | 3931 | @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3932 | Do not warn when a string or character literal is followed by a |
3933 | ud-suffix which does not begin with an underscore. As a conforming | |
3934 | extension, GCC treats such suffixes as separate preprocessing tokens | |
3935 | in order to maintain backwards compatibility with code that uses | |
3936 | formatting macros from @code{<inttypes.h>}. For example: | |
3937 | ||
3938 | @smallexample | |
3939 | #define __STDC_FORMAT_MACROS | |
3940 | #include <inttypes.h> | |
3941 | #include <stdio.h> | |
3942 | ||
3943 | int main() @{ | |
3944 | int64_t i64 = 123; | |
3945 | printf("My int64: %" PRId64"\n", i64); | |
3946 | @} | |
3947 | @end smallexample | |
3948 | ||
3949 | In this case, @code{PRId64} is treated as a separate preprocessing token. | |
3950 | ||
3951 | This option also controls warnings when a user-defined literal | |
3952 | operator is declared with a literal suffix identifier that doesn't | |
3953 | begin with an underscore. Literal suffix identifiers that don't begin | |
3954 | with an underscore are reserved for future standardization. | |
3955 | ||
3956 | These warnings are enabled by default. | |
3957 | ||
d77de738 ML |
3958 | @opindex Wnarrowing |
3959 | @opindex Wno-narrowing | |
ddf6fe37 | 3960 | @item -Wno-narrowing @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3961 | For C++11 and later standards, narrowing conversions are diagnosed by default, |
3962 | as required by the standard. A narrowing conversion from a constant produces | |
3963 | an error, and a narrowing conversion from a non-constant produces a warning, | |
3964 | but @option{-Wno-narrowing} suppresses the diagnostic. | |
3965 | Note that this does not affect the meaning of well-formed code; | |
3966 | narrowing conversions are still considered ill-formed in SFINAE contexts. | |
3967 | ||
3968 | With @option{-Wnarrowing} in C++98, warn when a narrowing | |
3969 | conversion prohibited by C++11 occurs within | |
3970 | @samp{@{ @}}, e.g. | |
3971 | ||
3972 | @smallexample | |
3973 | int i = @{ 2.2 @}; // error: narrowing from double to int | |
3974 | @end smallexample | |
3975 | ||
3976 | This flag is included in @option{-Wall} and @option{-Wc++11-compat}. | |
3977 | ||
d77de738 ML |
3978 | @opindex Wnoexcept |
3979 | @opindex Wno-noexcept | |
ddf6fe37 | 3980 | @item -Wnoexcept @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3981 | Warn when a noexcept-expression evaluates to false because of a call |
3982 | to a function that does not have a non-throwing exception | |
3983 | specification (i.e. @code{throw()} or @code{noexcept}) but is known by | |
3984 | the compiler to never throw an exception. | |
3985 | ||
d77de738 ML |
3986 | @opindex Wnoexcept-type |
3987 | @opindex Wno-noexcept-type | |
ddf6fe37 | 3988 | @item -Wnoexcept-type @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3989 | Warn if the C++17 feature making @code{noexcept} part of a function |
3990 | type changes the mangled name of a symbol relative to C++14. Enabled | |
3991 | by @option{-Wabi} and @option{-Wc++17-compat}. | |
3992 | ||
3993 | As an example: | |
3994 | ||
3995 | @smallexample | |
3996 | template <class T> void f(T t) @{ t(); @}; | |
3997 | void g() noexcept; | |
3998 | void h() @{ f(g); @} | |
3999 | @end smallexample | |
4000 | ||
4001 | @noindent | |
4002 | In C++14, @code{f} calls @code{f<void(*)()>}, but in | |
4003 | C++17 it calls @code{f<void(*)()noexcept>}. | |
4004 | ||
d77de738 ML |
4005 | @opindex Wclass-memaccess |
4006 | @opindex Wno-class-memaccess | |
ddf6fe37 | 4007 | @item -Wclass-memaccess @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4008 | Warn when the destination of a call to a raw memory function such as |
4009 | @code{memset} or @code{memcpy} is an object of class type, and when writing | |
4010 | into such an object might bypass the class non-trivial or deleted constructor | |
4011 | or copy assignment, violate const-correctness or encapsulation, or corrupt | |
4012 | virtual table pointers. Modifying the representation of such objects may | |
4013 | violate invariants maintained by member functions of the class. For example, | |
4014 | the call to @code{memset} below is undefined because it modifies a non-trivial | |
4015 | class object and is, therefore, diagnosed. The safe way to either initialize | |
4016 | or clear the storage of objects of such types is by using the appropriate | |
4017 | constructor or assignment operator, if one is available. | |
4018 | @smallexample | |
4019 | std::string str = "abc"; | |
4020 | memset (&str, 0, sizeof str); | |
4021 | @end smallexample | |
4022 | The @option{-Wclass-memaccess} option is enabled by @option{-Wall}. | |
4023 | Explicitly casting the pointer to the class object to @code{void *} or | |
4024 | to a type that can be safely accessed by the raw memory function suppresses | |
4025 | the warning. | |
4026 | ||
d77de738 ML |
4027 | @opindex Wnon-virtual-dtor |
4028 | @opindex Wno-non-virtual-dtor | |
ddf6fe37 | 4029 | @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4030 | Warn when a class has virtual functions and an accessible non-virtual |
4031 | destructor itself or in an accessible polymorphic base class, in which | |
4032 | case it is possible but unsafe to delete an instance of a derived | |
4033 | class through a pointer to the class itself or base class. This | |
4034 | warning is automatically enabled if @option{-Weffc++} is specified. | |
51f28e3a JW |
4035 | The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall}) |
4036 | should be preferred because it warns about the unsafe cases without false | |
4037 | positives. | |
d77de738 | 4038 | |
d77de738 ML |
4039 | @opindex Wregister |
4040 | @opindex Wno-register | |
ddf6fe37 | 4041 | @item -Wregister @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4042 | Warn on uses of the @code{register} storage class specifier, except |
4043 | when it is part of the GNU @ref{Explicit Register Variables} extension. | |
4044 | The use of the @code{register} keyword as storage class specifier has | |
4045 | been deprecated in C++11 and removed in C++17. | |
4046 | Enabled by default with @option{-std=c++17}. | |
4047 | ||
d77de738 ML |
4048 | @opindex Wreorder |
4049 | @opindex Wno-reorder | |
4050 | @cindex reordering, warning | |
4051 | @cindex warning for reordering of member initializers | |
f33d7a88 | 4052 | @item -Wreorder @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4053 | Warn when the order of member initializers given in the code does not |
4054 | match the order in which they must be executed. For instance: | |
4055 | ||
4056 | @smallexample | |
4057 | struct A @{ | |
4058 | int i; | |
4059 | int j; | |
4060 | A(): j (0), i (1) @{ @} | |
4061 | @}; | |
4062 | @end smallexample | |
4063 | ||
4064 | @noindent | |
4065 | The compiler rearranges the member initializers for @code{i} | |
4066 | and @code{j} to match the declaration order of the members, emitting | |
4067 | a warning to that effect. This warning is enabled by @option{-Wall}. | |
4068 | ||
d77de738 ML |
4069 | @opindex Wpessimizing-move |
4070 | @opindex Wno-pessimizing-move | |
ddf6fe37 | 4071 | @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4072 | This warning warns when a call to @code{std::move} prevents copy |
4073 | elision. A typical scenario when copy elision can occur is when returning in | |
4074 | a function with a class return type, when the expression being returned is the | |
4075 | name of a non-volatile automatic object, and is not a function parameter, and | |
4076 | has the same type as the function return type. | |
4077 | ||
4078 | @smallexample | |
4079 | struct T @{ | |
4080 | @dots{} | |
4081 | @}; | |
4082 | T fn() | |
4083 | @{ | |
4084 | T t; | |
4085 | @dots{} | |
4086 | return std::move (t); | |
4087 | @} | |
4088 | @end smallexample | |
4089 | ||
4090 | But in this example, the @code{std::move} call prevents copy elision. | |
4091 | ||
4092 | This warning is enabled by @option{-Wall}. | |
4093 | ||
d77de738 ML |
4094 | @opindex Wredundant-move |
4095 | @opindex Wno-redundant-move | |
ddf6fe37 | 4096 | @item -Wno-redundant-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4097 | This warning warns about redundant calls to @code{std::move}; that is, when |
4098 | a move operation would have been performed even without the @code{std::move} | |
4099 | call. This happens because the compiler is forced to treat the object as if | |
4100 | it were an rvalue in certain situations such as returning a local variable, | |
4101 | where copy elision isn't applicable. Consider: | |
4102 | ||
4103 | @smallexample | |
4104 | struct T @{ | |
4105 | @dots{} | |
4106 | @}; | |
4107 | T fn(T t) | |
4108 | @{ | |
4109 | @dots{} | |
4110 | return std::move (t); | |
4111 | @} | |
4112 | @end smallexample | |
4113 | ||
4114 | Here, the @code{std::move} call is redundant. Because G++ implements Core | |
4115 | Issue 1579, another example is: | |
4116 | ||
4117 | @smallexample | |
4118 | struct T @{ // convertible to U | |
4119 | @dots{} | |
4120 | @}; | |
4121 | struct U @{ | |
4122 | @dots{} | |
4123 | @}; | |
4124 | U fn() | |
4125 | @{ | |
4126 | T t; | |
4127 | @dots{} | |
4128 | return std::move (t); | |
4129 | @} | |
4130 | @end smallexample | |
4131 | In this example, copy elision isn't applicable because the type of the | |
4132 | expression being returned and the function return type differ, yet G++ | |
4133 | treats the return value as if it were designated by an rvalue. | |
4134 | ||
4135 | This warning is enabled by @option{-Wextra}. | |
4136 | ||
d77de738 ML |
4137 | @opindex Wrange-loop-construct |
4138 | @opindex Wno-range-loop-construct | |
ddf6fe37 | 4139 | @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4140 | This warning warns when a C++ range-based for-loop is creating an unnecessary |
4141 | copy. This can happen when the range declaration is not a reference, but | |
4142 | probably should be. For example: | |
4143 | ||
4144 | @smallexample | |
4145 | struct S @{ char arr[128]; @}; | |
4146 | void fn () @{ | |
4147 | S arr[5]; | |
4148 | for (const auto x : arr) @{ @dots{} @} | |
4149 | @} | |
4150 | @end smallexample | |
4151 | ||
4152 | It does not warn when the type being copied is a trivially-copyable type whose | |
4153 | size is less than 64 bytes. | |
4154 | ||
4155 | This warning also warns when a loop variable in a range-based for-loop is | |
4156 | initialized with a value of a different type resulting in a copy. For example: | |
4157 | ||
4158 | @smallexample | |
4159 | void fn() @{ | |
4160 | int arr[10]; | |
4161 | for (const double &x : arr) @{ @dots{} @} | |
4162 | @} | |
4163 | @end smallexample | |
4164 | ||
4165 | In the example above, in every iteration of the loop a temporary value of | |
4166 | type @code{double} is created and destroyed, to which the reference | |
4167 | @code{const double &} is bound. | |
4168 | ||
4169 | This warning is enabled by @option{-Wall}. | |
4170 | ||
d77de738 ML |
4171 | @opindex Wredundant-tags |
4172 | @opindex Wno-redundant-tags | |
ddf6fe37 | 4173 | @item -Wredundant-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4174 | Warn about redundant class-key and enum-key in references to class types |
4175 | and enumerated types in contexts where the key can be eliminated without | |
4176 | causing an ambiguity. For example: | |
4177 | ||
4178 | @smallexample | |
4179 | struct foo; | |
4180 | struct foo *p; // warn that keyword struct can be eliminated | |
4181 | @end smallexample | |
4182 | ||
4183 | @noindent | |
4184 | On the other hand, in this example there is no warning: | |
4185 | ||
4186 | @smallexample | |
4187 | struct foo; | |
4188 | void foo (); // "hides" struct foo | |
4189 | void bar (struct foo&); // no warning, keyword struct is necessary | |
4190 | @end smallexample | |
4191 | ||
d77de738 ML |
4192 | @opindex Wsubobject-linkage |
4193 | @opindex Wno-subobject-linkage | |
ddf6fe37 | 4194 | @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4195 | Do not warn |
4196 | if a class type has a base or a field whose type uses the anonymous | |
4197 | namespace or depends on a type with no linkage. If a type A depends on | |
4198 | a type B with no or internal linkage, defining it in multiple | |
4199 | translation units would be an ODR violation because the meaning of B | |
4200 | is different in each translation unit. If A only appears in a single | |
4201 | translation unit, the best way to silence the warning is to give it | |
4202 | internal linkage by putting it in an anonymous namespace as well. The | |
4203 | compiler doesn't give this warning for types defined in the main .C | |
4204 | file, as those are unlikely to have multiple definitions. | |
4205 | @option{-Wsubobject-linkage} is enabled by default. | |
4206 | ||
d77de738 ML |
4207 | @opindex Weffc++ |
4208 | @opindex Wno-effc++ | |
ddf6fe37 | 4209 | @item -Weffc++ @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4210 | Warn about violations of the following style guidelines from Scott Meyers' |
4211 | @cite{Effective C++} series of books: | |
4212 | ||
4213 | @itemize @bullet | |
4214 | @item | |
4215 | Define a copy constructor and an assignment operator for classes | |
4216 | with dynamically-allocated memory. | |
4217 | ||
4218 | @item | |
4219 | Prefer initialization to assignment in constructors. | |
4220 | ||
4221 | @item | |
4222 | Have @code{operator=} return a reference to @code{*this}. | |
4223 | ||
4224 | @item | |
4225 | Don't try to return a reference when you must return an object. | |
4226 | ||
4227 | @item | |
4228 | Distinguish between prefix and postfix forms of increment and | |
4229 | decrement operators. | |
4230 | ||
4231 | @item | |
4232 | Never overload @code{&&}, @code{||}, or @code{,}. | |
4233 | ||
4234 | @end itemize | |
4235 | ||
4236 | This option also enables @option{-Wnon-virtual-dtor}, which is also | |
4237 | one of the effective C++ recommendations. However, the check is | |
4238 | extended to warn about the lack of virtual destructor in accessible | |
4239 | non-polymorphic bases classes too. | |
4240 | ||
4241 | When selecting this option, be aware that the standard library | |
4242 | headers do not obey all of these guidelines; use @samp{grep -v} | |
4243 | to filter out those warnings. | |
4244 | ||
d77de738 ML |
4245 | @opindex Wexceptions |
4246 | @opindex Wno-exceptions | |
ddf6fe37 | 4247 | @item -Wno-exceptions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4248 | Disable the warning about the case when an exception handler is shadowed by |
4249 | another handler, which can point out a wrong ordering of exception handlers. | |
4250 | ||
d77de738 ML |
4251 | @opindex Wstrict-null-sentinel |
4252 | @opindex Wno-strict-null-sentinel | |
ddf6fe37 | 4253 | @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4254 | Warn about the use of an uncasted @code{NULL} as sentinel. When |
4255 | compiling only with GCC this is a valid sentinel, as @code{NULL} is defined | |
4256 | to @code{__null}. Although it is a null pointer constant rather than a | |
4257 | null pointer, it is guaranteed to be of the same size as a pointer. | |
4258 | But this use is not portable across different compilers. | |
4259 | ||
d77de738 ML |
4260 | @opindex Wno-non-template-friend |
4261 | @opindex Wnon-template-friend | |
ddf6fe37 | 4262 | @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4263 | Disable warnings when non-template friend functions are declared |
4264 | within a template. In very old versions of GCC that predate implementation | |
4265 | of the ISO standard, declarations such as | |
4266 | @samp{friend int foo(int)}, where the name of the friend is an unqualified-id, | |
4267 | could be interpreted as a particular specialization of a template | |
4268 | function; the warning exists to diagnose compatibility problems, | |
4269 | and is enabled by default. | |
4270 | ||
d77de738 ML |
4271 | @opindex Wold-style-cast |
4272 | @opindex Wno-old-style-cast | |
ddf6fe37 | 4273 | @item -Wold-style-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4274 | Warn if an old-style (C-style) cast to a non-void type is used within |
4275 | a C++ program. The new-style casts (@code{dynamic_cast}, | |
4276 | @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are | |
4277 | less vulnerable to unintended effects and much easier to search for. | |
4278 | ||
d77de738 ML |
4279 | @opindex Woverloaded-virtual |
4280 | @opindex Wno-overloaded-virtual | |
4281 | @cindex overloaded virtual function, warning | |
4282 | @cindex warning for overloaded virtual function | |
f33d7a88 AA |
4283 | @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)} |
4284 | @itemx -Woverloaded-virtual=@var{n} | |
d77de738 ML |
4285 | Warn when a function declaration hides virtual functions from a |
4286 | base class. For example, in: | |
4287 | ||
4288 | @smallexample | |
4289 | struct A @{ | |
4290 | virtual void f(); | |
4291 | @}; | |
4292 | ||
4293 | struct B: public A @{ | |
4294 | void f(int); // does not override | |
4295 | @}; | |
4296 | @end smallexample | |
4297 | ||
4298 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
4299 | like: | |
4300 | ||
4301 | @smallexample | |
4302 | B* b; | |
4303 | b->f(); | |
4304 | @end smallexample | |
4305 | ||
4306 | @noindent | |
4307 | fails to compile. | |
4308 | ||
d82490d5 JW |
4309 | In cases where the different signatures are not an accident, the |
4310 | simplest solution is to add a using-declaration to the derived class | |
4311 | to un-hide the base function, e.g. add @code{using A::f;} to @code{B}. | |
4312 | ||
d77de738 ML |
4313 | The optional level suffix controls the behavior when all the |
4314 | declarations in the derived class override virtual functions in the | |
4315 | base class, even if not all of the base functions are overridden: | |
4316 | ||
4317 | @smallexample | |
4318 | struct C @{ | |
4319 | virtual void f(); | |
4320 | virtual void f(int); | |
4321 | @}; | |
4322 | ||
4323 | struct D: public C @{ | |
4324 | void f(int); // does override | |
4325 | @} | |
4326 | @end smallexample | |
4327 | ||
4328 | This pattern is less likely to be a mistake; if D is only used | |
4329 | virtually, the user might have decided that the base class semantics | |
4330 | for some of the overloads are fine. | |
4331 | ||
4332 | At level 1, this case does not warn; at level 2, it does. | |
4333 | @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is | |
4334 | included in @option{-Wall}. | |
4335 | ||
d77de738 ML |
4336 | @opindex Wno-pmf-conversions |
4337 | @opindex Wpmf-conversions | |
ddf6fe37 | 4338 | @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4339 | Disable the diagnostic for converting a bound pointer to member function |
4340 | to a plain pointer. | |
4341 | ||
d77de738 ML |
4342 | @opindex Wsign-promo |
4343 | @opindex Wno-sign-promo | |
ddf6fe37 | 4344 | @item -Wsign-promo @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4345 | Warn when overload resolution chooses a promotion from unsigned or |
4346 | enumerated type to a signed type, over a conversion to an unsigned type of | |
4347 | the same size. Previous versions of G++ tried to preserve | |
4348 | unsignedness, but the standard mandates the current behavior. | |
4349 | ||
d77de738 ML |
4350 | @opindex Wtemplates |
4351 | @opindex Wno-templates | |
ddf6fe37 | 4352 | @item -Wtemplates @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4353 | Warn when a primary template declaration is encountered. Some coding |
4354 | rules disallow templates, and this may be used to enforce that rule. | |
4355 | The warning is inactive inside a system header file, such as the STL, so | |
4356 | one can still use the STL. One may also instantiate or specialize | |
4357 | templates. | |
4358 | ||
d77de738 ML |
4359 | @opindex Wmismatched-new-delete |
4360 | @opindex Wno-mismatched-new-delete | |
ddf6fe37 | 4361 | @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4362 | Warn for mismatches between calls to @code{operator new} or @code{operator |
4363 | delete} and the corresponding call to the allocation or deallocation function. | |
4364 | This includes invocations of C++ @code{operator delete} with pointers | |
4365 | returned from either mismatched forms of @code{operator new}, or from other | |
4366 | functions that allocate objects for which the @code{operator delete} isn't | |
4367 | a suitable deallocator, as well as calls to other deallocation functions | |
4368 | with pointers returned from @code{operator new} for which the deallocation | |
4369 | function isn't suitable. | |
4370 | ||
4371 | For example, the @code{delete} expression in the function below is diagnosed | |
4372 | because it doesn't match the array form of the @code{new} expression | |
4373 | the pointer argument was returned from. Similarly, the call to @code{free} | |
4374 | is also diagnosed. | |
4375 | ||
4376 | @smallexample | |
4377 | void f () | |
4378 | @{ | |
4379 | int *a = new int[n]; | |
4380 | delete a; // warning: mismatch in array forms of expressions | |
4381 | ||
4382 | char *p = new char[n]; | |
4383 | free (p); // warning: mismatch between new and free | |
4384 | @} | |
4385 | @end smallexample | |
4386 | ||
4387 | The related option @option{-Wmismatched-dealloc} diagnoses mismatches | |
4388 | involving allocation and deallocation functions other than @code{operator | |
4389 | new} and @code{operator delete}. | |
4390 | ||
4391 | @option{-Wmismatched-new-delete} is included in @option{-Wall}. | |
4392 | ||
d77de738 ML |
4393 | @opindex Wmismatched-tags |
4394 | @opindex Wno-mismatched-tags | |
ddf6fe37 | 4395 | @item -Wmismatched-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4396 | Warn for declarations of structs, classes, and class templates and their |
4397 | specializations with a class-key that does not match either the definition | |
4398 | or the first declaration if no definition is provided. | |
4399 | ||
4400 | For example, the declaration of @code{struct Object} in the argument list | |
4401 | of @code{draw} triggers the warning. To avoid it, either remove the redundant | |
4402 | class-key @code{struct} or replace it with @code{class} to match its definition. | |
4403 | @smallexample | |
4404 | class Object @{ | |
4405 | public: | |
4406 | virtual ~Object () = 0; | |
4407 | @}; | |
4408 | void draw (struct Object*); | |
4409 | @end smallexample | |
4410 | ||
4411 | It is not wrong to declare a class with the class-key @code{struct} as | |
4412 | the example above shows. The @option{-Wmismatched-tags} option is intended | |
4413 | to help achieve a consistent style of class declarations. In code that is | |
4414 | intended to be portable to Windows-based compilers the warning helps prevent | |
4415 | unresolved references due to the difference in the mangling of symbols | |
4416 | declared with different class-keys. The option can be used either on its | |
4417 | own or in conjunction with @option{-Wredundant-tags}. | |
4418 | ||
d77de738 ML |
4419 | @opindex Wmultiple-inheritance |
4420 | @opindex Wno-multiple-inheritance | |
ddf6fe37 | 4421 | @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4422 | Warn when a class is defined with multiple direct base classes. Some |
4423 | coding rules disallow multiple inheritance, and this may be used to | |
4424 | enforce that rule. The warning is inactive inside a system header file, | |
4425 | such as the STL, so one can still use the STL. One may also define | |
4426 | classes that indirectly use multiple inheritance. | |
4427 | ||
d77de738 ML |
4428 | @opindex Wvirtual-inheritance |
4429 | @opindex Wno-virtual-inheritance | |
ddf6fe37 | 4430 | @item -Wvirtual-inheritance |
d77de738 ML |
4431 | Warn when a class is defined with a virtual direct base class. Some |
4432 | coding rules disallow multiple inheritance, and this may be used to | |
4433 | enforce that rule. The warning is inactive inside a system header file, | |
4434 | such as the STL, so one can still use the STL. One may also define | |
4435 | classes that indirectly use virtual inheritance. | |
4436 | ||
d77de738 ML |
4437 | @opindex Wvirtual-move-assign |
4438 | @opindex Wno-virtual-move-assign | |
ddf6fe37 | 4439 | @item -Wno-virtual-move-assign |
d77de738 ML |
4440 | Suppress warnings about inheriting from a virtual base with a |
4441 | non-trivial C++11 move assignment operator. This is dangerous because | |
4442 | if the virtual base is reachable along more than one path, it is | |
4443 | moved multiple times, which can mean both objects end up in the | |
4444 | moved-from state. If the move assignment operator is written to avoid | |
4445 | moving from a moved-from object, this warning can be disabled. | |
4446 | ||
d77de738 ML |
4447 | @opindex Wnamespaces |
4448 | @opindex Wno-namespaces | |
ddf6fe37 | 4449 | @item -Wnamespaces |
d77de738 ML |
4450 | Warn when a namespace definition is opened. Some coding rules disallow |
4451 | namespaces, and this may be used to enforce that rule. The warning is | |
4452 | inactive inside a system header file, such as the STL, so one can still | |
4453 | use the STL. One may also use using directives and qualified names. | |
4454 | ||
d77de738 ML |
4455 | @opindex Wterminate |
4456 | @opindex Wno-terminate | |
ddf6fe37 | 4457 | @item -Wno-terminate @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4458 | Disable the warning about a throw-expression that will immediately |
4459 | result in a call to @code{terminate}. | |
4460 | ||
d77de738 ML |
4461 | @opindex Wvexing-parse |
4462 | @opindex Wno-vexing-parse | |
ddf6fe37 | 4463 | @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4464 | Warn about the most vexing parse syntactic ambiguity. This warns about |
4465 | the cases when a declaration looks like a variable definition, but the | |
4466 | C++ language requires it to be interpreted as a function declaration. | |
4467 | For instance: | |
4468 | ||
4469 | @smallexample | |
4470 | void f(double a) @{ | |
4471 | int i(); // extern int i (void); | |
4472 | int n(int(a)); // extern int n (int); | |
4473 | @} | |
4474 | @end smallexample | |
4475 | ||
4476 | Another example: | |
4477 | ||
4478 | @smallexample | |
4479 | struct S @{ S(int); @}; | |
4480 | void f(double a) @{ | |
4481 | S x(int(a)); // extern struct S x (int); | |
4482 | S y(int()); // extern struct S y (int (*) (void)); | |
4483 | S z(); // extern struct S z (void); | |
4484 | @} | |
4485 | @end smallexample | |
4486 | ||
4487 | The warning will suggest options how to deal with such an ambiguity; e.g., | |
4488 | it can suggest removing the parentheses or using braces instead. | |
4489 | ||
4490 | This warning is enabled by default. | |
4491 | ||
d77de738 ML |
4492 | @opindex Wno-class-conversion |
4493 | @opindex Wclass-conversion | |
ddf6fe37 | 4494 | @item -Wno-class-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4495 | Do not warn when a conversion function converts an |
4496 | object to the same type, to a base class of that type, or to void; such | |
4497 | a conversion function will never be called. | |
4498 | ||
d77de738 ML |
4499 | @opindex Wvolatile |
4500 | @opindex Wno-volatile | |
ddf6fe37 | 4501 | @item -Wvolatile @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4502 | Warn about deprecated uses of the @code{volatile} qualifier. This includes |
4503 | postfix and prefix @code{++} and @code{--} expressions of | |
4504 | @code{volatile}-qualified types, using simple assignments where the left | |
4505 | operand is a @code{volatile}-qualified non-class type for their value, | |
4506 | compound assignments where the left operand is a @code{volatile}-qualified | |
4507 | non-class type, @code{volatile}-qualified function return type, | |
4508 | @code{volatile}-qualified parameter type, and structured bindings of a | |
4509 | @code{volatile}-qualified type. This usage was deprecated in C++20. | |
4510 | ||
4511 | Enabled by default with @option{-std=c++20}. | |
4512 | ||
d77de738 ML |
4513 | @opindex Wzero-as-null-pointer-constant |
4514 | @opindex Wno-zero-as-null-pointer-constant | |
ddf6fe37 | 4515 | @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4516 | Warn when a literal @samp{0} is used as null pointer constant. This can |
4517 | be useful to facilitate the conversion to @code{nullptr} in C++11. | |
4518 | ||
d77de738 ML |
4519 | @opindex Waligned-new |
4520 | @opindex Wno-aligned-new | |
ddf6fe37 | 4521 | @item -Waligned-new |
d77de738 ML |
4522 | Warn about a new-expression of a type that requires greater alignment |
4523 | than the @code{alignof(std::max_align_t)} but uses an allocation | |
4524 | function without an explicit alignment parameter. This option is | |
4525 | enabled by @option{-Wall}. | |
4526 | ||
4527 | Normally this only warns about global allocation functions, but | |
4528 | @option{-Waligned-new=all} also warns about class member allocation | |
4529 | functions. | |
4530 | ||
d77de738 ML |
4531 | @opindex Wplacement-new |
4532 | @opindex Wno-placement-new | |
ddf6fe37 AA |
4533 | @item -Wno-placement-new |
4534 | @itemx -Wplacement-new=@var{n} | |
d77de738 ML |
4535 | Warn about placement new expressions with undefined behavior, such as |
4536 | constructing an object in a buffer that is smaller than the type of | |
4537 | the object. For example, the placement new expression below is diagnosed | |
4538 | because it attempts to construct an array of 64 integers in a buffer only | |
4539 | 64 bytes large. | |
4540 | @smallexample | |
4541 | char buf [64]; | |
4542 | new (buf) int[64]; | |
4543 | @end smallexample | |
4544 | This warning is enabled by default. | |
4545 | ||
4546 | @table @gcctabopt | |
4547 | @item -Wplacement-new=1 | |
4548 | This is the default warning level of @option{-Wplacement-new}. At this | |
4549 | level the warning is not issued for some strictly undefined constructs that | |
4550 | GCC allows as extensions for compatibility with legacy code. For example, | |
4551 | the following @code{new} expression is not diagnosed at this level even | |
4552 | though it has undefined behavior according to the C++ standard because | |
4553 | it writes past the end of the one-element array. | |
4554 | @smallexample | |
4555 | struct S @{ int n, a[1]; @}; | |
4556 | S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); | |
4557 | new (s->a)int [32](); | |
4558 | @end smallexample | |
4559 | ||
4560 | @item -Wplacement-new=2 | |
4561 | At this level, in addition to diagnosing all the same constructs as at level | |
4562 | 1, a diagnostic is also issued for placement new expressions that construct | |
4563 | an object in the last member of structure whose type is an array of a single | |
4564 | element and whose size is less than the size of the object being constructed. | |
4565 | While the previous example would be diagnosed, the following construct makes | |
4566 | use of the flexible member array extension to avoid the warning at level 2. | |
4567 | @smallexample | |
4568 | struct S @{ int n, a[]; @}; | |
4569 | S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); | |
4570 | new (s->a)int [32](); | |
4571 | @end smallexample | |
4572 | ||
4573 | @end table | |
4574 | ||
d77de738 ML |
4575 | @opindex Wcatch-value |
4576 | @opindex Wno-catch-value | |
ddf6fe37 AA |
4577 | @item -Wcatch-value |
4578 | @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)} | |
d77de738 ML |
4579 | Warn about catch handlers that do not catch via reference. |
4580 | With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short) | |
4581 | warn about polymorphic class types that are caught by value. | |
4582 | With @option{-Wcatch-value=2} warn about all class types that are caught | |
4583 | by value. With @option{-Wcatch-value=3} warn about all types that are | |
4584 | not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}. | |
4585 | ||
d77de738 ML |
4586 | @opindex Wconditionally-supported |
4587 | @opindex Wno-conditionally-supported | |
ddf6fe37 | 4588 | @item -Wconditionally-supported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4589 | Warn for conditionally-supported (C++11 [intro.defs]) constructs. |
4590 | ||
d77de738 ML |
4591 | @opindex Wdelete-incomplete |
4592 | @opindex Wno-delete-incomplete | |
ddf6fe37 | 4593 | @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4594 | Do not warn when deleting a pointer to incomplete type, which may cause |
4595 | undefined behavior at runtime. This warning is enabled by default. | |
4596 | ||
d77de738 ML |
4597 | @opindex Wextra-semi |
4598 | @opindex Wno-extra-semi | |
ddf6fe37 | 4599 | @item -Wextra-semi @r{(C++, Objective-C++ only)} |
d77de738 ML |
4600 | Warn about redundant semicolons after in-class function definitions. |
4601 | ||
d77de738 ML |
4602 | @opindex Winaccessible-base |
4603 | @opindex Wno-inaccessible-base | |
ddf6fe37 | 4604 | @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)} |
d77de738 ML |
4605 | This option controls warnings |
4606 | when a base class is inaccessible in a class derived from it due to | |
4607 | ambiguity. The warning is enabled by default. | |
4608 | Note that the warning for ambiguous virtual | |
4609 | bases is enabled by the @option{-Wextra} option. | |
4610 | @smallexample | |
4611 | @group | |
4612 | struct A @{ int a; @}; | |
4613 | ||
4614 | struct B : A @{ @}; | |
4615 | ||
4616 | struct C : B, A @{ @}; | |
4617 | @end group | |
4618 | @end smallexample | |
4619 | ||
d77de738 ML |
4620 | @opindex Winherited-variadic-ctor |
4621 | @opindex Wno-inherited-variadic-ctor | |
ddf6fe37 | 4622 | @item -Wno-inherited-variadic-ctor |
d77de738 ML |
4623 | Suppress warnings about use of C++11 inheriting constructors when the |
4624 | base class inherited from has a C variadic constructor; the warning is | |
4625 | on by default because the ellipsis is not inherited. | |
4626 | ||
d77de738 ML |
4627 | @opindex Wno-invalid-offsetof |
4628 | @opindex Winvalid-offsetof | |
ddf6fe37 | 4629 | @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4630 | Suppress warnings from applying the @code{offsetof} macro to a non-POD |
4631 | type. According to the 2014 ISO C++ standard, applying @code{offsetof} | |
4632 | to a non-standard-layout type is undefined. In existing C++ implementations, | |
4633 | however, @code{offsetof} typically gives meaningful results. | |
4634 | This flag is for users who are aware that they are | |
4635 | writing nonportable code and who have deliberately chosen to ignore the | |
4636 | warning about it. | |
4637 | ||
4638 | The restrictions on @code{offsetof} may be relaxed in a future version | |
4639 | of the C++ standard. | |
4640 | ||
d77de738 ML |
4641 | @opindex Wsized-deallocation |
4642 | @opindex Wno-sized-deallocation | |
ddf6fe37 | 4643 | @item -Wsized-deallocation @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4644 | Warn about a definition of an unsized deallocation function |
4645 | @smallexample | |
4646 | void operator delete (void *) noexcept; | |
4647 | void operator delete[] (void *) noexcept; | |
4648 | @end smallexample | |
4649 | without a definition of the corresponding sized deallocation function | |
4650 | @smallexample | |
4651 | void operator delete (void *, std::size_t) noexcept; | |
4652 | void operator delete[] (void *, std::size_t) noexcept; | |
4653 | @end smallexample | |
4654 | or vice versa. Enabled by @option{-Wextra} along with | |
4655 | @option{-fsized-deallocation}. | |
4656 | ||
d77de738 ML |
4657 | @opindex Wno-suggest-final-types |
4658 | @opindex Wsuggest-final-types | |
ddf6fe37 | 4659 | @item -Wsuggest-final-types |
d77de738 ML |
4660 | Warn about types with virtual methods where code quality would be improved |
4661 | if the type were declared with the C++11 @code{final} specifier, | |
4662 | or, if possible, | |
4663 | declared in an anonymous namespace. This allows GCC to more aggressively | |
4664 | devirtualize the polymorphic calls. This warning is more effective with | |
4665 | link-time optimization, | |
4666 | where the information about the class hierarchy graph is | |
4667 | more complete. | |
4668 | ||
d77de738 ML |
4669 | @opindex Wno-suggest-final-methods |
4670 | @opindex Wsuggest-final-methods | |
ddf6fe37 | 4671 | @item -Wsuggest-final-methods |
d77de738 ML |
4672 | Warn about virtual methods where code quality would be improved if the method |
4673 | were declared with the C++11 @code{final} specifier, | |
4674 | or, if possible, its type were | |
4675 | declared in an anonymous namespace or with the @code{final} specifier. | |
4676 | This warning is | |
4677 | more effective with link-time optimization, where the information about the | |
4678 | class hierarchy graph is more complete. It is recommended to first consider | |
4679 | suggestions of @option{-Wsuggest-final-types} and then rebuild with new | |
4680 | annotations. | |
4681 | ||
d77de738 ML |
4682 | @opindex Wsuggest-override |
4683 | @opindex Wno-suggest-override | |
ddf6fe37 | 4684 | @item -Wsuggest-override |
d77de738 ML |
4685 | Warn about overriding virtual functions that are not marked with the |
4686 | @code{override} keyword. | |
4687 | ||
d77de738 ML |
4688 | @opindex Wuse-after-free |
4689 | @opindex Wno-use-after-free | |
ddf6fe37 AA |
4690 | @item -Wuse-after-free |
4691 | @itemx -Wuse-after-free=@var{n} | |
d77de738 ML |
4692 | Warn about uses of pointers to dynamically allocated objects that have |
4693 | been rendered indeterminate by a call to a deallocation function. | |
4694 | The warning is enabled at all optimization levels but may yield different | |
4695 | results with optimization than without. | |
4696 | ||
4697 | @table @gcctabopt | |
4698 | @item -Wuse-after-free=1 | |
4699 | At level 1 the warning attempts to diagnose only unconditional uses | |
4700 | of pointers made indeterminate by a deallocation call or a successful | |
4701 | call to @code{realloc}, regardless of whether or not the call resulted | |
4702 | in an actual reallocatio of memory. This includes double-@code{free} | |
4703 | calls as well as uses in arithmetic and relational expressions. Although | |
4704 | undefined, uses of indeterminate pointers in equality (or inequality) | |
4705 | expressions are not diagnosed at this level. | |
4706 | @item -Wuse-after-free=2 | |
4707 | At level 2, in addition to unconditional uses, the warning also diagnoses | |
4708 | conditional uses of pointers made indeterminate by a deallocation call. | |
4709 | As at level 2, uses in equality (or inequality) expressions are not | |
4710 | diagnosed. For example, the second call to @code{free} in the following | |
4711 | function is diagnosed at this level: | |
4712 | @smallexample | |
4713 | struct A @{ int refcount; void *data; @}; | |
4714 | ||
4715 | void release (struct A *p) | |
4716 | @{ | |
4717 | int refcount = --p->refcount; | |
4718 | free (p); | |
4719 | if (refcount == 0) | |
4720 | free (p->data); // warning: p may be used after free | |
4721 | @} | |
4722 | @end smallexample | |
4723 | @item -Wuse-after-free=3 | |
4724 | At level 3, the warning also diagnoses uses of indeterminate pointers in | |
4725 | equality expressions. All uses of indeterminate pointers are undefined | |
4726 | but equality tests sometimes appear after calls to @code{realloc} as | |
4727 | an attempt to determine whether the call resulted in relocating the object | |
4728 | to a different address. They are diagnosed at a separate level to aid | |
4729 | legacy code gradually transition to safe alternatives. For example, | |
4730 | the equality test in the function below is diagnosed at this level: | |
4731 | @smallexample | |
4732 | void adjust_pointers (int**, int); | |
4733 | ||
4734 | void grow (int **p, int n) | |
4735 | @{ | |
4736 | int **q = (int**)realloc (p, n *= 2); | |
4737 | if (q == p) | |
4738 | return; | |
4739 | adjust_pointers ((int**)q, n); | |
4740 | @} | |
4741 | @end smallexample | |
4742 | To avoid the warning at this level, store offsets into allocated memory | |
4743 | instead of pointers. This approach obviates needing to adjust the stored | |
4744 | pointers after reallocation. | |
4745 | @end table | |
4746 | ||
4747 | @option{-Wuse-after-free=2} is included in @option{-Wall}. | |
4748 | ||
d77de738 ML |
4749 | @opindex Wuseless-cast |
4750 | @opindex Wno-useless-cast | |
ddf6fe37 | 4751 | @item -Wuseless-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4752 | Warn when an expression is cast to its own type. This warning does not |
4753 | occur when a class object is converted to a non-reference type as that | |
4754 | is a way to create a temporary: | |
4755 | ||
4756 | @smallexample | |
4757 | struct S @{ @}; | |
4758 | void g (S&&); | |
4759 | void f (S&& arg) | |
4760 | @{ | |
4761 | g (S(arg)); // make arg prvalue so that it can bind to S&& | |
4762 | @} | |
4763 | @end smallexample | |
4764 | ||
d77de738 ML |
4765 | @opindex Wconversion-null |
4766 | @opindex Wno-conversion-null | |
ddf6fe37 | 4767 | @item -Wno-conversion-null @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4768 | Do not warn for conversions between @code{NULL} and non-pointer |
4769 | types. @option{-Wconversion-null} is enabled by default. | |
4770 | ||
4771 | @end table | |
4772 | ||
4773 | @node Objective-C and Objective-C++ Dialect Options | |
4774 | @section Options Controlling Objective-C and Objective-C++ Dialects | |
4775 | ||
4776 | @cindex compiler options, Objective-C and Objective-C++ | |
4777 | @cindex Objective-C and Objective-C++ options, command-line | |
4778 | @cindex options, Objective-C and Objective-C++ | |
4779 | (NOTE: This manual does not describe the Objective-C and Objective-C++ | |
4780 | languages themselves. @xref{Standards,,Language Standards | |
4781 | Supported by GCC}, for references.) | |
4782 | ||
4783 | This section describes the command-line options that are only meaningful | |
4784 | for Objective-C and Objective-C++ programs. You can also use most of | |
4785 | the language-independent GNU compiler options. | |
4786 | For example, you might compile a file @file{some_class.m} like this: | |
4787 | ||
4788 | @smallexample | |
4789 | gcc -g -fgnu-runtime -O -c some_class.m | |
4790 | @end smallexample | |
4791 | ||
4792 | @noindent | |
4793 | In this example, @option{-fgnu-runtime} is an option meant only for | |
4794 | Objective-C and Objective-C++ programs; you can use the other options with | |
4795 | any language supported by GCC@. | |
4796 | ||
4797 | Note that since Objective-C is an extension of the C language, Objective-C | |
4798 | compilations may also use options specific to the C front-end (e.g., | |
4799 | @option{-Wtraditional}). Similarly, Objective-C++ compilations may use | |
4800 | C++-specific options (e.g., @option{-Wabi}). | |
4801 | ||
4802 | Here is a list of options that are @emph{only} for compiling Objective-C | |
4803 | and Objective-C++ programs: | |
4804 | ||
4805 | @table @gcctabopt | |
d77de738 | 4806 | @opindex fconstant-string-class |
ddf6fe37 | 4807 | @item -fconstant-string-class=@var{class-name} |
d77de738 ML |
4808 | Use @var{class-name} as the name of the class to instantiate for each |
4809 | literal string specified with the syntax @code{@@"@dots{}"}. The default | |
4810 | class name is @code{NXConstantString} if the GNU runtime is being used, and | |
4811 | @code{NSConstantString} if the NeXT runtime is being used (see below). The | |
4812 | @option{-fconstant-cfstrings} option, if also present, overrides the | |
4813 | @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals | |
4814 | to be laid out as constant CoreFoundation strings. | |
4815 | ||
d77de738 | 4816 | @opindex fgnu-runtime |
ddf6fe37 | 4817 | @item -fgnu-runtime |
d77de738 ML |
4818 | Generate object code compatible with the standard GNU Objective-C |
4819 | runtime. This is the default for most types of systems. | |
4820 | ||
d77de738 | 4821 | @opindex fnext-runtime |
ddf6fe37 | 4822 | @item -fnext-runtime |
d77de738 ML |
4823 | Generate output compatible with the NeXT runtime. This is the default |
4824 | for NeXT-based systems, including Darwin and Mac OS X@. The macro | |
4825 | @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is | |
4826 | used. | |
4827 | ||
d77de738 ML |
4828 | @opindex fno-nil-receivers |
4829 | @opindex fnil-receivers | |
ddf6fe37 | 4830 | @item -fno-nil-receivers |
d77de738 ML |
4831 | Assume that all Objective-C message dispatches (@code{[receiver |
4832 | message:arg]}) in this translation unit ensure that the receiver is | |
4833 | not @code{nil}. This allows for more efficient entry points in the | |
4834 | runtime to be used. This option is only available in conjunction with | |
4835 | the NeXT runtime and ABI version 0 or 1. | |
4836 | ||
d77de738 | 4837 | @opindex fobjc-abi-version |
ddf6fe37 | 4838 | @item -fobjc-abi-version=@var{n} |
d77de738 ML |
4839 | Use version @var{n} of the Objective-C ABI for the selected runtime. |
4840 | This option is currently supported only for the NeXT runtime. In that | |
4841 | case, Version 0 is the traditional (32-bit) ABI without support for | |
4842 | properties and other Objective-C 2.0 additions. Version 1 is the | |
4843 | traditional (32-bit) ABI with support for properties and other | |
4844 | Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If | |
4845 | nothing is specified, the default is Version 0 on 32-bit target | |
4846 | machines, and Version 2 on 64-bit target machines. | |
4847 | ||
d77de738 | 4848 | @opindex fobjc-call-cxx-cdtors |
ddf6fe37 | 4849 | @item -fobjc-call-cxx-cdtors |
d77de738 ML |
4850 | For each Objective-C class, check if any of its instance variables is a |
4851 | C++ object with a non-trivial default constructor. If so, synthesize a | |
4852 | special @code{- (id) .cxx_construct} instance method which runs | |
4853 | non-trivial default constructors on any such instance variables, in order, | |
4854 | and then return @code{self}. Similarly, check if any instance variable | |
4855 | is a C++ object with a non-trivial destructor, and if so, synthesize a | |
4856 | special @code{- (void) .cxx_destruct} method which runs | |
4857 | all such default destructors, in reverse order. | |
4858 | ||
4859 | The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct} | |
4860 | methods thusly generated only operate on instance variables | |
4861 | declared in the current Objective-C class, and not those inherited | |
4862 | from superclasses. It is the responsibility of the Objective-C | |
4863 | runtime to invoke all such methods in an object's inheritance | |
4864 | hierarchy. The @code{- (id) .cxx_construct} methods are invoked | |
4865 | by the runtime immediately after a new object instance is allocated; | |
4866 | the @code{- (void) .cxx_destruct} methods are invoked immediately | |
4867 | before the runtime deallocates an object instance. | |
4868 | ||
4869 | As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has | |
4870 | support for invoking the @code{- (id) .cxx_construct} and | |
4871 | @code{- (void) .cxx_destruct} methods. | |
4872 | ||
d77de738 | 4873 | @opindex fobjc-direct-dispatch |
ddf6fe37 | 4874 | @item -fobjc-direct-dispatch |
d77de738 ML |
4875 | Allow fast jumps to the message dispatcher. On Darwin this is |
4876 | accomplished via the comm page. | |
4877 | ||
d77de738 | 4878 | @opindex fobjc-exceptions |
ddf6fe37 | 4879 | @item -fobjc-exceptions |
d77de738 ML |
4880 | Enable syntactic support for structured exception handling in |
4881 | Objective-C, similar to what is offered by C++. This option | |
4882 | is required to use the Objective-C keywords @code{@@try}, | |
4883 | @code{@@throw}, @code{@@catch}, @code{@@finally} and | |
4884 | @code{@@synchronized}. This option is available with both the GNU | |
4885 | runtime and the NeXT runtime (but not available in conjunction with | |
4886 | the NeXT runtime on Mac OS X 10.2 and earlier). | |
4887 | ||
d77de738 | 4888 | @opindex fobjc-gc |
ddf6fe37 | 4889 | @item -fobjc-gc |
d77de738 ML |
4890 | Enable garbage collection (GC) in Objective-C and Objective-C++ |
4891 | programs. This option is only available with the NeXT runtime; the | |
4892 | GNU runtime has a different garbage collection implementation that | |
4893 | does not require special compiler flags. | |
4894 | ||
d77de738 | 4895 | @opindex fobjc-nilcheck |
ddf6fe37 | 4896 | @item -fobjc-nilcheck |
d77de738 ML |
4897 | For the NeXT runtime with version 2 of the ABI, check for a nil |
4898 | receiver in method invocations before doing the actual method call. | |
4899 | This is the default and can be disabled using | |
4900 | @option{-fno-objc-nilcheck}. Class methods and super calls are never | |
4901 | checked for nil in this way no matter what this flag is set to. | |
4902 | Currently this flag does nothing when the GNU runtime, or an older | |
4903 | version of the NeXT runtime ABI, is used. | |
4904 | ||
d77de738 | 4905 | @opindex fobjc-std |
ddf6fe37 | 4906 | @item -fobjc-std=objc1 |
d77de738 ML |
4907 | Conform to the language syntax of Objective-C 1.0, the language |
4908 | recognized by GCC 4.0. This only affects the Objective-C additions to | |
4909 | the C/C++ language; it does not affect conformance to C/C++ standards, | |
4910 | which is controlled by the separate C/C++ dialect option flags. When | |
4911 | this option is used with the Objective-C or Objective-C++ compiler, | |
4912 | any Objective-C syntax that is not recognized by GCC 4.0 is rejected. | |
4913 | This is useful if you need to make sure that your Objective-C code can | |
4914 | be compiled with older versions of GCC@. | |
4915 | ||
d77de738 | 4916 | @opindex freplace-objc-classes |
ddf6fe37 | 4917 | @item -freplace-objc-classes |
d77de738 ML |
4918 | Emit a special marker instructing @command{ld(1)} not to statically link in |
4919 | the resulting object file, and allow @command{dyld(1)} to load it in at | |
4920 | run time instead. This is used in conjunction with the Fix-and-Continue | |
4921 | debugging mode, where the object file in question may be recompiled and | |
4922 | dynamically reloaded in the course of program execution, without the need | |
4923 | to restart the program itself. Currently, Fix-and-Continue functionality | |
4924 | is only available in conjunction with the NeXT runtime on Mac OS X 10.3 | |
4925 | and later. | |
4926 | ||
d77de738 | 4927 | @opindex fzero-link |
ddf6fe37 | 4928 | @item -fzero-link |
d77de738 ML |
4929 | When compiling for the NeXT runtime, the compiler ordinarily replaces calls |
4930 | to @code{objc_getClass("@dots{}")} (when the name of the class is known at | |
4931 | compile time) with static class references that get initialized at load time, | |
4932 | which improves run-time performance. Specifying the @option{-fzero-link} flag | |
4933 | suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")} | |
4934 | to be retained. This is useful in Zero-Link debugging mode, since it allows | |
4935 | for individual class implementations to be modified during program execution. | |
4936 | The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")} | |
4937 | regardless of command-line options. | |
4938 | ||
d77de738 ML |
4939 | @opindex fno-local-ivars |
4940 | @opindex flocal-ivars | |
ddf6fe37 | 4941 | @item -fno-local-ivars |
d77de738 ML |
4942 | By default instance variables in Objective-C can be accessed as if |
4943 | they were local variables from within the methods of the class they're | |
4944 | declared in. This can lead to shadowing between instance variables | |
4945 | and other variables declared either locally inside a class method or | |
4946 | globally with the same name. Specifying the @option{-fno-local-ivars} | |
4947 | flag disables this behavior thus avoiding variable shadowing issues. | |
4948 | ||
d77de738 | 4949 | @opindex fivar-visibility |
ddf6fe37 | 4950 | @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} |
d77de738 ML |
4951 | Set the default instance variable visibility to the specified option |
4952 | so that instance variables declared outside the scope of any access | |
4953 | modifier directives default to the specified visibility. | |
4954 | ||
d77de738 | 4955 | @opindex gen-decls |
ddf6fe37 | 4956 | @item -gen-decls |
d77de738 ML |
4957 | Dump interface declarations for all classes seen in the source file to a |
4958 | file named @file{@var{sourcename}.decl}. | |
4959 | ||
d77de738 ML |
4960 | @opindex Wassign-intercept |
4961 | @opindex Wno-assign-intercept | |
ddf6fe37 | 4962 | @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4963 | Warn whenever an Objective-C assignment is being intercepted by the |
4964 | garbage collector. | |
4965 | ||
d77de738 ML |
4966 | @opindex Wproperty-assign-default |
4967 | @opindex Wno-property-assign-default | |
ddf6fe37 | 4968 | @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4969 | Do not warn if a property for an Objective-C object has no assign |
4970 | semantics specified. | |
4971 | ||
d77de738 ML |
4972 | @opindex Wno-protocol |
4973 | @opindex Wprotocol | |
ddf6fe37 | 4974 | @item -Wno-protocol @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4975 | If a class is declared to implement a protocol, a warning is issued for |
4976 | every method in the protocol that is not implemented by the class. The | |
4977 | default behavior is to issue a warning for every method not explicitly | |
4978 | implemented in the class, even if a method implementation is inherited | |
4979 | from the superclass. If you use the @option{-Wno-protocol} option, then | |
4980 | methods inherited from the superclass are considered to be implemented, | |
4981 | and no warning is issued for them. | |
4982 | ||
d77de738 | 4983 | @opindex Wobjc-root-class |
ddf6fe37 | 4984 | @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4985 | Warn if a class interface lacks a superclass. Most classes will inherit |
4986 | from @code{NSObject} (or @code{Object}) for example. When declaring | |
4987 | classes intended to be root classes, the warning can be suppressed by | |
4988 | marking their interfaces with @code{__attribute__((objc_root_class))}. | |
4989 | ||
d77de738 ML |
4990 | @opindex Wselector |
4991 | @opindex Wno-selector | |
ddf6fe37 | 4992 | @item -Wselector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4993 | Warn if multiple methods of different types for the same selector are |
4994 | found during compilation. The check is performed on the list of methods | |
4995 | in the final stage of compilation. Additionally, a check is performed | |
4996 | for each selector appearing in a @code{@@selector(@dots{})} | |
4997 | expression, and a corresponding method for that selector has been found | |
4998 | during compilation. Because these checks scan the method table only at | |
4999 | the end of compilation, these warnings are not produced if the final | |
5000 | stage of compilation is not reached, for example because an error is | |
5001 | found during compilation, or because the @option{-fsyntax-only} option is | |
5002 | being used. | |
5003 | ||
d77de738 ML |
5004 | @opindex Wstrict-selector-match |
5005 | @opindex Wno-strict-selector-match | |
ddf6fe37 | 5006 | @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5007 | Warn if multiple methods with differing argument and/or return types are |
5008 | found for a given selector when attempting to send a message using this | |
5009 | selector to a receiver of type @code{id} or @code{Class}. When this flag | |
5010 | is off (which is the default behavior), the compiler omits such warnings | |
5011 | if any differences found are confined to types that share the same size | |
5012 | and alignment. | |
5013 | ||
d77de738 ML |
5014 | @opindex Wundeclared-selector |
5015 | @opindex Wno-undeclared-selector | |
ddf6fe37 | 5016 | @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5017 | Warn if a @code{@@selector(@dots{})} expression referring to an |
5018 | undeclared selector is found. A selector is considered undeclared if no | |
5019 | method with that name has been declared before the | |
5020 | @code{@@selector(@dots{})} expression, either explicitly in an | |
5021 | @code{@@interface} or @code{@@protocol} declaration, or implicitly in | |
5022 | an @code{@@implementation} section. This option always performs its | |
5023 | checks as soon as a @code{@@selector(@dots{})} expression is found, | |
5024 | while @option{-Wselector} only performs its checks in the final stage of | |
5025 | compilation. This also enforces the coding style convention | |
5026 | that methods and selectors must be declared before being used. | |
5027 | ||
d77de738 | 5028 | @opindex print-objc-runtime-info |
ddf6fe37 | 5029 | @item -print-objc-runtime-info |
d77de738 ML |
5030 | Generate C header describing the largest structure that is passed by |
5031 | value, if any. | |
5032 | ||
5033 | @end table | |
5034 | ||
5035 | @node Diagnostic Message Formatting Options | |
5036 | @section Options to Control Diagnostic Messages Formatting | |
5037 | @cindex options to control diagnostics formatting | |
5038 | @cindex diagnostic messages | |
5039 | @cindex message formatting | |
5040 | ||
5041 | Traditionally, diagnostic messages have been formatted irrespective of | |
5042 | the output device's aspect (e.g.@: its width, @dots{}). You can use the | |
5043 | options described below | |
5044 | to control the formatting algorithm for diagnostic messages, | |
5045 | e.g.@: how many characters per line, how often source location | |
5046 | information should be reported. Note that some language front ends may not | |
5047 | honor these options. | |
5048 | ||
5049 | @table @gcctabopt | |
d77de738 | 5050 | @opindex fmessage-length |
ddf6fe37 | 5051 | @item -fmessage-length=@var{n} |
d77de738 ML |
5052 | Try to format error messages so that they fit on lines of about |
5053 | @var{n} characters. If @var{n} is zero, then no line-wrapping is | |
5054 | done; each error message appears on a single line. This is the | |
5055 | default for all front ends. | |
5056 | ||
5057 | Note - this option also affects the display of the @samp{#error} and | |
5058 | @samp{#warning} pre-processor directives, and the @samp{deprecated} | |
5059 | function/type/variable attribute. It does not however affect the | |
5060 | @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas. | |
5061 | ||
5062 | @item -fdiagnostics-plain-output | |
5063 | This option requests that diagnostic output look as plain as possible, which | |
5064 | may be useful when running @command{dejagnu} or other utilities that need to | |
5065 | parse diagnostics output and prefer that it remain more stable over time. | |
5066 | @option{-fdiagnostics-plain-output} is currently equivalent to the following | |
5067 | options: | |
43b72ede AA |
5068 | @gccoptlist{-fno-diagnostics-show-caret |
5069 | -fno-diagnostics-show-line-numbers | |
5070 | -fdiagnostics-color=never | |
5071 | -fdiagnostics-urls=never | |
d77de738 ML |
5072 | -fdiagnostics-path-format=separate-events} |
5073 | In the future, if GCC changes the default appearance of its diagnostics, the | |
5074 | corresponding option to disable the new behavior will be added to this list. | |
5075 | ||
d77de738 | 5076 | @opindex fdiagnostics-show-location |
ddf6fe37 | 5077 | @item -fdiagnostics-show-location=once |
d77de738 ML |
5078 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
5079 | reporter to emit source location information @emph{once}; that is, in | |
5080 | case the message is too long to fit on a single physical line and has to | |
5081 | be wrapped, the source location won't be emitted (as prefix) again, | |
5082 | over and over, in subsequent continuation lines. This is the default | |
5083 | behavior. | |
5084 | ||
5085 | @item -fdiagnostics-show-location=every-line | |
5086 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
5087 | messages reporter to emit the same source location information (as | |
5088 | prefix) for physical lines that result from the process of breaking | |
5089 | a message which is too long to fit on a single line. | |
5090 | ||
ddf6fe37 | 5091 | @opindex fdiagnostics-color |
d77de738 ML |
5092 | @cindex highlight, color |
5093 | @vindex GCC_COLORS @r{environment variable} | |
f33d7a88 AA |
5094 | @item -fdiagnostics-color[=@var{WHEN}] |
5095 | @itemx -fno-diagnostics-color | |
d77de738 ML |
5096 | Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always}, |
5097 | or @samp{auto}. The default depends on how the compiler has been configured, | |
5098 | it can be any of the above @var{WHEN} options or also @samp{never} | |
5099 | if @env{GCC_COLORS} environment variable isn't present in the environment, | |
5100 | and @samp{auto} otherwise. | |
5101 | @samp{auto} makes GCC use color only when the standard error is a terminal, | |
5102 | and when not executing in an emacs shell. | |
5103 | The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are | |
5104 | aliases for @option{-fdiagnostics-color=always} and | |
5105 | @option{-fdiagnostics-color=never}, respectively. | |
5106 | ||
5107 | The colors are defined by the environment variable @env{GCC_COLORS}. | |
5108 | Its value is a colon-separated list of capabilities and Select Graphic | |
5109 | Rendition (SGR) substrings. SGR commands are interpreted by the | |
5110 | terminal or terminal emulator. (See the section in the documentation | |
5111 | of your text terminal for permitted values and their meanings as | |
5112 | character attributes.) These substring values are integers in decimal | |
5113 | representation and can be concatenated with semicolons. | |
5114 | Common values to concatenate include | |
5115 | @samp{1} for bold, | |
5116 | @samp{4} for underline, | |
5117 | @samp{5} for blink, | |
5118 | @samp{7} for inverse, | |
5119 | @samp{39} for default foreground color, | |
5120 | @samp{30} to @samp{37} for foreground colors, | |
5121 | @samp{90} to @samp{97} for 16-color mode foreground colors, | |
5122 | @samp{38;5;0} to @samp{38;5;255} | |
5123 | for 88-color and 256-color modes foreground colors, | |
5124 | @samp{49} for default background color, | |
5125 | @samp{40} to @samp{47} for background colors, | |
5126 | @samp{100} to @samp{107} for 16-color mode background colors, | |
5127 | and @samp{48;5;0} to @samp{48;5;255} | |
5128 | for 88-color and 256-color modes background colors. | |
5129 | ||
5130 | The default @env{GCC_COLORS} is | |
5131 | @smallexample | |
5132 | error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ | |
5133 | quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ | |
5134 | diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ | |
5135 | type-diff=01;32:fnname=01;32:targs=35 | |
5136 | @end smallexample | |
5137 | @noindent | |
5138 | where @samp{01;31} is bold red, @samp{01;35} is bold magenta, | |
5139 | @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue, | |
5140 | @samp{01} is bold, and @samp{31} is red. | |
5141 | Setting @env{GCC_COLORS} to the empty string disables colors. | |
5142 | Supported capabilities are as follows. | |
5143 | ||
5144 | @table @code | |
d77de738 | 5145 | @vindex error GCC_COLORS @r{capability} |
f33d7a88 | 5146 | @item error= |
d77de738 ML |
5147 | SGR substring for error: markers. |
5148 | ||
d77de738 | 5149 | @vindex warning GCC_COLORS @r{capability} |
f33d7a88 | 5150 | @item warning= |
d77de738 ML |
5151 | SGR substring for warning: markers. |
5152 | ||
d77de738 | 5153 | @vindex note GCC_COLORS @r{capability} |
f33d7a88 | 5154 | @item note= |
d77de738 ML |
5155 | SGR substring for note: markers. |
5156 | ||
d77de738 | 5157 | @vindex path GCC_COLORS @r{capability} |
f33d7a88 | 5158 | @item path= |
d77de738 ML |
5159 | SGR substring for colorizing paths of control-flow events as printed |
5160 | via @option{-fdiagnostics-path-format=}, such as the identifiers of | |
5161 | individual events and lines indicating interprocedural calls and returns. | |
5162 | ||
d77de738 | 5163 | @vindex range1 GCC_COLORS @r{capability} |
f33d7a88 | 5164 | @item range1= |
d77de738 ML |
5165 | SGR substring for first additional range. |
5166 | ||
d77de738 | 5167 | @vindex range2 GCC_COLORS @r{capability} |
f33d7a88 | 5168 | @item range2= |
d77de738 ML |
5169 | SGR substring for second additional range. |
5170 | ||
d77de738 | 5171 | @vindex locus GCC_COLORS @r{capability} |
f33d7a88 | 5172 | @item locus= |
d77de738 ML |
5173 | SGR substring for location information, @samp{file:line} or |
5174 | @samp{file:line:column} etc. | |
5175 | ||
d77de738 | 5176 | @vindex quote GCC_COLORS @r{capability} |
f33d7a88 | 5177 | @item quote= |
d77de738 ML |
5178 | SGR substring for information printed within quotes. |
5179 | ||
d77de738 | 5180 | @vindex fnname GCC_COLORS @r{capability} |
f33d7a88 | 5181 | @item fnname= |
d77de738 ML |
5182 | SGR substring for names of C++ functions. |
5183 | ||
d77de738 | 5184 | @vindex targs GCC_COLORS @r{capability} |
f33d7a88 | 5185 | @item targs= |
d77de738 ML |
5186 | SGR substring for C++ function template parameter bindings. |
5187 | ||
d77de738 | 5188 | @vindex fixit-insert GCC_COLORS @r{capability} |
f33d7a88 | 5189 | @item fixit-insert= |
d77de738 ML |
5190 | SGR substring for fix-it hints suggesting text to |
5191 | be inserted or replaced. | |
5192 | ||
d77de738 | 5193 | @vindex fixit-delete GCC_COLORS @r{capability} |
f33d7a88 | 5194 | @item fixit-delete= |
d77de738 ML |
5195 | SGR substring for fix-it hints suggesting text to |
5196 | be deleted. | |
5197 | ||
d77de738 | 5198 | @vindex diff-filename GCC_COLORS @r{capability} |
f33d7a88 | 5199 | @item diff-filename= |
d77de738 ML |
5200 | SGR substring for filename headers within generated patches. |
5201 | ||
d77de738 | 5202 | @vindex diff-hunk GCC_COLORS @r{capability} |
f33d7a88 | 5203 | @item diff-hunk= |
d77de738 ML |
5204 | SGR substring for the starts of hunks within generated patches. |
5205 | ||
d77de738 | 5206 | @vindex diff-delete GCC_COLORS @r{capability} |
f33d7a88 | 5207 | @item diff-delete= |
d77de738 ML |
5208 | SGR substring for deleted lines within generated patches. |
5209 | ||
d77de738 | 5210 | @vindex diff-insert GCC_COLORS @r{capability} |
f33d7a88 | 5211 | @item diff-insert= |
d77de738 ML |
5212 | SGR substring for inserted lines within generated patches. |
5213 | ||
d77de738 | 5214 | @vindex type-diff GCC_COLORS @r{capability} |
f33d7a88 | 5215 | @item type-diff= |
d77de738 ML |
5216 | SGR substring for highlighting mismatching types within template |
5217 | arguments in the C++ frontend. | |
5218 | @end table | |
5219 | ||
d77de738 ML |
5220 | @opindex fdiagnostics-urls |
5221 | @cindex urls | |
5222 | @vindex GCC_URLS @r{environment variable} | |
5223 | @vindex TERM_URLS @r{environment variable} | |
f33d7a88 | 5224 | @item -fdiagnostics-urls[=@var{WHEN}] |
d77de738 ML |
5225 | Use escape sequences to embed URLs in diagnostics. For example, when |
5226 | @option{-fdiagnostics-show-option} emits text showing the command-line | |
5227 | option controlling a diagnostic, embed a URL for documentation of that | |
5228 | option. | |
5229 | ||
5230 | @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}. | |
5231 | @samp{auto} makes GCC use URL escape sequences only when the standard error | |
5232 | is a terminal, and when not executing in an emacs shell or any graphical | |
5233 | terminal which is known to be incompatible with this feature, see below. | |
5234 | ||
5235 | The default depends on how the compiler has been configured. | |
5236 | It can be any of the above @var{WHEN} options. | |
5237 | ||
5238 | GCC can also be configured (via the | |
5239 | @option{--with-diagnostics-urls=auto-if-env} configure-time option) | |
5240 | so that the default is affected by environment variables. | |
5241 | Under such a configuration, GCC defaults to using @samp{auto} | |
5242 | if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are | |
5243 | present and non-empty in the environment of the compiler, or @samp{never} | |
5244 | if neither are. | |
5245 | ||
5246 | However, even with @option{-fdiagnostics-urls=always} the behavior is | |
5247 | dependent on those environment variables: | |
5248 | If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in | |
5249 | diagnostics. If set to @samp{st}, URLs use ST escape sequences. | |
5250 | If set to @samp{bel}, the default, URLs use BEL escape sequences. | |
5251 | Any other non-empty value enables the feature. | |
5252 | If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback. | |
5253 | Note: ST is an ANSI escape sequence, string terminator @samp{ESC \}, | |
5254 | BEL is an ASCII character, CTRL-G that usually sounds like a beep. | |
5255 | ||
5256 | At this time GCC tries to detect also a few terminals that are known to | |
5257 | not implement the URL feature, and have bugs or at least had bugs in | |
5258 | some versions that are still in use, where the URL escapes are likely | |
5259 | to misbehave, i.e. print garbage on the screen. | |
5260 | That list is currently xfce4-terminal, certain known to be buggy | |
5261 | gnome-terminal versions, the linux console, and mingw. | |
5262 | This check can be skipped with the @option{-fdiagnostics-urls=always}. | |
5263 | ||
d77de738 ML |
5264 | @opindex fno-diagnostics-show-option |
5265 | @opindex fdiagnostics-show-option | |
ddf6fe37 | 5266 | @item -fno-diagnostics-show-option |
d77de738 ML |
5267 | By default, each diagnostic emitted includes text indicating the |
5268 | command-line option that directly controls the diagnostic (if such an | |
5269 | option is known to the diagnostic machinery). Specifying the | |
5270 | @option{-fno-diagnostics-show-option} flag suppresses that behavior. | |
5271 | ||
d77de738 ML |
5272 | @opindex fno-diagnostics-show-caret |
5273 | @opindex fdiagnostics-show-caret | |
ddf6fe37 | 5274 | @item -fno-diagnostics-show-caret |
d77de738 ML |
5275 | By default, each diagnostic emitted includes the original source line |
5276 | and a caret @samp{^} indicating the column. This option suppresses this | |
5277 | information. The source line is truncated to @var{n} characters, if | |
5278 | the @option{-fmessage-length=n} option is given. When the output is done | |
5279 | to the terminal, the width is limited to the width given by the | |
5280 | @env{COLUMNS} environment variable or, if not set, to the terminal width. | |
5281 | ||
d77de738 ML |
5282 | @opindex fno-diagnostics-show-labels |
5283 | @opindex fdiagnostics-show-labels | |
ddf6fe37 | 5284 | @item -fno-diagnostics-show-labels |
d77de738 ML |
5285 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5286 | diagnostics can label ranges of source code with pertinent information, such | |
5287 | as the types of expressions: | |
5288 | ||
5289 | @smallexample | |
5290 | printf ("foo %s bar", long_i + long_j); | |
5291 | ~^ ~~~~~~~~~~~~~~~ | |
5292 | | | | |
5293 | char * long int | |
5294 | @end smallexample | |
5295 | ||
5296 | This option suppresses the printing of these labels (in the example above, | |
5297 | the vertical bars and the ``char *'' and ``long int'' text). | |
5298 | ||
d77de738 ML |
5299 | @opindex fno-diagnostics-show-cwe |
5300 | @opindex fdiagnostics-show-cwe | |
ddf6fe37 | 5301 | @item -fno-diagnostics-show-cwe |
d77de738 ML |
5302 | Diagnostic messages can optionally have an associated |
5303 | @uref{https://cwe.mitre.org/index.html, CWE} identifier. | |
5304 | GCC itself only provides such metadata for some of the @option{-fanalyzer} | |
5305 | diagnostics. GCC plugins may also provide diagnostics with such metadata. | |
5306 | By default, if this information is present, it will be printed with | |
5307 | the diagnostic. This option suppresses the printing of this metadata. | |
5308 | ||
d77de738 ML |
5309 | @opindex fno-diagnostics-show-rules |
5310 | @opindex fdiagnostics-show-rules | |
ddf6fe37 | 5311 | @item -fno-diagnostics-show-rules |
d77de738 ML |
5312 | Diagnostic messages can optionally have rules associated with them, such |
5313 | as from a coding standard, or a specification. | |
5314 | GCC itself does not do this for any of its diagnostics, but plugins may do so. | |
5315 | By default, if this information is present, it will be printed with | |
5316 | the diagnostic. This option suppresses the printing of this metadata. | |
5317 | ||
d77de738 ML |
5318 | @opindex fno-diagnostics-show-line-numbers |
5319 | @opindex fdiagnostics-show-line-numbers | |
ddf6fe37 | 5320 | @item -fno-diagnostics-show-line-numbers |
d77de738 ML |
5321 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5322 | a left margin is printed, showing line numbers. This option suppresses this | |
5323 | left margin. | |
5324 | ||
d77de738 | 5325 | @opindex fdiagnostics-minimum-margin-width |
ddf6fe37 | 5326 | @item -fdiagnostics-minimum-margin-width=@var{width} |
d77de738 ML |
5327 | This option controls the minimum width of the left margin printed by |
5328 | @option{-fdiagnostics-show-line-numbers}. It defaults to 6. | |
5329 | ||
d77de738 | 5330 | @opindex fdiagnostics-parseable-fixits |
ddf6fe37 | 5331 | @item -fdiagnostics-parseable-fixits |
d77de738 ML |
5332 | Emit fix-it hints in a machine-parseable format, suitable for consumption |
5333 | by IDEs. For each fix-it, a line will be printed after the relevant | |
5334 | diagnostic, starting with the string ``fix-it:''. For example: | |
5335 | ||
5336 | @smallexample | |
5337 | fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all" | |
5338 | @end smallexample | |
5339 | ||
5340 | The location is expressed as a half-open range, expressed as a count of | |
5341 | bytes, starting at byte 1 for the initial column. In the above example, | |
5342 | bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the | |
5343 | given string: | |
5344 | ||
5345 | @smallexample | |
5346 | 00000000011111111112222222222 | |
5347 | 12345678901234567890123456789 | |
5348 | gtk_widget_showall (dlg); | |
5349 | ^^^^^^^^^^^^^^^^^^ | |
5350 | gtk_widget_show_all | |
5351 | @end smallexample | |
5352 | ||
5353 | The filename and replacement string escape backslash as ``\\", tab as ``\t'', | |
5354 | newline as ``\n'', double quotes as ``\"'', non-printable characters as octal | |
5355 | (e.g. vertical tab as ``\013''). | |
5356 | ||
5357 | An empty replacement string indicates that the given range is to be removed. | |
5358 | An empty range (e.g. ``45:3-45:3'') indicates that the string is to | |
5359 | be inserted at the given position. | |
5360 | ||
d77de738 | 5361 | @opindex fdiagnostics-generate-patch |
ddf6fe37 | 5362 | @item -fdiagnostics-generate-patch |
d77de738 ML |
5363 | Print fix-it hints to stderr in unified diff format, after any diagnostics |
5364 | are printed. For example: | |
5365 | ||
5366 | @smallexample | |
5367 | --- test.c | |
5368 | +++ test.c | |
5369 | @@ -42,5 +42,5 @@ | |
5370 | ||
5371 | void show_cb(GtkDialog *dlg) | |
5372 | @{ | |
5373 | - gtk_widget_showall(dlg); | |
5374 | + gtk_widget_show_all(dlg); | |
5375 | @} | |
5376 | ||
5377 | @end smallexample | |
5378 | ||
5379 | The diff may or may not be colorized, following the same rules | |
5380 | as for diagnostics (see @option{-fdiagnostics-color}). | |
5381 | ||
d77de738 | 5382 | @opindex fdiagnostics-show-template-tree |
ddf6fe37 | 5383 | @item -fdiagnostics-show-template-tree |
d77de738 ML |
5384 | |
5385 | In the C++ frontend, when printing diagnostics showing mismatching | |
5386 | template types, such as: | |
5387 | ||
5388 | @smallexample | |
5389 | could not convert 'std::map<int, std::vector<double> >()' | |
5390 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5391 | @end smallexample | |
5392 | ||
5393 | the @option{-fdiagnostics-show-template-tree} flag enables printing a | |
5394 | tree-like structure showing the common and differing parts of the types, | |
5395 | such as: | |
5396 | ||
5397 | @smallexample | |
5398 | map< | |
5399 | [...], | |
5400 | vector< | |
5401 | [double != float]>> | |
5402 | @end smallexample | |
5403 | ||
5404 | The parts that differ are highlighted with color (``double'' and | |
5405 | ``float'' in this case). | |
5406 | ||
d77de738 ML |
5407 | @opindex fno-elide-type |
5408 | @opindex felide-type | |
ddf6fe37 | 5409 | @item -fno-elide-type |
d77de738 ML |
5410 | By default when the C++ frontend prints diagnostics showing mismatching |
5411 | template types, common parts of the types are printed as ``[...]'' to | |
5412 | simplify the error message. For example: | |
5413 | ||
5414 | @smallexample | |
5415 | could not convert 'std::map<int, std::vector<double> >()' | |
5416 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5417 | @end smallexample | |
5418 | ||
5419 | Specifying the @option{-fno-elide-type} flag suppresses that behavior. | |
5420 | This flag also affects the output of the | |
5421 | @option{-fdiagnostics-show-template-tree} flag. | |
5422 | ||
d77de738 | 5423 | @opindex fdiagnostics-path-format |
ddf6fe37 | 5424 | @item -fdiagnostics-path-format=@var{KIND} |
d77de738 ML |
5425 | Specify how to print paths of control-flow events for diagnostics that |
5426 | have such a path associated with them. | |
5427 | ||
5428 | @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events}, | |
5429 | the default. | |
5430 | ||
5431 | @samp{none} means to not print diagnostic paths. | |
5432 | ||
5433 | @samp{separate-events} means to print a separate ``note'' diagnostic for | |
5434 | each event within the diagnostic. For example: | |
5435 | ||
5436 | @smallexample | |
5437 | test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter | |
5438 | test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL | |
5439 | test.c:27:3: note: (2) when 'i < count' | |
5440 | test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5441 | @end smallexample | |
5442 | ||
5443 | @samp{inline-events} means to print the events ``inline'' within the source | |
5444 | code. This view attempts to consolidate the events into runs of | |
5445 | sufficiently-close events, printing them as labelled ranges within the source. | |
5446 | ||
5447 | For example, the same events as above might be printed as: | |
5448 | ||
5449 | @smallexample | |
5450 | 'test': events 1-3 | |
5451 | | | |
5452 | | 25 | list = PyList_New(0); | |
5453 | | | ^~~~~~~~~~~~~ | |
5454 | | | | | |
5455 | | | (1) when 'PyList_New' fails, returning NULL | |
5456 | | 26 | | |
5457 | | 27 | for (i = 0; i < count; i++) @{ | |
5458 | | | ~~~ | |
5459 | | | | | |
5460 | | | (2) when 'i < count' | |
5461 | | 28 | item = PyLong_FromLong(random()); | |
5462 | | 29 | PyList_Append(list, item); | |
5463 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5464 | | | | | |
5465 | | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5466 | | | |
5467 | @end smallexample | |
5468 | ||
5469 | Interprocedural control flow is shown by grouping the events by stack frame, | |
5470 | and using indentation to show how stack frames are nested, pushed, and popped. | |
5471 | ||
5472 | For example: | |
5473 | ||
5474 | @smallexample | |
5475 | 'test': events 1-2 | |
5476 | | | |
5477 | | 133 | @{ | |
5478 | | | ^ | |
5479 | | | | | |
5480 | | | (1) entering 'test' | |
5481 | | 134 | boxed_int *obj = make_boxed_int (i); | |
5482 | | | ~~~~~~~~~~~~~~~~~~ | |
5483 | | | | | |
5484 | | | (2) calling 'make_boxed_int' | |
5485 | | | |
5486 | +--> 'make_boxed_int': events 3-4 | |
5487 | | | |
5488 | | 120 | @{ | |
5489 | | | ^ | |
5490 | | | | | |
5491 | | | (3) entering 'make_boxed_int' | |
5492 | | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); | |
5493 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5494 | | | | | |
5495 | | | (4) calling 'wrapped_malloc' | |
5496 | | | |
5497 | +--> 'wrapped_malloc': events 5-6 | |
5498 | | | |
5499 | | 7 | @{ | |
5500 | | | ^ | |
5501 | | | | | |
5502 | | | (5) entering 'wrapped_malloc' | |
5503 | | 8 | return malloc (size); | |
5504 | | | ~~~~~~~~~~~~~ | |
5505 | | | | | |
5506 | | | (6) calling 'malloc' | |
5507 | | | |
5508 | <-------------+ | |
5509 | | | |
5510 | 'test': event 7 | |
5511 | | | |
5512 | | 138 | free_boxed_int (obj); | |
5513 | | | ^~~~~~~~~~~~~~~~~~~~ | |
5514 | | | | | |
5515 | | | (7) calling 'free_boxed_int' | |
5516 | | | |
5517 | (etc) | |
5518 | @end smallexample | |
5519 | ||
d77de738 | 5520 | @opindex fdiagnostics-show-path-depths |
ddf6fe37 | 5521 | @item -fdiagnostics-show-path-depths |
d77de738 ML |
5522 | This option provides additional information when printing control-flow paths |
5523 | associated with a diagnostic. | |
5524 | ||
5525 | If this is option is provided then the stack depth will be printed for | |
5526 | each run of events within @option{-fdiagnostics-path-format=inline-events}. | |
5527 | If provided with @option{-fdiagnostics-path-format=separate-events}, then | |
5528 | the stack depth and function declaration will be appended when printing | |
5529 | each event. | |
5530 | ||
5531 | This is intended for use by GCC developers and plugin developers when | |
5532 | debugging diagnostics that report interprocedural control flow. | |
5533 | ||
d77de738 ML |
5534 | @opindex fno-show-column |
5535 | @opindex fshow-column | |
ddf6fe37 | 5536 | @item -fno-show-column |
d77de738 ML |
5537 | Do not print column numbers in diagnostics. This may be necessary if |
5538 | diagnostics are being scanned by a program that does not understand the | |
5539 | column numbers, such as @command{dejagnu}. | |
5540 | ||
d77de738 | 5541 | @opindex fdiagnostics-column-unit |
ddf6fe37 | 5542 | @item -fdiagnostics-column-unit=@var{UNIT} |
d77de738 ML |
5543 | Select the units for the column number. This affects traditional diagnostics |
5544 | (in the absence of @option{-fno-show-column}), as well as JSON format | |
5545 | diagnostics if requested. | |
5546 | ||
5547 | The default @var{UNIT}, @samp{display}, considers the number of display | |
5548 | columns occupied by each character. This may be larger than the number | |
5549 | of bytes required to encode the character, in the case of tab | |
5550 | characters, or it may be smaller, in the case of multibyte characters. | |
5551 | For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one | |
5552 | display column, and its UTF-8 encoding requires two bytes; the character | |
5553 | ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and | |
5554 | its UTF-8 encoding requires four bytes. | |
5555 | ||
5556 | Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte | |
5557 | count in all cases, as was traditionally output by GCC prior to version 11.1.0. | |
5558 | ||
d77de738 | 5559 | @opindex fdiagnostics-column-origin |
ddf6fe37 | 5560 | @item -fdiagnostics-column-origin=@var{ORIGIN} |
d77de738 ML |
5561 | Select the origin for column numbers, i.e. the column number assigned to the |
5562 | first column. The default value of 1 corresponds to traditional GCC | |
5563 | behavior and to the GNU style guide. Some utilities may perform better with an | |
5564 | origin of 0; any non-negative value may be specified. | |
5565 | ||
d77de738 | 5566 | @opindex fdiagnostics-escape-format |
ddf6fe37 | 5567 | @item -fdiagnostics-escape-format=@var{FORMAT} |
d77de738 ML |
5568 | When GCC prints pertinent source lines for a diagnostic it normally attempts |
5569 | to print the source bytes directly. However, some diagnostics relate to encoding | |
5570 | issues in the source file, such as malformed UTF-8, or issues with Unicode | |
5571 | normalization. These diagnostics are flagged so that GCC will escape bytes | |
5572 | that are not printable ASCII when printing their pertinent source lines. | |
5573 | ||
5574 | This option controls how such bytes should be escaped. | |
5575 | ||
5576 | The default @var{FORMAT}, @samp{unicode} displays Unicode characters that | |
5577 | are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not | |
5578 | correspond to a Unicode character validly-encoded in UTF-8-encoded will be | |
5579 | displayed as hexadecimal in the form @samp{<XX>}. | |
5580 | ||
5581 | For example, a source line containing the string @samp{before} followed by the | |
5582 | Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding | |
5583 | 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by | |
5584 | the string @samp{after} will be printed for such a diagnostic as: | |
5585 | ||
5586 | @smallexample | |
5587 | before<U+03C0><BF>after | |
5588 | @end smallexample | |
5589 | ||
5590 | Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes | |
5591 | in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII | |
5592 | Unicode characters. For the example above, the following will be printed: | |
5593 | ||
5594 | @smallexample | |
5595 | before<CF><80><BF>after | |
5596 | @end smallexample | |
5597 | ||
d77de738 | 5598 | @opindex fdiagnostics-format |
ddf6fe37 | 5599 | @item -fdiagnostics-format=@var{FORMAT} |
d77de738 ML |
5600 | Select a different format for printing diagnostics. |
5601 | @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file}, | |
5602 | @samp{json}, @samp{json-stderr}, or @samp{json-file}. | |
5603 | ||
5604 | The default is @samp{text}. | |
5605 | ||
5606 | The @samp{sarif-stderr} and @samp{sarif-file} formats both emit | |
5607 | diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file | |
5608 | named @file{@var{source}.sarif}, respectively. | |
5609 | ||
5610 | The @samp{json} format is a synonym for @samp{json-stderr}. | |
5611 | The @samp{json-stderr} and @samp{json-file} formats are identical, apart from | |
5612 | where the JSON is emitted to - with the former, the JSON is emitted to stderr, | |
5613 | whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}. | |
5614 | ||
5615 | The emitted JSON consists of a top-level JSON array containing JSON objects | |
5616 | representing the diagnostics. The JSON is emitted as one line, without | |
5617 | formatting; the examples below have been formatted for clarity. | |
5618 | ||
5619 | Diagnostics can have child diagnostics. For example, this error and note: | |
5620 | ||
5621 | @smallexample | |
5622 | misleading-indentation.c:15:3: warning: this 'if' clause does not | |
5623 | guard... [-Wmisleading-indentation] | |
5624 | 15 | if (flag) | |
5625 | | ^~ | |
5626 | misleading-indentation.c:17:5: note: ...this statement, but the latter | |
5627 | is misleadingly indented as if it were guarded by the 'if' | |
5628 | 17 | y = 2; | |
5629 | | ^ | |
5630 | @end smallexample | |
5631 | ||
5632 | @noindent | |
5633 | might be printed in JSON form (after formatting) like this: | |
5634 | ||
5635 | @smallexample | |
5636 | [ | |
5637 | @{ | |
5638 | "kind": "warning", | |
5639 | "locations": [ | |
5640 | @{ | |
5641 | "caret": @{ | |
5642 | "display-column": 3, | |
5643 | "byte-column": 3, | |
5644 | "column": 3, | |
5645 | "file": "misleading-indentation.c", | |
5646 | "line": 15 | |
5647 | @}, | |
5648 | "finish": @{ | |
5649 | "display-column": 4, | |
5650 | "byte-column": 4, | |
5651 | "column": 4, | |
5652 | "file": "misleading-indentation.c", | |
5653 | "line": 15 | |
5654 | @} | |
5655 | @} | |
5656 | ], | |
5657 | "message": "this \u2018if\u2019 clause does not guard...", | |
5658 | "option": "-Wmisleading-indentation", | |
5659 | "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", | |
5660 | "children": [ | |
5661 | @{ | |
5662 | "kind": "note", | |
5663 | "locations": [ | |
5664 | @{ | |
5665 | "caret": @{ | |
5666 | "display-column": 5, | |
5667 | "byte-column": 5, | |
5668 | "column": 5, | |
5669 | "file": "misleading-indentation.c", | |
5670 | "line": 17 | |
5671 | @} | |
5672 | @} | |
5673 | ], | |
5674 | "escape-source": false, | |
5675 | "message": "...this statement, but the latter is @dots{}" | |
5676 | @} | |
5677 | ] | |
5678 | "escape-source": false, | |
5679 | "column-origin": 1, | |
5680 | @} | |
5681 | ] | |
5682 | @end smallexample | |
5683 | ||
5684 | @noindent | |
5685 | where the @code{note} is a child of the @code{warning}. | |
5686 | ||
5687 | A diagnostic has a @code{kind}. If this is @code{warning}, then there is | |
5688 | an @code{option} key describing the command-line option controlling the | |
5689 | warning. | |
5690 | ||
5691 | A diagnostic can contain zero or more locations. Each location has an | |
5692 | optional @code{label} string and up to three positions within it: a | |
5693 | @code{caret} position and optional @code{start} and @code{finish} positions. | |
5694 | A position is described by a @code{file} name, a @code{line} number, and | |
5695 | three numbers indicating a column position: | |
5696 | @itemize @bullet | |
5697 | ||
5698 | @item | |
5699 | @code{display-column} counts display columns, accounting for tabs and | |
5700 | multibyte characters. | |
5701 | ||
5702 | @item | |
5703 | @code{byte-column} counts raw bytes. | |
5704 | ||
5705 | @item | |
5706 | @code{column} is equal to one of | |
5707 | the previous two, as dictated by the @option{-fdiagnostics-column-unit} | |
5708 | option. | |
5709 | ||
5710 | @end itemize | |
5711 | All three columns are relative to the origin specified by | |
5712 | @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may | |
5713 | be set, for instance, to 0 for compatibility with other utilities that | |
5714 | number columns from 0. The column origin is recorded in the JSON output in | |
5715 | the @code{column-origin} tag. In the remaining examples below, the extra | |
5716 | column number outputs have been omitted for brevity. | |
5717 | ||
5718 | For example, this error: | |
5719 | ||
5720 | @smallexample | |
5721 | bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka | |
5722 | 'struct s'@} and 'T' @{aka 'struct t'@}) | |
5723 | 64 | return callee_4a () + callee_4b (); | |
5724 | | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | |
5725 | | | | | |
5726 | | | T @{aka struct t@} | |
5727 | | S @{aka struct s@} | |
5728 | @end smallexample | |
5729 | ||
5730 | @noindent | |
5731 | has three locations. Its primary location is at the ``+'' token at column | |
5732 | 23. It has two secondary locations, describing the left and right-hand sides | |
5733 | of the expression, which have labels. It might be printed in JSON form as: | |
5734 | ||
5735 | @smallexample | |
5736 | @{ | |
5737 | "children": [], | |
5738 | "kind": "error", | |
5739 | "locations": [ | |
5740 | @{ | |
5741 | "caret": @{ | |
5742 | "column": 23, "file": "bad-binary-ops.c", "line": 64 | |
5743 | @} | |
5744 | @}, | |
5745 | @{ | |
5746 | "caret": @{ | |
5747 | "column": 10, "file": "bad-binary-ops.c", "line": 64 | |
5748 | @}, | |
5749 | "finish": @{ | |
5750 | "column": 21, "file": "bad-binary-ops.c", "line": 64 | |
5751 | @}, | |
5752 | "label": "S @{aka struct s@}" | |
5753 | @}, | |
5754 | @{ | |
5755 | "caret": @{ | |
5756 | "column": 25, "file": "bad-binary-ops.c", "line": 64 | |
5757 | @}, | |
5758 | "finish": @{ | |
5759 | "column": 36, "file": "bad-binary-ops.c", "line": 64 | |
5760 | @}, | |
5761 | "label": "T @{aka struct t@}" | |
5762 | @} | |
5763 | ], | |
5764 | "escape-source": false, | |
5765 | "message": "invalid operands to binary + @dots{}" | |
5766 | @} | |
5767 | @end smallexample | |
5768 | ||
5769 | If a diagnostic contains fix-it hints, it has a @code{fixits} array, | |
5770 | consisting of half-open intervals, similar to the output of | |
5771 | @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic | |
5772 | with a replacement fix-it hint: | |
5773 | ||
5774 | @smallexample | |
5775 | demo.c:8:15: error: 'struct s' has no member named 'colour'; did you | |
5776 | mean 'color'? | |
5777 | 8 | return ptr->colour; | |
5778 | | ^~~~~~ | |
5779 | | color | |
5780 | @end smallexample | |
5781 | ||
5782 | @noindent | |
5783 | might be printed in JSON form as: | |
5784 | ||
5785 | @smallexample | |
5786 | @{ | |
5787 | "children": [], | |
5788 | "fixits": [ | |
5789 | @{ | |
5790 | "next": @{ | |
5791 | "column": 21, | |
5792 | "file": "demo.c", | |
5793 | "line": 8 | |
5794 | @}, | |
5795 | "start": @{ | |
5796 | "column": 15, | |
5797 | "file": "demo.c", | |
5798 | "line": 8 | |
5799 | @}, | |
5800 | "string": "color" | |
5801 | @} | |
5802 | ], | |
5803 | "kind": "error", | |
5804 | "locations": [ | |
5805 | @{ | |
5806 | "caret": @{ | |
5807 | "column": 15, | |
5808 | "file": "demo.c", | |
5809 | "line": 8 | |
5810 | @}, | |
5811 | "finish": @{ | |
5812 | "column": 20, | |
5813 | "file": "demo.c", | |
5814 | "line": 8 | |
5815 | @} | |
5816 | @} | |
5817 | ], | |
5818 | "escape-source": false, | |
5819 | "message": "\u2018struct s\u2019 has no member named @dots{}" | |
5820 | @} | |
5821 | @end smallexample | |
5822 | ||
5823 | @noindent | |
5824 | where the fix-it hint suggests replacing the text from @code{start} up | |
5825 | to but not including @code{next} with @code{string}'s value. Deletions | |
5826 | are expressed via an empty value for @code{string}, insertions by | |
5827 | having @code{start} equal @code{next}. | |
5828 | ||
5829 | If the diagnostic has a path of control-flow events associated with it, | |
5830 | it has a @code{path} array of objects representing the events. Each | |
5831 | event object has a @code{description} string, a @code{location} object, | |
5832 | along with a @code{function} string and a @code{depth} number for | |
5833 | representing interprocedural paths. The @code{function} represents the | |
5834 | current function at that event, and the @code{depth} represents the | |
5835 | stack depth relative to some baseline: the higher, the more frames are | |
5836 | within the stack. | |
5837 | ||
5838 | For example, the intraprocedural example shown for | |
5839 | @option{-fdiagnostics-path-format=} might have this JSON for its path: | |
5840 | ||
5841 | @smallexample | |
5842 | "path": [ | |
5843 | @{ | |
5844 | "depth": 0, | |
5845 | "description": "when 'PyList_New' fails, returning NULL", | |
5846 | "function": "test", | |
5847 | "location": @{ | |
5848 | "column": 10, | |
5849 | "file": "test.c", | |
5850 | "line": 25 | |
5851 | @} | |
5852 | @}, | |
5853 | @{ | |
5854 | "depth": 0, | |
5855 | "description": "when 'i < count'", | |
5856 | "function": "test", | |
5857 | "location": @{ | |
5858 | "column": 3, | |
5859 | "file": "test.c", | |
5860 | "line": 27 | |
5861 | @} | |
5862 | @}, | |
5863 | @{ | |
5864 | "depth": 0, | |
5865 | "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", | |
5866 | "function": "test", | |
5867 | "location": @{ | |
5868 | "column": 5, | |
5869 | "file": "test.c", | |
5870 | "line": 29 | |
5871 | @} | |
5872 | @} | |
5873 | ] | |
5874 | @end smallexample | |
5875 | ||
5876 | Diagnostics have a boolean attribute @code{escape-source}, hinting whether | |
5877 | non-ASCII bytes should be escaped when printing the pertinent lines of | |
5878 | source code (@code{true} for diagnostics involving source encoding issues). | |
5879 | ||
5880 | @end table | |
5881 | ||
5882 | @node Warning Options | |
5883 | @section Options to Request or Suppress Warnings | |
5884 | @cindex options to control warnings | |
5885 | @cindex warning messages | |
5886 | @cindex messages, warning | |
5887 | @cindex suppressing warnings | |
5888 | ||
5889 | Warnings are diagnostic messages that report constructions that | |
5890 | are not inherently erroneous but that are risky or suggest there | |
5891 | may have been an error. | |
5892 | ||
5893 | The following language-independent options do not enable specific | |
5894 | warnings but control the kinds of diagnostics produced by GCC@. | |
5895 | ||
5896 | @table @gcctabopt | |
5897 | @cindex syntax checking | |
d77de738 | 5898 | @opindex fsyntax-only |
ddf6fe37 | 5899 | @item -fsyntax-only |
d77de738 ML |
5900 | Check the code for syntax errors, but don't do anything beyond that. |
5901 | ||
d77de738 | 5902 | @opindex fmax-errors |
ddf6fe37 | 5903 | @item -fmax-errors=@var{n} |
d77de738 ML |
5904 | Limits the maximum number of error messages to @var{n}, at which point |
5905 | GCC bails out rather than attempting to continue processing the source | |
5906 | code. If @var{n} is 0 (the default), there is no limit on the number | |
5907 | of error messages produced. If @option{-Wfatal-errors} is also | |
5908 | specified, then @option{-Wfatal-errors} takes precedence over this | |
5909 | option. | |
5910 | ||
d77de738 | 5911 | @opindex w |
ddf6fe37 | 5912 | @item -w |
d77de738 ML |
5913 | Inhibit all warning messages. |
5914 | ||
d77de738 ML |
5915 | @opindex Werror |
5916 | @opindex Wno-error | |
ddf6fe37 | 5917 | @item -Werror |
d77de738 ML |
5918 | Make all warnings into errors. |
5919 | ||
d77de738 ML |
5920 | @opindex Werror= |
5921 | @opindex Wno-error= | |
ddf6fe37 | 5922 | @item -Werror= |
d77de738 ML |
5923 | Make the specified warning into an error. The specifier for a warning |
5924 | is appended; for example @option{-Werror=switch} turns the warnings | |
5925 | controlled by @option{-Wswitch} into errors. This switch takes a | |
5926 | negative form, to be used to negate @option{-Werror} for specific | |
5927 | warnings; for example @option{-Wno-error=switch} makes | |
5928 | @option{-Wswitch} warnings not be errors, even when @option{-Werror} | |
5929 | is in effect. | |
5930 | ||
5931 | The warning message for each controllable warning includes the | |
5932 | option that controls the warning. That option can then be used with | |
5933 | @option{-Werror=} and @option{-Wno-error=} as described above. | |
5934 | (Printing of the option in the warning message can be disabled using the | |
5935 | @option{-fno-diagnostics-show-option} flag.) | |
5936 | ||
5937 | Note that specifying @option{-Werror=}@var{foo} automatically implies | |
5938 | @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not | |
5939 | imply anything. | |
5940 | ||
d77de738 ML |
5941 | @opindex Wfatal-errors |
5942 | @opindex Wno-fatal-errors | |
ddf6fe37 | 5943 | @item -Wfatal-errors |
d77de738 ML |
5944 | This option causes the compiler to abort compilation on the first error |
5945 | occurred rather than trying to keep going and printing further error | |
5946 | messages. | |
5947 | ||
5948 | @end table | |
5949 | ||
5950 | You can request many specific warnings with options beginning with | |
5951 | @samp{-W}, for example @option{-Wimplicit} to request warnings on | |
5952 | implicit declarations. Each of these specific warning options also | |
5953 | has a negative form beginning @samp{-Wno-} to turn off warnings; for | |
5954 | example, @option{-Wno-implicit}. This manual lists only one of the | |
5955 | two forms, whichever is not the default. For further | |
5956 | language-specific options also refer to @ref{C++ Dialect Options} and | |
5957 | @ref{Objective-C and Objective-C++ Dialect Options}. | |
5958 | Additional warnings can be produced by enabling the static analyzer; | |
5959 | @xref{Static Analyzer Options}. | |
5960 | ||
5961 | Some options, such as @option{-Wall} and @option{-Wextra}, turn on other | |
5962 | options, such as @option{-Wunused}, which may turn on further options, | |
5963 | such as @option{-Wunused-value}. The combined effect of positive and | |
5964 | negative forms is that more specific options have priority over less | |
5965 | specific ones, independently of their position in the command-line. For | |
5966 | options of the same specificity, the last one takes effect. Options | |
5967 | enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect | |
5968 | as if they appeared at the end of the command-line. | |
5969 | ||
5970 | When an unrecognized warning option is requested (e.g., | |
5971 | @option{-Wunknown-warning}), GCC emits a diagnostic stating | |
5972 | that the option is not recognized. However, if the @option{-Wno-} form | |
5973 | is used, the behavior is slightly different: no diagnostic is | |
5974 | produced for @option{-Wno-unknown-warning} unless other diagnostics | |
5975 | are being produced. This allows the use of new @option{-Wno-} options | |
5976 | with old compilers, but if something goes wrong, the compiler | |
5977 | warns that an unrecognized option is present. | |
5978 | ||
5979 | The effectiveness of some warnings depends on optimizations also being | |
5980 | enabled. For example @option{-Wsuggest-final-types} is more effective | |
5981 | with link-time optimization and some instances of other warnings may | |
5982 | not be issued at all unless optimization is enabled. While optimization | |
5983 | in general improves the efficacy of control and data flow sensitive | |
5984 | warnings, in some cases it may also cause false positives. | |
5985 | ||
5986 | @table @gcctabopt | |
d77de738 ML |
5987 | @opindex pedantic |
5988 | @opindex Wpedantic | |
5989 | @opindex Wno-pedantic | |
ddf6fe37 AA |
5990 | @item -Wpedantic |
5991 | @itemx -pedantic | |
d77de738 | 5992 | Issue all the warnings demanded by strict ISO C and ISO C++; |
5fccebdb JM |
5993 | diagnose all programs that use forbidden extensions, and some other |
5994 | programs that do not follow ISO C and ISO C++. This follows the version | |
5995 | of the ISO C or C++ standard specified by any @option{-std} option used. | |
d77de738 ML |
5996 | |
5997 | Valid ISO C and ISO C++ programs should compile properly with or without | |
5998 | this option (though a rare few require @option{-ansi} or a | |
5fccebdb | 5999 | @option{-std} option specifying the version of the standard)@. However, |
d77de738 | 6000 | without this option, certain GNU extensions and traditional C and C++ |
5fccebdb JM |
6001 | features are supported as well. With this option, they are diagnosed |
6002 | (or rejected with @option{-pedantic-errors}). | |
d77de738 ML |
6003 | |
6004 | @option{-Wpedantic} does not cause warning messages for use of the | |
6005 | alternate keywords whose names begin and end with @samp{__}. This alternate | |
6006 | format can also be used to disable warnings for non-ISO @samp{__intN} types, | |
6007 | i.e. @samp{__intN__}. | |
6008 | Pedantic warnings are also disabled in the expression that follows | |
6009 | @code{__extension__}. However, only system header files should use | |
6010 | these escape routes; application programs should avoid them. | |
6011 | @xref{Alternate Keywords}. | |
6012 | ||
5fccebdb JM |
6013 | Some warnings about non-conforming programs are controlled by options |
6014 | other than @option{-Wpedantic}; in many cases they are implied by | |
6015 | @option{-Wpedantic} but can be disabled separately by their specific | |
6016 | option, e.g. @option{-Wpedantic -Wno-pointer-sign}. | |
d77de738 ML |
6017 | |
6018 | Where the standard specified with @option{-std} represents a GNU | |
6019 | extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a | |
6020 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
6021 | extended dialect is based. Warnings from @option{-Wpedantic} are given | |
6022 | where they are required by the base standard. (It does not make sense | |
6023 | for such warnings to be given only for features not in the specified GNU | |
6024 | C dialect, since by definition the GNU dialects of C include all | |
6025 | features the compiler supports with the given option, and there would be | |
6026 | nothing to warn about.) | |
6027 | ||
d77de738 | 6028 | @opindex pedantic-errors |
ddf6fe37 | 6029 | @item -pedantic-errors |
d77de738 ML |
6030 | Give an error whenever the @dfn{base standard} (see @option{-Wpedantic}) |
6031 | requires a diagnostic, in some cases where there is undefined behavior | |
6032 | at compile-time and in some other cases that do not prevent compilation | |
6033 | of programs that are valid according to the standard. This is not | |
5fccebdb JM |
6034 | equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be |
6035 | useful, as it only makes errors of the diagnostics that are controlled by | |
6036 | @option{-Wpedantic}, whereas this option also affects required diagnostics that | |
6037 | are always enabled or controlled by options other than @option{-Wpedantic}. | |
6038 | ||
6039 | If you want the required diagnostics that are warnings by default to | |
6040 | be errors instead, but don't also want to enable the @option{-Wpedantic} | |
6041 | diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic} | |
6042 | (or @option{-pedantic-errors -Wno-error=pedantic} to enable them but | |
6043 | only as warnings). | |
6044 | ||
6045 | Some required diagnostics are errors by default, but can be reduced to | |
6046 | warnings using @option{-fpermissive} or their specific warning option, | |
6047 | e.g. @option{-Wno-error=narrowing}. | |
6048 | ||
6049 | Some diagnostics for non-ISO practices are controlled by specific | |
6050 | warning options other than @option{-Wpedantic}, but are also made | |
6051 | errors by @option{-pedantic-errors}. For instance: | |
6052 | ||
6053 | @gccoptlist{ | |
6054 | -Wattributes @r{(for standard attributes)} | |
6055 | -Wchanges-meaning @r{(C++)} | |
6056 | -Wcomma-subscript @r{(C++23 or later)} | |
6057 | -Wdeclaration-after-statement @r{(C90 or earlier)} | |
6058 | -Wimplicit-int @r{(C99 or later)} | |
6059 | -Wimplicit-function-declaration @r{(C99 or later)} | |
6060 | -Wincompatible-pointer-types | |
6061 | -Wint-conversion | |
6062 | -Wlong-long @r{(C90 or earlier)} | |
6063 | -Wmain | |
6064 | -Wnarrowing @r{(C++11 or later)} | |
6065 | -Wpointer-arith | |
6066 | -Wpointer-sign | |
6067 | -Wincompatible-pointer-types | |
6068 | -Wregister @r{(C++17 or later)} | |
6069 | -Wvla @r{(C90 or earlier)} | |
6070 | -Wwrite-strings @r{(C++11 or later)} | |
6071 | } | |
d77de738 | 6072 | |
d77de738 ML |
6073 | @opindex Wall |
6074 | @opindex Wno-all | |
ddf6fe37 | 6075 | @item -Wall |
d77de738 ML |
6076 | This enables all the warnings about constructions that some users |
6077 | consider questionable, and that are easy to avoid (or modify to | |
6078 | prevent the warning), even in conjunction with macros. This also | |
6079 | enables some language-specific warnings described in @ref{C++ Dialect | |
6080 | Options} and @ref{Objective-C and Objective-C++ Dialect Options}. | |
6081 | ||
6082 | @option{-Wall} turns on the following warning flags: | |
6083 | ||
43b72ede AA |
6084 | @gccoptlist{-Waddress |
6085 | -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} | |
6086 | -Warray-compare | |
6087 | -Warray-parameter=2 @r{(C and Objective-C only)} | |
6088 | -Wbool-compare | |
6089 | -Wbool-operation | |
6090 | -Wc++11-compat -Wc++14-compat | |
6091 | -Wcatch-value @r{(C++ and Objective-C++ only)} | |
6092 | -Wchar-subscripts | |
6093 | -Wcomment | |
6094 | -Wdangling-pointer=2 | |
6095 | -Wduplicate-decl-specifier @r{(C and Objective-C only)} | |
6096 | -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} | |
6097 | -Wenum-int-mismatch @r{(C and Objective-C only)} | |
6098 | -Wformat | |
6099 | -Wformat-overflow | |
6100 | -Wformat-truncation | |
6101 | -Wint-in-bool-context | |
6102 | -Wimplicit @r{(C and Objective-C only)} | |
6103 | -Wimplicit-int @r{(C and Objective-C only)} | |
6104 | -Wimplicit-function-declaration @r{(C and Objective-C only)} | |
6105 | -Winit-self @r{(only for C++)} | |
6106 | -Wlogical-not-parentheses | |
6107 | -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} | |
6108 | -Wmaybe-uninitialized | |
6109 | -Wmemset-elt-size | |
6110 | -Wmemset-transposed-args | |
6111 | -Wmisleading-indentation @r{(only for C/C++)} | |
6112 | -Wmismatched-dealloc | |
6113 | -Wmismatched-new-delete @r{(only for C/C++)} | |
6114 | -Wmissing-attributes | |
6115 | -Wmissing-braces @r{(only for C/ObjC)} | |
6116 | -Wmultistatement-macros | |
6117 | -Wnarrowing @r{(only for C++)} | |
6118 | -Wnonnull | |
6119 | -Wnonnull-compare | |
6120 | -Wopenmp-simd | |
6121 | -Wparentheses | |
6122 | -Wpessimizing-move @r{(only for C++)} | |
6123 | -Wpointer-sign | |
6124 | -Wrange-loop-construct @r{(only for C++)} | |
6125 | -Wreorder | |
6126 | -Wrestrict | |
6127 | -Wreturn-type | |
6128 | -Wself-move @r{(only for C++)} | |
6129 | -Wsequence-point | |
6130 | -Wsign-compare @r{(only in C++)} | |
6131 | -Wsizeof-array-div | |
6132 | -Wsizeof-pointer-div | |
6133 | -Wsizeof-pointer-memaccess | |
6134 | -Wstrict-aliasing | |
6135 | -Wstrict-overflow=1 | |
6136 | -Wswitch | |
6137 | -Wtautological-compare | |
6138 | -Wtrigraphs | |
6139 | -Wuninitialized | |
6140 | -Wunknown-pragmas | |
6141 | -Wunused-function | |
6142 | -Wunused-label | |
6143 | -Wunused-value | |
6144 | -Wunused-variable | |
6145 | -Wuse-after-free=2 | |
6146 | -Wvla-parameter @r{(C and Objective-C only)} | |
6147 | -Wvolatile-register-var | |
d77de738 ML |
6148 | -Wzero-length-bounds} |
6149 | ||
6150 | Note that some warning flags are not implied by @option{-Wall}. Some of | |
6151 | them warn about constructions that users generally do not consider | |
6152 | questionable, but which occasionally you might wish to check for; | |
6153 | others warn about constructions that are necessary or hard to avoid in | |
6154 | some cases, and there is no simple way to modify the code to suppress | |
6155 | the warning. Some of them are enabled by @option{-Wextra} but many of | |
6156 | them must be enabled individually. | |
6157 | ||
d77de738 ML |
6158 | @opindex W |
6159 | @opindex Wextra | |
6160 | @opindex Wno-extra | |
ddf6fe37 | 6161 | @item -Wextra |
d77de738 ML |
6162 | This enables some extra warning flags that are not enabled by |
6163 | @option{-Wall}. (This option used to be called @option{-W}. The older | |
6164 | name is still supported, but the newer name is more descriptive.) | |
6165 | ||
43b72ede AA |
6166 | @gccoptlist{-Wclobbered |
6167 | -Wcast-function-type | |
6168 | -Wdeprecated-copy @r{(C++ only)} | |
6169 | -Wempty-body | |
6170 | -Wenum-conversion @r{(C only)} | |
6171 | -Wignored-qualifiers | |
6172 | -Wimplicit-fallthrough=3 | |
6173 | -Wmissing-field-initializers | |
6174 | -Wmissing-parameter-type @r{(C only)} | |
6175 | -Wold-style-declaration @r{(C only)} | |
6176 | -Woverride-init | |
6177 | -Wsign-compare @r{(C only)} | |
6178 | -Wstring-compare | |
6179 | -Wredundant-move @r{(only for C++)} | |
6180 | -Wtype-limits | |
6181 | -Wuninitialized | |
6182 | -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} | |
6183 | -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} | |
d77de738 ML |
6184 | -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}} |
6185 | ||
6186 | ||
6187 | The option @option{-Wextra} also prints warning messages for the | |
6188 | following cases: | |
6189 | ||
6190 | @itemize @bullet | |
6191 | ||
6192 | @item | |
6193 | A pointer is compared against integer zero with @code{<}, @code{<=}, | |
6194 | @code{>}, or @code{>=}. | |
6195 | ||
6196 | @item | |
6197 | (C++ only) An enumerator and a non-enumerator both appear in a | |
6198 | conditional expression. | |
6199 | ||
6200 | @item | |
6201 | (C++ only) Ambiguous virtual bases. | |
6202 | ||
6203 | @item | |
6204 | (C++ only) Subscripting an array that has been declared @code{register}. | |
6205 | ||
6206 | @item | |
6207 | (C++ only) Taking the address of a variable that has been declared | |
6208 | @code{register}. | |
6209 | ||
6210 | @item | |
6211 | (C++ only) A base class is not initialized in the copy constructor | |
6212 | of a derived class. | |
6213 | ||
6214 | @end itemize | |
6215 | ||
d77de738 ML |
6216 | @opindex Wabi |
6217 | @opindex Wno-abi | |
ddf6fe37 | 6218 | @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
6219 | |
6220 | Warn about code affected by ABI changes. This includes code that may | |
6221 | not be compatible with the vendor-neutral C++ ABI as well as the psABI | |
6222 | for the particular target. | |
6223 | ||
6224 | Since G++ now defaults to updating the ABI with each major release, | |
6225 | normally @option{-Wabi} warns only about C++ ABI compatibility | |
6226 | problems if there is a check added later in a release series for an | |
6227 | ABI issue discovered since the initial release. @option{-Wabi} warns | |
6228 | about more things if an older ABI version is selected (with | |
6229 | @option{-fabi-version=@var{n}}). | |
6230 | ||
6231 | @option{-Wabi} can also be used with an explicit version number to | |
6232 | warn about C++ ABI compatibility with a particular @option{-fabi-version} | |
6233 | level, e.g.@: @option{-Wabi=2} to warn about changes relative to | |
6234 | @option{-fabi-version=2}. | |
6235 | ||
6236 | If an explicit version number is provided and | |
6237 | @option{-fabi-compat-version} is not specified, the version number | |
6238 | from this option is used for compatibility aliases. If no explicit | |
6239 | version number is provided with this option, but | |
6240 | @option{-fabi-compat-version} is specified, that version number is | |
6241 | used for C++ ABI warnings. | |
6242 | ||
6243 | Although an effort has been made to warn about | |
6244 | all such cases, there are probably some cases that are not warned about, | |
6245 | even though G++ is generating incompatible code. There may also be | |
6246 | cases where warnings are emitted even though the code that is generated | |
6247 | is compatible. | |
6248 | ||
6249 | You should rewrite your code to avoid these warnings if you are | |
6250 | concerned about the fact that code generated by G++ may not be binary | |
6251 | compatible with code generated by other compilers. | |
6252 | ||
6253 | Known incompatibilities in @option{-fabi-version=2} (which was the | |
6254 | default from GCC 3.4 to 4.9) include: | |
6255 | ||
6256 | @itemize @bullet | |
6257 | ||
6258 | @item | |
6259 | A template with a non-type template parameter of reference type was | |
6260 | mangled incorrectly: | |
6261 | @smallexample | |
6262 | extern int N; | |
6263 | template <int &> struct S @{@}; | |
6264 | void n (S<N>) @{2@} | |
6265 | @end smallexample | |
6266 | ||
6267 | This was fixed in @option{-fabi-version=3}. | |
6268 | ||
6269 | @item | |
6270 | SIMD vector types declared using @code{__attribute ((vector_size))} were | |
6271 | mangled in a non-standard way that does not allow for overloading of | |
6272 | functions taking vectors of different sizes. | |
6273 | ||
6274 | The mangling was changed in @option{-fabi-version=4}. | |
6275 | ||
6276 | @item | |
6277 | @code{__attribute ((const))} and @code{noreturn} were mangled as type | |
6278 | qualifiers, and @code{decltype} of a plain declaration was folded away. | |
6279 | ||
6280 | These mangling issues were fixed in @option{-fabi-version=5}. | |
6281 | ||
6282 | @item | |
6283 | Scoped enumerators passed as arguments to a variadic function are | |
6284 | promoted like unscoped enumerators, causing @code{va_arg} to complain. | |
6285 | On most targets this does not actually affect the parameter passing | |
6286 | ABI, as there is no way to pass an argument smaller than @code{int}. | |
6287 | ||
6288 | Also, the ABI changed the mangling of template argument packs, | |
6289 | @code{const_cast}, @code{static_cast}, prefix increment/decrement, and | |
6290 | a class scope function used as a template argument. | |
6291 | ||
6292 | These issues were corrected in @option{-fabi-version=6}. | |
6293 | ||
6294 | @item | |
6295 | Lambdas in default argument scope were mangled incorrectly, and the | |
6296 | ABI changed the mangling of @code{nullptr_t}. | |
6297 | ||
6298 | These issues were corrected in @option{-fabi-version=7}. | |
6299 | ||
6300 | @item | |
6301 | When mangling a function type with function-cv-qualifiers, the | |
6302 | un-qualified function type was incorrectly treated as a substitution | |
6303 | candidate. | |
6304 | ||
6305 | This was fixed in @option{-fabi-version=8}, the default for GCC 5.1. | |
6306 | ||
6307 | @item | |
6308 | @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to | |
6309 | unaligned accesses. Note that this did not affect the ABI of a | |
6310 | function with a @code{nullptr_t} parameter, as parameters have a | |
6311 | minimum alignment. | |
6312 | ||
6313 | This was fixed in @option{-fabi-version=9}, the default for GCC 5.2. | |
6314 | ||
6315 | @item | |
6316 | Target-specific attributes that affect the identity of a type, such as | |
6317 | ia32 calling conventions on a function type (stdcall, regparm, etc.), | |
6318 | did not affect the mangled name, leading to name collisions when | |
6319 | function pointers were used as template arguments. | |
6320 | ||
6321 | This was fixed in @option{-fabi-version=10}, the default for GCC 6.1. | |
6322 | ||
6323 | @end itemize | |
6324 | ||
6325 | This option also enables warnings about psABI-related changes. | |
6326 | The known psABI changes at this point include: | |
6327 | ||
6328 | @itemize @bullet | |
6329 | ||
6330 | @item | |
6331 | For SysV/x86-64, unions with @code{long double} members are | |
6332 | passed in memory as specified in psABI. Prior to GCC 4.4, this was not | |
6333 | the case. For example: | |
6334 | ||
6335 | @smallexample | |
6336 | union U @{ | |
6337 | long double ld; | |
6338 | int i; | |
6339 | @}; | |
6340 | @end smallexample | |
6341 | ||
6342 | @noindent | |
6343 | @code{union U} is now always passed in memory. | |
6344 | ||
6345 | @end itemize | |
6346 | ||
e2f939d3 JM |
6347 | @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)} |
6348 | C++ requires that unqualified uses of a name within a class have the | |
6349 | same meaning in the complete scope of the class, so declaring the name | |
6350 | after using it is ill-formed: | |
6351 | @smallexample | |
6352 | struct A; | |
6353 | struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning | |
6354 | struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning | |
6355 | @end smallexample | |
6356 | By default, the B1 case is only a warning because the two declarations | |
6357 | have the same type, while the B2 case is an error. Both diagnostics | |
6358 | can be disabled with @option{-Wno-changes-meaning}. Alternately, the | |
6359 | error case can be reduced to a warning with | |
6360 | @option{-Wno-error=changes-meaning} or @option{-fpermissive}. | |
6361 | ||
6362 | Both diagnostics are also suppressed by @option{-fms-extensions}. | |
6363 | ||
d77de738 ML |
6364 | @opindex Wchar-subscripts |
6365 | @opindex Wno-char-subscripts | |
ddf6fe37 | 6366 | @item -Wchar-subscripts |
d77de738 ML |
6367 | Warn if an array subscript has type @code{char}. This is a common cause |
6368 | of error, as programmers often forget that this type is signed on some | |
6369 | machines. | |
6370 | This warning is enabled by @option{-Wall}. | |
6371 | ||
d77de738 ML |
6372 | @opindex Wno-coverage-mismatch |
6373 | @opindex Wcoverage-mismatch | |
ddf6fe37 | 6374 | @item -Wno-coverage-mismatch |
d77de738 ML |
6375 | Warn if feedback profiles do not match when using the |
6376 | @option{-fprofile-use} option. | |
6377 | If a source file is changed between compiling with @option{-fprofile-generate} | |
6378 | and with @option{-fprofile-use}, the files with the profile feedback can fail | |
6379 | to match the source file and GCC cannot use the profile feedback | |
6380 | information. By default, this warning is enabled and is treated as an | |
6381 | error. @option{-Wno-coverage-mismatch} can be used to disable the | |
6382 | warning or @option{-Wno-error=coverage-mismatch} can be used to | |
6383 | disable the error. Disabling the error for this warning can result in | |
6384 | poorly optimized code and is useful only in the | |
6385 | case of very minor changes such as bug fixes to an existing code-base. | |
6386 | Completely disabling the warning is not recommended. | |
6387 | ||
d77de738 ML |
6388 | @opindex Wno-coverage-invalid-line-number |
6389 | @opindex Wcoverage-invalid-line-number | |
ddf6fe37 | 6390 | @item -Wno-coverage-invalid-line-number |
d77de738 ML |
6391 | Warn in case a function ends earlier than it begins due |
6392 | to an invalid linenum macros. The warning is emitted only | |
6393 | with @option{--coverage} enabled. | |
6394 | ||
6395 | By default, this warning is enabled and is treated as an | |
6396 | error. @option{-Wno-coverage-invalid-line-number} can be used to disable the | |
6397 | warning or @option{-Wno-error=coverage-invalid-line-number} can be used to | |
6398 | disable the error. | |
6399 | ||
d77de738 ML |
6400 | @opindex Wno-cpp |
6401 | @opindex Wcpp | |
ddf6fe37 | 6402 | @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)} |
d77de738 ML |
6403 | Suppress warning messages emitted by @code{#warning} directives. |
6404 | ||
d77de738 ML |
6405 | @opindex Wdouble-promotion |
6406 | @opindex Wno-double-promotion | |
ddf6fe37 | 6407 | @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6408 | Give a warning when a value of type @code{float} is implicitly |
6409 | promoted to @code{double}. CPUs with a 32-bit ``single-precision'' | |
6410 | floating-point unit implement @code{float} in hardware, but emulate | |
6411 | @code{double} in software. On such a machine, doing computations | |
6412 | using @code{double} values is much more expensive because of the | |
6413 | overhead required for software emulation. | |
6414 | ||
6415 | It is easy to accidentally do computations with @code{double} because | |
6416 | floating-point literals are implicitly of type @code{double}. For | |
6417 | example, in: | |
6418 | @smallexample | |
6419 | @group | |
6420 | float area(float radius) | |
6421 | @{ | |
6422 | return 3.14159 * radius * radius; | |
6423 | @} | |
6424 | @end group | |
6425 | @end smallexample | |
6426 | the compiler performs the entire computation with @code{double} | |
6427 | because the floating-point literal is a @code{double}. | |
6428 | ||
d77de738 ML |
6429 | @opindex Wduplicate-decl-specifier |
6430 | @opindex Wno-duplicate-decl-specifier | |
ddf6fe37 | 6431 | @item -Wduplicate-decl-specifier @r{(C and Objective-C only)} |
d77de738 ML |
6432 | Warn if a declaration has duplicate @code{const}, @code{volatile}, |
6433 | @code{restrict} or @code{_Atomic} specifier. This warning is enabled by | |
6434 | @option{-Wall}. | |
6435 | ||
d77de738 ML |
6436 | @opindex Wformat |
6437 | @opindex Wno-format | |
6438 | @opindex ffreestanding | |
6439 | @opindex fno-builtin | |
6440 | @opindex Wformat= | |
ddf6fe37 AA |
6441 | @item -Wformat |
6442 | @itemx -Wformat=@var{n} | |
d77de738 ML |
6443 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
6444 | the arguments supplied have types appropriate to the format string | |
6445 | specified, and that the conversions specified in the format string make | |
6446 | sense. This includes standard functions, and others specified by format | |
6447 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
6448 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
6449 | not in the C standard) families (or other target-specific families). | |
6450 | Which functions are checked without format attributes having been | |
6451 | specified depends on the standard version selected, and such checks of | |
6452 | functions without the attribute specified are disabled by | |
6453 | @option{-ffreestanding} or @option{-fno-builtin}. | |
6454 | ||
6455 | The formats are checked against the format features supported by GNU | |
6456 | libc version 2.2. These include all ISO C90 and C99 features, as well | |
6457 | as features from the Single Unix Specification and some BSD and GNU | |
6458 | extensions. Other library implementations may not support all these | |
6459 | features; GCC does not support warning about features that go beyond a | |
6460 | particular library's limitations. However, if @option{-Wpedantic} is used | |
6461 | with @option{-Wformat}, warnings are given about format features not | |
6462 | in the selected standard version (but not for @code{strfmon} formats, | |
6463 | since those are not in any version of the C standard). @xref{C Dialect | |
6464 | Options,,Options Controlling C Dialect}. | |
6465 | ||
6466 | @table @gcctabopt | |
d77de738 ML |
6467 | @opindex Wformat |
6468 | @opindex Wformat=1 | |
ddf6fe37 AA |
6469 | @item -Wformat=1 |
6470 | @itemx -Wformat | |
d77de738 ML |
6471 | Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and |
6472 | @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since | |
6473 | @option{-Wformat} also checks for null format arguments for several | |
6474 | functions, @option{-Wformat} also implies @option{-Wnonnull}. Some | |
6475 | aspects of this level of format checking can be disabled by the | |
6476 | options: @option{-Wno-format-contains-nul}, | |
6477 | @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}. | |
6478 | @option{-Wformat} is enabled by @option{-Wall}. | |
6479 | ||
d77de738 | 6480 | @opindex Wformat=2 |
ddf6fe37 | 6481 | @item -Wformat=2 |
d77de738 ML |
6482 | Enable @option{-Wformat} plus additional format checks. Currently |
6483 | equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security | |
6484 | -Wformat-y2k}. | |
6485 | @end table | |
6486 | ||
d77de738 ML |
6487 | @opindex Wno-format-contains-nul |
6488 | @opindex Wformat-contains-nul | |
ddf6fe37 | 6489 | @item -Wno-format-contains-nul |
d77de738 ML |
6490 | If @option{-Wformat} is specified, do not warn about format strings that |
6491 | contain NUL bytes. | |
6492 | ||
d77de738 ML |
6493 | @opindex Wno-format-extra-args |
6494 | @opindex Wformat-extra-args | |
ddf6fe37 | 6495 | @item -Wno-format-extra-args |
d77de738 ML |
6496 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
6497 | @code{printf} or @code{scanf} format function. The C standard specifies | |
6498 | that such arguments are ignored. | |
6499 | ||
6500 | Where the unused arguments lie between used arguments that are | |
6501 | specified with @samp{$} operand number specifications, normally | |
6502 | warnings are still given, since the implementation could not know what | |
6503 | type to pass to @code{va_arg} to skip the unused arguments. However, | |
6504 | in the case of @code{scanf} formats, this option suppresses the | |
6505 | warning if the unused arguments are all pointers, since the Single | |
6506 | Unix Specification says that such unused arguments are allowed. | |
6507 | ||
d77de738 ML |
6508 | @opindex Wformat-overflow |
6509 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6510 | @item -Wformat-overflow |
6511 | @itemx -Wformat-overflow=@var{level} | |
d77de738 ML |
6512 | Warn about calls to formatted input/output functions such as @code{sprintf} |
6513 | and @code{vsprintf} that might overflow the destination buffer. When the | |
6514 | exact number of bytes written by a format directive cannot be determined | |
6515 | at compile-time it is estimated based on heuristics that depend on the | |
6516 | @var{level} argument and on optimization. While enabling optimization | |
6517 | will in most cases improve the accuracy of the warning, it may also | |
6518 | result in false positives. | |
6519 | ||
6520 | @table @gcctabopt | |
d77de738 ML |
6521 | @opindex Wformat-overflow |
6522 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6523 | @item -Wformat-overflow |
6524 | @itemx -Wformat-overflow=1 | |
d77de738 ML |
6525 | Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat} |
6526 | employs a conservative approach that warns only about calls that most | |
6527 | likely overflow the buffer. At this level, numeric arguments to format | |
6528 | directives with unknown values are assumed to have the value of one, and | |
6529 | strings of unknown length to be empty. Numeric arguments that are known | |
6530 | to be bounded to a subrange of their type, or string arguments whose output | |
6531 | is bounded either by their directive's precision or by a finite set of | |
6532 | string literals, are assumed to take on the value within the range that | |
6533 | results in the most bytes on output. For example, the call to @code{sprintf} | |
6534 | below is diagnosed because even with both @var{a} and @var{b} equal to zero, | |
6535 | the terminating NUL character (@code{'\0'}) appended by the function | |
6536 | to the destination buffer will be written past its end. Increasing | |
6537 | the size of the buffer by a single byte is sufficient to avoid the | |
6538 | warning, though it may not be sufficient to avoid the overflow. | |
6539 | ||
6540 | @smallexample | |
6541 | void f (int a, int b) | |
6542 | @{ | |
6543 | char buf [13]; | |
6544 | sprintf (buf, "a = %i, b = %i\n", a, b); | |
6545 | @} | |
6546 | @end smallexample | |
6547 | ||
6548 | @item -Wformat-overflow=2 | |
6549 | Level @var{2} warns also about calls that might overflow the destination | |
6550 | buffer given an argument of sufficient length or magnitude. At level | |
6551 | @var{2}, unknown numeric arguments are assumed to have the minimum | |
6552 | representable value for signed types with a precision greater than 1, and | |
6553 | the maximum representable value otherwise. Unknown string arguments whose | |
6554 | length cannot be assumed to be bounded either by the directive's precision, | |
6555 | or by a finite set of string literals they may evaluate to, or the character | |
6556 | array they may point to, are assumed to be 1 character long. | |
6557 | ||
6558 | At level @var{2}, the call in the example above is again diagnosed, but | |
6559 | this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first | |
6560 | @code{%i} directive will write some of its digits beyond the end of | |
6561 | the destination buffer. To make the call safe regardless of the values | |
6562 | of the two variables, the size of the destination buffer must be increased | |
6563 | to at least 34 bytes. GCC includes the minimum size of the buffer in | |
6564 | an informational note following the warning. | |
6565 | ||
6566 | An alternative to increasing the size of the destination buffer is to | |
6567 | constrain the range of formatted values. The maximum length of string | |
6568 | arguments can be bounded by specifying the precision in the format | |
6569 | directive. When numeric arguments of format directives can be assumed | |
6570 | to be bounded by less than the precision of their type, choosing | |
6571 | an appropriate length modifier to the format specifier will reduce | |
6572 | the required buffer size. For example, if @var{a} and @var{b} in the | |
6573 | example above can be assumed to be within the precision of | |
6574 | the @code{short int} type then using either the @code{%hi} format | |
6575 | directive or casting the argument to @code{short} reduces the maximum | |
6576 | required size of the buffer to 24 bytes. | |
6577 | ||
6578 | @smallexample | |
6579 | void f (int a, int b) | |
6580 | @{ | |
6581 | char buf [23]; | |
6582 | sprintf (buf, "a = %hi, b = %i\n", a, (short)b); | |
6583 | @} | |
6584 | @end smallexample | |
6585 | @end table | |
6586 | ||
d77de738 ML |
6587 | @opindex Wno-format-zero-length |
6588 | @opindex Wformat-zero-length | |
ddf6fe37 | 6589 | @item -Wno-format-zero-length |
d77de738 ML |
6590 | If @option{-Wformat} is specified, do not warn about zero-length formats. |
6591 | The C standard specifies that zero-length formats are allowed. | |
6592 | ||
d77de738 ML |
6593 | @opindex Wformat-nonliteral |
6594 | @opindex Wno-format-nonliteral | |
ddf6fe37 | 6595 | @item -Wformat-nonliteral |
d77de738 ML |
6596 | If @option{-Wformat} is specified, also warn if the format string is not a |
6597 | string literal and so cannot be checked, unless the format function | |
6598 | takes its format arguments as a @code{va_list}. | |
6599 | ||
d77de738 ML |
6600 | @opindex Wformat-security |
6601 | @opindex Wno-format-security | |
ddf6fe37 | 6602 | @item -Wformat-security |
d77de738 ML |
6603 | If @option{-Wformat} is specified, also warn about uses of format |
6604 | functions that represent possible security problems. At present, this | |
6605 | warns about calls to @code{printf} and @code{scanf} functions where the | |
6606 | format string is not a string literal and there are no format arguments, | |
6607 | as in @code{printf (foo);}. This may be a security hole if the format | |
6608 | string came from untrusted input and contains @samp{%n}. (This is | |
6609 | currently a subset of what @option{-Wformat-nonliteral} warns about, but | |
6610 | in future warnings may be added to @option{-Wformat-security} that are not | |
6611 | included in @option{-Wformat-nonliteral}.) | |
6612 | ||
d77de738 ML |
6613 | @opindex Wformat-signedness |
6614 | @opindex Wno-format-signedness | |
ddf6fe37 | 6615 | @item -Wformat-signedness |
d77de738 ML |
6616 | If @option{-Wformat} is specified, also warn if the format string |
6617 | requires an unsigned argument and the argument is signed and vice versa. | |
6618 | ||
d77de738 ML |
6619 | @opindex Wformat-truncation |
6620 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6621 | @item -Wformat-truncation |
6622 | @itemx -Wformat-truncation=@var{level} | |
d77de738 ML |
6623 | Warn about calls to formatted input/output functions such as @code{snprintf} |
6624 | and @code{vsnprintf} that might result in output truncation. When the exact | |
6625 | number of bytes written by a format directive cannot be determined at | |
6626 | compile-time it is estimated based on heuristics that depend on | |
6627 | the @var{level} argument and on optimization. While enabling optimization | |
6628 | will in most cases improve the accuracy of the warning, it may also result | |
6629 | in false positives. Except as noted otherwise, the option uses the same | |
6630 | logic @option{-Wformat-overflow}. | |
6631 | ||
6632 | @table @gcctabopt | |
d77de738 ML |
6633 | @opindex Wformat-truncation |
6634 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6635 | @item -Wformat-truncation |
6636 | @itemx -Wformat-truncation=1 | |
d77de738 ML |
6637 | Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat} |
6638 | employs a conservative approach that warns only about calls to bounded | |
6639 | functions whose return value is unused and that will most likely result | |
6640 | in output truncation. | |
6641 | ||
6642 | @item -Wformat-truncation=2 | |
6643 | Level @var{2} warns also about calls to bounded functions whose return | |
6644 | value is used and that might result in truncation given an argument of | |
6645 | sufficient length or magnitude. | |
6646 | @end table | |
6647 | ||
d77de738 ML |
6648 | @opindex Wformat-y2k |
6649 | @opindex Wno-format-y2k | |
ddf6fe37 | 6650 | @item -Wformat-y2k |
d77de738 ML |
6651 | If @option{-Wformat} is specified, also warn about @code{strftime} |
6652 | formats that may yield only a two-digit year. | |
6653 | ||
d77de738 ML |
6654 | @opindex Wnonnull |
6655 | @opindex Wno-nonnull | |
ddf6fe37 | 6656 | @item -Wnonnull |
d77de738 ML |
6657 | Warn about passing a null pointer for arguments marked as |
6658 | requiring a non-null value by the @code{nonnull} function attribute. | |
6659 | ||
6660 | @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It | |
6661 | can be disabled with the @option{-Wno-nonnull} option. | |
6662 | ||
d77de738 ML |
6663 | @opindex Wnonnull-compare |
6664 | @opindex Wno-nonnull-compare | |
ddf6fe37 | 6665 | @item -Wnonnull-compare |
d77de738 ML |
6666 | Warn when comparing an argument marked with the @code{nonnull} |
6667 | function attribute against null inside the function. | |
6668 | ||
6669 | @option{-Wnonnull-compare} is included in @option{-Wall}. It | |
6670 | can be disabled with the @option{-Wno-nonnull-compare} option. | |
6671 | ||
d77de738 ML |
6672 | @opindex Wnull-dereference |
6673 | @opindex Wno-null-dereference | |
ddf6fe37 | 6674 | @item -Wnull-dereference |
d77de738 ML |
6675 | Warn if the compiler detects paths that trigger erroneous or |
6676 | undefined behavior due to dereferencing a null pointer. This option | |
6677 | is only active when @option{-fdelete-null-pointer-checks} is active, | |
6678 | which is enabled by optimizations in most targets. The precision of | |
6679 | the warnings depends on the optimization options used. | |
6680 | ||
2ae5384d JM |
6681 | @opindex Wnrvo |
6682 | @opindex Wno-nrvo | |
6683 | @item -Wnrvo @r{(C++ and Objective-C++ only)} | |
6684 | Warn if the compiler does not elide the copy from a local variable to | |
6685 | the return value of a function in a context where it is allowed by | |
6686 | [class.copy.elision]. This elision is commonly known as the Named | |
6687 | Return Value Optimization. For instance, in the example below the | |
6688 | compiler cannot elide copies from both v1 and b2, so it elides neither. | |
6689 | ||
6690 | @smallexample | |
6691 | std::vector<int> f() | |
6692 | @{ | |
6693 | std::vector<int> v1, v2; | |
6694 | // ... | |
6695 | if (cond) return v1; | |
6696 | else return v2; // warning: not eliding copy | |
6697 | @} | |
6698 | @end smallexample | |
6699 | ||
d77de738 ML |
6700 | @opindex Winfinite-recursion |
6701 | @opindex Wno-infinite-recursion | |
ddf6fe37 | 6702 | @item -Winfinite-recursion |
d77de738 ML |
6703 | Warn about infinitely recursive calls. The warning is effective at all |
6704 | optimization levels but requires optimization in order to detect infinite | |
6705 | recursion in calls between two or more functions. | |
6706 | @option{-Winfinite-recursion} is included in @option{-Wall}. | |
6707 | ||
ce51e843 ML |
6708 | Compare with @option{-Wanalyzer-infinite-recursion} which provides a |
6709 | similar diagnostic, but is implemented in a different way (as part of | |
6710 | @option{-fanalyzer}). | |
6711 | ||
d77de738 ML |
6712 | @opindex Winit-self |
6713 | @opindex Wno-init-self | |
ddf6fe37 | 6714 | @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6715 | Warn about uninitialized variables that are initialized with themselves. |
6716 | Note this option can only be used with the @option{-Wuninitialized} option. | |
6717 | ||
6718 | For example, GCC warns about @code{i} being uninitialized in the | |
6719 | following snippet only when @option{-Winit-self} has been specified: | |
6720 | @smallexample | |
6721 | @group | |
6722 | int f() | |
6723 | @{ | |
6724 | int i = i; | |
6725 | return i; | |
6726 | @} | |
6727 | @end group | |
6728 | @end smallexample | |
6729 | ||
6730 | This warning is enabled by @option{-Wall} in C++. | |
6731 | ||
d77de738 ML |
6732 | @opindex Wimplicit-int |
6733 | @opindex Wno-implicit-int | |
ddf6fe37 | 6734 | @item -Wno-implicit-int @r{(C and Objective-C only)} |
d77de738 ML |
6735 | This option controls warnings when a declaration does not specify a type. |
6736 | This warning is enabled by default in C99 and later dialects of C, | |
6737 | and also by @option{-Wall}. | |
6738 | ||
5fccebdb JM |
6739 | This warning is upgraded to an error by @option{-pedantic-errors}. |
6740 | ||
d77de738 ML |
6741 | @opindex Wimplicit-function-declaration |
6742 | @opindex Wno-implicit-function-declaration | |
ddf6fe37 | 6743 | @item -Wno-implicit-function-declaration @r{(C and Objective-C only)} |
d77de738 ML |
6744 | This option controls warnings when a function is used before being declared. |
6745 | This warning is enabled by default in C99 and later dialects of C, | |
6746 | and also by @option{-Wall}. | |
5fccebdb JM |
6747 | |
6748 | This warning is upgraded to an error by @option{-pedantic-errors}. | |
d77de738 | 6749 | |
d77de738 ML |
6750 | @opindex Wimplicit |
6751 | @opindex Wno-implicit | |
ddf6fe37 | 6752 | @item -Wimplicit @r{(C and Objective-C only)} |
d77de738 ML |
6753 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
6754 | This warning is enabled by @option{-Wall}. | |
6755 | ||
d77de738 ML |
6756 | @opindex Wimplicit-fallthrough |
6757 | @opindex Wno-implicit-fallthrough | |
ddf6fe37 | 6758 | @item -Wimplicit-fallthrough |
d77de738 ML |
6759 | @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3} |
6760 | and @option{-Wno-implicit-fallthrough} is the same as | |
6761 | @option{-Wimplicit-fallthrough=0}. | |
6762 | ||
d77de738 | 6763 | @opindex Wimplicit-fallthrough= |
ddf6fe37 | 6764 | @item -Wimplicit-fallthrough=@var{n} |
d77de738 ML |
6765 | Warn when a switch case falls through. For example: |
6766 | ||
6767 | @smallexample | |
6768 | @group | |
6769 | switch (cond) | |
6770 | @{ | |
6771 | case 1: | |
6772 | a = 1; | |
6773 | break; | |
6774 | case 2: | |
6775 | a = 2; | |
6776 | case 3: | |
6777 | a = 3; | |
6778 | break; | |
6779 | @} | |
6780 | @end group | |
6781 | @end smallexample | |
6782 | ||
6783 | This warning does not warn when the last statement of a case cannot | |
6784 | fall through, e.g. when there is a return statement or a call to function | |
6785 | declared with the noreturn attribute. @option{-Wimplicit-fallthrough=} | |
6786 | also takes into account control flow statements, such as ifs, and only | |
6787 | warns when appropriate. E.g.@: | |
6788 | ||
6789 | @smallexample | |
6790 | @group | |
6791 | switch (cond) | |
6792 | @{ | |
6793 | case 1: | |
6794 | if (i > 3) @{ | |
6795 | bar (5); | |
6796 | break; | |
6797 | @} else if (i < 1) @{ | |
6798 | bar (0); | |
6799 | @} else | |
6800 | return; | |
6801 | default: | |
6802 | @dots{} | |
6803 | @} | |
6804 | @end group | |
6805 | @end smallexample | |
6806 | ||
6807 | Since there are occasions where a switch case fall through is desirable, | |
6808 | GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is | |
6809 | to be used along with a null statement to suppress this warning that | |
6810 | would normally occur: | |
6811 | ||
6812 | @smallexample | |
6813 | @group | |
6814 | switch (cond) | |
6815 | @{ | |
6816 | case 1: | |
6817 | bar (0); | |
6818 | __attribute__ ((fallthrough)); | |
6819 | default: | |
6820 | @dots{} | |
6821 | @} | |
6822 | @end group | |
6823 | @end smallexample | |
6824 | ||
6825 | C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough} | |
6826 | warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11 | |
6827 | or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension. | |
6828 | Instead of these attributes, it is also possible to add a fallthrough comment | |
6829 | to silence the warning. The whole body of the C or C++ style comment should | |
6830 | match the given regular expressions listed below. The option argument @var{n} | |
6831 | specifies what kind of comments are accepted: | |
6832 | ||
6833 | @itemize @bullet | |
6834 | ||
6835 | @item @option{-Wimplicit-fallthrough=0} disables the warning altogether. | |
6836 | ||
6837 | @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular | |
6838 | expression, any comment is used as fallthrough comment. | |
6839 | ||
6840 | @item @option{-Wimplicit-fallthrough=2} case insensitively matches | |
6841 | @code{.*falls?[ \t-]*thr(ough|u).*} regular expression. | |
6842 | ||
6843 | @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the | |
6844 | following regular expressions: | |
6845 | ||
6846 | @itemize @bullet | |
6847 | ||
6848 | @item @code{-fallthrough} | |
6849 | ||
6850 | @item @code{@@fallthrough@@} | |
6851 | ||
6852 | @item @code{lint -fallthrough[ \t]*} | |
6853 | ||
6854 | @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?} | |
6855 | ||
6856 | @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6857 | ||
6858 | @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6859 | ||
6860 | @end itemize | |
6861 | ||
6862 | @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the | |
6863 | following regular expressions: | |
6864 | ||
6865 | @itemize @bullet | |
6866 | ||
6867 | @item @code{-fallthrough} | |
6868 | ||
6869 | @item @code{@@fallthrough@@} | |
6870 | ||
6871 | @item @code{lint -fallthrough[ \t]*} | |
6872 | ||
6873 | @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*} | |
6874 | ||
6875 | @end itemize | |
6876 | ||
6877 | @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as | |
6878 | fallthrough comments, only attributes disable the warning. | |
6879 | ||
6880 | @end itemize | |
6881 | ||
6882 | The comment needs to be followed after optional whitespace and other comments | |
6883 | by @code{case} or @code{default} keywords or by a user label that precedes some | |
6884 | @code{case} or @code{default} label. | |
6885 | ||
6886 | @smallexample | |
6887 | @group | |
6888 | switch (cond) | |
6889 | @{ | |
6890 | case 1: | |
6891 | bar (0); | |
6892 | /* FALLTHRU */ | |
6893 | default: | |
6894 | @dots{} | |
6895 | @} | |
6896 | @end group | |
6897 | @end smallexample | |
6898 | ||
6899 | The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}. | |
6900 | ||
d77de738 ML |
6901 | @opindex Wif-not-aligned |
6902 | @opindex Wno-if-not-aligned | |
ddf6fe37 | 6903 | @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6904 | Control if warnings triggered by the @code{warn_if_not_aligned} attribute |
6905 | should be issued. These warnings are enabled by default. | |
6906 | ||
d77de738 ML |
6907 | @opindex Wignored-qualifiers |
6908 | @opindex Wno-ignored-qualifiers | |
ddf6fe37 | 6909 | @item -Wignored-qualifiers @r{(C and C++ only)} |
d77de738 ML |
6910 | Warn if the return type of a function has a type qualifier |
6911 | such as @code{const}. For ISO C such a type qualifier has no effect, | |
6912 | since the value returned by a function is not an lvalue. | |
6913 | For C++, the warning is only emitted for scalar types or @code{void}. | |
6914 | ISO C prohibits qualified @code{void} return types on function | |
6915 | definitions, so such return types always receive a warning | |
6916 | even without this option. | |
6917 | ||
6918 | This warning is also enabled by @option{-Wextra}. | |
6919 | ||
d77de738 ML |
6920 | @opindex Wignored-attributes |
6921 | @opindex Wno-ignored-attributes | |
ddf6fe37 | 6922 | @item -Wno-ignored-attributes @r{(C and C++ only)} |
d77de738 ML |
6923 | This option controls warnings when an attribute is ignored. |
6924 | This is different from the | |
6925 | @option{-Wattributes} option in that it warns whenever the compiler decides | |
6926 | to drop an attribute, not that the attribute is either unknown, used in a | |
6927 | wrong place, etc. This warning is enabled by default. | |
6928 | ||
d77de738 ML |
6929 | @opindex Wmain |
6930 | @opindex Wno-main | |
ddf6fe37 | 6931 | @item -Wmain |
d77de738 ML |
6932 | Warn if the type of @code{main} is suspicious. @code{main} should be |
6933 | a function with external linkage, returning int, taking either zero | |
6934 | arguments, two, or three arguments of appropriate types. This warning | |
6935 | is enabled by default in C++ and is enabled by either @option{-Wall} | |
6936 | or @option{-Wpedantic}. | |
6937 | ||
5fccebdb JM |
6938 | This warning is upgraded to an error by @option{-pedantic-errors}. |
6939 | ||
d77de738 ML |
6940 | @opindex Wmisleading-indentation |
6941 | @opindex Wno-misleading-indentation | |
ddf6fe37 | 6942 | @item -Wmisleading-indentation @r{(C and C++ only)} |
d77de738 ML |
6943 | Warn when the indentation of the code does not reflect the block structure. |
6944 | Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and | |
6945 | @code{for} clauses with a guarded statement that does not use braces, | |
6946 | followed by an unguarded statement with the same indentation. | |
6947 | ||
6948 | In the following example, the call to ``bar'' is misleadingly indented as | |
6949 | if it were guarded by the ``if'' conditional. | |
6950 | ||
6951 | @smallexample | |
6952 | if (some_condition ()) | |
6953 | foo (); | |
6954 | bar (); /* Gotcha: this is not guarded by the "if". */ | |
6955 | @end smallexample | |
6956 | ||
6957 | In the case of mixed tabs and spaces, the warning uses the | |
6958 | @option{-ftabstop=} option to determine if the statements line up | |
6959 | (defaulting to 8). | |
6960 | ||
6961 | The warning is not issued for code involving multiline preprocessor logic | |
6962 | such as the following example. | |
6963 | ||
6964 | @smallexample | |
6965 | if (flagA) | |
6966 | foo (0); | |
6967 | #if SOME_CONDITION_THAT_DOES_NOT_HOLD | |
6968 | if (flagB) | |
6969 | #endif | |
6970 | foo (1); | |
6971 | @end smallexample | |
6972 | ||
6973 | The warning is not issued after a @code{#line} directive, since this | |
6974 | typically indicates autogenerated code, and no assumptions can be made | |
6975 | about the layout of the file that the directive references. | |
6976 | ||
6977 | This warning is enabled by @option{-Wall} in C and C++. | |
6978 | ||
d77de738 ML |
6979 | @opindex Wmissing-attributes |
6980 | @opindex Wno-missing-attributes | |
ddf6fe37 | 6981 | @item -Wmissing-attributes |
d77de738 ML |
6982 | Warn when a declaration of a function is missing one or more attributes |
6983 | that a related function is declared with and whose absence may adversely | |
6984 | affect the correctness or efficiency of generated code. For example, | |
6985 | the warning is issued for declarations of aliases that use attributes | |
6986 | to specify less restrictive requirements than those of their targets. | |
6987 | This typically represents a potential optimization opportunity. | |
6988 | By contrast, the @option{-Wattribute-alias=2} option controls warnings | |
6989 | issued when the alias is more restrictive than the target, which could | |
6990 | lead to incorrect code generation. | |
6991 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
6992 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
6993 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
6994 | @code{returns_nonnull}, and @code{returns_twice}. | |
6995 | ||
6996 | In C++, the warning is issued when an explicit specialization of a primary | |
6997 | template declared with attribute @code{alloc_align}, @code{alloc_size}, | |
6998 | @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc}, | |
6999 | or @code{nonnull} is declared without it. Attributes @code{deprecated}, | |
7000 | @code{error}, and @code{warning} suppress the warning. | |
7001 | (@pxref{Function Attributes}). | |
7002 | ||
7003 | You can use the @code{copy} attribute to apply the same | |
7004 | set of attributes to a declaration as that on another declaration without | |
7005 | explicitly enumerating the attributes. This attribute can be applied | |
7006 | to declarations of functions (@pxref{Common Function Attributes}), | |
7007 | variables (@pxref{Common Variable Attributes}), or types | |
7008 | (@pxref{Common Type Attributes}). | |
7009 | ||
7010 | @option{-Wmissing-attributes} is enabled by @option{-Wall}. | |
7011 | ||
7012 | For example, since the declaration of the primary function template | |
7013 | below makes use of both attribute @code{malloc} and @code{alloc_size} | |
7014 | the declaration of the explicit specialization of the template is | |
7015 | diagnosed because it is missing one of the attributes. | |
7016 | ||
7017 | @smallexample | |
7018 | template <class T> | |
7019 | T* __attribute__ ((malloc, alloc_size (1))) | |
7020 | allocate (size_t); | |
7021 | ||
7022 | template <> | |
7023 | void* __attribute__ ((malloc)) // missing alloc_size | |
7024 | allocate<void> (size_t); | |
7025 | @end smallexample | |
7026 | ||
d77de738 ML |
7027 | @opindex Wmissing-braces |
7028 | @opindex Wno-missing-braces | |
ddf6fe37 | 7029 | @item -Wmissing-braces |
d77de738 ML |
7030 | Warn if an aggregate or union initializer is not fully bracketed. In |
7031 | the following example, the initializer for @code{a} is not fully | |
7032 | bracketed, but that for @code{b} is fully bracketed. | |
7033 | ||
7034 | @smallexample | |
7035 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
7036 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
7037 | @end smallexample | |
7038 | ||
7039 | This warning is enabled by @option{-Wall}. | |
7040 | ||
d77de738 ML |
7041 | @opindex Wmissing-include-dirs |
7042 | @opindex Wno-missing-include-dirs | |
ddf6fe37 | 7043 | @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)} |
d77de738 ML |
7044 | Warn if a user-supplied include directory does not exist. This opions is disabled |
7045 | by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially | |
7046 | enabled by default by warning for -I and -J, only. | |
7047 | ||
d77de738 ML |
7048 | @opindex Wmissing-profile |
7049 | @opindex Wno-missing-profile | |
ddf6fe37 | 7050 | @item -Wno-missing-profile |
d77de738 ML |
7051 | This option controls warnings if feedback profiles are missing when using the |
7052 | @option{-fprofile-use} option. | |
7053 | This option diagnoses those cases where a new function or a new file is added | |
7054 | between compiling with @option{-fprofile-generate} and with | |
7055 | @option{-fprofile-use}, without regenerating the profiles. | |
7056 | In these cases, the profile feedback data files do not contain any | |
7057 | profile feedback information for | |
7058 | the newly added function or file respectively. Also, in the case when profile | |
7059 | count data (.gcda) files are removed, GCC cannot use any profile feedback | |
7060 | information. In all these cases, warnings are issued to inform you that a | |
7061 | profile generation step is due. | |
7062 | Ignoring the warning can result in poorly optimized code. | |
7063 | @option{-Wno-missing-profile} can be used to | |
7064 | disable the warning, but this is not recommended and should be done only | |
7065 | when non-existent profile data is justified. | |
7066 | ||
d77de738 ML |
7067 | @opindex Wmismatched-dealloc |
7068 | @opindex Wno-mismatched-dealloc | |
ddf6fe37 | 7069 | @item -Wmismatched-dealloc |
d77de738 ML |
7070 | |
7071 | Warn for calls to deallocation functions with pointer arguments returned | |
7072 | from from allocations functions for which the former isn't a suitable | |
7073 | deallocator. A pair of functions can be associated as matching allocators | |
7074 | and deallocators by use of attribute @code{malloc}. Unless disabled by | |
7075 | the @option{-fno-builtin} option the standard functions @code{calloc}, | |
7076 | @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding | |
7077 | forms of C++ @code{operator new} and @code{operator delete} are implicitly | |
7078 | associated as matching allocators and deallocators. In the following | |
7079 | example @code{mydealloc} is the deallocator for pointers returned from | |
7080 | @code{myalloc}. | |
7081 | ||
7082 | @smallexample | |
7083 | void mydealloc (void*); | |
7084 | ||
7085 | __attribute__ ((malloc (mydealloc, 1))) void* | |
7086 | myalloc (size_t); | |
7087 | ||
7088 | void f (void) | |
7089 | @{ | |
7090 | void *p = myalloc (32); | |
7091 | // @dots{}use p@dots{} | |
7092 | free (p); // warning: not a matching deallocator for myalloc | |
7093 | mydealloc (p); // ok | |
7094 | @} | |
7095 | @end smallexample | |
7096 | ||
7097 | In C++, the related option @option{-Wmismatched-new-delete} diagnoses | |
7098 | mismatches involving either @code{operator new} or @code{operator delete}. | |
7099 | ||
7100 | Option @option{-Wmismatched-dealloc} is included in @option{-Wall}. | |
7101 | ||
d77de738 ML |
7102 | @opindex Wmultistatement-macros |
7103 | @opindex Wno-multistatement-macros | |
ddf6fe37 | 7104 | @item -Wmultistatement-macros |
d77de738 ML |
7105 | Warn about unsafe multiple statement macros that appear to be guarded |
7106 | by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or | |
7107 | @code{while}, in which only the first statement is actually guarded after | |
7108 | the macro is expanded. | |
7109 | ||
7110 | For example: | |
7111 | ||
7112 | @smallexample | |
7113 | #define DOIT x++; y++ | |
7114 | if (c) | |
7115 | DOIT; | |
7116 | @end smallexample | |
7117 | ||
7118 | will increment @code{y} unconditionally, not just when @code{c} holds. | |
7119 | The can usually be fixed by wrapping the macro in a do-while loop: | |
7120 | @smallexample | |
7121 | #define DOIT do @{ x++; y++; @} while (0) | |
7122 | if (c) | |
7123 | DOIT; | |
7124 | @end smallexample | |
7125 | ||
7126 | This warning is enabled by @option{-Wall} in C and C++. | |
7127 | ||
d77de738 ML |
7128 | @opindex Wparentheses |
7129 | @opindex Wno-parentheses | |
ddf6fe37 | 7130 | @item -Wparentheses |
d77de738 ML |
7131 | Warn if parentheses are omitted in certain contexts, such |
7132 | as when there is an assignment in a context where a truth value | |
7133 | is expected, or when operators are nested whose precedence people | |
7134 | often get confused about. | |
7135 | ||
7136 | Also warn if a comparison like @code{x<=y<=z} appears; this is | |
7137 | equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different | |
7138 | interpretation from that of ordinary mathematical notation. | |
7139 | ||
7140 | Also warn for dangerous uses of the GNU extension to | |
7141 | @code{?:} with omitted middle operand. When the condition | |
7142 | in the @code{?}: operator is a boolean expression, the omitted value is | |
7143 | always 1. Often programmers expect it to be a value computed | |
7144 | inside the conditional expression instead. | |
7145 | ||
7146 | For C++ this also warns for some cases of unnecessary parentheses in | |
7147 | declarations, which can indicate an attempt at a function call instead | |
7148 | of a declaration: | |
7149 | @smallexample | |
7150 | @{ | |
7151 | // Declares a local variable called mymutex. | |
7152 | std::unique_lock<std::mutex> (mymutex); | |
7153 | // User meant std::unique_lock<std::mutex> lock (mymutex); | |
7154 | @} | |
7155 | @end smallexample | |
7156 | ||
7157 | This warning is enabled by @option{-Wall}. | |
7158 | ||
d77de738 ML |
7159 | @opindex Wself-move |
7160 | @opindex Wno-self-move | |
ddf6fe37 | 7161 | @item -Wno-self-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
7162 | This warning warns when a value is moved to itself with @code{std::move}. |
7163 | Such a @code{std::move} typically has no effect. | |
7164 | ||
7165 | @smallexample | |
7166 | struct T @{ | |
7167 | @dots{} | |
7168 | @}; | |
7169 | void fn() | |
7170 | @{ | |
7171 | T t; | |
7172 | @dots{} | |
7173 | t = std::move (t); | |
7174 | @} | |
7175 | @end smallexample | |
7176 | ||
7177 | This warning is enabled by @option{-Wall}. | |
7178 | ||
d77de738 ML |
7179 | @opindex Wsequence-point |
7180 | @opindex Wno-sequence-point | |
ddf6fe37 | 7181 | @item -Wsequence-point |
d77de738 ML |
7182 | Warn about code that may have undefined semantics because of violations |
7183 | of sequence point rules in the C and C++ standards. | |
7184 | ||
7185 | The C and C++ standards define the order in which expressions in a C/C++ | |
7186 | program are evaluated in terms of @dfn{sequence points}, which represent | |
7187 | a partial ordering between the execution of parts of the program: those | |
7188 | executed before the sequence point, and those executed after it. These | |
7189 | occur after the evaluation of a full expression (one which is not part | |
7190 | of a larger expression), after the evaluation of the first operand of a | |
7191 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
7192 | function is called (but after the evaluation of its arguments and the | |
7193 | expression denoting the called function), and in certain other places. | |
7194 | Other than as expressed by the sequence point rules, the order of | |
7195 | evaluation of subexpressions of an expression is not specified. All | |
7196 | these rules describe only a partial order rather than a total order, | |
7197 | since, for example, if two functions are called within one expression | |
7198 | with no sequence point between them, the order in which the functions | |
7199 | are called is not specified. However, the standards committee have | |
7200 | ruled that function calls do not overlap. | |
7201 | ||
7202 | It is not specified when between sequence points modifications to the | |
7203 | values of objects take effect. Programs whose behavior depends on this | |
7204 | have undefined behavior; the C and C++ standards specify that ``Between | |
7205 | the previous and next sequence point an object shall have its stored | |
7206 | value modified at most once by the evaluation of an expression. | |
7207 | Furthermore, the prior value shall be read only to determine the value | |
7208 | to be stored.''. If a program breaks these rules, the results on any | |
7209 | particular implementation are entirely unpredictable. | |
7210 | ||
7211 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
7212 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
7213 | diagnosed by this option, and it may give an occasional false positive | |
7214 | result, but in general it has been found fairly effective at detecting | |
7215 | this sort of problem in programs. | |
7216 | ||
7217 | The C++17 standard will define the order of evaluation of operands in | |
7218 | more cases: in particular it requires that the right-hand side of an | |
7219 | assignment be evaluated before the left-hand side, so the above | |
7220 | examples are no longer undefined. But this option will still warn | |
7221 | about them, to help people avoid writing code that is undefined in C | |
7222 | and earlier revisions of C++. | |
7223 | ||
7224 | The standard is worded confusingly, therefore there is some debate | |
7225 | over the precise meaning of the sequence point rules in subtle cases. | |
7226 | Links to discussions of the problem, including proposed formal | |
7227 | definitions, may be found on the GCC readings page, at | |
7228 | @uref{https://gcc.gnu.org/@/readings.html}. | |
7229 | ||
7230 | This warning is enabled by @option{-Wall} for C and C++. | |
7231 | ||
d77de738 ML |
7232 | @opindex Wno-return-local-addr |
7233 | @opindex Wreturn-local-addr | |
ddf6fe37 | 7234 | @item -Wno-return-local-addr |
d77de738 ML |
7235 | Do not warn about returning a pointer (or in C++, a reference) to a |
7236 | variable that goes out of scope after the function returns. | |
7237 | ||
d77de738 ML |
7238 | @opindex Wreturn-type |
7239 | @opindex Wno-return-type | |
ddf6fe37 | 7240 | @item -Wreturn-type |
d77de738 ML |
7241 | Warn whenever a function is defined with a return type that defaults |
7242 | to @code{int}. Also warn about any @code{return} statement with no | |
7243 | return value in a function whose return type is not @code{void} | |
7244 | (falling off the end of the function body is considered returning | |
7245 | without a value). | |
7246 | ||
7247 | For C only, warn about a @code{return} statement with an expression in a | |
7248 | function whose return type is @code{void}, unless the expression type is | |
7249 | also @code{void}. As a GNU extension, the latter case is accepted | |
7250 | without a warning unless @option{-Wpedantic} is used. Attempting | |
7251 | to use the return value of a non-@code{void} function other than @code{main} | |
7252 | that flows off the end by reaching the closing curly brace that terminates | |
7253 | the function is undefined. | |
7254 | ||
7255 | Unlike in C, in C++, flowing off the end of a non-@code{void} function other | |
7256 | than @code{main} results in undefined behavior even when the value of | |
7257 | the function is not used. | |
7258 | ||
7259 | This warning is enabled by default in C++ and by @option{-Wall} otherwise. | |
7260 | ||
d77de738 ML |
7261 | @opindex Wshift-count-negative |
7262 | @opindex Wno-shift-count-negative | |
ddf6fe37 | 7263 | @item -Wno-shift-count-negative |
d77de738 ML |
7264 | Controls warnings if a shift count is negative. |
7265 | This warning is enabled by default. | |
7266 | ||
d77de738 ML |
7267 | @opindex Wshift-count-overflow |
7268 | @opindex Wno-shift-count-overflow | |
ddf6fe37 | 7269 | @item -Wno-shift-count-overflow |
d77de738 ML |
7270 | Controls warnings if a shift count is greater than or equal to the bit width |
7271 | of the type. This warning is enabled by default. | |
7272 | ||
d77de738 ML |
7273 | @opindex Wshift-negative-value |
7274 | @opindex Wno-shift-negative-value | |
ddf6fe37 | 7275 | @item -Wshift-negative-value |
d77de738 ML |
7276 | Warn if left shifting a negative value. This warning is enabled by |
7277 | @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes. | |
7278 | ||
d77de738 ML |
7279 | @opindex Wshift-overflow |
7280 | @opindex Wno-shift-overflow | |
ddf6fe37 AA |
7281 | @item -Wno-shift-overflow |
7282 | @itemx -Wshift-overflow=@var{n} | |
d77de738 ML |
7283 | These options control warnings about left shift overflows. |
7284 | ||
7285 | @table @gcctabopt | |
7286 | @item -Wshift-overflow=1 | |
7287 | This is the warning level of @option{-Wshift-overflow} and is enabled | |
7288 | by default in C99 and C++11 modes (and newer). This warning level does | |
7289 | not warn about left-shifting 1 into the sign bit. (However, in C, such | |
7290 | an overflow is still rejected in contexts where an integer constant expression | |
7291 | is required.) No warning is emitted in C++20 mode (and newer), as signed left | |
7292 | shifts always wrap. | |
7293 | ||
7294 | @item -Wshift-overflow=2 | |
7295 | This warning level also warns about left-shifting 1 into the sign bit, | |
7296 | unless C++14 mode (or newer) is active. | |
7297 | @end table | |
7298 | ||
d77de738 ML |
7299 | @opindex Wswitch |
7300 | @opindex Wno-switch | |
ddf6fe37 | 7301 | @item -Wswitch |
d77de738 ML |
7302 | Warn whenever a @code{switch} statement has an index of enumerated type |
7303 | and lacks a @code{case} for one or more of the named codes of that | |
7304 | enumeration. (The presence of a @code{default} label prevents this | |
7305 | warning.) @code{case} labels outside the enumeration range also | |
7306 | provoke warnings when this option is used (even if there is a | |
7307 | @code{default} label). | |
7308 | This warning is enabled by @option{-Wall}. | |
7309 | ||
d77de738 ML |
7310 | @opindex Wswitch-default |
7311 | @opindex Wno-switch-default | |
ddf6fe37 | 7312 | @item -Wswitch-default |
d77de738 ML |
7313 | Warn whenever a @code{switch} statement does not have a @code{default} |
7314 | case. | |
7315 | ||
d77de738 ML |
7316 | @opindex Wswitch-enum |
7317 | @opindex Wno-switch-enum | |
ddf6fe37 | 7318 | @item -Wswitch-enum |
d77de738 ML |
7319 | Warn whenever a @code{switch} statement has an index of enumerated type |
7320 | and lacks a @code{case} for one or more of the named codes of that | |
7321 | enumeration. @code{case} labels outside the enumeration range also | |
7322 | provoke warnings when this option is used. The only difference | |
7323 | between @option{-Wswitch} and this option is that this option gives a | |
7324 | warning about an omitted enumeration code even if there is a | |
7325 | @code{default} label. | |
7326 | ||
d77de738 ML |
7327 | @opindex Wswitch-bool |
7328 | @opindex Wno-switch-bool | |
ddf6fe37 | 7329 | @item -Wno-switch-bool |
d77de738 ML |
7330 | Do not warn when a @code{switch} statement has an index of boolean type |
7331 | and the case values are outside the range of a boolean type. | |
7332 | It is possible to suppress this warning by casting the controlling | |
7333 | expression to a type other than @code{bool}. For example: | |
7334 | @smallexample | |
7335 | @group | |
7336 | switch ((int) (a == 4)) | |
7337 | @{ | |
7338 | @dots{} | |
7339 | @} | |
7340 | @end group | |
7341 | @end smallexample | |
7342 | This warning is enabled by default for C and C++ programs. | |
7343 | ||
d77de738 ML |
7344 | @opindex Wswitch-outside-range |
7345 | @opindex Wno-switch-outside-range | |
ddf6fe37 | 7346 | @item -Wno-switch-outside-range |
d77de738 ML |
7347 | This option controls warnings when a @code{switch} case has a value |
7348 | that is outside of its | |
7349 | respective type range. This warning is enabled by default for | |
7350 | C and C++ programs. | |
7351 | ||
d77de738 ML |
7352 | @opindex Wswitch-unreachable |
7353 | @opindex Wno-switch-unreachable | |
ddf6fe37 | 7354 | @item -Wno-switch-unreachable |
d77de738 ML |
7355 | Do not warn when a @code{switch} statement contains statements between the |
7356 | controlling expression and the first case label, which will never be | |
7357 | executed. For example: | |
7358 | @smallexample | |
7359 | @group | |
7360 | switch (cond) | |
7361 | @{ | |
7362 | i = 15; | |
7363 | @dots{} | |
7364 | case 5: | |
7365 | @dots{} | |
7366 | @} | |
7367 | @end group | |
7368 | @end smallexample | |
7369 | @option{-Wswitch-unreachable} does not warn if the statement between the | |
7370 | controlling expression and the first case label is just a declaration: | |
7371 | @smallexample | |
7372 | @group | |
7373 | switch (cond) | |
7374 | @{ | |
7375 | int i; | |
7376 | @dots{} | |
7377 | case 5: | |
7378 | i = 5; | |
7379 | @dots{} | |
7380 | @} | |
7381 | @end group | |
7382 | @end smallexample | |
7383 | This warning is enabled by default for C and C++ programs. | |
7384 | ||
d77de738 ML |
7385 | @opindex Wsync-nand |
7386 | @opindex Wno-sync-nand | |
ddf6fe37 | 7387 | @item -Wsync-nand @r{(C and C++ only)} |
d77de738 ML |
7388 | Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch} |
7389 | built-in functions are used. These functions changed semantics in GCC 4.4. | |
7390 | ||
d77de738 ML |
7391 | @opindex Wtrivial-auto-var-init |
7392 | @opindex Wno-trivial-auto-var-init | |
ddf6fe37 | 7393 | @item -Wtrivial-auto-var-init |
d77de738 ML |
7394 | Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic |
7395 | variable. A common situation is an automatic variable that is declared | |
7396 | between the controlling expression and the first case label of a @code{switch} | |
7397 | statement. | |
7398 | ||
d77de738 ML |
7399 | @opindex Wunused-but-set-parameter |
7400 | @opindex Wno-unused-but-set-parameter | |
ddf6fe37 | 7401 | @item -Wunused-but-set-parameter |
d77de738 ML |
7402 | Warn whenever a function parameter is assigned to, but otherwise unused |
7403 | (aside from its declaration). | |
7404 | ||
7405 | To suppress this warning use the @code{unused} attribute | |
7406 | (@pxref{Variable Attributes}). | |
7407 | ||
7408 | This warning is also enabled by @option{-Wunused} together with | |
7409 | @option{-Wextra}. | |
7410 | ||
d77de738 ML |
7411 | @opindex Wunused-but-set-variable |
7412 | @opindex Wno-unused-but-set-variable | |
ddf6fe37 | 7413 | @item -Wunused-but-set-variable |
d77de738 ML |
7414 | Warn whenever a local variable is assigned to, but otherwise unused |
7415 | (aside from its declaration). | |
7416 | This warning is enabled by @option{-Wall}. | |
7417 | ||
7418 | To suppress this warning use the @code{unused} attribute | |
7419 | (@pxref{Variable Attributes}). | |
7420 | ||
7421 | This warning is also enabled by @option{-Wunused}, which is enabled | |
7422 | by @option{-Wall}. | |
7423 | ||
d77de738 ML |
7424 | @opindex Wunused-function |
7425 | @opindex Wno-unused-function | |
ddf6fe37 | 7426 | @item -Wunused-function |
d77de738 ML |
7427 | Warn whenever a static function is declared but not defined or a |
7428 | non-inline static function is unused. | |
7429 | This warning is enabled by @option{-Wall}. | |
7430 | ||
d77de738 ML |
7431 | @opindex Wunused-label |
7432 | @opindex Wno-unused-label | |
ddf6fe37 | 7433 | @item -Wunused-label |
d77de738 ML |
7434 | Warn whenever a label is declared but not used. |
7435 | This warning is enabled by @option{-Wall}. | |
7436 | ||
7437 | To suppress this warning use the @code{unused} attribute | |
7438 | (@pxref{Variable Attributes}). | |
7439 | ||
d77de738 ML |
7440 | @opindex Wunused-local-typedefs |
7441 | @opindex Wno-unused-local-typedefs | |
ddf6fe37 | 7442 | @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
7443 | Warn when a typedef locally defined in a function is not used. |
7444 | This warning is enabled by @option{-Wall}. | |
7445 | ||
d77de738 ML |
7446 | @opindex Wunused-parameter |
7447 | @opindex Wno-unused-parameter | |
ddf6fe37 | 7448 | @item -Wunused-parameter |
d77de738 ML |
7449 | Warn whenever a function parameter is unused aside from its declaration. |
7450 | ||
7451 | To suppress this warning use the @code{unused} attribute | |
7452 | (@pxref{Variable Attributes}). | |
7453 | ||
d77de738 ML |
7454 | @opindex Wunused-result |
7455 | @opindex Wno-unused-result | |
ddf6fe37 | 7456 | @item -Wno-unused-result |
d77de738 ML |
7457 | Do not warn if a caller of a function marked with attribute |
7458 | @code{warn_unused_result} (@pxref{Function Attributes}) does not use | |
7459 | its return value. The default is @option{-Wunused-result}. | |
7460 | ||
d77de738 ML |
7461 | @opindex Wunused-variable |
7462 | @opindex Wno-unused-variable | |
ddf6fe37 | 7463 | @item -Wunused-variable |
d77de738 ML |
7464 | Warn whenever a local or static variable is unused aside from its |
7465 | declaration. This option implies @option{-Wunused-const-variable=1} for C, | |
7466 | but not for C++. This warning is enabled by @option{-Wall}. | |
7467 | ||
7468 | To suppress this warning use the @code{unused} attribute | |
7469 | (@pxref{Variable Attributes}). | |
7470 | ||
d77de738 ML |
7471 | @opindex Wunused-const-variable |
7472 | @opindex Wno-unused-const-variable | |
ddf6fe37 AA |
7473 | @item -Wunused-const-variable |
7474 | @itemx -Wunused-const-variable=@var{n} | |
d77de738 ML |
7475 | Warn whenever a constant static variable is unused aside from its declaration. |
7476 | @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable} | |
7477 | for C, but not for C++. In C this declares variable storage, but in C++ this | |
7478 | is not an error since const variables take the place of @code{#define}s. | |
7479 | ||
7480 | To suppress this warning use the @code{unused} attribute | |
7481 | (@pxref{Variable Attributes}). | |
7482 | ||
7483 | @table @gcctabopt | |
7484 | @item -Wunused-const-variable=1 | |
7485 | This is the warning level that is enabled by @option{-Wunused-variable} for | |
7486 | C. It warns only about unused static const variables defined in the main | |
7487 | compilation unit, but not about static const variables declared in any | |
7488 | header included. | |
7489 | ||
7490 | @item -Wunused-const-variable=2 | |
7491 | This warning level also warns for unused constant static variables in | |
7492 | headers (excluding system headers). This is the warning level of | |
7493 | @option{-Wunused-const-variable} and must be explicitly requested since | |
7494 | in C++ this isn't an error and in C it might be harder to clean up all | |
7495 | headers included. | |
7496 | @end table | |
7497 | ||
d77de738 ML |
7498 | @opindex Wunused-value |
7499 | @opindex Wno-unused-value | |
ddf6fe37 | 7500 | @item -Wunused-value |
d77de738 ML |
7501 | Warn whenever a statement computes a result that is explicitly not |
7502 | used. To suppress this warning cast the unused expression to | |
7503 | @code{void}. This includes an expression-statement or the left-hand | |
7504 | side of a comma expression that contains no side effects. For example, | |
7505 | an expression such as @code{x[i,j]} causes a warning, while | |
7506 | @code{x[(void)i,j]} does not. | |
7507 | ||
7508 | This warning is enabled by @option{-Wall}. | |
7509 | ||
d77de738 ML |
7510 | @opindex Wunused |
7511 | @opindex Wno-unused | |
ddf6fe37 | 7512 | @item -Wunused |
d77de738 ML |
7513 | All the above @option{-Wunused} options combined. |
7514 | ||
7515 | In order to get a warning about an unused function parameter, you must | |
7516 | either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies | |
7517 | @option{-Wunused}), or separately specify @option{-Wunused-parameter}. | |
7518 | ||
d77de738 ML |
7519 | @opindex Wuninitialized |
7520 | @opindex Wno-uninitialized | |
ddf6fe37 | 7521 | @item -Wuninitialized |
d77de738 ML |
7522 | Warn if an object with automatic or allocated storage duration is used |
7523 | without having been initialized. In C++, also warn if a non-static | |
7524 | reference or non-static @code{const} member appears in a class without | |
7525 | constructors. | |
7526 | ||
7527 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7528 | object to a @code{const}-qualified argument of a built-in function known to | |
7529 | read the object is also diagnosed by this warning. | |
7530 | (@option{-Wmaybe-uninitialized} is issued for ordinary functions.) | |
7531 | ||
7532 | If you want to warn about code that uses the uninitialized value of the | |
7533 | variable in its own initializer, use the @option{-Winit-self} option. | |
7534 | ||
7535 | These warnings occur for individual uninitialized elements of | |
7536 | structure, union or array variables as well as for variables that are | |
7537 | uninitialized as a whole. They do not occur for variables or elements | |
7538 | declared @code{volatile}. Because these warnings depend on | |
7539 | optimization, the exact variables or elements for which there are | |
7540 | warnings depend on the precise optimization options and version of GCC | |
7541 | used. | |
7542 | ||
7543 | Note that there may be no warning about a variable that is used only | |
7544 | to compute a value that itself is never used, because such | |
7545 | computations may be deleted by data flow analysis before the warnings | |
7546 | are printed. | |
7547 | ||
7548 | In C++, this warning also warns about using uninitialized objects in | |
7549 | member-initializer-lists. For example, GCC warns about @code{b} being | |
7550 | uninitialized in the following snippet: | |
7551 | ||
7552 | @smallexample | |
7553 | struct A @{ | |
7554 | int a; | |
7555 | int b; | |
7556 | A() : a(b) @{ @} | |
7557 | @}; | |
7558 | @end smallexample | |
7559 | ||
d77de738 ML |
7560 | @opindex Winvalid-memory-model |
7561 | @opindex Wno-invalid-memory-model | |
ddf6fe37 | 7562 | @item -Wno-invalid-memory-model |
d77de738 ML |
7563 | This option controls warnings |
7564 | for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins}, | |
7565 | and the C11 atomic generic functions with a memory consistency argument | |
7566 | that is either invalid for the operation or outside the range of values | |
7567 | of the @code{memory_order} enumeration. For example, since the | |
7568 | @code{__atomic_store} and @code{__atomic_store_n} built-ins are only | |
7569 | defined for the relaxed, release, and sequentially consistent memory | |
7570 | orders the following code is diagnosed: | |
7571 | ||
7572 | @smallexample | |
7573 | void store (int *i) | |
7574 | @{ | |
7575 | __atomic_store_n (i, 0, memory_order_consume); | |
7576 | @} | |
7577 | @end smallexample | |
7578 | ||
7579 | @option{-Winvalid-memory-model} is enabled by default. | |
7580 | ||
d77de738 ML |
7581 | @opindex Wmaybe-uninitialized |
7582 | @opindex Wno-maybe-uninitialized | |
ddf6fe37 | 7583 | @item -Wmaybe-uninitialized |
d77de738 ML |
7584 | For an object with automatic or allocated storage duration, if there exists |
7585 | a path from the function entry to a use of the object that is initialized, | |
7586 | but there exist some other paths for which the object is not initialized, | |
7587 | the compiler emits a warning if it cannot prove the uninitialized paths | |
7588 | are not executed at run time. | |
7589 | ||
7590 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7591 | object to a @code{const}-qualified function argument is also diagnosed by | |
7592 | this warning. (@option{-Wuninitialized} is issued for built-in functions | |
7593 | known to read the object.) Annotating the function with attribute | |
7594 | @code{access (none)} indicates that the argument isn't used to access | |
7595 | the object and avoids the warning (@pxref{Common Function Attributes}). | |
7596 | ||
7597 | These warnings are only possible in optimizing compilation, because otherwise | |
7598 | GCC does not keep track of the state of variables. | |
7599 | ||
7600 | These warnings are made optional because GCC may not be able to determine when | |
7601 | the code is correct in spite of appearing to have an error. Here is one | |
7602 | example of how this can happen: | |
7603 | ||
7604 | @smallexample | |
7605 | @group | |
7606 | @{ | |
7607 | int x; | |
7608 | switch (y) | |
7609 | @{ | |
7610 | case 1: x = 1; | |
7611 | break; | |
7612 | case 2: x = 4; | |
7613 | break; | |
7614 | case 3: x = 5; | |
7615 | @} | |
7616 | foo (x); | |
7617 | @} | |
7618 | @end group | |
7619 | @end smallexample | |
7620 | ||
7621 | @noindent | |
7622 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
7623 | always initialized, but GCC doesn't know this. To suppress the | |
7624 | warning, you need to provide a default case with assert(0) or | |
7625 | similar code. | |
7626 | ||
7627 | @cindex @code{longjmp} warnings | |
7628 | This option also warns when a non-volatile automatic variable might be | |
7629 | changed by a call to @code{longjmp}. | |
7630 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
7631 | where @code{longjmp} will be called; in fact, a signal handler could | |
7632 | call it at any point in the code. As a result, you may get a warning | |
7633 | even when there is in fact no problem because @code{longjmp} cannot | |
7634 | in fact be called at the place that would cause a problem. | |
7635 | ||
7636 | Some spurious warnings can be avoided if you declare all the functions | |
7637 | you use that never return as @code{noreturn}. @xref{Function | |
7638 | Attributes}. | |
7639 | ||
7640 | This warning is enabled by @option{-Wall} or @option{-Wextra}. | |
7641 | ||
d77de738 ML |
7642 | @opindex Wunknown-pragmas |
7643 | @opindex Wno-unknown-pragmas | |
7644 | @cindex warning for unknown pragmas | |
7645 | @cindex unknown pragmas, warning | |
7646 | @cindex pragmas, warning of unknown | |
f33d7a88 | 7647 | @item -Wunknown-pragmas |
d77de738 ML |
7648 | Warn when a @code{#pragma} directive is encountered that is not understood by |
7649 | GCC@. If this command-line option is used, warnings are even issued | |
7650 | for unknown pragmas in system header files. This is not the case if | |
7651 | the warnings are only enabled by the @option{-Wall} command-line option. | |
7652 | ||
d77de738 ML |
7653 | @opindex Wno-pragmas |
7654 | @opindex Wpragmas | |
ddf6fe37 | 7655 | @item -Wno-pragmas |
d77de738 ML |
7656 | Do not warn about misuses of pragmas, such as incorrect parameters, |
7657 | invalid syntax, or conflicts between pragmas. See also | |
7658 | @option{-Wunknown-pragmas}. | |
7659 | ||
d77de738 ML |
7660 | @opindex Wno-prio-ctor-dtor |
7661 | @opindex Wprio-ctor-dtor | |
ddf6fe37 | 7662 | @item -Wno-prio-ctor-dtor |
d77de738 ML |
7663 | Do not warn if a priority from 0 to 100 is used for constructor or destructor. |
7664 | The use of constructor and destructor attributes allow you to assign a | |
7665 | priority to the constructor/destructor to control its order of execution | |
7666 | before @code{main} is called or after it returns. The priority values must be | |
7667 | greater than 100 as the compiler reserves priority values between 0--100 for | |
7668 | the implementation. | |
7669 | ||
d77de738 ML |
7670 | @opindex Wstrict-aliasing |
7671 | @opindex Wno-strict-aliasing | |
ddf6fe37 | 7672 | @item -Wstrict-aliasing |
d77de738 ML |
7673 | This option is only active when @option{-fstrict-aliasing} is active. |
7674 | It warns about code that might break the strict aliasing rules that the | |
7675 | compiler is using for optimization. The warning does not catch all | |
7676 | cases, but does attempt to catch the more common pitfalls. It is | |
7677 | included in @option{-Wall}. | |
7678 | It is equivalent to @option{-Wstrict-aliasing=3} | |
7679 | ||
d77de738 | 7680 | @opindex Wstrict-aliasing=n |
ddf6fe37 | 7681 | @item -Wstrict-aliasing=n |
d77de738 ML |
7682 | This option is only active when @option{-fstrict-aliasing} is active. |
7683 | It warns about code that might break the strict aliasing rules that the | |
7684 | compiler is using for optimization. | |
7685 | Higher levels correspond to higher accuracy (fewer false positives). | |
7686 | Higher levels also correspond to more effort, similar to the way @option{-O} | |
7687 | works. | |
7688 | @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}. | |
7689 | ||
7690 | Level 1: Most aggressive, quick, least accurate. | |
7691 | Possibly useful when higher levels | |
7692 | do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few | |
7693 | false negatives. However, it has many false positives. | |
7694 | Warns for all pointer conversions between possibly incompatible types, | |
7695 | even if never dereferenced. Runs in the front end only. | |
7696 | ||
7697 | Level 2: Aggressive, quick, not too precise. | |
7698 | May still have many false positives (not as many as level 1 though), | |
7699 | and few false negatives (but possibly more than level 1). | |
7700 | Unlike level 1, it only warns when an address is taken. Warns about | |
7701 | incomplete types. Runs in the front end only. | |
7702 | ||
7703 | Level 3 (default for @option{-Wstrict-aliasing}): | |
7704 | Should have very few false positives and few false | |
7705 | negatives. Slightly slower than levels 1 or 2 when optimization is enabled. | |
7706 | Takes care of the common pun+dereference pattern in the front end: | |
7707 | @code{*(int*)&some_float}. | |
7708 | If optimization is enabled, it also runs in the back end, where it deals | |
7709 | with multiple statement cases using flow-sensitive points-to information. | |
7710 | Only warns when the converted pointer is dereferenced. | |
7711 | Does not warn about incomplete types. | |
7712 | ||
d77de738 ML |
7713 | @opindex Wstrict-overflow |
7714 | @opindex Wno-strict-overflow | |
ddf6fe37 AA |
7715 | @item -Wstrict-overflow |
7716 | @itemx -Wstrict-overflow=@var{n} | |
d77de738 ML |
7717 | This option is only active when signed overflow is undefined. |
7718 | It warns about cases where the compiler optimizes based on the | |
7719 | assumption that signed overflow does not occur. Note that it does not | |
7720 | warn about all cases where the code might overflow: it only warns | |
7721 | about cases where the compiler implements some optimization. Thus | |
7722 | this warning depends on the optimization level. | |
7723 | ||
7724 | An optimization that assumes that signed overflow does not occur is | |
7725 | perfectly safe if the values of the variables involved are such that | |
7726 | overflow never does, in fact, occur. Therefore this warning can | |
7727 | easily give a false positive: a warning about code that is not | |
7728 | actually a problem. To help focus on important issues, several | |
7729 | warning levels are defined. No warnings are issued for the use of | |
7730 | undefined signed overflow when estimating how many iterations a loop | |
7731 | requires, in particular when determining whether a loop will be | |
7732 | executed at all. | |
7733 | ||
7734 | @table @gcctabopt | |
7735 | @item -Wstrict-overflow=1 | |
7736 | Warn about cases that are both questionable and easy to avoid. For | |
7737 | example the compiler simplifies | |
7738 | @code{x + 1 > x} to @code{1}. This level of | |
7739 | @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels | |
7740 | are not, and must be explicitly requested. | |
7741 | ||
7742 | @item -Wstrict-overflow=2 | |
7743 | Also warn about other cases where a comparison is simplified to a | |
7744 | constant. For example: @code{abs (x) >= 0}. This can only be | |
7745 | simplified when signed integer overflow is undefined, because | |
7746 | @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than | |
7747 | zero. @option{-Wstrict-overflow} (with no level) is the same as | |
7748 | @option{-Wstrict-overflow=2}. | |
7749 | ||
7750 | @item -Wstrict-overflow=3 | |
7751 | Also warn about other cases where a comparison is simplified. For | |
7752 | example: @code{x + 1 > 1} is simplified to @code{x > 0}. | |
7753 | ||
7754 | @item -Wstrict-overflow=4 | |
7755 | Also warn about other simplifications not covered by the above cases. | |
7756 | For example: @code{(x * 10) / 5} is simplified to @code{x * 2}. | |
7757 | ||
7758 | @item -Wstrict-overflow=5 | |
7759 | Also warn about cases where the compiler reduces the magnitude of a | |
7760 | constant involved in a comparison. For example: @code{x + 2 > y} is | |
7761 | simplified to @code{x + 1 >= y}. This is reported only at the | |
7762 | highest warning level because this simplification applies to many | |
7763 | comparisons, so this warning level gives a very large number of | |
7764 | false positives. | |
7765 | @end table | |
7766 | ||
d77de738 ML |
7767 | @opindex Wstring-compare |
7768 | @opindex Wno-string-compare | |
ddf6fe37 | 7769 | @item -Wstring-compare |
d77de738 ML |
7770 | Warn for calls to @code{strcmp} and @code{strncmp} whose result is |
7771 | determined to be either zero or non-zero in tests for such equality | |
7772 | owing to the length of one argument being greater than the size of | |
7773 | the array the other argument is stored in (or the bound in the case | |
7774 | of @code{strncmp}). Such calls could be mistakes. For example, | |
7775 | the call to @code{strcmp} below is diagnosed because its result is | |
7776 | necessarily non-zero irrespective of the contents of the array @code{a}. | |
7777 | ||
7778 | @smallexample | |
7779 | extern char a[4]; | |
7780 | void f (char *d) | |
7781 | @{ | |
7782 | strcpy (d, "string"); | |
7783 | @dots{} | |
7784 | if (0 == strcmp (a, d)) // cannot be true | |
7785 | puts ("a and d are the same"); | |
7786 | @} | |
7787 | @end smallexample | |
7788 | ||
7789 | @option{-Wstring-compare} is enabled by @option{-Wextra}. | |
7790 | ||
ddf6fe37 AA |
7791 | @opindex Wstringop-overflow |
7792 | @opindex Wno-stringop-overflow | |
d77de738 ML |
7793 | @item -Wno-stringop-overflow |
7794 | @item -Wstringop-overflow | |
7795 | @itemx -Wstringop-overflow=@var{type} | |
d77de738 ML |
7796 | Warn for calls to string manipulation functions such as @code{memcpy} and |
7797 | @code{strcpy} that are determined to overflow the destination buffer. The | |
7798 | optional argument is one greater than the type of Object Size Checking to | |
7799 | perform to determine the size of the destination. @xref{Object Size Checking}. | |
7800 | The argument is meaningful only for functions that operate on character arrays | |
7801 | but not for raw memory functions like @code{memcpy} which always make use | |
7802 | of Object Size type-0. The option also warns for calls that specify a size | |
7803 | in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes. | |
7804 | The option produces the best results with optimization enabled but can detect | |
7805 | a small subset of simple buffer overflows even without optimization in | |
7806 | calls to the GCC built-in functions like @code{__builtin_memcpy} that | |
7807 | correspond to the standard functions. In any case, the option warns about | |
7808 | just a subset of buffer overflows detected by the corresponding overflow | |
7809 | checking built-ins. For example, the option issues a warning for | |
7810 | the @code{strcpy} call below because it copies at least 5 characters | |
7811 | (the string @code{"blue"} including the terminating NUL) into the buffer | |
7812 | of size 4. | |
7813 | ||
7814 | @smallexample | |
7815 | enum Color @{ blue, purple, yellow @}; | |
7816 | const char* f (enum Color clr) | |
7817 | @{ | |
7818 | static char buf [4]; | |
7819 | const char *str; | |
7820 | switch (clr) | |
7821 | @{ | |
7822 | case blue: str = "blue"; break; | |
7823 | case purple: str = "purple"; break; | |
7824 | case yellow: str = "yellow"; break; | |
7825 | @} | |
7826 | ||
7827 | return strcpy (buf, str); // warning here | |
7828 | @} | |
7829 | @end smallexample | |
7830 | ||
7831 | Option @option{-Wstringop-overflow=2} is enabled by default. | |
7832 | ||
7833 | @table @gcctabopt | |
d77de738 ML |
7834 | @opindex Wstringop-overflow |
7835 | @opindex Wno-stringop-overflow | |
ddf6fe37 AA |
7836 | @item -Wstringop-overflow |
7837 | @itemx -Wstringop-overflow=1 | |
d77de738 ML |
7838 | The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking |
7839 | to determine the sizes of destination objects. At this setting the option | |
7840 | does not warn for writes past the end of subobjects of larger objects accessed | |
7841 | by pointers unless the size of the largest surrounding object is known. When | |
7842 | the destination may be one of several objects it is assumed to be the largest | |
7843 | one of them. On Linux systems, when optimization is enabled at this setting | |
7844 | the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro | |
7845 | is defined to a non-zero value. | |
7846 | ||
7847 | @item -Wstringop-overflow=2 | |
7848 | The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking | |
7849 | to determine the sizes of destination objects. At this setting the option | |
7850 | warns about overflows when writing to members of the largest complete | |
7851 | objects whose exact size is known. However, it does not warn for excessive | |
7852 | writes to the same members of unknown objects referenced by pointers since | |
7853 | they may point to arrays containing unknown numbers of elements. This is | |
7854 | the default setting of the option. | |
7855 | ||
7856 | @item -Wstringop-overflow=3 | |
7857 | The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking | |
7858 | to determine the sizes of destination objects. At this setting the option | |
7859 | warns about overflowing the smallest object or data member. This is the | |
7860 | most restrictive setting of the option that may result in warnings for safe | |
7861 | code. | |
7862 | ||
7863 | @item -Wstringop-overflow=4 | |
7864 | The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking | |
7865 | to determine the sizes of destination objects. At this setting the option | |
7866 | warns about overflowing any data members, and when the destination is | |
7867 | one of several objects it uses the size of the largest of them to decide | |
7868 | whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this | |
7869 | setting of the option may result in warnings for benign code. | |
7870 | @end table | |
7871 | ||
d77de738 ML |
7872 | @opindex Wstringop-overread |
7873 | @opindex Wno-stringop-overread | |
ddf6fe37 | 7874 | @item -Wno-stringop-overread |
d77de738 ML |
7875 | Warn for calls to string manipulation functions such as @code{memchr}, or |
7876 | @code{strcpy} that are determined to read past the end of the source | |
7877 | sequence. | |
7878 | ||
7879 | Option @option{-Wstringop-overread} is enabled by default. | |
7880 | ||
d77de738 ML |
7881 | @opindex Wstringop-truncation |
7882 | @opindex Wno-stringop-truncation | |
ddf6fe37 | 7883 | @item -Wno-stringop-truncation |
d77de738 ML |
7884 | Do not warn for calls to bounded string manipulation functions |
7885 | such as @code{strncat}, | |
7886 | @code{strncpy}, and @code{stpncpy} that may either truncate the copied string | |
7887 | or leave the destination unchanged. | |
7888 | ||
7889 | In the following example, the call to @code{strncat} specifies a bound that | |
7890 | is less than the length of the source string. As a result, the copy of | |
7891 | the source will be truncated and so the call is diagnosed. To avoid the | |
7892 | warning use @code{bufsize - strlen (buf) - 1)} as the bound. | |
7893 | ||
7894 | @smallexample | |
7895 | void append (char *buf, size_t bufsize) | |
7896 | @{ | |
7897 | strncat (buf, ".txt", 3); | |
7898 | @} | |
7899 | @end smallexample | |
7900 | ||
7901 | As another example, the following call to @code{strncpy} results in copying | |
7902 | to @code{d} just the characters preceding the terminating NUL, without | |
7903 | appending the NUL to the end. Assuming the result of @code{strncpy} is | |
7904 | necessarily a NUL-terminated string is a common mistake, and so the call | |
7905 | is diagnosed. To avoid the warning when the result is not expected to be | |
7906 | NUL-terminated, call @code{memcpy} instead. | |
7907 | ||
7908 | @smallexample | |
7909 | void copy (char *d, const char *s) | |
7910 | @{ | |
7911 | strncpy (d, s, strlen (s)); | |
7912 | @} | |
7913 | @end smallexample | |
7914 | ||
7915 | In the following example, the call to @code{strncpy} specifies the size | |
7916 | of the destination buffer as the bound. If the length of the source | |
7917 | string is equal to or greater than this size the result of the copy will | |
7918 | not be NUL-terminated. Therefore, the call is also diagnosed. To avoid | |
7919 | the warning, specify @code{sizeof buf - 1} as the bound and set the last | |
7920 | element of the buffer to @code{NUL}. | |
7921 | ||
7922 | @smallexample | |
7923 | void copy (const char *s) | |
7924 | @{ | |
7925 | char buf[80]; | |
7926 | strncpy (buf, s, sizeof buf); | |
7927 | @dots{} | |
7928 | @} | |
7929 | @end smallexample | |
7930 | ||
7931 | In situations where a character array is intended to store a sequence | |
7932 | of bytes with no terminating @code{NUL} such an array may be annotated | |
7933 | with attribute @code{nonstring} to avoid this warning. Such arrays, | |
7934 | however, are not suitable arguments to functions that expect | |
7935 | @code{NUL}-terminated strings. To help detect accidental misuses of | |
7936 | such arrays GCC issues warnings unless it can prove that the use is | |
7937 | safe. @xref{Common Variable Attributes}. | |
7938 | ||
2a27ae32 QZ |
7939 | @opindex Wstrict-flex-arrays |
7940 | @opindex Wno-strict-flex-arrays | |
ddf6fe37 | 7941 | @item -Wstrict-flex-arrays |
2a27ae32 QZ |
7942 | Warn about inproper usages of flexible array members |
7943 | according to the @var{level} of the @code{strict_flex_array (@var{level})} | |
7944 | attribute attached to the trailing array field of a structure if it's | |
7945 | available, otherwise according to the @var{level} of the option | |
7946 | @option{-fstrict-flex-arrays=@var{level}}. | |
7947 | ||
7948 | This option is effective only when @var{level} is bigger than 0. Otherwise, | |
7949 | it will be ignored with a warning. | |
7950 | ||
7951 | when @var{level}=1, warnings will be issued for a trailing array reference | |
7952 | of a structure that have 2 or more elements if the trailing array is referenced | |
7953 | as a flexible array member. | |
7954 | ||
7955 | when @var{level}=2, in addition to @var{level}=1, additional warnings will be | |
7956 | issued for a trailing one-element array reference of a structure | |
7957 | if the array is referenced as a flexible array member. | |
7958 | ||
7959 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
7960 | issued for a trailing zero-length array reference of a structure | |
7961 | if the array is referenced as a flexible array member. | |
7962 | ||
7963 | ||
d77de738 ML |
7964 | @opindex Wsuggest-attribute= |
7965 | @opindex Wno-suggest-attribute= | |
ddf6fe37 | 7966 | @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]} |
d77de738 ML |
7967 | Warn for cases where adding an attribute may be beneficial. The |
7968 | attributes currently supported are listed below. | |
7969 | ||
7970 | @table @gcctabopt | |
d77de738 ML |
7971 | @opindex Wsuggest-attribute=pure |
7972 | @opindex Wno-suggest-attribute=pure | |
7973 | @opindex Wsuggest-attribute=const | |
7974 | @opindex Wno-suggest-attribute=const | |
7975 | @opindex Wsuggest-attribute=noreturn | |
7976 | @opindex Wno-suggest-attribute=noreturn | |
7977 | @opindex Wmissing-noreturn | |
7978 | @opindex Wno-missing-noreturn | |
7979 | @opindex Wsuggest-attribute=malloc | |
7980 | @opindex Wno-suggest-attribute=malloc | |
ddf6fe37 AA |
7981 | @item -Wsuggest-attribute=pure |
7982 | @itemx -Wsuggest-attribute=const | |
7983 | @itemx -Wsuggest-attribute=noreturn | |
7984 | @itemx -Wmissing-noreturn | |
7985 | @itemx -Wsuggest-attribute=malloc | |
d77de738 ML |
7986 | |
7987 | Warn about functions that might be candidates for attributes | |
7988 | @code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler | |
7989 | only warns for functions visible in other compilation units or (in the case of | |
7990 | @code{pure} and @code{const}) if it cannot prove that the function returns | |
7991 | normally. A function returns normally if it doesn't contain an infinite loop or | |
7992 | return abnormally by throwing, calling @code{abort} or trapping. This analysis | |
7993 | requires option @option{-fipa-pure-const}, which is enabled by default at | |
7994 | @option{-O} and higher. Higher optimization levels improve the accuracy | |
7995 | of the analysis. | |
7996 | ||
d77de738 ML |
7997 | @opindex Wsuggest-attribute=format |
7998 | @opindex Wmissing-format-attribute | |
7999 | @opindex Wno-suggest-attribute=format | |
8000 | @opindex Wno-missing-format-attribute | |
8001 | @opindex Wformat | |
8002 | @opindex Wno-format | |
ddf6fe37 AA |
8003 | @item -Wsuggest-attribute=format |
8004 | @itemx -Wmissing-format-attribute | |
d77de738 ML |
8005 | |
8006 | Warn about function pointers that might be candidates for @code{format} | |
8007 | attributes. Note these are only possible candidates, not absolute ones. | |
8008 | GCC guesses that function pointers with @code{format} attributes that | |
8009 | are used in assignment, initialization, parameter passing or return | |
8010 | statements should have a corresponding @code{format} attribute in the | |
8011 | resulting type. I.e.@: the left-hand side of the assignment or | |
8012 | initialization, the type of the parameter variable, or the return type | |
8013 | of the containing function respectively should also have a @code{format} | |
8014 | attribute to avoid the warning. | |
8015 | ||
8016 | GCC also warns about function definitions that might be | |
8017 | candidates for @code{format} attributes. Again, these are only | |
8018 | possible candidates. GCC guesses that @code{format} attributes | |
8019 | might be appropriate for any function that calls a function like | |
8020 | @code{vprintf} or @code{vscanf}, but this might not always be the | |
8021 | case, and some functions for which @code{format} attributes are | |
8022 | appropriate may not be detected. | |
8023 | ||
d77de738 ML |
8024 | @opindex Wsuggest-attribute=cold |
8025 | @opindex Wno-suggest-attribute=cold | |
ddf6fe37 | 8026 | @item -Wsuggest-attribute=cold |
d77de738 ML |
8027 | |
8028 | Warn about functions that might be candidates for @code{cold} attribute. This | |
8029 | is based on static detection and generally only warns about functions which | |
8030 | always leads to a call to another @code{cold} function such as wrappers of | |
8031 | C++ @code{throw} or fatal error reporting functions leading to @code{abort}. | |
8032 | @end table | |
8033 | ||
d77de738 ML |
8034 | @opindex Wno-alloc-zero |
8035 | @opindex Walloc-zero | |
ddf6fe37 | 8036 | @item -Walloc-zero |
d77de738 ML |
8037 | Warn about calls to allocation functions decorated with attribute |
8038 | @code{alloc_size} that specify zero bytes, including those to the built-in | |
8039 | forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc}, | |
8040 | @code{malloc}, and @code{realloc}. Because the behavior of these functions | |
8041 | when called with a zero size differs among implementations (and in the case | |
8042 | of @code{realloc} has been deprecated) relying on it may result in subtle | |
8043 | portability bugs and should be avoided. | |
8044 | ||
d77de738 ML |
8045 | @opindex Walloc-size-larger-than= |
8046 | @opindex Wno-alloc-size-larger-than | |
ddf6fe37 | 8047 | @item -Walloc-size-larger-than=@var{byte-size} |
d77de738 ML |
8048 | Warn about calls to functions decorated with attribute @code{alloc_size} |
8049 | that attempt to allocate objects larger than the specified number of bytes, | |
8050 | or where the result of the size computation in an integer type with infinite | |
8051 | precision would exceed the value of @samp{PTRDIFF_MAX} on the target. | |
8052 | @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8053 | Warnings controlled by the option can be disabled either by specifying | |
8054 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8055 | @option{-Wno-alloc-size-larger-than}. | |
8056 | @xref{Function Attributes}. | |
8057 | ||
d77de738 | 8058 | @opindex Wno-alloc-size-larger-than |
ddf6fe37 | 8059 | @item -Wno-alloc-size-larger-than |
d77de738 ML |
8060 | Disable @option{-Walloc-size-larger-than=} warnings. The option is |
8061 | equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or | |
8062 | larger. | |
8063 | ||
d77de738 ML |
8064 | @opindex Wno-alloca |
8065 | @opindex Walloca | |
ddf6fe37 | 8066 | @item -Walloca |
d77de738 ML |
8067 | This option warns on all uses of @code{alloca} in the source. |
8068 | ||
d77de738 ML |
8069 | @opindex Walloca-larger-than= |
8070 | @opindex Wno-alloca-larger-than | |
ddf6fe37 | 8071 | @item -Walloca-larger-than=@var{byte-size} |
d77de738 ML |
8072 | This option warns on calls to @code{alloca} with an integer argument whose |
8073 | value is either zero, or that is not bounded by a controlling predicate | |
8074 | that limits its value to at most @var{byte-size}. It also warns for calls | |
8075 | to @code{alloca} where the bound value is unknown. Arguments of non-integer | |
8076 | types are considered unbounded even if they appear to be constrained to | |
8077 | the expected range. | |
8078 | ||
8079 | For example, a bounded case of @code{alloca} could be: | |
8080 | ||
8081 | @smallexample | |
8082 | void func (size_t n) | |
8083 | @{ | |
8084 | void *p; | |
8085 | if (n <= 1000) | |
8086 | p = alloca (n); | |
8087 | else | |
8088 | p = malloc (n); | |
8089 | f (p); | |
8090 | @} | |
8091 | @end smallexample | |
8092 | ||
8093 | In the above example, passing @code{-Walloca-larger-than=1000} would not | |
8094 | issue a warning because the call to @code{alloca} is known to be at most | |
8095 | 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed, | |
8096 | the compiler would emit a warning. | |
8097 | ||
8098 | Unbounded uses, on the other hand, are uses of @code{alloca} with no | |
8099 | controlling predicate constraining its integer argument. For example: | |
8100 | ||
8101 | @smallexample | |
8102 | void func () | |
8103 | @{ | |
8104 | void *p = alloca (n); | |
8105 | f (p); | |
8106 | @} | |
8107 | @end smallexample | |
8108 | ||
8109 | If @code{-Walloca-larger-than=500} were passed, the above would trigger | |
8110 | a warning, but this time because of the lack of bounds checking. | |
8111 | ||
8112 | Note, that even seemingly correct code involving signed integers could | |
8113 | cause a warning: | |
8114 | ||
8115 | @smallexample | |
8116 | void func (signed int n) | |
8117 | @{ | |
8118 | if (n < 500) | |
8119 | @{ | |
8120 | p = alloca (n); | |
8121 | f (p); | |
8122 | @} | |
8123 | @} | |
8124 | @end smallexample | |
8125 | ||
8126 | In the above example, @var{n} could be negative, causing a larger than | |
8127 | expected argument to be implicitly cast into the @code{alloca} call. | |
8128 | ||
8129 | This option also warns when @code{alloca} is used in a loop. | |
8130 | ||
8131 | @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default | |
8132 | but is usually only effective when @option{-ftree-vrp} is active (default | |
8133 | for @option{-O2} and above). | |
8134 | ||
8135 | See also @option{-Wvla-larger-than=}@samp{byte-size}. | |
8136 | ||
d77de738 | 8137 | @opindex Wno-alloca-larger-than |
ddf6fe37 | 8138 | @item -Wno-alloca-larger-than |
d77de738 ML |
8139 | Disable @option{-Walloca-larger-than=} warnings. The option is |
8140 | equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger. | |
8141 | ||
d77de738 ML |
8142 | @opindex Warith-conversion |
8143 | @opindex Wno-arith-conversion | |
ddf6fe37 | 8144 | @item -Warith-conversion |
d77de738 ML |
8145 | Do warn about implicit conversions from arithmetic operations even |
8146 | when conversion of the operands to the same type cannot change their | |
8147 | values. This affects warnings from @option{-Wconversion}, | |
8148 | @option{-Wfloat-conversion}, and @option{-Wsign-conversion}. | |
8149 | ||
8150 | @smallexample | |
8151 | @group | |
8152 | void f (char c, int i) | |
8153 | @{ | |
8154 | c = c + i; // warns with @option{-Wconversion} | |
8155 | c = c + 1; // only warns with @option{-Warith-conversion} | |
8156 | @} | |
8157 | @end group | |
8158 | @end smallexample | |
8159 | ||
d77de738 ML |
8160 | @opindex Wno-array-bounds |
8161 | @opindex Warray-bounds | |
ddf6fe37 AA |
8162 | @item -Warray-bounds |
8163 | @itemx -Warray-bounds=@var{n} | |
d77de738 ML |
8164 | Warn about out of bounds subscripts or offsets into arrays. This warning |
8165 | is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp} | |
8166 | is active (the default for @option{-O2} and above) but a subset of instances | |
8167 | are issued even without optimization. | |
8168 | ||
710c9676 QZ |
8169 | By default, the trailing array of a structure will be treated as a flexible |
8170 | array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}} | |
8171 | if it is declared as either a flexible array member per C99 standard onwards | |
8172 | (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element | |
8173 | array (@samp{[1]}). As a result, out of bounds subscripts or offsets into | |
8174 | zero-length arrays or one-element arrays are not warned by default. | |
8175 | ||
8176 | You can add the option @option{-fstrict-flex-arrays} or | |
8177 | @option{-fstrict-flex-arrays=@var{level}} to control how this | |
8178 | option treat trailing array of a structure as a flexible array member: | |
8179 | ||
8180 | when @var{level}<=1, no change to the default behavior. | |
8181 | ||
8182 | when @var{level}=2, additional warnings will be issued for out of bounds | |
8183 | subscripts or offsets into one-element arrays; | |
8184 | ||
8185 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8186 | issued for out of bounds subscripts or offsets into zero-length arrays. | |
8187 | ||
d77de738 ML |
8188 | @table @gcctabopt |
8189 | @item -Warray-bounds=1 | |
8190 | This is the default warning level of @option{-Warray-bounds} and is enabled | |
8191 | by @option{-Wall}; higher levels are not, and must be explicitly requested. | |
8192 | ||
8193 | @item -Warray-bounds=2 | |
710c9676 QZ |
8194 | This warning level also warns about the intermediate results of pointer |
8195 | arithmetic that may yield out of bounds values. This warning level may | |
8196 | give a larger number of false positives and is deactivated by default. | |
d77de738 ML |
8197 | @end table |
8198 | ||
d77de738 ML |
8199 | @opindex Warray-compare |
8200 | @opindex Wno-array-compare | |
ddf6fe37 | 8201 | @item -Warray-compare |
d77de738 ML |
8202 | Warn about equality and relational comparisons between two operands of array |
8203 | type. This comparison was deprecated in C++20. For example: | |
8204 | ||
8205 | @smallexample | |
8206 | int arr1[5]; | |
8207 | int arr2[5]; | |
8208 | bool same = arr1 == arr2; | |
8209 | @end smallexample | |
8210 | ||
8211 | @option{-Warray-compare} is enabled by @option{-Wall}. | |
8212 | ||
ddf6fe37 | 8213 | @opindex Wno-array-parameter |
d77de738 ML |
8214 | @item -Warray-parameter |
8215 | @itemx -Warray-parameter=@var{n} | |
d77de738 ML |
8216 | Warn about redeclarations of functions involving arguments of array or |
8217 | pointer types of inconsistent kinds or forms, and enable the detection | |
8218 | of out-of-bounds accesses to such parameters by warnings such as | |
8219 | @option{-Warray-bounds}. | |
8220 | ||
8221 | If the first function declaration uses the array form the bound specified | |
8222 | in the array is assumed to be the minimum number of elements expected to | |
8223 | be provided in calls to the function and the maximum number of elements | |
8224 | accessed by it. Failing to provide arguments of sufficient size or accessing | |
8225 | more than the maximum number of elements may be diagnosed by warnings such | |
8226 | as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies | |
8227 | involving array parameters declared using the @code{T[static N]} form. | |
8228 | ||
8229 | For example, the warning triggers for the following redeclarations because | |
8230 | the first one allows an array of any size to be passed to @code{f} while | |
8231 | the second one with the keyword @code{static} specifies that the array | |
8232 | argument must have at least four elements. | |
8233 | ||
8234 | @smallexample | |
8235 | void f (int[static 4]); | |
8236 | void f (int[]); // warning (inconsistent array form) | |
8237 | ||
8238 | void g (void) | |
8239 | @{ | |
8240 | int *p = (int *)malloc (4); | |
8241 | f (p); // warning (array too small) | |
8242 | @dots{} | |
8243 | @} | |
8244 | @end smallexample | |
8245 | ||
8246 | At level 2 the warning also triggers for redeclarations involving any other | |
8247 | inconsistency in array or pointer argument forms denoting array sizes. | |
8248 | Pointers and arrays of unspecified bound are considered equivalent and do | |
8249 | not trigger a warning. | |
8250 | ||
8251 | @smallexample | |
8252 | void g (int*); | |
8253 | void g (int[]); // no warning | |
8254 | void g (int[8]); // warning (inconsistent array bound) | |
8255 | @end smallexample | |
8256 | ||
8257 | @option{-Warray-parameter=2} is included in @option{-Wall}. The | |
8258 | @option{-Wvla-parameter} option triggers warnings for similar inconsistencies | |
8259 | involving Variable Length Array arguments. | |
8260 | ||
d77de738 ML |
8261 | @opindex Wattribute-alias |
8262 | @opindex Wno-attribute-alias | |
ddf6fe37 AA |
8263 | @item -Wattribute-alias=@var{n} |
8264 | @itemx -Wno-attribute-alias | |
d77de738 ML |
8265 | Warn about declarations using the @code{alias} and similar attributes whose |
8266 | target is incompatible with the type of the alias. | |
8267 | @xref{Function Attributes,,Declaring Attributes of Functions}. | |
8268 | ||
8269 | @table @gcctabopt | |
8270 | @item -Wattribute-alias=1 | |
8271 | The default warning level of the @option{-Wattribute-alias} option diagnoses | |
8272 | incompatibilities between the type of the alias declaration and that of its | |
8273 | target. Such incompatibilities are typically indicative of bugs. | |
8274 | ||
8275 | @item -Wattribute-alias=2 | |
8276 | ||
8277 | At this level @option{-Wattribute-alias} also diagnoses cases where | |
8278 | the attributes of the alias declaration are more restrictive than the | |
8279 | attributes applied to its target. These mismatches can potentially | |
8280 | result in incorrect code generation. In other cases they may be | |
8281 | benign and could be resolved simply by adding the missing attribute to | |
8282 | the target. For comparison, see the @option{-Wmissing-attributes} | |
8283 | option, which controls diagnostics when the alias declaration is less | |
8284 | restrictive than the target, rather than more restrictive. | |
8285 | ||
8286 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
8287 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
8288 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
8289 | @code{returns_nonnull}, and @code{returns_twice}. | |
8290 | @end table | |
8291 | ||
8292 | @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}. | |
8293 | This is the default. You can disable these warnings with either | |
8294 | @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}. | |
8295 | ||
d77de738 ML |
8296 | @opindex Wbidi-chars= |
8297 | @opindex Wbidi-chars | |
8298 | @opindex Wno-bidi-chars | |
ddf6fe37 | 8299 | @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} |
d77de738 ML |
8300 | Warn about possibly misleading UTF-8 bidirectional control characters in |
8301 | comments, string literals, character constants, and identifiers. Such | |
8302 | characters can change left-to-right writing direction into right-to-left | |
8303 | (and vice versa), which can cause confusion between the logical order and | |
8304 | visual order. This may be dangerous; for instance, it may seem that a piece | |
8305 | of code is not commented out, whereas it in fact is. | |
8306 | ||
8307 | There are three levels of warning supported by GCC@. The default is | |
8308 | @option{-Wbidi-chars=unpaired}, which warns about improperly terminated | |
8309 | bidi contexts. @option{-Wbidi-chars=none} turns the warning off. | |
8310 | @option{-Wbidi-chars=any} warns about any use of bidirectional control | |
8311 | characters. | |
8312 | ||
8313 | By default, this warning does not warn about UCNs. It is, however, possible | |
8314 | to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or | |
8315 | @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid, | |
8316 | and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous | |
8317 | @option{-Wbidi-chars=any} was specified. | |
8318 | ||
d77de738 ML |
8319 | @opindex Wno-bool-compare |
8320 | @opindex Wbool-compare | |
ddf6fe37 | 8321 | @item -Wbool-compare |
d77de738 ML |
8322 | Warn about boolean expression compared with an integer value different from |
8323 | @code{true}/@code{false}. For instance, the following comparison is | |
8324 | always false: | |
8325 | @smallexample | |
8326 | int n = 5; | |
8327 | @dots{} | |
8328 | if ((n > 1) == 2) @{ @dots{} @} | |
8329 | @end smallexample | |
8330 | This warning is enabled by @option{-Wall}. | |
8331 | ||
d77de738 ML |
8332 | @opindex Wno-bool-operation |
8333 | @opindex Wbool-operation | |
ddf6fe37 | 8334 | @item -Wbool-operation |
d77de738 ML |
8335 | Warn about suspicious operations on expressions of a boolean type. For |
8336 | instance, bitwise negation of a boolean is very likely a bug in the program. | |
8337 | For C, this warning also warns about incrementing or decrementing a boolean, | |
8338 | which rarely makes sense. (In C++, decrementing a boolean is always invalid. | |
8339 | Incrementing a boolean is invalid in C++17, and deprecated otherwise.) | |
8340 | ||
8341 | This warning is enabled by @option{-Wall}. | |
8342 | ||
d77de738 ML |
8343 | @opindex Wno-duplicated-branches |
8344 | @opindex Wduplicated-branches | |
ddf6fe37 | 8345 | @item -Wduplicated-branches |
d77de738 ML |
8346 | Warn when an if-else has identical branches. This warning detects cases like |
8347 | @smallexample | |
8348 | if (p != NULL) | |
8349 | return 0; | |
8350 | else | |
8351 | return 0; | |
8352 | @end smallexample | |
8353 | It doesn't warn when both branches contain just a null statement. This warning | |
8354 | also warn for conditional operators: | |
8355 | @smallexample | |
8356 | int i = x ? *p : *p; | |
8357 | @end smallexample | |
8358 | ||
d77de738 ML |
8359 | @opindex Wno-duplicated-cond |
8360 | @opindex Wduplicated-cond | |
ddf6fe37 | 8361 | @item -Wduplicated-cond |
d77de738 ML |
8362 | Warn about duplicated conditions in an if-else-if chain. For instance, |
8363 | warn for the following code: | |
8364 | @smallexample | |
8365 | if (p->q != NULL) @{ @dots{} @} | |
8366 | else if (p->q != NULL) @{ @dots{} @} | |
8367 | @end smallexample | |
8368 | ||
d77de738 ML |
8369 | @opindex Wno-frame-address |
8370 | @opindex Wframe-address | |
ddf6fe37 | 8371 | @item -Wframe-address |
d77de738 ML |
8372 | Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address} |
8373 | is called with an argument greater than 0. Such calls may return indeterminate | |
8374 | values or crash the program. The warning is included in @option{-Wall}. | |
8375 | ||
d77de738 ML |
8376 | @opindex Wno-discarded-qualifiers |
8377 | @opindex Wdiscarded-qualifiers | |
ddf6fe37 | 8378 | @item -Wno-discarded-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8379 | Do not warn if type qualifiers on pointers are being discarded. |
8380 | Typically, the compiler warns if a @code{const char *} variable is | |
8381 | passed to a function that takes a @code{char *} parameter. This option | |
8382 | can be used to suppress such a warning. | |
8383 | ||
d77de738 ML |
8384 | @opindex Wno-discarded-array-qualifiers |
8385 | @opindex Wdiscarded-array-qualifiers | |
ddf6fe37 | 8386 | @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8387 | Do not warn if type qualifiers on arrays which are pointer targets |
8388 | are being discarded. Typically, the compiler warns if a | |
8389 | @code{const int (*)[]} variable is passed to a function that | |
8390 | takes a @code{int (*)[]} parameter. This option can be used to | |
8391 | suppress such a warning. | |
8392 | ||
d77de738 ML |
8393 | @opindex Wno-incompatible-pointer-types |
8394 | @opindex Wincompatible-pointer-types | |
ddf6fe37 | 8395 | @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)} |
d77de738 ML |
8396 | Do not warn when there is a conversion between pointers that have incompatible |
8397 | types. This warning is for cases not covered by @option{-Wno-pointer-sign}, | |
8398 | which warns for pointer argument passing or assignment with different | |
8399 | signedness. | |
8400 | ||
5fccebdb JM |
8401 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8402 | ||
d77de738 ML |
8403 | @opindex Wno-int-conversion |
8404 | @opindex Wint-conversion | |
ddf6fe37 | 8405 | @item -Wno-int-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8406 | Do not warn about incompatible integer to pointer and pointer to integer |
8407 | conversions. This warning is about implicit conversions; for explicit | |
8408 | conversions the warnings @option{-Wno-int-to-pointer-cast} and | |
8409 | @option{-Wno-pointer-to-int-cast} may be used. | |
8410 | ||
5fccebdb JM |
8411 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8412 | ||
d77de738 ML |
8413 | @opindex Wzero-length-bounds |
8414 | @opindex Wzero-length-bounds | |
ddf6fe37 | 8415 | @item -Wzero-length-bounds |
d77de738 ML |
8416 | Warn about accesses to elements of zero-length array members that might |
8417 | overlap other members of the same object. Declaring interior zero-length | |
8e9c65d3 | 8418 | arrays is discouraged because accesses to them are undefined. |
d77de738 ML |
8419 | @xref{Zero Length}. |
8420 | ||
8421 | For example, the first two stores in function @code{bad} are diagnosed | |
8422 | because the array elements overlap the subsequent members @code{b} and | |
8423 | @code{c}. The third store is diagnosed by @option{-Warray-bounds} | |
8424 | because it is beyond the bounds of the enclosing object. | |
8425 | ||
8426 | @smallexample | |
8427 | struct X @{ int a[0]; int b, c; @}; | |
8428 | struct X x; | |
8429 | ||
8430 | void bad (void) | |
8431 | @{ | |
8432 | x.a[0] = 0; // -Wzero-length-bounds | |
8433 | x.a[1] = 1; // -Wzero-length-bounds | |
8434 | x.a[2] = 2; // -Warray-bounds | |
8435 | @} | |
8436 | @end smallexample | |
8437 | ||
8438 | Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}. | |
8439 | ||
d77de738 ML |
8440 | @opindex Wno-div-by-zero |
8441 | @opindex Wdiv-by-zero | |
ddf6fe37 | 8442 | @item -Wno-div-by-zero |
d77de738 ML |
8443 | Do not warn about compile-time integer division by zero. Floating-point |
8444 | division by zero is not warned about, as it can be a legitimate way of | |
8445 | obtaining infinities and NaNs. | |
8446 | ||
d77de738 ML |
8447 | @opindex Wsystem-headers |
8448 | @opindex Wno-system-headers | |
8449 | @cindex warnings from system headers | |
8450 | @cindex system headers, warnings from | |
f33d7a88 | 8451 | @item -Wsystem-headers |
d77de738 ML |
8452 | Print warning messages for constructs found in system header files. |
8453 | Warnings from system headers are normally suppressed, on the assumption | |
8454 | that they usually do not indicate real problems and would only make the | |
8455 | compiler output harder to read. Using this command-line option tells | |
8456 | GCC to emit warnings from system headers as if they occurred in user | |
8457 | code. However, note that using @option{-Wall} in conjunction with this | |
8458 | option does @emph{not} warn about unknown pragmas in system | |
8459 | headers---for that, @option{-Wunknown-pragmas} must also be used. | |
8460 | ||
d77de738 ML |
8461 | @opindex Wtautological-compare |
8462 | @opindex Wno-tautological-compare | |
ddf6fe37 | 8463 | @item -Wtautological-compare |
d77de738 ML |
8464 | Warn if a self-comparison always evaluates to true or false. This |
8465 | warning detects various mistakes such as: | |
8466 | @smallexample | |
8467 | int i = 1; | |
8468 | @dots{} | |
8469 | if (i > i) @{ @dots{} @} | |
8470 | @end smallexample | |
8471 | ||
8472 | This warning also warns about bitwise comparisons that always evaluate | |
8473 | to true or false, for instance: | |
8474 | @smallexample | |
8475 | if ((a & 16) == 10) @{ @dots{} @} | |
8476 | @end smallexample | |
8477 | will always be false. | |
8478 | ||
8479 | This warning is enabled by @option{-Wall}. | |
8480 | ||
d77de738 ML |
8481 | @opindex Wtrampolines |
8482 | @opindex Wno-trampolines | |
ddf6fe37 | 8483 | @item -Wtrampolines |
d77de738 ML |
8484 | Warn about trampolines generated for pointers to nested functions. |
8485 | A trampoline is a small piece of data or code that is created at run | |
8486 | time on the stack when the address of a nested function is taken, and is | |
8487 | used to call the nested function indirectly. For some targets, it is | |
8488 | made up of data only and thus requires no special treatment. But, for | |
8489 | most targets, it is made up of code and thus requires the stack to be | |
8490 | made executable in order for the program to work properly. | |
8491 | ||
d77de738 ML |
8492 | @opindex Wfloat-equal |
8493 | @opindex Wno-float-equal | |
ddf6fe37 | 8494 | @item -Wfloat-equal |
d77de738 ML |
8495 | Warn if floating-point values are used in equality comparisons. |
8496 | ||
8497 | The idea behind this is that sometimes it is convenient (for the | |
8498 | programmer) to consider floating-point values as approximations to | |
8499 | infinitely precise real numbers. If you are doing this, then you need | |
8500 | to compute (by analyzing the code, or in some other way) the maximum or | |
8501 | likely maximum error that the computation introduces, and allow for it | |
8502 | when performing comparisons (and when producing output, but that's a | |
8503 | different problem). In particular, instead of testing for equality, you | |
8504 | should check to see whether the two values have ranges that overlap; and | |
8505 | this is done with the relational operators, so equality comparisons are | |
8506 | probably mistaken. | |
8507 | ||
d77de738 ML |
8508 | @opindex Wtraditional |
8509 | @opindex Wno-traditional | |
ddf6fe37 | 8510 | @item -Wtraditional @r{(C and Objective-C only)} |
d77de738 ML |
8511 | Warn about certain constructs that behave differently in traditional and |
8512 | ISO C@. Also warn about ISO C constructs that have no traditional C | |
8513 | equivalent, and/or problematic constructs that should be avoided. | |
8514 | ||
8515 | @itemize @bullet | |
8516 | @item | |
8517 | Macro parameters that appear within string literals in the macro body. | |
8518 | In traditional C macro replacement takes place within string literals, | |
8519 | but in ISO C it does not. | |
8520 | ||
8521 | @item | |
8522 | In traditional C, some preprocessor directives did not exist. | |
8523 | Traditional preprocessors only considered a line to be a directive | |
8524 | if the @samp{#} appeared in column 1 on the line. Therefore | |
8525 | @option{-Wtraditional} warns about directives that traditional C | |
8526 | understands but ignores because the @samp{#} does not appear as the | |
8527 | first character on the line. It also suggests you hide directives like | |
8528 | @code{#pragma} not understood by traditional C by indenting them. Some | |
8529 | traditional implementations do not recognize @code{#elif}, so this option | |
8530 | suggests avoiding it altogether. | |
8531 | ||
8532 | @item | |
8533 | A function-like macro that appears without arguments. | |
8534 | ||
8535 | @item | |
8536 | The unary plus operator. | |
8537 | ||
8538 | @item | |
8539 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point | |
8540 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
8541 | constants.) Note, these suffixes appear in macros defined in the system | |
8542 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. | |
8543 | Use of these macros in user code might normally lead to spurious | |
8544 | warnings, however GCC's integrated preprocessor has enough context to | |
8545 | avoid warning in these cases. | |
8546 | ||
8547 | @item | |
8548 | A function declared external in one block and then used after the end of | |
8549 | the block. | |
8550 | ||
8551 | @item | |
8552 | A @code{switch} statement has an operand of type @code{long}. | |
8553 | ||
8554 | @item | |
8555 | A non-@code{static} function declaration follows a @code{static} one. | |
8556 | This construct is not accepted by some traditional C compilers. | |
8557 | ||
8558 | @item | |
8559 | The ISO type of an integer constant has a different width or | |
8560 | signedness from its traditional type. This warning is only issued if | |
8561 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which | |
8562 | typically represent bit patterns, are not warned about. | |
8563 | ||
8564 | @item | |
8565 | Usage of ISO string concatenation is detected. | |
8566 | ||
8567 | @item | |
8568 | Initialization of automatic aggregates. | |
8569 | ||
8570 | @item | |
8571 | Identifier conflicts with labels. Traditional C lacks a separate | |
8572 | namespace for labels. | |
8573 | ||
8574 | @item | |
8575 | Initialization of unions. If the initializer is zero, the warning is | |
8576 | omitted. This is done under the assumption that the zero initializer in | |
8577 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing | |
8578 | initializer warnings and relies on default initialization to zero in the | |
8579 | traditional C case. | |
8580 | ||
8581 | @item | |
8582 | Conversions by prototypes between fixed/floating-point values and vice | |
8583 | versa. The absence of these prototypes when compiling with traditional | |
8584 | C causes serious problems. This is a subset of the possible | |
8585 | conversion warnings; for the full set use @option{-Wtraditional-conversion}. | |
8586 | ||
8587 | @item | |
8588 | Use of ISO C style function definitions. This warning intentionally is | |
8589 | @emph{not} issued for prototype declarations or variadic functions | |
8590 | because these ISO C features appear in your code when using | |
8591 | libiberty's traditional C compatibility macros, @code{PARAMS} and | |
8592 | @code{VPARAMS}. This warning is also bypassed for nested functions | |
8593 | because that feature is already a GCC extension and thus not relevant to | |
8594 | traditional C compatibility. | |
8595 | @end itemize | |
8596 | ||
d77de738 ML |
8597 | @opindex Wtraditional-conversion |
8598 | @opindex Wno-traditional-conversion | |
ddf6fe37 | 8599 | @item -Wtraditional-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8600 | Warn if a prototype causes a type conversion that is different from what |
8601 | would happen to the same argument in the absence of a prototype. This | |
8602 | includes conversions of fixed point to floating and vice versa, and | |
8603 | conversions changing the width or signedness of a fixed-point argument | |
8604 | except when the same as the default promotion. | |
8605 | ||
d77de738 ML |
8606 | @opindex Wdeclaration-after-statement |
8607 | @opindex Wno-declaration-after-statement | |
ddf6fe37 | 8608 | @item -Wdeclaration-after-statement @r{(C and Objective-C only)} |
d77de738 ML |
8609 | Warn when a declaration is found after a statement in a block. This |
8610 | construct, known from C++, was introduced with ISO C99 and is by default | |
8611 | allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}. | |
8612 | ||
5fccebdb JM |
8613 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8614 | ||
d77de738 ML |
8615 | @opindex Wshadow |
8616 | @opindex Wno-shadow | |
ddf6fe37 | 8617 | @item -Wshadow |
d77de738 ML |
8618 | Warn whenever a local variable or type declaration shadows another |
8619 | variable, parameter, type, class member (in C++), or instance variable | |
8620 | (in Objective-C) or whenever a built-in function is shadowed. Note | |
8621 | that in C++, the compiler warns if a local variable shadows an | |
8622 | explicit typedef, but not if it shadows a struct/class/enum. | |
8623 | If this warning is enabled, it includes also all instances of | |
8624 | local shadowing. This means that @option{-Wno-shadow=local} | |
8625 | and @option{-Wno-shadow=compatible-local} are ignored when | |
8626 | @option{-Wshadow} is used. | |
8627 | Same as @option{-Wshadow=global}. | |
8628 | ||
d77de738 ML |
8629 | @opindex Wno-shadow-ivar |
8630 | @opindex Wshadow-ivar | |
ddf6fe37 | 8631 | @item -Wno-shadow-ivar @r{(Objective-C only)} |
d77de738 ML |
8632 | Do not warn whenever a local variable shadows an instance variable in an |
8633 | Objective-C method. | |
8634 | ||
d77de738 | 8635 | @opindex Wshadow=global |
ddf6fe37 | 8636 | @item -Wshadow=global |
d77de738 ML |
8637 | Warn for any shadowing. |
8638 | Same as @option{-Wshadow}. | |
8639 | ||
d77de738 | 8640 | @opindex Wshadow=local |
ddf6fe37 | 8641 | @item -Wshadow=local |
d77de738 ML |
8642 | Warn when a local variable shadows another local variable or parameter. |
8643 | ||
d77de738 | 8644 | @opindex Wshadow=compatible-local |
ddf6fe37 | 8645 | @item -Wshadow=compatible-local |
d77de738 ML |
8646 | Warn when a local variable shadows another local variable or parameter |
8647 | whose type is compatible with that of the shadowing variable. In C++, | |
8648 | type compatibility here means the type of the shadowing variable can be | |
8649 | converted to that of the shadowed variable. The creation of this flag | |
8650 | (in addition to @option{-Wshadow=local}) is based on the idea that when | |
8651 | a local variable shadows another one of incompatible type, it is most | |
8652 | likely intentional, not a bug or typo, as shown in the following example: | |
8653 | ||
8654 | @smallexample | |
8655 | @group | |
8656 | for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i) | |
8657 | @{ | |
8658 | for (int i = 0; i < N; ++i) | |
8659 | @{ | |
8660 | ... | |
8661 | @} | |
8662 | ... | |
8663 | @} | |
8664 | @end group | |
8665 | @end smallexample | |
8666 | ||
8667 | Since the two variable @code{i} in the example above have incompatible types, | |
8668 | enabling only @option{-Wshadow=compatible-local} does not emit a warning. | |
8669 | Because their types are incompatible, if a programmer accidentally uses one | |
8670 | in place of the other, type checking is expected to catch that and emit an | |
8671 | error or warning. Use of this flag instead of @option{-Wshadow=local} can | |
8672 | possibly reduce the number of warnings triggered by intentional shadowing. | |
8673 | Note that this also means that shadowing @code{const char *i} by | |
8674 | @code{char *i} does not emit a warning. | |
8675 | ||
8676 | This warning is also enabled by @option{-Wshadow=local}. | |
8677 | ||
d77de738 ML |
8678 | @opindex Wlarger-than= |
8679 | @opindex Wlarger-than-@var{byte-size} | |
ddf6fe37 | 8680 | @item -Wlarger-than=@var{byte-size} |
d77de738 ML |
8681 | Warn whenever an object is defined whose size exceeds @var{byte-size}. |
8682 | @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8683 | Warnings controlled by the option can be disabled either by specifying | |
8684 | @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}. | |
8685 | ||
8686 | Also warn for calls to bounded functions such as @code{memchr} or | |
8687 | @code{strnlen} that specify a bound greater than the largest possible | |
8688 | object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings | |
8689 | can only be disabled by @option{-Wno-larger-than}. | |
8690 | ||
d77de738 | 8691 | @opindex Wno-larger-than |
ddf6fe37 | 8692 | @item -Wno-larger-than |
d77de738 ML |
8693 | Disable @option{-Wlarger-than=} warnings. The option is equivalent |
8694 | to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger. | |
8695 | ||
d77de738 ML |
8696 | @opindex Wframe-larger-than= |
8697 | @opindex Wno-frame-larger-than | |
ddf6fe37 | 8698 | @item -Wframe-larger-than=@var{byte-size} |
d77de738 ML |
8699 | Warn if the size of a function frame exceeds @var{byte-size}. |
8700 | The computation done to determine the stack frame size is approximate | |
8701 | and not conservative. | |
8702 | The actual requirements may be somewhat greater than @var{byte-size} | |
8703 | even if you do not get a warning. In addition, any space allocated | |
8704 | via @code{alloca}, variable-length arrays, or related constructs | |
8705 | is not included by the compiler when determining | |
8706 | whether or not to issue a warning. | |
8707 | @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8708 | Warnings controlled by the option can be disabled either by specifying | |
8709 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8710 | @option{-Wno-frame-larger-than}. | |
8711 | ||
d77de738 | 8712 | @opindex Wno-frame-larger-than |
ddf6fe37 | 8713 | @item -Wno-frame-larger-than |
d77de738 ML |
8714 | Disable @option{-Wframe-larger-than=} warnings. The option is equivalent |
8715 | to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger. | |
8716 | ||
d77de738 ML |
8717 | @opindex Wfree-nonheap-object |
8718 | @opindex Wno-free-nonheap-object | |
ddf6fe37 | 8719 | @item -Wfree-nonheap-object |
d77de738 ML |
8720 | Warn when attempting to deallocate an object that was either not allocated |
8721 | on the heap, or by using a pointer that was not returned from a prior call | |
8722 | to the corresponding allocation function. For example, because the call | |
8723 | to @code{stpcpy} returns a pointer to the terminating nul character and | |
8724 | not to the beginning of the object, the call to @code{free} below is | |
8725 | diagnosed. | |
8726 | ||
8727 | @smallexample | |
8728 | void f (char *p) | |
8729 | @{ | |
8730 | p = stpcpy (p, "abc"); | |
8731 | // ... | |
8732 | free (p); // warning | |
8733 | @} | |
8734 | @end smallexample | |
8735 | ||
8736 | @option{-Wfree-nonheap-object} is included in @option{-Wall}. | |
8737 | ||
d77de738 ML |
8738 | @opindex Wstack-usage |
8739 | @opindex Wno-stack-usage | |
ddf6fe37 | 8740 | @item -Wstack-usage=@var{byte-size} |
d77de738 ML |
8741 | Warn if the stack usage of a function might exceed @var{byte-size}. |
8742 | The computation done to determine the stack usage is conservative. | |
8743 | Any space allocated via @code{alloca}, variable-length arrays, or related | |
8744 | constructs is included by the compiler when determining whether or not to | |
8745 | issue a warning. | |
8746 | ||
8747 | The message is in keeping with the output of @option{-fstack-usage}. | |
8748 | ||
8749 | @itemize | |
8750 | @item | |
8751 | If the stack usage is fully static but exceeds the specified amount, it's: | |
8752 | ||
8753 | @smallexample | |
8754 | warning: stack usage is 1120 bytes | |
8755 | @end smallexample | |
8756 | @item | |
8757 | If the stack usage is (partly) dynamic but bounded, it's: | |
8758 | ||
8759 | @smallexample | |
8760 | warning: stack usage might be 1648 bytes | |
8761 | @end smallexample | |
8762 | @item | |
8763 | If the stack usage is (partly) dynamic and not bounded, it's: | |
8764 | ||
8765 | @smallexample | |
8766 | warning: stack usage might be unbounded | |
8767 | @end smallexample | |
8768 | @end itemize | |
8769 | ||
8770 | @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default. | |
8771 | Warnings controlled by the option can be disabled either by specifying | |
8772 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8773 | @option{-Wno-stack-usage}. | |
8774 | ||
d77de738 | 8775 | @opindex Wno-stack-usage |
ddf6fe37 | 8776 | @item -Wno-stack-usage |
d77de738 ML |
8777 | Disable @option{-Wstack-usage=} warnings. The option is equivalent |
8778 | to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger. | |
8779 | ||
d77de738 ML |
8780 | @opindex Wunsafe-loop-optimizations |
8781 | @opindex Wno-unsafe-loop-optimizations | |
ddf6fe37 | 8782 | @item -Wunsafe-loop-optimizations |
d77de738 ML |
8783 | Warn if the loop cannot be optimized because the compiler cannot |
8784 | assume anything on the bounds of the loop indices. With | |
8785 | @option{-funsafe-loop-optimizations} warn if the compiler makes | |
8786 | such assumptions. | |
8787 | ||
d77de738 ML |
8788 | @opindex Wno-pedantic-ms-format |
8789 | @opindex Wpedantic-ms-format | |
ddf6fe37 | 8790 | @item -Wno-pedantic-ms-format @r{(MinGW targets only)} |
d77de738 ML |
8791 | When used in combination with @option{-Wformat} |
8792 | and @option{-pedantic} without GNU extensions, this option | |
8793 | disables the warnings about non-ISO @code{printf} / @code{scanf} format | |
8794 | width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets, | |
8795 | which depend on the MS runtime. | |
8796 | ||
d77de738 ML |
8797 | @opindex Wpointer-arith |
8798 | @opindex Wno-pointer-arith | |
ddf6fe37 | 8799 | @item -Wpointer-arith |
d77de738 ML |
8800 | Warn about anything that depends on the ``size of'' a function type or |
8801 | of @code{void}. GNU C assigns these types a size of 1, for | |
8802 | convenience in calculations with @code{void *} pointers and pointers | |
8803 | to functions. In C++, warn also when an arithmetic operation involves | |
8804 | @code{NULL}. This warning is also enabled by @option{-Wpedantic}. | |
8805 | ||
5fccebdb JM |
8806 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8807 | ||
d77de738 ML |
8808 | @opindex Wpointer-compare |
8809 | @opindex Wno-pointer-compare | |
ddf6fe37 | 8810 | @item -Wno-pointer-compare |
d77de738 ML |
8811 | Do not warn if a pointer is compared with a zero character constant. |
8812 | This usually | |
8813 | means that the pointer was meant to be dereferenced. For example: | |
8814 | ||
8815 | @smallexample | |
8816 | const char *p = foo (); | |
8817 | if (p == '\0') | |
8818 | return 42; | |
8819 | @end smallexample | |
8820 | ||
8821 | Note that the code above is invalid in C++11. | |
8822 | ||
8823 | This warning is enabled by default. | |
8824 | ||
d77de738 ML |
8825 | @opindex Wtsan |
8826 | @opindex Wno-tsan | |
ddf6fe37 | 8827 | @item -Wtsan |
d77de738 ML |
8828 | Warn about unsupported features in ThreadSanitizer. |
8829 | ||
8830 | ThreadSanitizer does not support @code{std::atomic_thread_fence} and | |
8831 | can report false positives. | |
8832 | ||
8833 | This warning is enabled by default. | |
8834 | ||
d77de738 ML |
8835 | @opindex Wtype-limits |
8836 | @opindex Wno-type-limits | |
ddf6fe37 | 8837 | @item -Wtype-limits |
d77de738 ML |
8838 | Warn if a comparison is always true or always false due to the limited |
8839 | range of the data type, but do not warn for constant expressions. For | |
8840 | example, warn if an unsigned variable is compared against zero with | |
8841 | @code{<} or @code{>=}. This warning is also enabled by | |
8842 | @option{-Wextra}. | |
8843 | ||
d77de738 ML |
8844 | @opindex Wabsolute-value |
8845 | @opindex Wno-absolute-value | |
ddf6fe37 | 8846 | @item -Wabsolute-value @r{(C and Objective-C only)} |
d77de738 ML |
8847 | Warn for calls to standard functions that compute the absolute value |
8848 | of an argument when a more appropriate standard function is available. | |
8849 | For example, calling @code{abs(3.14)} triggers the warning because the | |
8850 | appropriate function to call to compute the absolute value of a double | |
8851 | argument is @code{fabs}. The option also triggers warnings when the | |
8852 | argument in a call to such a function has an unsigned type. This | |
8853 | warning can be suppressed with an explicit type cast and it is also | |
8854 | enabled by @option{-Wextra}. | |
8855 | ||
8856 | @include cppwarnopts.texi | |
8857 | ||
d77de738 ML |
8858 | @opindex Wbad-function-cast |
8859 | @opindex Wno-bad-function-cast | |
ddf6fe37 | 8860 | @item -Wbad-function-cast @r{(C and Objective-C only)} |
d77de738 ML |
8861 | Warn when a function call is cast to a non-matching type. |
8862 | For example, warn if a call to a function returning an integer type | |
8863 | is cast to a pointer type. | |
8864 | ||
d77de738 ML |
8865 | @opindex Wc90-c99-compat |
8866 | @opindex Wno-c90-c99-compat | |
ddf6fe37 | 8867 | @item -Wc90-c99-compat @r{(C and Objective-C only)} |
d77de738 ML |
8868 | Warn about features not present in ISO C90, but present in ISO C99. |
8869 | For instance, warn about use of variable length arrays, @code{long long} | |
8870 | type, @code{bool} type, compound literals, designated initializers, and so | |
8871 | on. This option is independent of the standards mode. Warnings are disabled | |
8872 | in the expression that follows @code{__extension__}. | |
8873 | ||
d77de738 ML |
8874 | @opindex Wc99-c11-compat |
8875 | @opindex Wno-c99-c11-compat | |
ddf6fe37 | 8876 | @item -Wc99-c11-compat @r{(C and Objective-C only)} |
d77de738 ML |
8877 | Warn about features not present in ISO C99, but present in ISO C11. |
8878 | For instance, warn about use of anonymous structures and unions, | |
8879 | @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier, | |
8880 | @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword, | |
8881 | and so on. This option is independent of the standards mode. Warnings are | |
8882 | disabled in the expression that follows @code{__extension__}. | |
8883 | ||
d77de738 ML |
8884 | @opindex Wc11-c2x-compat |
8885 | @opindex Wno-c11-c2x-compat | |
ddf6fe37 | 8886 | @item -Wc11-c2x-compat @r{(C and Objective-C only)} |
d77de738 ML |
8887 | Warn about features not present in ISO C11, but present in ISO C2X. |
8888 | For instance, warn about omitting the string in @code{_Static_assert}, | |
8889 | use of @samp{[[]]} syntax for attributes, use of decimal | |
8890 | floating-point types, and so on. This option is independent of the | |
8891 | standards mode. Warnings are disabled in the expression that follows | |
8892 | @code{__extension__}. | |
8893 | ||
5fccebdb JM |
8894 | When not compiling in C2X mode, these warnings are upgraded to errors |
8895 | by @option{-pedantic-errors}. | |
8896 | ||
d77de738 ML |
8897 | @opindex Wc++-compat |
8898 | @opindex Wno-c++-compat | |
ddf6fe37 | 8899 | @item -Wc++-compat @r{(C and Objective-C only)} |
d77de738 ML |
8900 | Warn about ISO C constructs that are outside of the common subset of |
8901 | ISO C and ISO C++, e.g.@: request for implicit conversion from | |
8902 | @code{void *} to a pointer to non-@code{void} type. | |
8903 | ||
d77de738 ML |
8904 | @opindex Wc++11-compat |
8905 | @opindex Wno-c++11-compat | |
ddf6fe37 | 8906 | @item -Wc++11-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8907 | Warn about C++ constructs whose meaning differs between ISO C++ 1998 |
8908 | and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords | |
8909 | in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is | |
8910 | enabled by @option{-Wall}. | |
8911 | ||
d77de738 ML |
8912 | @opindex Wc++14-compat |
8913 | @opindex Wno-c++14-compat | |
ddf6fe37 | 8914 | @item -Wc++14-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8915 | Warn about C++ constructs whose meaning differs between ISO C++ 2011 |
8916 | and ISO C++ 2014. This warning is enabled by @option{-Wall}. | |
8917 | ||
d77de738 ML |
8918 | @opindex Wc++17-compat |
8919 | @opindex Wno-c++17-compat | |
ddf6fe37 | 8920 | @item -Wc++17-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8921 | Warn about C++ constructs whose meaning differs between ISO C++ 2014 |
8922 | and ISO C++ 2017. This warning is enabled by @option{-Wall}. | |
8923 | ||
d77de738 ML |
8924 | @opindex Wc++20-compat |
8925 | @opindex Wno-c++20-compat | |
ddf6fe37 | 8926 | @item -Wc++20-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8927 | Warn about C++ constructs whose meaning differs between ISO C++ 2017 |
8928 | and ISO C++ 2020. This warning is enabled by @option{-Wall}. | |
8929 | ||
d77de738 ML |
8930 | @opindex Wc++11-extensions |
8931 | @opindex Wno-c++11-extensions | |
ddf6fe37 | 8932 | @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8933 | Do not warn about C++11 constructs in code being compiled using |
8934 | an older C++ standard. Even without this option, some C++11 constructs | |
8935 | will only be diagnosed if @option{-Wpedantic} is used. | |
8936 | ||
d77de738 ML |
8937 | @opindex Wc++14-extensions |
8938 | @opindex Wno-c++14-extensions | |
ddf6fe37 | 8939 | @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8940 | Do not warn about C++14 constructs in code being compiled using |
8941 | an older C++ standard. Even without this option, some C++14 constructs | |
8942 | will only be diagnosed if @option{-Wpedantic} is used. | |
8943 | ||
d77de738 ML |
8944 | @opindex Wc++17-extensions |
8945 | @opindex Wno-c++17-extensions | |
ddf6fe37 | 8946 | @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8947 | Do not warn about C++17 constructs in code being compiled using |
8948 | an older C++ standard. Even without this option, some C++17 constructs | |
8949 | will only be diagnosed if @option{-Wpedantic} is used. | |
8950 | ||
d77de738 ML |
8951 | @opindex Wc++20-extensions |
8952 | @opindex Wno-c++20-extensions | |
ddf6fe37 | 8953 | @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8954 | Do not warn about C++20 constructs in code being compiled using |
8955 | an older C++ standard. Even without this option, some C++20 constructs | |
8956 | will only be diagnosed if @option{-Wpedantic} is used. | |
8957 | ||
d77de738 ML |
8958 | @opindex Wc++23-extensions |
8959 | @opindex Wno-c++23-extensions | |
ddf6fe37 | 8960 | @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8961 | Do not warn about C++23 constructs in code being compiled using |
8962 | an older C++ standard. Even without this option, some C++23 constructs | |
8963 | will only be diagnosed if @option{-Wpedantic} is used. | |
8964 | ||
d77de738 ML |
8965 | @opindex Wcast-qual |
8966 | @opindex Wno-cast-qual | |
ddf6fe37 | 8967 | @item -Wcast-qual |
d77de738 ML |
8968 | Warn whenever a pointer is cast so as to remove a type qualifier from |
8969 | the target type. For example, warn if a @code{const char *} is cast | |
8970 | to an ordinary @code{char *}. | |
8971 | ||
8972 | Also warn when making a cast that introduces a type qualifier in an | |
8973 | unsafe way. For example, casting @code{char **} to @code{const char **} | |
8974 | is unsafe, as in this example: | |
8975 | ||
8976 | @smallexample | |
8977 | /* p is char ** value. */ | |
8978 | const char **q = (const char **) p; | |
8979 | /* Assignment of readonly string to const char * is OK. */ | |
8980 | *q = "string"; | |
8981 | /* Now char** pointer points to read-only memory. */ | |
8982 | **p = 'b'; | |
8983 | @end smallexample | |
8984 | ||
d77de738 ML |
8985 | @opindex Wcast-align |
8986 | @opindex Wno-cast-align | |
ddf6fe37 | 8987 | @item -Wcast-align |
d77de738 ML |
8988 | Warn whenever a pointer is cast such that the required alignment of the |
8989 | target is increased. For example, warn if a @code{char *} is cast to | |
8990 | an @code{int *} on machines where integers can only be accessed at | |
8991 | two- or four-byte boundaries. | |
8992 | ||
d77de738 | 8993 | @opindex Wcast-align=strict |
ddf6fe37 | 8994 | @item -Wcast-align=strict |
d77de738 ML |
8995 | Warn whenever a pointer is cast such that the required alignment of the |
8996 | target is increased. For example, warn if a @code{char *} is cast to | |
8997 | an @code{int *} regardless of the target machine. | |
8998 | ||
d77de738 ML |
8999 | @opindex Wcast-function-type |
9000 | @opindex Wno-cast-function-type | |
ddf6fe37 | 9001 | @item -Wcast-function-type |
d77de738 ML |
9002 | Warn when a function pointer is cast to an incompatible function pointer. |
9003 | In a cast involving function types with a variable argument list only | |
9004 | the types of initial arguments that are provided are considered. | |
9005 | Any parameter of pointer-type matches any other pointer-type. Any benign | |
9006 | differences in integral types are ignored, like @code{int} vs.@: @code{long} | |
9007 | on ILP32 targets. Likewise type qualifiers are ignored. The function | |
9008 | type @code{void (*) (void)} is special and matches everything, which can | |
9009 | be used to suppress this warning. | |
9010 | In a cast involving pointer to member types this warning warns whenever | |
9011 | the type cast is changing the pointer to member type. | |
9012 | This warning is enabled by @option{-Wextra}. | |
9013 | ||
d77de738 ML |
9014 | @opindex Wwrite-strings |
9015 | @opindex Wno-write-strings | |
ddf6fe37 | 9016 | @item -Wwrite-strings |
d77de738 ML |
9017 | When compiling C, give string constants the type @code{const |
9018 | char[@var{length}]} so that copying the address of one into a | |
9019 | non-@code{const} @code{char *} pointer produces a warning. These | |
9020 | warnings help you find at compile time code that can try to write | |
9021 | into a string constant, but only if you have been very careful about | |
9022 | using @code{const} in declarations and prototypes. Otherwise, it is | |
9023 | just a nuisance. This is why we did not make @option{-Wall} request | |
9024 | these warnings. | |
9025 | ||
9026 | When compiling C++, warn about the deprecated conversion from string | |
9027 | literals to @code{char *}. This warning is enabled by default for C++ | |
9028 | programs. | |
9029 | ||
5fccebdb JM |
9030 | This warning is upgraded to an error by @option{-pedantic-errors} in |
9031 | C++11 mode or later. | |
9032 | ||
d77de738 ML |
9033 | @opindex Wclobbered |
9034 | @opindex Wno-clobbered | |
f33d7a88 | 9035 | @item -Wclobbered |
d77de738 ML |
9036 | Warn for variables that might be changed by @code{longjmp} or |
9037 | @code{vfork}. This warning is also enabled by @option{-Wextra}. | |
9038 | ||
320dc51c TS |
9039 | @opindex Wcomplain-wrong-lang |
9040 | @opindex Wno-complain-wrong-lang | |
f33d7a88 | 9041 | @item -Wno-complain-wrong-lang |
320dc51c TS |
9042 | By default, language front ends complain when a command-line option is |
9043 | valid, but not applicable to that front end. | |
9044 | This may be disabled with @option{-Wno-complain-wrong-lang}, | |
9045 | which is mostly useful when invoking a single compiler driver for | |
9046 | multiple source files written in different languages, for example: | |
9047 | ||
9048 | @smallexample | |
9049 | $ g++ -fno-rtti a.cc b.f90 | |
9050 | @end smallexample | |
9051 | ||
9052 | The driver @file{g++} invokes the C++ front end to compile @file{a.cc} | |
9053 | and the Fortran front end to compile @file{b.f90}. | |
9054 | The latter front end diagnoses | |
9055 | @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran}, | |
9056 | which may be disabled with @option{-Wno-complain-wrong-lang}. | |
9057 | ||
d77de738 ML |
9058 | @opindex Wconversion |
9059 | @opindex Wno-conversion | |
f33d7a88 | 9060 | @item -Wconversion |
d77de738 ML |
9061 | Warn for implicit conversions that may alter a value. This includes |
9062 | conversions between real and integer, like @code{abs (x)} when | |
9063 | @code{x} is @code{double}; conversions between signed and unsigned, | |
9064 | like @code{unsigned ui = -1}; and conversions to smaller types, like | |
9065 | @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs | |
9066 | ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not | |
9067 | changed by the conversion like in @code{abs (2.0)}. Warnings about | |
9068 | conversions between signed and unsigned integers can be disabled by | |
9069 | using @option{-Wno-sign-conversion}. | |
9070 | ||
9071 | For C++, also warn for confusing overload resolution for user-defined | |
9072 | conversions; and conversions that never use a type conversion | |
9073 | operator: conversions to @code{void}, the same type, a base class or a | |
9074 | reference to them. Warnings about conversions between signed and | |
9075 | unsigned integers are disabled by default in C++ unless | |
9076 | @option{-Wsign-conversion} is explicitly enabled. | |
9077 | ||
9078 | Warnings about conversion from arithmetic on a small type back to that | |
9079 | type are only given with @option{-Warith-conversion}. | |
9080 | ||
d77de738 ML |
9081 | @opindex Wdangling-else |
9082 | @opindex Wno-dangling-else | |
ddf6fe37 | 9083 | @item -Wdangling-else |
d77de738 ML |
9084 | Warn about constructions where there may be confusion to which |
9085 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
9086 | such a case: | |
9087 | ||
9088 | @smallexample | |
9089 | @group | |
9090 | @{ | |
9091 | if (a) | |
9092 | if (b) | |
9093 | foo (); | |
9094 | else | |
9095 | bar (); | |
9096 | @} | |
9097 | @end group | |
9098 | @end smallexample | |
9099 | ||
9100 | In C/C++, every @code{else} branch belongs to the innermost possible | |
9101 | @code{if} statement, which in this example is @code{if (b)}. This is | |
9102 | often not what the programmer expected, as illustrated in the above | |
9103 | example by indentation the programmer chose. When there is the | |
9104 | potential for this confusion, GCC issues a warning when this flag | |
9105 | is specified. To eliminate the warning, add explicit braces around | |
9106 | the innermost @code{if} statement so there is no way the @code{else} | |
9107 | can belong to the enclosing @code{if}. The resulting code | |
9108 | looks like this: | |
9109 | ||
9110 | @smallexample | |
9111 | @group | |
9112 | @{ | |
9113 | if (a) | |
9114 | @{ | |
9115 | if (b) | |
9116 | foo (); | |
9117 | else | |
9118 | bar (); | |
9119 | @} | |
9120 | @} | |
9121 | @end group | |
9122 | @end smallexample | |
9123 | ||
9124 | This warning is enabled by @option{-Wparentheses}. | |
9125 | ||
d77de738 ML |
9126 | @opindex Wdangling-pointer |
9127 | @opindex Wno-dangling-pointer | |
ddf6fe37 AA |
9128 | @item -Wdangling-pointer |
9129 | @itemx -Wdangling-pointer=@var{n} | |
d77de738 ML |
9130 | Warn about uses of pointers (or C++ references) to objects with automatic |
9131 | storage duration after their lifetime has ended. This includes local | |
9132 | variables declared in nested blocks, compound literals and other unnamed | |
9133 | temporary objects. In addition, warn about storing the address of such | |
9134 | objects in escaped pointers. The warning is enabled at all optimization | |
9135 | levels but may yield different results with optimization than without. | |
9136 | ||
9137 | @table @gcctabopt | |
9138 | @item -Wdangling-pointer=1 | |
9139 | At level 1 the warning diagnoses only unconditional uses of dangling pointers. | |
9140 | For example | |
9141 | @smallexample | |
9142 | int f (int c1, int c2, x) | |
9143 | @{ | |
9144 | char *p = strchr ((char[])@{ c1, c2 @}, c3); | |
4ace81b6 SL |
9145 | // warning: dangling pointer to a compound literal |
9146 | return p ? *p : 'x'; | |
d77de738 ML |
9147 | @} |
9148 | @end smallexample | |
9149 | In the following function the store of the address of the local variable | |
9150 | @code{x} in the escaped pointer @code{*p} also triggers the warning. | |
9151 | @smallexample | |
9152 | void g (int **p) | |
9153 | @{ | |
9154 | int x = 7; | |
4ace81b6 SL |
9155 | // warning: storing the address of a local variable in *p |
9156 | *p = &x; | |
d77de738 ML |
9157 | @} |
9158 | @end smallexample | |
9159 | ||
9160 | @item -Wdangling-pointer=2 | |
9161 | At level 2, in addition to unconditional uses the warning also diagnoses | |
9162 | conditional uses of dangling pointers. | |
9163 | ||
9164 | For example, because the array @var{a} in the following function is out of | |
9165 | scope when the pointer @var{s} that was set to point is used, the warning | |
9166 | triggers at this level. | |
9167 | ||
9168 | @smallexample | |
9169 | void f (char *s) | |
9170 | @{ | |
9171 | if (!s) | |
9172 | @{ | |
9173 | char a[12] = "tmpname"; | |
9174 | s = a; | |
9175 | @} | |
4ace81b6 SL |
9176 | // warning: dangling pointer to a may be used |
9177 | strcat (s, ".tmp"); | |
d77de738 ML |
9178 | ... |
9179 | @} | |
9180 | @end smallexample | |
9181 | @end table | |
9182 | ||
9183 | @option{-Wdangling-pointer=2} is included in @option{-Wall}. | |
9184 | ||
d77de738 ML |
9185 | @opindex Wdate-time |
9186 | @opindex Wno-date-time | |
ddf6fe37 | 9187 | @item -Wdate-time |
d77de738 ML |
9188 | Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__} |
9189 | are encountered as they might prevent bit-wise-identical reproducible | |
9190 | compilations. | |
9191 | ||
d77de738 ML |
9192 | @opindex Wempty-body |
9193 | @opindex Wno-empty-body | |
ddf6fe37 | 9194 | @item -Wempty-body |
d77de738 ML |
9195 | Warn if an empty body occurs in an @code{if}, @code{else} or @code{do |
9196 | while} statement. This warning is also enabled by @option{-Wextra}. | |
9197 | ||
d77de738 ML |
9198 | @opindex Wendif-labels |
9199 | @opindex Wno-endif-labels | |
ddf6fe37 | 9200 | @item -Wno-endif-labels |
d77de738 ML |
9201 | Do not warn about stray tokens after @code{#else} and @code{#endif}. |
9202 | ||
d77de738 ML |
9203 | @opindex Wenum-compare |
9204 | @opindex Wno-enum-compare | |
ddf6fe37 | 9205 | @item -Wenum-compare |
d77de738 ML |
9206 | Warn about a comparison between values of different enumerated types. |
9207 | In C++ enumerated type mismatches in conditional expressions are also | |
9208 | diagnosed and the warning is enabled by default. In C this warning is | |
9209 | enabled by @option{-Wall}. | |
9210 | ||
d77de738 ML |
9211 | @opindex Wenum-conversion |
9212 | @opindex Wno-enum-conversion | |
ddf6fe37 | 9213 | @item -Wenum-conversion |
d77de738 ML |
9214 | Warn when a value of enumerated type is implicitly converted to a |
9215 | different enumerated type. This warning is enabled by @option{-Wextra} | |
9216 | in C@. | |
9217 | ||
d77de738 ML |
9218 | @opindex Wenum-int-mismatch |
9219 | @opindex Wno-enum-int-mismatch | |
ddf6fe37 | 9220 | @item -Wenum-int-mismatch @r{(C and Objective-C only)} |
d77de738 ML |
9221 | Warn about mismatches between an enumerated type and an integer type in |
9222 | declarations. For example: | |
9223 | ||
9224 | @smallexample | |
9225 | enum E @{ l = -1, z = 0, g = 1 @}; | |
9226 | int foo(void); | |
9227 | enum E foo(void); | |
9228 | @end smallexample | |
9229 | ||
9230 | In C, an enumerated type is compatible with @code{char}, a signed | |
9231 | integer type, or an unsigned integer type. However, since the choice | |
9232 | of the underlying type of an enumerated type is implementation-defined, | |
9233 | such mismatches may cause portability issues. In C++, such mismatches | |
9234 | are an error. In C, this warning is enabled by @option{-Wall} and | |
9235 | @option{-Wc++-compat}. | |
9236 | ||
d77de738 ML |
9237 | @opindex Wjump-misses-init |
9238 | @opindex Wno-jump-misses-init | |
ddf6fe37 | 9239 | @item -Wjump-misses-init @r{(C, Objective-C only)} |
d77de738 ML |
9240 | Warn if a @code{goto} statement or a @code{switch} statement jumps |
9241 | forward across the initialization of a variable, or jumps backward to a | |
9242 | label after the variable has been initialized. This only warns about | |
9243 | variables that are initialized when they are declared. This warning is | |
9244 | only supported for C and Objective-C; in C++ this sort of branch is an | |
9245 | error in any case. | |
9246 | ||
9247 | @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It | |
9248 | can be disabled with the @option{-Wno-jump-misses-init} option. | |
9249 | ||
d77de738 ML |
9250 | @opindex Wsign-compare |
9251 | @opindex Wno-sign-compare | |
9252 | @cindex warning for comparison of signed and unsigned values | |
9253 | @cindex comparison of signed and unsigned values, warning | |
9254 | @cindex signed and unsigned values, comparison warning | |
f33d7a88 | 9255 | @item -Wsign-compare |
d77de738 ML |
9256 | Warn when a comparison between signed and unsigned values could produce |
9257 | an incorrect result when the signed value is converted to unsigned. | |
9258 | In C++, this warning is also enabled by @option{-Wall}. In C, it is | |
9259 | also enabled by @option{-Wextra}. | |
9260 | ||
d77de738 ML |
9261 | @opindex Wsign-conversion |
9262 | @opindex Wno-sign-conversion | |
ddf6fe37 | 9263 | @item -Wsign-conversion |
d77de738 ML |
9264 | Warn for implicit conversions that may change the sign of an integer |
9265 | value, like assigning a signed integer expression to an unsigned | |
9266 | integer variable. An explicit cast silences the warning. In C, this | |
9267 | option is enabled also by @option{-Wconversion}. | |
9268 | ||
d77de738 ML |
9269 | @opindex Wfloat-conversion |
9270 | @opindex Wno-float-conversion | |
ddf6fe37 | 9271 | @item -Wfloat-conversion |
d77de738 ML |
9272 | Warn for implicit conversions that reduce the precision of a real value. |
9273 | This includes conversions from real to integer, and from higher precision | |
9274 | real to lower precision real values. This option is also enabled by | |
9275 | @option{-Wconversion}. | |
9276 | ||
d77de738 ML |
9277 | @opindex Wno-scalar-storage-order |
9278 | @opindex Wscalar-storage-order | |
ddf6fe37 | 9279 | @item -Wno-scalar-storage-order |
d77de738 ML |
9280 | Do not warn on suspicious constructs involving reverse scalar storage order. |
9281 | ||
d77de738 ML |
9282 | @opindex Wsizeof-array-div |
9283 | @opindex Wno-sizeof-array-div | |
ddf6fe37 | 9284 | @item -Wsizeof-array-div |
d77de738 ML |
9285 | Warn about divisions of two sizeof operators when the first one is applied |
9286 | to an array and the divisor does not equal the size of the array element. | |
9287 | In such a case, the computation will not yield the number of elements in the | |
9288 | array, which is likely what the user intended. This warning warns e.g. about | |
9289 | @smallexample | |
9290 | int fn () | |
9291 | @{ | |
9292 | int arr[10]; | |
9293 | return sizeof (arr) / sizeof (short); | |
9294 | @} | |
9295 | @end smallexample | |
9296 | ||
9297 | This warning is enabled by @option{-Wall}. | |
9298 | ||
d77de738 ML |
9299 | @opindex Wsizeof-pointer-div |
9300 | @opindex Wno-sizeof-pointer-div | |
ddf6fe37 | 9301 | @item -Wsizeof-pointer-div |
d77de738 ML |
9302 | Warn for suspicious divisions of two sizeof expressions that divide |
9303 | the pointer size by the element size, which is the usual way to compute | |
9304 | the array size but won't work out correctly with pointers. This warning | |
9305 | warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is | |
9306 | not an array, but a pointer. This warning is enabled by @option{-Wall}. | |
9307 | ||
d77de738 ML |
9308 | @opindex Wsizeof-pointer-memaccess |
9309 | @opindex Wno-sizeof-pointer-memaccess | |
ddf6fe37 | 9310 | @item -Wsizeof-pointer-memaccess |
d77de738 ML |
9311 | Warn for suspicious length parameters to certain string and memory built-in |
9312 | functions if the argument uses @code{sizeof}. This warning triggers for | |
9313 | example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not | |
9314 | an array, but a pointer, and suggests a possible fix, or about | |
9315 | @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess} | |
9316 | also warns about calls to bounded string copy functions like @code{strncat} | |
9317 | or @code{strncpy} that specify as the bound a @code{sizeof} expression of | |
9318 | the source array. For example, in the following function the call to | |
9319 | @code{strncat} specifies the size of the source string as the bound. That | |
9320 | is almost certainly a mistake and so the call is diagnosed. | |
9321 | @smallexample | |
9322 | void make_file (const char *name) | |
9323 | @{ | |
9324 | char path[PATH_MAX]; | |
9325 | strncpy (path, name, sizeof path - 1); | |
9326 | strncat (path, ".text", sizeof ".text"); | |
9327 | @dots{} | |
9328 | @} | |
9329 | @end smallexample | |
9330 | ||
9331 | The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}. | |
9332 | ||
d77de738 ML |
9333 | @opindex Wsizeof-array-argument |
9334 | @opindex Wno-sizeof-array-argument | |
ddf6fe37 | 9335 | @item -Wno-sizeof-array-argument |
d77de738 ML |
9336 | Do not warn when the @code{sizeof} operator is applied to a parameter that is |
9337 | declared as an array in a function definition. This warning is enabled by | |
9338 | default for C and C++ programs. | |
9339 | ||
d77de738 ML |
9340 | @opindex Wmemset-elt-size |
9341 | @opindex Wno-memset-elt-size | |
ddf6fe37 | 9342 | @item -Wmemset-elt-size |
d77de738 ML |
9343 | Warn for suspicious calls to the @code{memset} built-in function, if the |
9344 | first argument references an array, and the third argument is a number | |
9345 | equal to the number of elements, but not equal to the size of the array | |
9346 | in memory. This indicates that the user has omitted a multiplication by | |
9347 | the element size. This warning is enabled by @option{-Wall}. | |
9348 | ||
d77de738 ML |
9349 | @opindex Wmemset-transposed-args |
9350 | @opindex Wno-memset-transposed-args | |
ddf6fe37 | 9351 | @item -Wmemset-transposed-args |
d77de738 ML |
9352 | Warn for suspicious calls to the @code{memset} built-in function where |
9353 | the second argument is not zero and the third argument is zero. For | |
9354 | example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because | |
9355 | @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic | |
9356 | is only emitted if the third argument is a literal zero. Otherwise, if | |
9357 | it is an expression that is folded to zero, or a cast of zero to some | |
9358 | type, it is far less likely that the arguments have been mistakenly | |
9359 | transposed and no warning is emitted. This warning is enabled | |
9360 | by @option{-Wall}. | |
9361 | ||
d77de738 ML |
9362 | @opindex Waddress |
9363 | @opindex Wno-address | |
ddf6fe37 | 9364 | @item -Waddress |
d77de738 ML |
9365 | Warn about suspicious uses of address expressions. These include comparing |
9366 | the address of a function or a declared object to the null pointer constant | |
9367 | such as in | |
9368 | @smallexample | |
9369 | void f (void); | |
9370 | void g (void) | |
9371 | @{ | |
9372 | if (!f) // warning: expression evaluates to false | |
9373 | abort (); | |
9374 | @} | |
9375 | @end smallexample | |
9376 | comparisons of a pointer to a string literal, such as in | |
9377 | @smallexample | |
9378 | void f (const char *x) | |
9379 | @{ | |
9380 | if (x == "abc") // warning: expression evaluates to false | |
9381 | puts ("equal"); | |
9382 | @} | |
9383 | @end smallexample | |
9384 | and tests of the results of pointer addition or subtraction for equality | |
9385 | to null, such as in | |
9386 | @smallexample | |
9387 | void f (const int *p, int i) | |
9388 | @{ | |
9389 | return p + i == NULL; | |
9390 | @} | |
9391 | @end smallexample | |
9392 | Such uses typically indicate a programmer error: the address of most | |
9393 | functions and objects necessarily evaluates to true (the exception are | |
9394 | weak symbols), so their use in a conditional might indicate missing | |
9395 | parentheses in a function call or a missing dereference in an array | |
9396 | expression. The subset of the warning for object pointers can be | |
9397 | suppressed by casting the pointer operand to an integer type such | |
9398 | as @code{intptr_t} or @code{uintptr_t}. | |
9399 | Comparisons against string literals result in unspecified behavior | |
9400 | and are not portable, and suggest the intent was to call @code{strcmp}. | |
9401 | The warning is suppressed if the suspicious expression is the result | |
9402 | of macro expansion. | |
9403 | @option{-Waddress} warning is enabled by @option{-Wall}. | |
9404 | ||
d77de738 ML |
9405 | @opindex Waddress-of-packed-member |
9406 | @opindex Wno-address-of-packed-member | |
ddf6fe37 | 9407 | @item -Wno-address-of-packed-member |
d77de738 ML |
9408 | Do not warn when the address of packed member of struct or union is taken, |
9409 | which usually results in an unaligned pointer value. This is | |
9410 | enabled by default. | |
9411 | ||
d77de738 ML |
9412 | @opindex Wlogical-op |
9413 | @opindex Wno-logical-op | |
ddf6fe37 | 9414 | @item -Wlogical-op |
d77de738 ML |
9415 | Warn about suspicious uses of logical operators in expressions. |
9416 | This includes using logical operators in contexts where a | |
9417 | bit-wise operator is likely to be expected. Also warns when | |
9418 | the operands of a logical operator are the same: | |
9419 | @smallexample | |
9420 | extern int a; | |
9421 | if (a < 0 && a < 0) @{ @dots{} @} | |
9422 | @end smallexample | |
9423 | ||
d77de738 ML |
9424 | @opindex Wlogical-not-parentheses |
9425 | @opindex Wno-logical-not-parentheses | |
ddf6fe37 | 9426 | @item -Wlogical-not-parentheses |
d77de738 ML |
9427 | Warn about logical not used on the left hand side operand of a comparison. |
9428 | This option does not warn if the right operand is considered to be a boolean | |
9429 | expression. Its purpose is to detect suspicious code like the following: | |
9430 | @smallexample | |
9431 | int a; | |
9432 | @dots{} | |
9433 | if (!a > 1) @{ @dots{} @} | |
9434 | @end smallexample | |
9435 | ||
9436 | It is possible to suppress the warning by wrapping the LHS into | |
9437 | parentheses: | |
9438 | @smallexample | |
9439 | if ((!a) > 1) @{ @dots{} @} | |
9440 | @end smallexample | |
9441 | ||
9442 | This warning is enabled by @option{-Wall}. | |
9443 | ||
d77de738 ML |
9444 | @opindex Waggregate-return |
9445 | @opindex Wno-aggregate-return | |
ddf6fe37 | 9446 | @item -Waggregate-return |
d77de738 ML |
9447 | Warn if any functions that return structures or unions are defined or |
9448 | called. (In languages where you can return an array, this also elicits | |
9449 | a warning.) | |
9450 | ||
d77de738 ML |
9451 | @opindex Wno-aggressive-loop-optimizations |
9452 | @opindex Waggressive-loop-optimizations | |
ddf6fe37 | 9453 | @item -Wno-aggressive-loop-optimizations |
d77de738 ML |
9454 | Warn if in a loop with constant number of iterations the compiler detects |
9455 | undefined behavior in some statement during one or more of the iterations. | |
9456 | ||
d77de738 ML |
9457 | @opindex Wno-attributes |
9458 | @opindex Wattributes | |
ddf6fe37 | 9459 | @item -Wno-attributes |
d77de738 ML |
9460 | Do not warn if an unexpected @code{__attribute__} is used, such as |
9461 | unrecognized attributes, function attributes applied to variables, | |
9462 | etc. This does not stop errors for incorrect use of supported | |
9463 | attributes. | |
9464 | ||
5fccebdb JM |
9465 | Warnings about ill-formed uses of standard attributes are upgraded to |
9466 | errors by @option{-pedantic-errors}. | |
9467 | ||
d77de738 ML |
9468 | Additionally, using @option{-Wno-attributes=}, it is possible to suppress |
9469 | warnings about unknown scoped attributes (in C++11 and C2X). For example, | |
9470 | @option{-Wno-attributes=vendor::attr} disables warning about the following | |
9471 | declaration: | |
9472 | ||
9473 | @smallexample | |
9474 | [[vendor::attr]] void f(); | |
9475 | @end smallexample | |
9476 | ||
9477 | It is also possible to disable warning about all attributes in a namespace | |
9478 | using @option{-Wno-attributes=vendor::} which prevents warning about both | |
9479 | of these declarations: | |
9480 | ||
9481 | @smallexample | |
9482 | [[vendor::safe]] void f(); | |
9483 | [[vendor::unsafe]] void f2(); | |
9484 | @end smallexample | |
9485 | ||
9486 | Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}. | |
9487 | ||
d77de738 ML |
9488 | @opindex Wno-builtin-declaration-mismatch |
9489 | @opindex Wbuiltin-declaration-mismatch | |
ddf6fe37 | 9490 | @item -Wno-builtin-declaration-mismatch |
d77de738 ML |
9491 | Warn if a built-in function is declared with an incompatible signature |
9492 | or as a non-function, or when a built-in function declared with a type | |
9493 | that does not include a prototype is called with arguments whose promoted | |
9494 | types do not match those expected by the function. When @option{-Wextra} | |
9495 | is specified, also warn when a built-in function that takes arguments is | |
9496 | declared without a prototype. The @option{-Wbuiltin-declaration-mismatch} | |
9497 | warning is enabled by default. To avoid the warning include the appropriate | |
9498 | header to bring the prototypes of built-in functions into scope. | |
9499 | ||
9500 | For example, the call to @code{memset} below is diagnosed by the warning | |
9501 | because the function expects a value of type @code{size_t} as its argument | |
9502 | but the type of @code{32} is @code{int}. With @option{-Wextra}, | |
9503 | the declaration of the function is diagnosed as well. | |
9504 | @smallexample | |
9505 | extern void* memset (); | |
9506 | void f (void *d) | |
9507 | @{ | |
9508 | memset (d, '\0', 32); | |
9509 | @} | |
9510 | @end smallexample | |
9511 | ||
d77de738 ML |
9512 | @opindex Wno-builtin-macro-redefined |
9513 | @opindex Wbuiltin-macro-redefined | |
ddf6fe37 | 9514 | @item -Wno-builtin-macro-redefined |
d77de738 ML |
9515 | Do not warn if certain built-in macros are redefined. This suppresses |
9516 | warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__}, | |
9517 | @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}. | |
9518 | ||
d77de738 ML |
9519 | @opindex Wstrict-prototypes |
9520 | @opindex Wno-strict-prototypes | |
ddf6fe37 | 9521 | @item -Wstrict-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9522 | Warn if a function is declared or defined without specifying the |
9523 | argument types. (An old-style function definition is permitted without | |
9524 | a warning if preceded by a declaration that specifies the argument | |
9525 | types.) | |
9526 | ||
d77de738 ML |
9527 | @opindex Wold-style-declaration |
9528 | @opindex Wno-old-style-declaration | |
ddf6fe37 | 9529 | @item -Wold-style-declaration @r{(C and Objective-C only)} |
d77de738 ML |
9530 | Warn for obsolescent usages, according to the C Standard, in a |
9531 | declaration. For example, warn if storage-class specifiers like | |
9532 | @code{static} are not the first things in a declaration. This warning | |
9533 | is also enabled by @option{-Wextra}. | |
9534 | ||
d77de738 ML |
9535 | @opindex Wold-style-definition |
9536 | @opindex Wno-old-style-definition | |
ddf6fe37 | 9537 | @item -Wold-style-definition @r{(C and Objective-C only)} |
d77de738 ML |
9538 | Warn if an old-style function definition is used. A warning is given |
9539 | even if there is a previous prototype. A definition using @samp{()} | |
9540 | is not considered an old-style definition in C2X mode, because it is | |
9541 | equivalent to @samp{(void)} in that case, but is considered an | |
9542 | old-style definition for older standards. | |
9543 | ||
d77de738 ML |
9544 | @opindex Wmissing-parameter-type |
9545 | @opindex Wno-missing-parameter-type | |
ddf6fe37 | 9546 | @item -Wmissing-parameter-type @r{(C and Objective-C only)} |
d77de738 ML |
9547 | A function parameter is declared without a type specifier in K&R-style |
9548 | functions: | |
9549 | ||
9550 | @smallexample | |
9551 | void foo(bar) @{ @} | |
9552 | @end smallexample | |
9553 | ||
9554 | This warning is also enabled by @option{-Wextra}. | |
9555 | ||
d77de738 ML |
9556 | @opindex Wmissing-prototypes |
9557 | @opindex Wno-missing-prototypes | |
ddf6fe37 | 9558 | @item -Wmissing-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9559 | Warn if a global function is defined without a previous prototype |
9560 | declaration. This warning is issued even if the definition itself | |
9561 | provides a prototype. Use this option to detect global functions | |
9562 | that do not have a matching prototype declaration in a header file. | |
9563 | This option is not valid for C++ because all function declarations | |
9564 | provide prototypes and a non-matching declaration declares an | |
9565 | overload rather than conflict with an earlier declaration. | |
9566 | Use @option{-Wmissing-declarations} to detect missing declarations in C++. | |
9567 | ||
d77de738 ML |
9568 | @opindex Wmissing-declarations |
9569 | @opindex Wno-missing-declarations | |
ddf6fe37 | 9570 | @item -Wmissing-declarations |
d77de738 ML |
9571 | Warn if a global function is defined without a previous declaration. |
9572 | Do so even if the definition itself provides a prototype. | |
9573 | Use this option to detect global functions that are not declared in | |
9574 | header files. In C, no warnings are issued for functions with previous | |
9575 | non-prototype declarations; use @option{-Wmissing-prototypes} to detect | |
9576 | missing prototypes. In C++, no warnings are issued for function templates, | |
9577 | or for inline functions, or for functions in anonymous namespaces. | |
9578 | ||
d77de738 ML |
9579 | @opindex Wmissing-field-initializers |
9580 | @opindex Wno-missing-field-initializers | |
9581 | @opindex W | |
9582 | @opindex Wextra | |
9583 | @opindex Wno-extra | |
ddf6fe37 | 9584 | @item -Wmissing-field-initializers |
d77de738 ML |
9585 | Warn if a structure's initializer has some fields missing. For |
9586 | example, the following code causes such a warning, because | |
9587 | @code{x.h} is implicitly zero: | |
9588 | ||
9589 | @smallexample | |
9590 | struct s @{ int f, g, h; @}; | |
9591 | struct s x = @{ 3, 4 @}; | |
9592 | @end smallexample | |
9593 | ||
0f8f1dee MP |
9594 | @c It's unclear if this behavior is desirable. See PR39589 and PR96868. |
9595 | In C this option does not warn about designated initializers, so the | |
9596 | following modification does not trigger a warning: | |
d77de738 ML |
9597 | |
9598 | @smallexample | |
9599 | struct s @{ int f, g, h; @}; | |
9600 | struct s x = @{ .f = 3, .g = 4 @}; | |
9601 | @end smallexample | |
9602 | ||
9603 | In C this option does not warn about the universal zero initializer | |
9604 | @samp{@{ 0 @}}: | |
9605 | ||
9606 | @smallexample | |
9607 | struct s @{ int f, g, h; @}; | |
9608 | struct s x = @{ 0 @}; | |
9609 | @end smallexample | |
9610 | ||
9611 | Likewise, in C++ this option does not warn about the empty @{ @} | |
9612 | initializer, for example: | |
9613 | ||
9614 | @smallexample | |
9615 | struct s @{ int f, g, h; @}; | |
9616 | s x = @{ @}; | |
9617 | @end smallexample | |
9618 | ||
9619 | This warning is included in @option{-Wextra}. To get other @option{-Wextra} | |
9620 | warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}. | |
9621 | ||
d77de738 ML |
9622 | @opindex Wmissing-requires |
9623 | @opindex Wno-missing-requires | |
ddf6fe37 | 9624 | @item -Wno-missing-requires |
d77de738 ML |
9625 | |
9626 | By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement: | |
9627 | ||
9628 | @smallexample | |
9629 | bool satisfied = requires @{ C<T> @}; | |
9630 | @end smallexample | |
9631 | ||
9632 | Here @samp{satisfied} will be true if @samp{C<T>} is a valid | |
9633 | expression, which it is for all T. Presumably the user meant to write | |
9634 | ||
9635 | @smallexample | |
9636 | bool satisfied = requires @{ requires C<T> @}; | |
9637 | @end smallexample | |
9638 | ||
9639 | so @samp{satisfied} is only true if concept @samp{C} is satisfied for | |
9640 | type @samp{T}. | |
9641 | ||
9642 | This warning can be disabled with @option{-Wno-missing-requires}. | |
9643 | ||
d77de738 ML |
9644 | @opindex Wmissing-template-keyword |
9645 | @opindex Wno-missing-template-keyword | |
ddf6fe37 | 9646 | @item -Wno-missing-template-keyword |
d77de738 ML |
9647 | |
9648 | The member access tokens ., -> and :: must be followed by the @code{template} | |
9649 | keyword if the parent object is dependent and the member being named is a | |
9650 | template. | |
9651 | ||
9652 | @smallexample | |
9653 | template <class X> | |
9654 | void DoStuff (X x) | |
9655 | @{ | |
9656 | x.template DoSomeOtherStuff<X>(); // Good. | |
9657 | x.DoMoreStuff<X>(); // Warning, x is dependent. | |
9658 | @} | |
9659 | @end smallexample | |
9660 | ||
9661 | In rare cases it is possible to get false positives. To silence this, wrap | |
9662 | the expression in parentheses. For example, the following is treated as a | |
9663 | template, even where m and N are integers: | |
9664 | ||
9665 | @smallexample | |
9666 | void NotATemplate (my_class t) | |
9667 | @{ | |
9668 | int N = 5; | |
9669 | ||
9670 | bool test = t.m < N > (0); // Treated as a template. | |
9671 | test = (t.m < N) > (0); // Same meaning, but not treated as a template. | |
9672 | @} | |
9673 | @end smallexample | |
9674 | ||
9675 | This warning can be disabled with @option{-Wno-missing-template-keyword}. | |
9676 | ||
d77de738 ML |
9677 | @opindex Wno-multichar |
9678 | @opindex Wmultichar | |
ddf6fe37 | 9679 | @item -Wno-multichar |
d77de738 ML |
9680 | Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. |
9681 | Usually they indicate a typo in the user's code, as they have | |
9682 | implementation-defined values, and should not be used in portable code. | |
9683 | ||
d77de738 ML |
9684 | @opindex Wnormalized= |
9685 | @opindex Wnormalized | |
9686 | @opindex Wno-normalized | |
9687 | @cindex NFC | |
9688 | @cindex NFKC | |
9689 | @cindex character set, input normalization | |
f33d7a88 | 9690 | @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} |
d77de738 ML |
9691 | In ISO C and ISO C++, two identifiers are different if they are |
9692 | different sequences of characters. However, sometimes when characters | |
9693 | outside the basic ASCII character set are used, you can have two | |
9694 | different character sequences that look the same. To avoid confusion, | |
9695 | the ISO 10646 standard sets out some @dfn{normalization rules} which | |
9696 | when applied ensure that two sequences that look the same are turned into | |
9697 | the same sequence. GCC can warn you if you are using identifiers that | |
9698 | have not been normalized; this option controls that warning. | |
9699 | ||
9700 | There are four levels of warning supported by GCC@. The default is | |
9701 | @option{-Wnormalized=nfc}, which warns about any identifier that is | |
9702 | not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the | |
9703 | recommended form for most uses. It is equivalent to | |
9704 | @option{-Wnormalized}. | |
9705 | ||
9706 | Unfortunately, there are some characters allowed in identifiers by | |
9707 | ISO C and ISO C++ that, when turned into NFC, are not allowed in | |
9708 | identifiers. That is, there's no way to use these symbols in portable | |
9709 | ISO C or C++ and have all your identifiers in NFC@. | |
9710 | @option{-Wnormalized=id} suppresses the warning for these characters. | |
9711 | It is hoped that future versions of the standards involved will correct | |
9712 | this, which is why this option is not the default. | |
9713 | ||
9714 | You can switch the warning off for all characters by writing | |
9715 | @option{-Wnormalized=none} or @option{-Wno-normalized}. You should | |
9716 | only do this if you are using some other normalization scheme (like | |
9717 | ``D''), because otherwise you can easily create bugs that are | |
9718 | literally impossible to see. | |
9719 | ||
9720 | Some characters in ISO 10646 have distinct meanings but look identical | |
9721 | in some fonts or display methodologies, especially once formatting has | |
9722 | been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL | |
9723 | LETTER N'', displays just like a regular @code{n} that has been | |
9724 | placed in a superscript. ISO 10646 defines the @dfn{NFKC} | |
9725 | normalization scheme to convert all these into a standard form as | |
9726 | well, and GCC warns if your code is not in NFKC if you use | |
9727 | @option{-Wnormalized=nfkc}. This warning is comparable to warning | |
9728 | about every identifier that contains the letter O because it might be | |
9729 | confused with the digit 0, and so is not the default, but may be | |
9730 | useful as a local coding convention if the programming environment | |
9731 | cannot be fixed to display these characters distinctly. | |
9732 | ||
d77de738 ML |
9733 | @opindex Wno-attribute-warning |
9734 | @opindex Wattribute-warning | |
ddf6fe37 | 9735 | @item -Wno-attribute-warning |
d77de738 ML |
9736 | Do not warn about usage of functions (@pxref{Function Attributes}) |
9737 | declared with @code{warning} attribute. By default, this warning is | |
9738 | enabled. @option{-Wno-attribute-warning} can be used to disable the | |
9739 | warning or @option{-Wno-error=attribute-warning} can be used to | |
9740 | disable the error when compiled with @option{-Werror} flag. | |
9741 | ||
d77de738 ML |
9742 | @opindex Wno-deprecated |
9743 | @opindex Wdeprecated | |
ddf6fe37 | 9744 | @item -Wno-deprecated |
d77de738 ML |
9745 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
9746 | ||
d77de738 ML |
9747 | @opindex Wno-deprecated-declarations |
9748 | @opindex Wdeprecated-declarations | |
ddf6fe37 | 9749 | @item -Wno-deprecated-declarations |
d77de738 ML |
9750 | Do not warn about uses of functions (@pxref{Function Attributes}), |
9751 | variables (@pxref{Variable Attributes}), and types (@pxref{Type | |
9752 | Attributes}) marked as deprecated by using the @code{deprecated} | |
9753 | attribute. | |
9754 | ||
d77de738 ML |
9755 | @opindex Wno-overflow |
9756 | @opindex Woverflow | |
ddf6fe37 | 9757 | @item -Wno-overflow |
d77de738 ML |
9758 | Do not warn about compile-time overflow in constant expressions. |
9759 | ||
d77de738 ML |
9760 | @opindex Wno-odr |
9761 | @opindex Wodr | |
ddf6fe37 | 9762 | @item -Wno-odr |
d77de738 ML |
9763 | Warn about One Definition Rule violations during link-time optimization. |
9764 | Enabled by default. | |
9765 | ||
d77de738 ML |
9766 | @opindex Wopenacc-parallelism |
9767 | @opindex Wno-openacc-parallelism | |
9768 | @cindex OpenACC accelerator programming | |
f33d7a88 | 9769 | @item -Wopenacc-parallelism |
d77de738 ML |
9770 | Warn about potentially suboptimal choices related to OpenACC parallelism. |
9771 | ||
d77de738 ML |
9772 | @opindex Wopenmp-simd |
9773 | @opindex Wno-openmp-simd | |
ddf6fe37 | 9774 | @item -Wopenmp-simd |
d77de738 ML |
9775 | Warn if the vectorizer cost model overrides the OpenMP |
9776 | simd directive set by user. The @option{-fsimd-cost-model=unlimited} | |
9777 | option can be used to relax the cost model. | |
9778 | ||
d77de738 ML |
9779 | @opindex Woverride-init |
9780 | @opindex Wno-override-init | |
9781 | @opindex W | |
9782 | @opindex Wextra | |
9783 | @opindex Wno-extra | |
ddf6fe37 | 9784 | @item -Woverride-init @r{(C and Objective-C only)} |
d77de738 ML |
9785 | Warn if an initialized field without side effects is overridden when |
9786 | using designated initializers (@pxref{Designated Inits, , Designated | |
9787 | Initializers}). | |
9788 | ||
9789 | This warning is included in @option{-Wextra}. To get other | |
9790 | @option{-Wextra} warnings without this one, use @option{-Wextra | |
9791 | -Wno-override-init}. | |
9792 | ||
d77de738 ML |
9793 | @opindex Woverride-init-side-effects |
9794 | @opindex Wno-override-init-side-effects | |
ddf6fe37 | 9795 | @item -Wno-override-init-side-effects @r{(C and Objective-C only)} |
d77de738 ML |
9796 | Do not warn if an initialized field with side effects is overridden when |
9797 | using designated initializers (@pxref{Designated Inits, , Designated | |
9798 | Initializers}). This warning is enabled by default. | |
9799 | ||
d77de738 ML |
9800 | @opindex Wpacked |
9801 | @opindex Wno-packed | |
ddf6fe37 | 9802 | @item -Wpacked |
d77de738 ML |
9803 | Warn if a structure is given the packed attribute, but the packed |
9804 | attribute has no effect on the layout or size of the structure. | |
9805 | Such structures may be mis-aligned for little benefit. For | |
9806 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
9807 | is misaligned even though @code{struct bar} does not itself | |
9808 | have the packed attribute: | |
9809 | ||
9810 | @smallexample | |
9811 | @group | |
9812 | struct foo @{ | |
9813 | int x; | |
9814 | char a, b, c, d; | |
9815 | @} __attribute__((packed)); | |
9816 | struct bar @{ | |
9817 | char z; | |
9818 | struct foo f; | |
9819 | @}; | |
9820 | @end group | |
9821 | @end smallexample | |
9822 | ||
d77de738 ML |
9823 | @opindex Wpacked-bitfield-compat |
9824 | @opindex Wno-packed-bitfield-compat | |
ddf6fe37 | 9825 | @item -Wnopacked-bitfield-compat |
d77de738 ML |
9826 | The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute |
9827 | on bit-fields of type @code{char}. This was fixed in GCC 4.4 but | |
9828 | the change can lead to differences in the structure layout. GCC | |
9829 | informs you when the offset of such a field has changed in GCC 4.4. | |
9830 | For example there is no longer a 4-bit padding between field @code{a} | |
9831 | and @code{b} in this structure: | |
9832 | ||
9833 | @smallexample | |
9834 | struct foo | |
9835 | @{ | |
9836 | char a:4; | |
9837 | char b:8; | |
9838 | @} __attribute__ ((packed)); | |
9839 | @end smallexample | |
9840 | ||
9841 | This warning is enabled by default. Use | |
9842 | @option{-Wno-packed-bitfield-compat} to disable this warning. | |
9843 | ||
d77de738 ML |
9844 | @opindex Wpacked-not-aligned |
9845 | @opindex Wno-packed-not-aligned | |
ddf6fe37 | 9846 | @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
9847 | Warn if a structure field with explicitly specified alignment in a |
9848 | packed struct or union is misaligned. For example, a warning will | |
9849 | be issued on @code{struct S}, like, @code{warning: alignment 1 of | |
9850 | 'struct S' is less than 8}, in this code: | |
9851 | ||
9852 | @smallexample | |
9853 | @group | |
9854 | struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @}; | |
9855 | struct __attribute__ ((packed)) S @{ | |
9856 | struct S8 s8; | |
9857 | @}; | |
9858 | @end group | |
9859 | @end smallexample | |
9860 | ||
9861 | This warning is enabled by @option{-Wall}. | |
9862 | ||
d77de738 ML |
9863 | @opindex Wpadded |
9864 | @opindex Wno-padded | |
ddf6fe37 | 9865 | @item -Wpadded |
d77de738 ML |
9866 | Warn if padding is included in a structure, either to align an element |
9867 | of the structure or to align the whole structure. Sometimes when this | |
9868 | happens it is possible to rearrange the fields of the structure to | |
9869 | reduce the padding and so make the structure smaller. | |
9870 | ||
d77de738 ML |
9871 | @opindex Wredundant-decls |
9872 | @opindex Wno-redundant-decls | |
ddf6fe37 | 9873 | @item -Wredundant-decls |
d77de738 ML |
9874 | Warn if anything is declared more than once in the same scope, even in |
9875 | cases where multiple declaration is valid and changes nothing. | |
9876 | ||
d77de738 ML |
9877 | @opindex Wrestrict |
9878 | @opindex Wno-restrict | |
ddf6fe37 | 9879 | @item -Wrestrict |
d77de738 ML |
9880 | Warn when an object referenced by a @code{restrict}-qualified parameter |
9881 | (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another | |
9882 | argument, or when copies between such objects overlap. For example, | |
9883 | the call to the @code{strcpy} function below attempts to truncate the string | |
9884 | by replacing its initial characters with the last four. However, because | |
9885 | the call writes the terminating NUL into @code{a[4]}, the copies overlap and | |
9886 | the call is diagnosed. | |
9887 | ||
9888 | @smallexample | |
9889 | void foo (void) | |
9890 | @{ | |
9891 | char a[] = "abcd1234"; | |
9892 | strcpy (a, a + 4); | |
9893 | @dots{} | |
9894 | @} | |
9895 | @end smallexample | |
9896 | The @option{-Wrestrict} option detects some instances of simple overlap | |
9897 | even without optimization but works best at @option{-O2} and above. It | |
9898 | is included in @option{-Wall}. | |
9899 | ||
d77de738 ML |
9900 | @opindex Wnested-externs |
9901 | @opindex Wno-nested-externs | |
ddf6fe37 | 9902 | @item -Wnested-externs @r{(C and Objective-C only)} |
d77de738 ML |
9903 | Warn if an @code{extern} declaration is encountered within a function. |
9904 | ||
d77de738 ML |
9905 | @opindex Winline |
9906 | @opindex Wno-inline | |
ddf6fe37 | 9907 | @item -Winline |
d77de738 ML |
9908 | Warn if a function that is declared as inline cannot be inlined. |
9909 | Even with this option, the compiler does not warn about failures to | |
9910 | inline functions declared in system headers. | |
9911 | ||
9912 | The compiler uses a variety of heuristics to determine whether or not | |
9913 | to inline a function. For example, the compiler takes into account | |
9914 | the size of the function being inlined and the amount of inlining | |
9915 | that has already been done in the current function. Therefore, | |
9916 | seemingly insignificant changes in the source program can cause the | |
9917 | warnings produced by @option{-Winline} to appear or disappear. | |
9918 | ||
d77de738 | 9919 | @opindex Winterference-size |
ddf6fe37 | 9920 | @item -Winterference-size |
d77de738 ML |
9921 | Warn about use of C++17 @code{std::hardware_destructive_interference_size} |
9922 | without specifying its value with @option{--param destructive-interference-size}. | |
9923 | Also warn about questionable values for that option. | |
9924 | ||
9925 | This variable is intended to be used for controlling class layout, to | |
9926 | avoid false sharing in concurrent code: | |
9927 | ||
9928 | @smallexample | |
9929 | struct independent_fields @{ | |
4ace81b6 SL |
9930 | alignas(std::hardware_destructive_interference_size) |
9931 | std::atomic<int> one; | |
9932 | alignas(std::hardware_destructive_interference_size) | |
9933 | std::atomic<int> two; | |
d77de738 ML |
9934 | @}; |
9935 | @end smallexample | |
9936 | ||
9937 | Here @samp{one} and @samp{two} are intended to be far enough apart | |
9938 | that stores to one won't require accesses to the other to reload the | |
9939 | cache line. | |
9940 | ||
9941 | By default, @option{--param destructive-interference-size} and | |
9942 | @option{--param constructive-interference-size} are set based on the | |
9943 | current @option{-mtune} option, typically to the L1 cache line size | |
9944 | for the particular target CPU, sometimes to a range if tuning for a | |
9945 | generic target. So all translation units that depend on ABI | |
9946 | compatibility for the use of these variables must be compiled with | |
9947 | the same @option{-mtune} (or @option{-mcpu}). | |
9948 | ||
9949 | If ABI stability is important, such as if the use is in a header for a | |
9950 | library, you should probably not use the hardware interference size | |
9951 | variables at all. Alternatively, you can force a particular value | |
9952 | with @option{--param}. | |
9953 | ||
9954 | If you are confident that your use of the variable does not affect ABI | |
9955 | outside a single build of your project, you can turn off the warning | |
9956 | with @option{-Wno-interference-size}. | |
9957 | ||
d77de738 ML |
9958 | @opindex Wint-in-bool-context |
9959 | @opindex Wno-int-in-bool-context | |
ddf6fe37 | 9960 | @item -Wint-in-bool-context |
d77de738 ML |
9961 | Warn for suspicious use of integer values where boolean values are expected, |
9962 | such as conditional expressions (?:) using non-boolean integer constants in | |
9963 | boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed | |
9964 | integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise | |
9965 | for all kinds of multiplications regardless of the data type. | |
9966 | This warning is enabled by @option{-Wall}. | |
9967 | ||
d77de738 ML |
9968 | @opindex Wno-int-to-pointer-cast |
9969 | @opindex Wint-to-pointer-cast | |
ddf6fe37 | 9970 | @item -Wno-int-to-pointer-cast |
d77de738 ML |
9971 | Suppress warnings from casts to pointer type of an integer of a |
9972 | different size. In C++, casting to a pointer type of smaller size is | |
9973 | an error. @option{Wint-to-pointer-cast} is enabled by default. | |
9974 | ||
9975 | ||
d77de738 ML |
9976 | @opindex Wno-pointer-to-int-cast |
9977 | @opindex Wpointer-to-int-cast | |
ddf6fe37 | 9978 | @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)} |
d77de738 ML |
9979 | Suppress warnings from casts from a pointer to an integer type of a |
9980 | different size. | |
9981 | ||
d77de738 ML |
9982 | @opindex Winvalid-pch |
9983 | @opindex Wno-invalid-pch | |
ddf6fe37 | 9984 | @item -Winvalid-pch |
d77de738 ML |
9985 | Warn if a precompiled header (@pxref{Precompiled Headers}) is found in |
9986 | the search path but cannot be used. | |
9987 | ||
d77de738 ML |
9988 | @opindex Winvalid-utf8 |
9989 | @opindex Wno-invalid-utf8 | |
ddf6fe37 | 9990 | @item -Winvalid-utf8 |
d77de738 ML |
9991 | Warn if an invalid UTF-8 character is found. |
9992 | This warning is on by default for C++23 if @option{-finput-charset=UTF-8} | |
9993 | is used and turned into error with @option{-pedantic-errors}. | |
9994 | ||
d77de738 ML |
9995 | @opindex Wunicode |
9996 | @opindex Wno-unicode | |
ddf6fe37 | 9997 | @item -Wno-unicode |
d77de738 ML |
9998 | Don't diagnose invalid forms of delimited or named escape sequences which are |
9999 | treated as separate tokens. @option{Wunicode} is enabled by default. | |
10000 | ||
d77de738 ML |
10001 | @opindex Wlong-long |
10002 | @opindex Wno-long-long | |
ddf6fe37 | 10003 | @item -Wlong-long |
d77de738 ML |
10004 | Warn if @code{long long} type is used. This is enabled by either |
10005 | @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98 | |
10006 | modes. To inhibit the warning messages, use @option{-Wno-long-long}. | |
10007 | ||
5fccebdb JM |
10008 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10009 | ||
d77de738 ML |
10010 | @opindex Wvariadic-macros |
10011 | @opindex Wno-variadic-macros | |
ddf6fe37 | 10012 | @item -Wvariadic-macros |
d77de738 ML |
10013 | Warn if variadic macros are used in ISO C90 mode, or if the GNU |
10014 | alternate syntax is used in ISO C99 mode. This is enabled by either | |
10015 | @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning | |
10016 | messages, use @option{-Wno-variadic-macros}. | |
10017 | ||
d77de738 ML |
10018 | @opindex Wvarargs |
10019 | @opindex Wno-varargs | |
ddf6fe37 | 10020 | @item -Wno-varargs |
d77de738 ML |
10021 | Do not warn upon questionable usage of the macros used to handle variable |
10022 | arguments like @code{va_start}. These warnings are enabled by default. | |
10023 | ||
d77de738 ML |
10024 | @opindex Wvector-operation-performance |
10025 | @opindex Wno-vector-operation-performance | |
ddf6fe37 | 10026 | @item -Wvector-operation-performance |
d77de738 ML |
10027 | Warn if vector operation is not implemented via SIMD capabilities of the |
10028 | architecture. Mainly useful for the performance tuning. | |
10029 | Vector operation can be implemented @code{piecewise}, which means that the | |
10030 | scalar operation is performed on every vector element; | |
10031 | @code{in parallel}, which means that the vector operation is implemented | |
10032 | using scalars of wider type, which normally is more performance efficient; | |
10033 | and @code{as a single scalar}, which means that vector fits into a | |
10034 | scalar type. | |
10035 | ||
d77de738 ML |
10036 | @opindex Wvla |
10037 | @opindex Wno-vla | |
ddf6fe37 | 10038 | @item -Wvla |
d77de738 ML |
10039 | Warn if a variable-length array is used in the code. |
10040 | @option{-Wno-vla} prevents the @option{-Wpedantic} warning of | |
10041 | the variable-length array. | |
10042 | ||
5fccebdb JM |
10043 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10044 | ||
d77de738 ML |
10045 | @opindex Wvla-larger-than= |
10046 | @opindex Wno-vla-larger-than | |
ddf6fe37 | 10047 | @item -Wvla-larger-than=@var{byte-size} |
d77de738 ML |
10048 | If this option is used, the compiler warns for declarations of |
10049 | variable-length arrays whose size is either unbounded, or bounded | |
10050 | by an argument that allows the array size to exceed @var{byte-size} | |
10051 | bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size} | |
10052 | works, but with variable-length arrays. | |
10053 | ||
10054 | Note that GCC may optimize small variable-length arrays of a known | |
10055 | value into plain arrays, so this warning may not get triggered for | |
10056 | such arrays. | |
10057 | ||
10058 | @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but | |
10059 | is typically only effective when @option{-ftree-vrp} is active (default | |
10060 | for @option{-O2} and above). | |
10061 | ||
10062 | See also @option{-Walloca-larger-than=@var{byte-size}}. | |
10063 | ||
d77de738 | 10064 | @opindex Wno-vla-larger-than |
ddf6fe37 | 10065 | @item -Wno-vla-larger-than |
d77de738 ML |
10066 | Disable @option{-Wvla-larger-than=} warnings. The option is equivalent |
10067 | to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger. | |
10068 | ||
d77de738 | 10069 | @opindex Wno-vla-parameter |
ddf6fe37 | 10070 | @item -Wvla-parameter |
d77de738 ML |
10071 | Warn about redeclarations of functions involving arguments of Variable |
10072 | Length Array types of inconsistent kinds or forms, and enable the detection | |
10073 | of out-of-bounds accesses to such parameters by warnings such as | |
10074 | @option{-Warray-bounds}. | |
10075 | ||
10076 | If the first function declaration uses the VLA form the bound specified | |
10077 | in the array is assumed to be the minimum number of elements expected to | |
10078 | be provided in calls to the function and the maximum number of elements | |
10079 | accessed by it. Failing to provide arguments of sufficient size or | |
10080 | accessing more than the maximum number of elements may be diagnosed. | |
10081 | ||
10082 | For example, the warning triggers for the following redeclarations because | |
10083 | the first one allows an array of any size to be passed to @code{f} while | |
10084 | the second one specifies that the array argument must have at least @code{n} | |
10085 | elements. In addition, calling @code{f} with the associated VLA bound | |
10086 | parameter in excess of the actual VLA bound triggers a warning as well. | |
10087 | ||
10088 | @smallexample | |
10089 | void f (int n, int[n]); | |
4ace81b6 SL |
10090 | // warning: argument 2 previously declared as a VLA |
10091 | void f (int, int[]); | |
d77de738 ML |
10092 | |
10093 | void g (int n) | |
10094 | @{ | |
10095 | if (n > 4) | |
10096 | return; | |
10097 | int a[n]; | |
4ace81b6 SL |
10098 | // warning: access to a by f may be out of bounds |
10099 | f (sizeof a, a); | |
d77de738 ML |
10100 | @dots{} |
10101 | @} | |
10102 | ||
10103 | @end smallexample | |
10104 | ||
10105 | @option{-Wvla-parameter} is included in @option{-Wall}. The | |
10106 | @option{-Warray-parameter} option triggers warnings for similar problems | |
10107 | involving ordinary array arguments. | |
10108 | ||
d77de738 ML |
10109 | @opindex Wvolatile-register-var |
10110 | @opindex Wno-volatile-register-var | |
ddf6fe37 | 10111 | @item -Wvolatile-register-var |
d77de738 ML |
10112 | Warn if a register variable is declared volatile. The volatile |
10113 | modifier does not inhibit all optimizations that may eliminate reads | |
10114 | and/or writes to register variables. This warning is enabled by | |
10115 | @option{-Wall}. | |
10116 | ||
d77de738 ML |
10117 | @opindex Wxor-used-as-pow |
10118 | @opindex Wno-xor-used-as-pow | |
ddf6fe37 | 10119 | @item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
10120 | Warn about uses of @code{^}, the exclusive or operator, where it appears |
10121 | the user meant exponentiation. Specifically, the warning occurs when the | |
10122 | left-hand side is the decimal constant 2 or 10 and the right-hand side | |
10123 | is also a decimal constant. | |
10124 | ||
10125 | In C and C++, @code{^} means exclusive or, whereas in some other languages | |
10126 | (e.g. TeX and some versions of BASIC) it means exponentiation. | |
10127 | ||
10128 | This warning is enabled by default. It can be silenced by converting one | |
10129 | of the operands to hexadecimal. | |
10130 | ||
d77de738 ML |
10131 | @opindex Wdisabled-optimization |
10132 | @opindex Wno-disabled-optimization | |
ddf6fe37 | 10133 | @item -Wdisabled-optimization |
d77de738 ML |
10134 | Warn if a requested optimization pass is disabled. This warning does |
10135 | not generally indicate that there is anything wrong with your code; it | |
10136 | merely indicates that GCC's optimizers are unable to handle the code | |
10137 | effectively. Often, the problem is that your code is too big or too | |
10138 | complex; GCC refuses to optimize programs when the optimization | |
10139 | itself is likely to take inordinate amounts of time. | |
10140 | ||
d77de738 ML |
10141 | @opindex Wpointer-sign |
10142 | @opindex Wno-pointer-sign | |
ddf6fe37 | 10143 | @item -Wpointer-sign @r{(C and Objective-C only)} |
d77de738 ML |
10144 | Warn for pointer argument passing or assignment with different signedness. |
10145 | This option is only supported for C and Objective-C@. It is implied by | |
10146 | @option{-Wall} and by @option{-Wpedantic}, which can be disabled with | |
10147 | @option{-Wno-pointer-sign}. | |
10148 | ||
5fccebdb JM |
10149 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10150 | ||
d77de738 ML |
10151 | @opindex Wstack-protector |
10152 | @opindex Wno-stack-protector | |
ddf6fe37 | 10153 | @item -Wstack-protector |
d77de738 ML |
10154 | This option is only active when @option{-fstack-protector} is active. It |
10155 | warns about functions that are not protected against stack smashing. | |
10156 | ||
d77de738 ML |
10157 | @opindex Woverlength-strings |
10158 | @opindex Wno-overlength-strings | |
ddf6fe37 | 10159 | @item -Woverlength-strings |
d77de738 ML |
10160 | Warn about string constants that are longer than the ``minimum |
10161 | maximum'' length specified in the C standard. Modern compilers | |
10162 | generally allow string constants that are much longer than the | |
10163 | standard's minimum limit, but very portable programs should avoid | |
10164 | using longer strings. | |
10165 | ||
10166 | The limit applies @emph{after} string constant concatenation, and does | |
10167 | not count the trailing NUL@. In C90, the limit was 509 characters; in | |
10168 | C99, it was raised to 4095. C++98 does not specify a normative | |
10169 | minimum maximum, so we do not diagnose overlength strings in C++@. | |
10170 | ||
10171 | This option is implied by @option{-Wpedantic}, and can be disabled with | |
10172 | @option{-Wno-overlength-strings}. | |
10173 | ||
d77de738 ML |
10174 | @opindex Wunsuffixed-float-constants |
10175 | @opindex Wno-unsuffixed-float-constants | |
ddf6fe37 | 10176 | @item -Wunsuffixed-float-constants @r{(C and Objective-C only)} |
d77de738 ML |
10177 | |
10178 | Issue a warning for any floating constant that does not have | |
10179 | a suffix. When used together with @option{-Wsystem-headers} it | |
10180 | warns about such constants in system header files. This can be useful | |
10181 | when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma | |
10182 | from the decimal floating-point extension to C99. | |
10183 | ||
d77de738 ML |
10184 | @opindex Wlto-type-mismatch |
10185 | @opindex Wno-lto-type-mismatch | |
ddf6fe37 | 10186 | @item -Wno-lto-type-mismatch |
d77de738 ML |
10187 | |
10188 | During the link-time optimization, do not warn about type mismatches in | |
10189 | global declarations from different compilation units. | |
10190 | Requires @option{-flto} to be enabled. Enabled by default. | |
10191 | ||
d77de738 ML |
10192 | @opindex Wdesignated-init |
10193 | @opindex Wno-designated-init | |
ddf6fe37 | 10194 | @item -Wno-designated-init @r{(C and Objective-C only)} |
d77de738 ML |
10195 | Suppress warnings when a positional initializer is used to initialize |
10196 | a structure that has been marked with the @code{designated_init} | |
10197 | attribute. | |
10198 | ||
10199 | @end table | |
10200 | ||
10201 | @node Static Analyzer Options | |
10202 | @section Options That Control Static Analysis | |
10203 | ||
10204 | @table @gcctabopt | |
d77de738 ML |
10205 | @opindex analyzer |
10206 | @opindex fanalyzer | |
10207 | @opindex fno-analyzer | |
ddf6fe37 | 10208 | @item -fanalyzer |
d77de738 ML |
10209 | This option enables an static analysis of program flow which looks |
10210 | for ``interesting'' interprocedural paths through the | |
10211 | code, and issues warnings for problems found on them. | |
10212 | ||
10213 | This analysis is much more expensive than other GCC warnings. | |
10214 | ||
a90316c6 DM |
10215 | In technical terms, it performs coverage-guided symbolic execution of |
10216 | the code being compiled. It is neither sound nor complete: it can | |
10217 | have false positives and false negatives. It is a bug-finding tool, | |
10218 | rather than a tool for proving program correctness. | |
10219 | ||
10220 | The analyzer is only suitable for use on C code in this release. | |
10221 | ||
d77de738 ML |
10222 | Enabling this option effectively enables the following warnings: |
10223 | ||
43b72ede AA |
10224 | @gccoptlist{ |
10225 | -Wanalyzer-allocation-size | |
10226 | -Wanalyzer-deref-before-check | |
10227 | -Wanalyzer-double-fclose | |
10228 | -Wanalyzer-double-free | |
10229 | -Wanalyzer-exposure-through-output-file | |
10230 | -Wanalyzer-exposure-through-uninit-copy | |
10231 | -Wanalyzer-fd-access-mode-mismatch | |
10232 | -Wanalyzer-fd-double-close | |
10233 | -Wanalyzer-fd-leak | |
10234 | -Wanalyzer-fd-phase-mismatch | |
10235 | -Wanalyzer-fd-type-mismatch | |
10236 | -Wanalyzer-fd-use-after-close | |
10237 | -Wanalyzer-fd-use-without-check | |
10238 | -Wanalyzer-file-leak | |
10239 | -Wanalyzer-free-of-non-heap | |
10240 | -Wanalyzer-imprecise-fp-arithmetic | |
10241 | -Wanalyzer-infinite-recursion | |
10242 | -Wanalyzer-jump-through-null | |
10243 | -Wanalyzer-malloc-leak | |
10244 | -Wanalyzer-mismatching-deallocation | |
10245 | -Wanalyzer-null-argument | |
10246 | -Wanalyzer-null-dereference | |
10247 | -Wanalyzer-out-of-bounds | |
10248 | -Wanalyzer-possible-null-argument | |
10249 | -Wanalyzer-possible-null-dereference | |
10250 | -Wanalyzer-putenv-of-auto-var | |
10251 | -Wanalyzer-shift-count-negative | |
10252 | -Wanalyzer-shift-count-overflow | |
10253 | -Wanalyzer-stale-setjmp-buffer | |
10254 | -Wanalyzer-unsafe-call-within-signal-handler | |
10255 | -Wanalyzer-use-after-free | |
10256 | -Wanalyzer-use-of-pointer-in-stale-stack-frame | |
10257 | -Wanalyzer-use-of-uninitialized-value | |
10258 | -Wanalyzer-va-arg-type-mismatch | |
10259 | -Wanalyzer-va-list-exhausted | |
10260 | -Wanalyzer-va-list-leak | |
10261 | -Wanalyzer-va-list-use-after-va-end | |
10262 | -Wanalyzer-write-to-const | |
10263 | -Wanalyzer-write-to-string-literal | |
d77de738 ML |
10264 | } |
10265 | @ignore | |
43b72ede AA |
10266 | -Wanalyzer-tainted-allocation-size |
10267 | -Wanalyzer-tainted-array-index | |
10268 | -Wanalyzer-tainted-divisor | |
10269 | -Wanalyzer-tainted-offset | |
10270 | -Wanalyzer-tainted-size | |
d77de738 ML |
10271 | @end ignore |
10272 | ||
10273 | This option is only available if GCC was configured with analyzer | |
10274 | support enabled. | |
10275 | ||
d77de738 ML |
10276 | @opindex Wanalyzer-too-complex |
10277 | @opindex Wno-analyzer-too-complex | |
ddf6fe37 | 10278 | @item -Wanalyzer-too-complex |
d77de738 ML |
10279 | If @option{-fanalyzer} is enabled, the analyzer uses various heuristics |
10280 | to attempt to explore the control flow and data flow in the program, | |
10281 | but these can be defeated by sufficiently complicated code. | |
10282 | ||
10283 | By default, the analysis silently stops if the code is too | |
10284 | complicated for the analyzer to fully explore and it reaches an internal | |
10285 | limit. The @option{-Wanalyzer-too-complex} option warns if this occurs. | |
10286 | ||
d77de738 ML |
10287 | @opindex Wanalyzer-allocation-size |
10288 | @opindex Wno-analyzer-allocation-size | |
ddf6fe37 | 10289 | @item -Wno-analyzer-allocation-size |
4ace81b6 SL |
10290 | This warning requires @option{-fanalyzer}, which enables it; |
10291 | to disable it, use @option{-Wno-analyzer-allocation-size}. | |
d77de738 ML |
10292 | |
10293 | This diagnostic warns for paths through the code in which a pointer to | |
10294 | a buffer is assigned to point at a buffer with a size that is not a | |
10295 | multiple of @code{sizeof (*pointer)}. | |
10296 | ||
10297 | See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. | |
10298 | ||
ce51e843 ML |
10299 | @opindex Wanalyzer-deref-before-check |
10300 | @opindex Wno-analyzer-deref-before-check | |
ddf6fe37 | 10301 | @item -Wno-analyzer-deref-before-check |
ce51e843 ML |
10302 | This warning requires @option{-fanalyzer}, which enables it; use |
10303 | @option{-Wno-analyzer-deref-before-check} | |
10304 | to disable it. | |
10305 | ||
10306 | This diagnostic warns for paths through the code in which a pointer | |
10307 | is checked for @code{NULL} *after* it has already been | |
10308 | dereferenced, suggesting that the pointer could have been NULL. | |
10309 | Such cases suggest that the check for NULL is either redundant, | |
10310 | or that it needs to be moved to before the pointer is dereferenced. | |
10311 | ||
10312 | This diagnostic also considers values passed to a function argument | |
10313 | marked with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10314 | value, and thus will complain if such values are checked for @code{NULL} | |
10315 | after returning from such a function call. | |
10316 | ||
10317 | This diagnostic is unlikely to be reported when any level of optimization | |
10318 | is enabled, as GCC's optimization logic will typically consider such | |
10319 | checks for NULL as being redundant, and optimize them away before the | |
10320 | analyzer "sees" them. Hence optimization should be disabled when | |
10321 | attempting to trigger this diagnostic. | |
10322 | ||
d77de738 ML |
10323 | @opindex Wanalyzer-double-fclose |
10324 | @opindex Wno-analyzer-double-fclose | |
ddf6fe37 | 10325 | @item -Wno-analyzer-double-fclose |
d77de738 ML |
10326 | This warning requires @option{-fanalyzer}, which enables it; use |
10327 | @option{-Wno-analyzer-double-fclose} to disable it. | |
10328 | ||
10329 | This diagnostic warns for paths through the code in which a @code{FILE *} | |
10330 | can have @code{fclose} called on it more than once. | |
10331 | ||
10332 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10333 | ||
d77de738 ML |
10334 | @opindex Wanalyzer-double-free |
10335 | @opindex Wno-analyzer-double-free | |
ddf6fe37 | 10336 | @item -Wno-analyzer-double-free |
d77de738 ML |
10337 | This warning requires @option{-fanalyzer}, which enables it; use |
10338 | @option{-Wno-analyzer-double-free} to disable it. | |
10339 | ||
10340 | This diagnostic warns for paths through the code in which a pointer | |
10341 | can have a deallocator called on it more than once, either @code{free}, | |
10342 | or a deallocator referenced by attribute @code{malloc}. | |
10343 | ||
10344 | See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}. | |
10345 | ||
d77de738 ML |
10346 | @opindex Wanalyzer-exposure-through-output-file |
10347 | @opindex Wno-analyzer-exposure-through-output-file | |
ddf6fe37 | 10348 | @item -Wno-analyzer-exposure-through-output-file |
d77de738 ML |
10349 | This warning requires @option{-fanalyzer}, which enables it; use |
10350 | @option{-Wno-analyzer-exposure-through-output-file} | |
10351 | to disable it. | |
10352 | ||
10353 | This diagnostic warns for paths through the code in which a | |
10354 | security-sensitive value is written to an output file | |
10355 | (such as writing a password to a log file). | |
10356 | ||
10357 | See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}. | |
10358 | ||
d77de738 ML |
10359 | @opindex Wanalyzer-exposure-through-uninit-copy |
10360 | @opindex Wno-analyzer-exposure-through-uninit-copy | |
ddf6fe37 | 10361 | @item -Wanalyzer-exposure-through-uninit-copy |
d77de738 ML |
10362 | This warning requires both @option{-fanalyzer} and the use of a plugin |
10363 | to specify a function that copies across a ``trust boundary''. Use | |
10364 | @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it. | |
10365 | ||
10366 | This diagnostic warns for ``infoleaks'' - paths through the code in which | |
10367 | uninitialized values are copied across a security boundary | |
10368 | (such as code within an OS kernel that copies a partially-initialized | |
10369 | struct on the stack to user space). | |
10370 | ||
10371 | See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}. | |
10372 | ||
d77de738 ML |
10373 | @opindex Wanalyzer-fd-access-mode-mismatch |
10374 | @opindex Wno-analyzer-fd-access-mode-mismatch | |
ddf6fe37 | 10375 | @item -Wno-analyzer-fd-access-mode-mismatch |
d77de738 ML |
10376 | This warning requires @option{-fanalyzer}, which enables it; use |
10377 | @option{-Wno-analyzer-fd-access-mode-mismatch} | |
10378 | to disable it. | |
10379 | ||
10380 | This diagnostic warns for paths through code in which a | |
10381 | @code{read} on a write-only file descriptor is attempted, or vice versa. | |
10382 | ||
10383 | This diagnostic also warns for code paths in a which a function with attribute | |
10384 | @code{fd_arg_read (N)} is called with a file descriptor opened with | |
10385 | @code{O_WRONLY} at referenced argument @code{N} or a function with attribute | |
10386 | @code{fd_arg_write (N)} is called with a file descriptor opened with | |
10387 | @code{O_RDONLY} at referenced argument @var{N}. | |
10388 | ||
d77de738 ML |
10389 | @opindex Wanalyzer-fd-double-close |
10390 | @opindex Wno-analyzer-fd-double-close | |
ddf6fe37 | 10391 | @item -Wno-analyzer-fd-double-close |
d77de738 ML |
10392 | This warning requires @option{-fanalyzer}, which enables it; use |
10393 | @option{-Wno-analyzer-fd-double-close} | |
10394 | to disable it. | |
10395 | ||
10396 | This diagnostic warns for paths through code in which a | |
10397 | file descriptor can be closed more than once. | |
10398 | ||
10399 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10400 | ||
d77de738 ML |
10401 | @opindex Wanalyzer-fd-leak |
10402 | @opindex Wno-analyzer-fd-leak | |
ddf6fe37 | 10403 | @item -Wno-analyzer-fd-leak |
d77de738 ML |
10404 | This warning requires @option{-fanalyzer}, which enables it; use |
10405 | @option{-Wno-analyzer-fd-leak} | |
10406 | to disable it. | |
10407 | ||
10408 | This diagnostic warns for paths through code in which an | |
10409 | open file descriptor is leaked. | |
10410 | ||
10411 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10412 | ||
86a90006 DM |
10413 | @opindex Wanalyzer-fd-phase-mismatch |
10414 | @opindex Wno-analyzer-fd-phase-mismatch | |
ddf6fe37 | 10415 | @item -Wno-analyzer-fd-phase-mismatch |
86a90006 DM |
10416 | This warning requires @option{-fanalyzer}, which enables it; use |
10417 | @option{-Wno-analyzer-fd-phase-mismatch} | |
10418 | to disable it. | |
10419 | ||
10420 | This diagnostic warns for paths through code in which an operation is | |
10421 | attempted in the wrong phase of a file descriptor's lifetime. | |
10422 | For example, it will warn on attempts to call @code{accept} on a stream | |
10423 | socket that has not yet had @code{listen} successfully called on it. | |
10424 | ||
10425 | See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}. | |
10426 | ||
86a90006 DM |
10427 | @opindex Wanalyzer-fd-type-mismatch |
10428 | @opindex Wno-analyzer-fd-type-mismatch | |
ddf6fe37 | 10429 | @item -Wno-analyzer-fd-type-mismatch |
86a90006 DM |
10430 | This warning requires @option{-fanalyzer}, which enables it; use |
10431 | @option{-Wno-analyzer-fd-type-mismatch} | |
10432 | to disable it. | |
10433 | ||
10434 | This diagnostic warns for paths through code in which an | |
10435 | operation is attempted on the wrong type of file descriptor. | |
10436 | For example, it will warn on attempts to use socket operations | |
10437 | on a file descriptor obtained via @code{open}, or when attempting | |
10438 | to use a stream socket operation on a datagram socket. | |
10439 | ||
d77de738 ML |
10440 | @opindex Wanalyzer-fd-use-after-close |
10441 | @opindex Wno-analyzer-fd-use-after-close | |
ddf6fe37 | 10442 | @item -Wno-analyzer-fd-use-after-close |
d77de738 ML |
10443 | This warning requires @option{-fanalyzer}, which enables it; use |
10444 | @option{-Wno-analyzer-fd-use-after-close} | |
10445 | to disable it. | |
10446 | ||
10447 | This diagnostic warns for paths through code in which a | |
10448 | read or write is called on a closed file descriptor. | |
10449 | ||
10450 | This diagnostic also warns for paths through code in which | |
10451 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10452 | or @code{fd_arg_write (N)} is called with a closed file descriptor at | |
10453 | referenced argument @code{N}. | |
10454 | ||
d77de738 ML |
10455 | @opindex Wanalyzer-fd-use-without-check |
10456 | @opindex Wno-analyzer-fd-use-without-check | |
ddf6fe37 | 10457 | @item -Wno-analyzer-fd-use-without-check |
d77de738 ML |
10458 | This warning requires @option{-fanalyzer}, which enables it; use |
10459 | @option{-Wno-analyzer-fd-use-without-check} | |
10460 | to disable it. | |
10461 | ||
10462 | This diagnostic warns for paths through code in which a | |
10463 | file descriptor is used without being checked for validity. | |
10464 | ||
10465 | This diagnostic also warns for paths through code in which | |
10466 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10467 | or @code{fd_arg_write (N)} is called with a file descriptor, at referenced | |
10468 | argument @code{N}, without being checked for validity. | |
10469 | ||
d77de738 ML |
10470 | @opindex Wanalyzer-file-leak |
10471 | @opindex Wno-analyzer-file-leak | |
ddf6fe37 | 10472 | @item -Wno-analyzer-file-leak |
d77de738 ML |
10473 | This warning requires @option{-fanalyzer}, which enables it; use |
10474 | @option{-Wno-analyzer-file-leak} | |
10475 | to disable it. | |
10476 | ||
10477 | This diagnostic warns for paths through the code in which a | |
10478 | @code{<stdio.h>} @code{FILE *} stream object is leaked. | |
10479 | ||
10480 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10481 | ||
d77de738 ML |
10482 | @opindex Wanalyzer-free-of-non-heap |
10483 | @opindex Wno-analyzer-free-of-non-heap | |
ddf6fe37 | 10484 | @item -Wno-analyzer-free-of-non-heap |
d77de738 ML |
10485 | This warning requires @option{-fanalyzer}, which enables it; use |
10486 | @option{-Wno-analyzer-free-of-non-heap} | |
10487 | to disable it. | |
10488 | ||
10489 | This diagnostic warns for paths through the code in which @code{free} | |
10490 | is called on a non-heap pointer (e.g. an on-stack buffer, or a global). | |
10491 | ||
10492 | See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}. | |
10493 | ||
d77de738 ML |
10494 | @opindex Wanalyzer-imprecise-fp-arithmetic |
10495 | @opindex Wno-analyzer-imprecise-fp-arithmetic | |
ddf6fe37 | 10496 | @item -Wno-analyzer-imprecise-fp-arithmetic |
d77de738 ML |
10497 | This warning requires @option{-fanalyzer}, which enables it; use |
10498 | @option{-Wno-analyzer-imprecise-fp-arithmetic} | |
10499 | to disable it. | |
10500 | ||
10501 | This diagnostic warns for paths through the code in which floating-point | |
10502 | arithmetic is used in locations where precise computation is needed. This | |
10503 | diagnostic only warns on use of floating-point operands inside the | |
10504 | calculation of an allocation size at the moment. | |
10505 | ||
ce51e843 ML |
10506 | @opindex Wanalyzer-infinite-recursion |
10507 | @opindex Wno-analyzer-infinite-recursion | |
ddf6fe37 | 10508 | @item -Wno-analyzer-infinite-recursion |
ce51e843 ML |
10509 | This warning requires @option{-fanalyzer}, which enables it; use |
10510 | @option{-Wno-analyzer-infinite-recursion} to disable it. | |
10511 | ||
10512 | This diagnostics warns for paths through the code which appear to | |
10513 | lead to infinite recursion. | |
10514 | ||
10515 | Specifically, when the analyzer "sees" a recursive call, it will compare | |
10516 | the state of memory at the entry to the new frame with that at the entry | |
10517 | to the previous frame of that function on the stack. The warning is | |
10518 | issued if nothing in memory appears to be changing; any changes observed | |
10519 | to parameters or globals are assumed to lead to termination of the | |
10520 | recursion and thus suppress the warning. | |
10521 | ||
10522 | This diagnostic is likely to miss cases of infinite recursion that | |
10523 | are convered to iteration by the optimizer before the analyzer "sees" | |
10524 | them. Hence optimization should be disabled when attempting to trigger | |
10525 | this diagnostic. | |
10526 | ||
10527 | Compare with @option{-Winfinite-recursion}, which provides a similar | |
10528 | diagnostic, but is implemented in a different way. | |
10529 | ||
d77de738 ML |
10530 | @opindex Wanalyzer-jump-through-null |
10531 | @opindex Wno-analyzer-jump-through-null | |
ddf6fe37 | 10532 | @item -Wno-analyzer-jump-through-null |
d77de738 ML |
10533 | This warning requires @option{-fanalyzer}, which enables it; use |
10534 | @option{-Wno-analyzer-jump-through-null} | |
10535 | to disable it. | |
10536 | ||
10537 | This diagnostic warns for paths through the code in which a @code{NULL} | |
10538 | function pointer is called. | |
10539 | ||
d77de738 ML |
10540 | @opindex Wanalyzer-malloc-leak |
10541 | @opindex Wno-analyzer-malloc-leak | |
ddf6fe37 | 10542 | @item -Wno-analyzer-malloc-leak |
d77de738 ML |
10543 | This warning requires @option{-fanalyzer}, which enables it; use |
10544 | @option{-Wno-analyzer-malloc-leak} | |
10545 | to disable it. | |
10546 | ||
10547 | This diagnostic warns for paths through the code in which a | |
10548 | pointer allocated via an allocator is leaked: either @code{malloc}, | |
10549 | or a function marked with attribute @code{malloc}. | |
10550 | ||
10551 | See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}. | |
10552 | ||
d77de738 ML |
10553 | @opindex Wanalyzer-mismatching-deallocation |
10554 | @opindex Wno-analyzer-mismatching-deallocation | |
ddf6fe37 | 10555 | @item -Wno-analyzer-mismatching-deallocation |
d77de738 ML |
10556 | This warning requires @option{-fanalyzer}, which enables it; use |
10557 | @option{-Wno-analyzer-mismatching-deallocation} | |
10558 | to disable it. | |
10559 | ||
10560 | This diagnostic warns for paths through the code in which the | |
10561 | wrong deallocation function is called on a pointer value, based on | |
10562 | which function was used to allocate the pointer value. The diagnostic | |
10563 | will warn about mismatches between @code{free}, scalar @code{delete} | |
10564 | and vector @code{delete[]}, and those marked as allocator/deallocator | |
10565 | pairs using attribute @code{malloc}. | |
10566 | ||
10567 | See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}. | |
10568 | ||
d77de738 ML |
10569 | @opindex Wanalyzer-out-of-bounds |
10570 | @opindex Wno-analyzer-out-of-bounds | |
ddf6fe37 | 10571 | @item -Wno-analyzer-out-of-bounds |
4ace81b6 | 10572 | This warning requires @option{-fanalyzer}, which enables it; use |
d77de738 ML |
10573 | @option{-Wno-analyzer-out-of-bounds} to disable it. |
10574 | ||
4ace81b6 | 10575 | This diagnostic warns for paths through the code in which a buffer is |
d77de738 ML |
10576 | definitely read or written out-of-bounds. The diagnostic applies for |
10577 | cases where the analyzer is able to determine a constant offset and for | |
10578 | accesses past the end of a buffer, also a constant capacity. Further, | |
10579 | the diagnostic does limited checking for accesses past the end when the | |
10580 | offset as well as the capacity is symbolic. | |
10581 | ||
10582 | See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}. | |
10583 | ||
d77de738 ML |
10584 | @opindex Wanalyzer-possible-null-argument |
10585 | @opindex Wno-analyzer-possible-null-argument | |
ddf6fe37 | 10586 | @item -Wno-analyzer-possible-null-argument |
d77de738 ML |
10587 | This warning requires @option{-fanalyzer}, which enables it; use |
10588 | @option{-Wno-analyzer-possible-null-argument} to disable it. | |
10589 | ||
10590 | This diagnostic warns for paths through the code in which a | |
10591 | possibly-NULL value is passed to a function argument marked | |
10592 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10593 | value. | |
10594 | ||
10595 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10596 | ||
d77de738 ML |
10597 | @opindex Wanalyzer-possible-null-dereference |
10598 | @opindex Wno-analyzer-possible-null-dereference | |
ddf6fe37 | 10599 | @item -Wno-analyzer-possible-null-dereference |
d77de738 ML |
10600 | This warning requires @option{-fanalyzer}, which enables it; use |
10601 | @option{-Wno-analyzer-possible-null-dereference} to disable it. | |
10602 | ||
10603 | This diagnostic warns for paths through the code in which a | |
10604 | possibly-NULL value is dereferenced. | |
10605 | ||
10606 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10607 | ||
d77de738 ML |
10608 | @opindex Wanalyzer-null-argument |
10609 | @opindex Wno-analyzer-null-argument | |
ddf6fe37 | 10610 | @item -Wno-analyzer-null-argument |
d77de738 ML |
10611 | This warning requires @option{-fanalyzer}, which enables it; use |
10612 | @option{-Wno-analyzer-null-argument} to disable it. | |
10613 | ||
10614 | This diagnostic warns for paths through the code in which a | |
10615 | value known to be NULL is passed to a function argument marked | |
10616 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10617 | value. | |
10618 | ||
10619 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10620 | ||
d77de738 ML |
10621 | @opindex Wanalyzer-null-dereference |
10622 | @opindex Wno-analyzer-null-dereference | |
ddf6fe37 | 10623 | @item -Wno-analyzer-null-dereference |
d77de738 ML |
10624 | This warning requires @option{-fanalyzer}, which enables it; use |
10625 | @option{-Wno-analyzer-null-dereference} to disable it. | |
10626 | ||
10627 | This diagnostic warns for paths through the code in which a | |
10628 | value known to be NULL is dereferenced. | |
10629 | ||
10630 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10631 | ||
d77de738 ML |
10632 | @opindex Wanalyzer-putenv-of-auto-var |
10633 | @opindex Wno-analyzer-putenv-of-auto-var | |
ddf6fe37 | 10634 | @item -Wno-analyzer-putenv-of-auto-var |
d77de738 ML |
10635 | This warning requires @option{-fanalyzer}, which enables it; use |
10636 | @option{-Wno-analyzer-putenv-of-auto-var} to disable it. | |
10637 | ||
10638 | This diagnostic warns for paths through the code in which a | |
10639 | call to @code{putenv} is passed a pointer to an automatic variable | |
10640 | or an on-stack buffer. | |
10641 | ||
10642 | 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}. | |
10643 | ||
d77de738 ML |
10644 | @opindex Wanalyzer-shift-count-negative |
10645 | @opindex Wno-analyzer-shift-count-negative | |
ddf6fe37 | 10646 | @item -Wno-analyzer-shift-count-negative |
d77de738 ML |
10647 | This warning requires @option{-fanalyzer}, which enables it; use |
10648 | @option{-Wno-analyzer-shift-count-negative} to disable it. | |
10649 | ||
10650 | This diagnostic warns for paths through the code in which a | |
10651 | shift is attempted with a negative count. It is analogous to | |
10652 | the @option{-Wshift-count-negative} diagnostic implemented in | |
10653 | the C/C++ front ends, but is implemented based on analyzing | |
10654 | interprocedural paths, rather than merely parsing the syntax tree. | |
10655 | However, the analyzer does not prioritize detection of such paths, so | |
10656 | false negatives are more likely relative to other warnings. | |
10657 | ||
d77de738 ML |
10658 | @opindex Wanalyzer-shift-count-overflow |
10659 | @opindex Wno-analyzer-shift-count-overflow | |
ddf6fe37 | 10660 | @item -Wno-analyzer-shift-count-overflow |
d77de738 ML |
10661 | This warning requires @option{-fanalyzer}, which enables it; use |
10662 | @option{-Wno-analyzer-shift-count-overflow} to disable it. | |
10663 | ||
10664 | This diagnostic warns for paths through the code in which a | |
10665 | shift is attempted with a count greater than or equal to the | |
10666 | precision of the operand's type. It is analogous to | |
10667 | the @option{-Wshift-count-overflow} diagnostic implemented in | |
10668 | the C/C++ front ends, but is implemented based on analyzing | |
10669 | interprocedural paths, rather than merely parsing the syntax tree. | |
10670 | However, the analyzer does not prioritize detection of such paths, so | |
10671 | false negatives are more likely relative to other warnings. | |
10672 | ||
d77de738 ML |
10673 | @opindex Wanalyzer-stale-setjmp-buffer |
10674 | @opindex Wno-analyzer-stale-setjmp-buffer | |
ddf6fe37 | 10675 | @item -Wno-analyzer-stale-setjmp-buffer |
d77de738 ML |
10676 | This warning requires @option{-fanalyzer}, which enables it; use |
10677 | @option{-Wno-analyzer-stale-setjmp-buffer} to disable it. | |
10678 | ||
10679 | This diagnostic warns for paths through the code in which | |
10680 | @code{longjmp} is called to rewind to a @code{jmp_buf} relating | |
10681 | to a @code{setjmp} call in a function that has returned. | |
10682 | ||
10683 | When @code{setjmp} is called on a @code{jmp_buf} to record a rewind | |
10684 | location, it records the stack frame. The stack frame becomes invalid | |
10685 | when the function containing the @code{setjmp} call returns. Attempting | |
10686 | to rewind to it via @code{longjmp} would reference a stack frame that | |
10687 | no longer exists, and likely lead to a crash (or worse). | |
10688 | ||
d77de738 ML |
10689 | @opindex Wanalyzer-tainted-allocation-size |
10690 | @opindex Wno-analyzer-tainted-allocation-size | |
ddf6fe37 | 10691 | @item -Wno-analyzer-tainted-allocation-size |
d77de738 ML |
10692 | This warning requires both @option{-fanalyzer} and |
10693 | @option{-fanalyzer-checker=taint} to enable it; | |
10694 | use @option{-Wno-analyzer-tainted-allocation-size} to disable it. | |
10695 | ||
10696 | This diagnostic warns for paths through the code in which a value | |
10697 | that could be under an attacker's control is used as the size | |
10698 | of an allocation without being sanitized, so that an attacker could | |
10699 | inject an excessively large allocation and potentially cause a denial | |
10700 | of service attack. | |
10701 | ||
10702 | See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. | |
10703 | ||
ce51e843 ML |
10704 | @opindex Wanalyzer-tainted-assertion |
10705 | @opindex Wno-analyzer-tainted-assertion | |
ddf6fe37 | 10706 | @item -Wno-analyzer-tainted-assertion |
ce51e843 ML |
10707 | |
10708 | This warning requires both @option{-fanalyzer} and | |
10709 | @option{-fanalyzer-checker=taint} to enable it; | |
10710 | use @option{-Wno-analyzer-tainted-assertion} to disable it. | |
10711 | ||
10712 | This diagnostic warns for paths through the code in which a value | |
10713 | that could be under an attacker's control is used as part of a | |
10714 | condition without being first sanitized, and that condition guards a | |
10715 | call to a function marked with attribute @code{noreturn} | |
10716 | (such as the function @code{__builtin_unreachable}). Such functions | |
10717 | typically indicate abnormal termination of the program, such as for | |
10718 | assertion failure handlers. For example: | |
10719 | ||
10720 | @smallexample | |
10721 | assert (some_tainted_value < SOME_LIMIT); | |
10722 | @end smallexample | |
10723 | ||
10724 | In such cases: | |
10725 | ||
10726 | @itemize | |
10727 | @item | |
10728 | when assertion-checking is enabled: an attacker could trigger | |
10729 | a denial of service by injecting an assertion failure | |
10730 | ||
10731 | @item | |
10732 | when assertion-checking is disabled, such as by defining @code{NDEBUG}, | |
10733 | an attacker could inject data that subverts the process, since it | |
10734 | presumably violates a precondition that is being assumed by the code. | |
10735 | ||
10736 | @end itemize | |
10737 | ||
10738 | Note that when assertion-checking is disabled, the assertions are | |
10739 | typically removed by the preprocessor before the analyzer has a chance | |
10740 | to "see" them, so this diagnostic can only generate warnings on builds | |
10741 | in which assertion-checking is enabled. | |
10742 | ||
10743 | For the purpose of this warning, any function marked with attribute | |
10744 | @code{noreturn} is considered as a possible assertion failure | |
10745 | handler, including @code{__builtin_unreachable}. Note that these functions | |
10746 | are sometimes removed by the optimizer before the analyzer "sees" them. | |
10747 | Hence optimization should be disabled when attempting to trigger this | |
10748 | diagnostic. | |
10749 | ||
10750 | See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}. | |
10751 | ||
10752 | The warning can also report problematic constructions such as | |
10753 | ||
10754 | @smallexample | |
10755 | switch (some_tainted_value) @{ | |
10756 | case 0: | |
10757 | /* [...etc; various valid cases omitted...] */ | |
10758 | break; | |
10759 | ||
10760 | default: | |
10761 | __builtin_unreachable (); /* BUG: attacker can trigger this */ | |
10762 | @} | |
10763 | @end smallexample | |
10764 | ||
10765 | despite the above not being an assertion failure, strictly speaking. | |
10766 | ||
d77de738 ML |
10767 | @opindex Wanalyzer-tainted-array-index |
10768 | @opindex Wno-analyzer-tainted-array-index | |
ddf6fe37 | 10769 | @item -Wno-analyzer-tainted-array-index |
d77de738 ML |
10770 | This warning requires both @option{-fanalyzer} and |
10771 | @option{-fanalyzer-checker=taint} to enable it; | |
10772 | use @option{-Wno-analyzer-tainted-array-index} to disable it. | |
10773 | ||
10774 | This diagnostic warns for paths through the code in which a value | |
10775 | that could be under an attacker's control is used as the index | |
10776 | of an array access without being sanitized, so that an attacker | |
10777 | could inject an out-of-bounds access. | |
10778 | ||
10779 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
10780 | ||
d77de738 ML |
10781 | @opindex Wanalyzer-tainted-divisor |
10782 | @opindex Wno-analyzer-tainted-divisor | |
ddf6fe37 | 10783 | @item -Wno-analyzer-tainted-divisor |
d77de738 ML |
10784 | This warning requires both @option{-fanalyzer} and |
10785 | @option{-fanalyzer-checker=taint} to enable it; | |
10786 | use @option{-Wno-analyzer-tainted-divisor} to disable it. | |
10787 | ||
10788 | This diagnostic warns for paths through the code in which a value | |
10789 | that could be under an attacker's control is used as the divisor | |
10790 | in a division or modulus operation without being sanitized, so that | |
10791 | an attacker could inject a division-by-zero. | |
10792 | ||
10793 | See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}. | |
10794 | ||
d77de738 ML |
10795 | @opindex Wanalyzer-tainted-offset |
10796 | @opindex Wno-analyzer-tainted-offset | |
ddf6fe37 | 10797 | @item -Wno-analyzer-tainted-offset |
d77de738 ML |
10798 | This warning requires both @option{-fanalyzer} and |
10799 | @option{-fanalyzer-checker=taint} to enable it; | |
10800 | use @option{-Wno-analyzer-tainted-offset} to disable it. | |
10801 | ||
10802 | This diagnostic warns for paths through the code in which a value | |
10803 | that could be under an attacker's control is used as a pointer offset | |
10804 | without being sanitized, so that an attacker could inject an out-of-bounds | |
10805 | access. | |
10806 | ||
10807 | See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. | |
10808 | ||
d77de738 ML |
10809 | @opindex Wanalyzer-tainted-size |
10810 | @opindex Wno-analyzer-tainted-size | |
ddf6fe37 | 10811 | @item -Wno-analyzer-tainted-size |
d77de738 ML |
10812 | This warning requires both @option{-fanalyzer} and |
10813 | @option{-fanalyzer-checker=taint} to enable it; | |
10814 | use @option{-Wno-analyzer-tainted-size} to disable it. | |
10815 | ||
10816 | This diagnostic warns for paths through the code in which a value | |
10817 | that could be under an attacker's control is used as the size of | |
10818 | an operation such as @code{memset} without being sanitized, so that an | |
10819 | attacker could inject an out-of-bounds access. | |
10820 | ||
10821 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
10822 | ||
d77de738 ML |
10823 | @opindex Wanalyzer-unsafe-call-within-signal-handler |
10824 | @opindex Wno-analyzer-unsafe-call-within-signal-handler | |
ddf6fe37 | 10825 | @item -Wno-analyzer-unsafe-call-within-signal-handler |
d77de738 ML |
10826 | This warning requires @option{-fanalyzer}, which enables it; use |
10827 | @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it. | |
10828 | ||
10829 | This diagnostic warns for paths through the code in which a | |
10830 | function known to be async-signal-unsafe (such as @code{fprintf}) is | |
10831 | called from a signal handler. | |
10832 | ||
10833 | See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}. | |
10834 | ||
d77de738 ML |
10835 | @opindex Wanalyzer-use-after-free |
10836 | @opindex Wno-analyzer-use-after-free | |
ddf6fe37 | 10837 | @item -Wno-analyzer-use-after-free |
d77de738 ML |
10838 | This warning requires @option{-fanalyzer}, which enables it; use |
10839 | @option{-Wno-analyzer-use-after-free} to disable it. | |
10840 | ||
10841 | This diagnostic warns for paths through the code in which a | |
10842 | pointer is used after a deallocator is called on it: either @code{free}, | |
10843 | or a deallocator referenced by attribute @code{malloc}. | |
10844 | ||
10845 | See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}. | |
10846 | ||
d77de738 ML |
10847 | @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame |
10848 | @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
ddf6fe37 | 10849 | @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame |
d77de738 ML |
10850 | This warning requires @option{-fanalyzer}, which enables it; use |
10851 | @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame} | |
10852 | to disable it. | |
10853 | ||
10854 | This diagnostic warns for paths through the code in which a pointer | |
10855 | is dereferenced that points to a variable in a stale stack frame. | |
10856 | ||
d77de738 ML |
10857 | @opindex Wanalyzer-va-arg-type-mismatch |
10858 | @opindex Wno-analyzer-va-arg-type-mismatch | |
ddf6fe37 | 10859 | @item -Wno-analyzer-va-arg-type-mismatch |
d77de738 ML |
10860 | This warning requires @option{-fanalyzer}, which enables it; use |
10861 | @option{-Wno-analyzer-va-arg-type-mismatch} | |
10862 | to disable it. | |
10863 | ||
10864 | This diagnostic warns for interprocedural paths through the code for which | |
10865 | the analyzer detects an attempt to use @code{va_arg} to extract a value | |
10866 | passed to a variadic call, but uses a type that does not match that of | |
10867 | the expression passed to the call. | |
10868 | ||
10869 | See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}. | |
10870 | ||
d77de738 ML |
10871 | @opindex Wanalyzer-va-list-exhausted |
10872 | @opindex Wno-analyzer-va-list-exhausted | |
ddf6fe37 | 10873 | @item -Wno-analyzer-va-list-exhausted |
d77de738 ML |
10874 | This warning requires @option{-fanalyzer}, which enables it; use |
10875 | @option{-Wno-analyzer-va-list-exhausted} | |
10876 | to disable it. | |
10877 | ||
10878 | This diagnostic warns for interprocedural paths through the code for which | |
10879 | the analyzer detects an attempt to use @code{va_arg} to access the next | |
10880 | value passed to a variadic call, but all of the values in the | |
10881 | @code{va_list} have already been consumed. | |
10882 | ||
10883 | See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}. | |
10884 | ||
d77de738 ML |
10885 | @opindex Wanalyzer-va-list-leak |
10886 | @opindex Wno-analyzer-va-list-leak | |
ddf6fe37 | 10887 | @item -Wno-analyzer-va-list-leak |
d77de738 ML |
10888 | This warning requires @option{-fanalyzer}, which enables it; use |
10889 | @option{-Wno-analyzer-va-list-leak} | |
10890 | to disable it. | |
10891 | ||
10892 | This diagnostic warns for interprocedural paths through the code for which | |
10893 | the analyzer detects that @code{va_start} or @code{va_copy} has been called | |
10894 | on a @code{va_list} without a corresponding call to @code{va_end}. | |
10895 | ||
d77de738 ML |
10896 | @opindex Wanalyzer-va-list-use-after-va-end |
10897 | @opindex Wno-analyzer-va-list-use-after-va-end | |
ddf6fe37 | 10898 | @item -Wno-analyzer-va-list-use-after-va-end |
d77de738 ML |
10899 | This warning requires @option{-fanalyzer}, which enables it; use |
10900 | @option{-Wno-analyzer-va-list-use-after-va-end} | |
10901 | to disable it. | |
10902 | ||
10903 | This diagnostic warns for interprocedural paths through the code for which | |
10904 | the analyzer detects an attempt to use a @code{va_list} after | |
10905 | @code{va_end} has been called on it. | |
10906 | @code{va_list}. | |
10907 | ||
d77de738 ML |
10908 | @opindex Wanalyzer-write-to-const |
10909 | @opindex Wno-analyzer-write-to-const | |
ddf6fe37 | 10910 | @item -Wno-analyzer-write-to-const |
d77de738 ML |
10911 | This warning requires @option{-fanalyzer}, which enables it; use |
10912 | @option{-Wno-analyzer-write-to-const} | |
10913 | to disable it. | |
10914 | ||
10915 | This diagnostic warns for paths through the code in which the analyzer | |
10916 | detects an attempt to write through a pointer to a @code{const} object. | |
10917 | However, the analyzer does not prioritize detection of such paths, so | |
10918 | false negatives are more likely relative to other warnings. | |
10919 | ||
d77de738 ML |
10920 | @opindex Wanalyzer-write-to-string-literal |
10921 | @opindex Wno-analyzer-write-to-string-literal | |
ddf6fe37 | 10922 | @item -Wno-analyzer-write-to-string-literal |
d77de738 ML |
10923 | This warning requires @option{-fanalyzer}, which enables it; use |
10924 | @option{-Wno-analyzer-write-to-string-literal} | |
10925 | to disable it. | |
10926 | ||
10927 | This diagnostic warns for paths through the code in which the analyzer | |
10928 | detects an attempt to write through a pointer to a string literal. | |
10929 | However, the analyzer does not prioritize detection of such paths, so | |
10930 | false negatives are more likely relative to other warnings. | |
10931 | ||
d77de738 ML |
10932 | @opindex Wanalyzer-use-of-uninitialized-value |
10933 | @opindex Wno-analyzer-use-of-uninitialized-value | |
ddf6fe37 | 10934 | @item -Wno-analyzer-use-of-uninitialized-value |
d77de738 ML |
10935 | This warning requires @option{-fanalyzer}, which enables it; use |
10936 | @option{-Wno-analyzer-use-of-uninitialized-value} to disable it. | |
10937 | ||
10938 | This diagnostic warns for paths through the code in which an uninitialized | |
10939 | value is used. | |
10940 | ||
10941 | See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}. | |
10942 | ||
10943 | @end table | |
10944 | ||
10945 | The analyzer has hardcoded knowledge about the behavior of the following | |
10946 | memory-management functions: | |
10947 | ||
10948 | @itemize @bullet | |
10949 | @item @code{alloca} | |
10950 | @item The built-in functions @code{__builtin_alloc}, | |
10951 | @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, | |
10952 | @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, | |
10953 | @code{__builtin_memcpy_chk}, @code{__builtin_memset}, | |
10954 | @code{__builtin_memset_chk}, @code{__builtin_realloc}, | |
10955 | @code{__builtin_stack_restore}, and @code{__builtin_stack_save} | |
10956 | @item @code{calloc} | |
10957 | @item @code{free} | |
10958 | @item @code{malloc} | |
10959 | @item @code{memset} | |
10960 | @item @code{operator delete} | |
10961 | @item @code{operator delete []} | |
10962 | @item @code{operator new} | |
10963 | @item @code{operator new []} | |
10964 | @item @code{realloc} | |
10965 | @item @code{strdup} | |
10966 | @item @code{strndup} | |
10967 | @end itemize | |
10968 | ||
4ace81b6 | 10969 | @noindent |
d77de738 ML |
10970 | of the following functions for working with file descriptors: |
10971 | ||
10972 | @itemize @bullet | |
10973 | @item @code{open} | |
10974 | @item @code{close} | |
10975 | @item @code{creat} | |
10976 | @item @code{dup}, @code{dup2} and @code{dup3} | |
78a17f44 | 10977 | @item @code{isatty} |
d77de738 ML |
10978 | @item @code{pipe}, and @code{pipe2} |
10979 | @item @code{read} | |
10980 | @item @code{write} | |
86a90006 | 10981 | @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect} |
d77de738 ML |
10982 | @end itemize |
10983 | ||
4ace81b6 | 10984 | @noindent |
d77de738 ML |
10985 | of the following functions for working with @code{<stdio.h>} streams: |
10986 | @itemize @bullet | |
10987 | @item The built-in functions @code{__builtin_fprintf}, | |
10988 | @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, | |
10989 | @code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, | |
10990 | @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, | |
10991 | @code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, | |
10992 | @code{__builtin_printf_unlocked}, @code{__builtin_putc}, | |
10993 | @code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, | |
10994 | @code{__builtin_putc_unlocked}, @code{__builtin_puts}, | |
10995 | @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and | |
10996 | @code{__builtin_vprintf} | |
10997 | @item @code{fopen} | |
10998 | @item @code{fclose} | |
78a17f44 | 10999 | @item @code{ferror} |
d77de738 ML |
11000 | @item @code{fgets} |
11001 | @item @code{fgets_unlocked} | |
78a17f44 | 11002 | @item @code{fileno} |
d77de738 | 11003 | @item @code{fread} |
78a17f44 | 11004 | @item @code{getc} |
d77de738 ML |
11005 | @item @code{getchar} |
11006 | @item @code{fprintf} | |
11007 | @item @code{printf} | |
11008 | @item @code{fwrite} | |
11009 | @end itemize | |
11010 | ||
4ace81b6 | 11011 | @noindent |
d77de738 ML |
11012 | and of the following functions: |
11013 | ||
11014 | @itemize @bullet | |
11015 | @item The built-in functions @code{__builtin_expect}, | |
11016 | @code{__builtin_expect_with_probability}, @code{__builtin_strchr}, | |
11017 | @code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, | |
11018 | @code{__builtin_strlen}, @code{__builtin_va_copy}, and | |
11019 | @code{__builtin_va_start} | |
11020 | @item The GNU extensions @code{error} and @code{error_at_line} | |
11021 | @item @code{getpass} | |
11022 | @item @code{longjmp} | |
11023 | @item @code{putenv} | |
11024 | @item @code{setjmp} | |
11025 | @item @code{siglongjmp} | |
11026 | @item @code{signal} | |
11027 | @item @code{sigsetjmp} | |
11028 | @item @code{strchr} | |
11029 | @item @code{strlen} | |
11030 | @end itemize | |
11031 | ||
11032 | In addition, various functions with an @code{__analyzer_} prefix have | |
11033 | special meaning to the analyzer, described in the GCC Internals manual. | |
11034 | ||
11035 | Pertinent parameters for controlling the exploration are: | |
4ace81b6 SL |
11036 | @itemize @bullet |
11037 | @item @option{--param analyzer-bb-explosion-factor=@var{value}} | |
11038 | @item @option{--param analyzer-max-enodes-per-program-point=@var{value}} | |
11039 | @item @option{--param analyzer-max-recursion-depth=@var{value}} | |
11040 | @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}} | |
11041 | @end itemize | |
d77de738 ML |
11042 | |
11043 | The following options control the analyzer. | |
11044 | ||
11045 | @table @gcctabopt | |
11046 | ||
d77de738 ML |
11047 | @opindex fanalyzer-call-summaries |
11048 | @opindex fno-analyzer-call-summaries | |
ddf6fe37 | 11049 | @item -fanalyzer-call-summaries |
d77de738 ML |
11050 | Simplify interprocedural analysis by computing the effect of certain calls, |
11051 | rather than exploring all paths through the function from callsite to each | |
11052 | possible return. | |
11053 | ||
11054 | If enabled, call summaries are only used for functions with more than one | |
11055 | call site, and that are sufficiently complicated (as per | |
11056 | @option{--param analyzer-min-snodes-for-call-summary=@var{value}}). | |
11057 | ||
d77de738 | 11058 | @opindex fanalyzer-checker |
ddf6fe37 | 11059 | @item -fanalyzer-checker=@var{name} |
d77de738 ML |
11060 | Restrict the analyzer to run just the named checker, and enable it. |
11061 | ||
11062 | Some checkers are disabled by default (even with @option{-fanalyzer}), | |
11063 | such as the @code{taint} checker that implements | |
11064 | @option{-Wanalyzer-tainted-array-index}, and this option is required | |
11065 | to enable them. | |
11066 | ||
11067 | @emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the | |
11068 | following warnings from @option{-fanalyzer}: | |
11069 | ||
43b72ede AA |
11070 | @gccoptlist{ |
11071 | -Wanalyzer-deref-before-check | |
11072 | -Wanalyzer-double-fclose | |
11073 | -Wanalyzer-double-free | |
11074 | -Wanalyzer-exposure-through-output-file | |
11075 | -Wanalyzer-fd-access-mode-mismatch | |
11076 | -Wanalyzer-fd-double-close | |
11077 | -Wanalyzer-fd-leak | |
11078 | -Wanalyzer-fd-use-after-close | |
11079 | -Wanalyzer-fd-use-without-check | |
11080 | -Wanalyzer-file-leak | |
11081 | -Wanalyzer-free-of-non-heap | |
11082 | -Wanalyzer-malloc-leak | |
11083 | -Wanalyzer-mismatching-deallocation | |
11084 | -Wanalyzer-null-argument | |
11085 | -Wanalyzer-null-dereference | |
11086 | -Wanalyzer-possible-null-argument | |
11087 | -Wanalyzer-possible-null-dereference | |
11088 | -Wanalyzer-unsafe-call-within-signal-handler | |
11089 | -Wanalyzer-use-after-free | |
11090 | -Wanalyzer-va-list-leak | |
11091 | -Wanalyzer-va-list-use-after-va-end | |
d77de738 ML |
11092 | } |
11093 | ||
d77de738 ML |
11094 | @opindex fanalyzer-feasibility |
11095 | @opindex fno-analyzer-feasibility | |
ddf6fe37 | 11096 | @item -fno-analyzer-feasibility |
d77de738 ML |
11097 | This option is intended for analyzer developers. |
11098 | ||
11099 | By default the analyzer verifies that there is a feasible control flow path | |
11100 | for each diagnostic it emits: that the conditions that hold are not mutually | |
11101 | exclusive. Diagnostics for which no feasible path can be found are rejected. | |
11102 | This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for | |
11103 | debugging issues in this code. | |
11104 | ||
d77de738 ML |
11105 | @opindex fanalyzer-fine-grained |
11106 | @opindex fno-analyzer-fine-grained | |
ddf6fe37 | 11107 | @item -fanalyzer-fine-grained |
d77de738 ML |
11108 | This option is intended for analyzer developers. |
11109 | ||
11110 | Internally the analyzer builds an ``exploded graph'' that combines | |
11111 | control flow graphs with data flow information. | |
11112 | ||
11113 | By default, an edge in this graph can contain the effects of a run | |
11114 | of multiple statements within a basic block. With | |
11115 | @option{-fanalyzer-fine-grained}, each statement gets its own edge. | |
11116 | ||
d77de738 ML |
11117 | @opindex fanalyzer-show-duplicate-count |
11118 | @opindex fno-analyzer-show-duplicate-count | |
ddf6fe37 | 11119 | @item -fanalyzer-show-duplicate-count |
d77de738 ML |
11120 | This option is intended for analyzer developers: if multiple diagnostics |
11121 | have been detected as being duplicates of each other, it emits a note when | |
11122 | reporting the best diagnostic, giving the number of additional diagnostics | |
11123 | that were suppressed by the deduplication logic. | |
11124 | ||
d77de738 ML |
11125 | @opindex fanalyzer-state-merge |
11126 | @opindex fno-analyzer-state-merge | |
ddf6fe37 | 11127 | @item -fno-analyzer-state-merge |
d77de738 ML |
11128 | This option is intended for analyzer developers. |
11129 | ||
11130 | By default the analyzer attempts to simplify analysis by merging | |
11131 | sufficiently similar states at each program point as it builds its | |
11132 | ``exploded graph''. With @option{-fno-analyzer-state-merge} this | |
11133 | merging can be suppressed, for debugging state-handling issues. | |
11134 | ||
d77de738 ML |
11135 | @opindex fanalyzer-state-purge |
11136 | @opindex fno-analyzer-state-purge | |
ddf6fe37 | 11137 | @item -fno-analyzer-state-purge |
d77de738 ML |
11138 | This option is intended for analyzer developers. |
11139 | ||
11140 | By default the analyzer attempts to simplify analysis by purging | |
11141 | aspects of state at a program point that appear to no longer be relevant | |
11142 | e.g. the values of locals that aren't accessed later in the function | |
11143 | and which aren't relevant to leak analysis. | |
11144 | ||
11145 | With @option{-fno-analyzer-state-purge} this purging of state can | |
11146 | be suppressed, for debugging state-handling issues. | |
11147 | ||
8f636915 DM |
11148 | @opindex fanalyzer-suppress-followups |
11149 | @opindex fno-analyzer-suppress-followups | |
f33d7a88 | 11150 | @item -fno-analyzer-suppress-followups |
8f636915 DM |
11151 | This option is intended for analyzer developers. |
11152 | ||
11153 | By default the analyzer will stop exploring an execution path after | |
11154 | encountering certain diagnostics, in order to avoid potentially issuing a | |
11155 | cascade of follow-up diagnostics. | |
11156 | ||
11157 | The diagnostics that terminate analysis along a path are: | |
11158 | ||
11159 | @itemize | |
11160 | @item @option{-Wanalyzer-null-argument} | |
11161 | @item @option{-Wanalyzer-null-dereference} | |
11162 | @item @option{-Wanalyzer-use-after-free} | |
11163 | @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame} | |
11164 | @item @option{-Wanalyzer-use-of-uninitialized-value} | |
11165 | @end itemize | |
11166 | ||
11167 | With @option{-fno-analyzer-suppress-followups} the analyzer will | |
11168 | continue to explore such paths even after such diagnostics, which may | |
11169 | be helpful for debugging issues in the analyzer, or for microbenchmarks | |
11170 | for detecting undefined behavior. | |
11171 | ||
d77de738 ML |
11172 | @opindex fanalyzer-transitivity |
11173 | @opindex fno-analyzer-transitivity | |
ddf6fe37 | 11174 | @item -fanalyzer-transitivity |
d77de738 ML |
11175 | This option enables transitivity of constraints within the analyzer. |
11176 | ||
d77de738 ML |
11177 | @opindex fanalyzer-undo-inlining |
11178 | @opindex fno-analyzer-undo-inlining | |
ddf6fe37 | 11179 | @item -fno-analyzer-undo-inlining |
d77de738 ML |
11180 | This option is intended for analyzer developers. |
11181 | ||
11182 | @option{-fanalyzer} runs relatively late compared to other code analysis | |
11183 | tools, and some optimizations have already been applied to the code. In | |
11184 | particular function inlining may have occurred, leading to the | |
11185 | interprocedural execution paths emitted by the analyzer containing | |
11186 | function frames that don't correspond to those in the original source | |
11187 | code. | |
11188 | ||
11189 | By default the analyzer attempts to reconstruct the original function | |
11190 | frames, and to emit events showing the inlined calls. | |
11191 | ||
11192 | With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct | |
11193 | the original frame information can be be disabled, which may be of help | |
11194 | when debugging issues in the analyzer. | |
11195 | ||
11196 | @item -fanalyzer-verbose-edges | |
11197 | This option is intended for analyzer developers. It enables more | |
11198 | verbose, lower-level detail in the descriptions of control flow | |
11199 | within diagnostic paths. | |
11200 | ||
11201 | @item -fanalyzer-verbose-state-changes | |
11202 | This option is intended for analyzer developers. It enables more | |
11203 | verbose, lower-level detail in the descriptions of events relating | |
11204 | to state machines within diagnostic paths. | |
11205 | ||
11206 | @item -fanalyzer-verbosity=@var{level} | |
11207 | This option controls the complexity of the control flow paths that are | |
11208 | emitted for analyzer diagnostics. | |
11209 | ||
11210 | The @var{level} can be one of: | |
11211 | ||
11212 | @table @samp | |
11213 | @item 0 | |
11214 | At this level, interprocedural call and return events are displayed, | |
11215 | along with the most pertinent state-change events relating to | |
11216 | a diagnostic. For example, for a double-@code{free} diagnostic, | |
11217 | both calls to @code{free} will be shown. | |
11218 | ||
11219 | @item 1 | |
11220 | As per the previous level, but also show events for the entry | |
11221 | to each function. | |
11222 | ||
11223 | @item 2 | |
11224 | As per the previous level, but also show events relating to | |
11225 | control flow that are significant to triggering the issue | |
11226 | (e.g. ``true path taken'' at a conditional). | |
11227 | ||
11228 | This level is the default. | |
11229 | ||
11230 | @item 3 | |
11231 | As per the previous level, but show all control flow events, not | |
11232 | just significant ones. | |
11233 | ||
11234 | @item 4 | |
11235 | This level is intended for analyzer developers; it adds various | |
11236 | other events intended for debugging the analyzer. | |
11237 | ||
11238 | @end table | |
11239 | ||
d77de738 | 11240 | @opindex fdump-analyzer |
ddf6fe37 | 11241 | @item -fdump-analyzer |
d77de738 ML |
11242 | Dump internal details about what the analyzer is doing to |
11243 | @file{@var{file}.analyzer.txt}. | |
4ace81b6 | 11244 | @option{-fdump-analyzer-stderr} overrides this option. |
d77de738 | 11245 | |
d77de738 | 11246 | @opindex fdump-analyzer-stderr |
ddf6fe37 | 11247 | @item -fdump-analyzer-stderr |
d77de738 ML |
11248 | Dump internal details about what the analyzer is doing to stderr. |
11249 | This option overrides @option{-fdump-analyzer}. | |
11250 | ||
d77de738 | 11251 | @opindex fdump-analyzer-callgraph |
ddf6fe37 | 11252 | @item -fdump-analyzer-callgraph |
d77de738 ML |
11253 | Dump a representation of the call graph suitable for viewing with |
11254 | GraphViz to @file{@var{file}.callgraph.dot}. | |
11255 | ||
d77de738 | 11256 | @opindex fdump-analyzer-exploded-graph |
ddf6fe37 | 11257 | @item -fdump-analyzer-exploded-graph |
d77de738 ML |
11258 | Dump a representation of the ``exploded graph'' suitable for viewing with |
11259 | GraphViz to @file{@var{file}.eg.dot}. | |
11260 | Nodes are color-coded based on state-machine states to emphasize | |
11261 | state changes. | |
11262 | ||
d77de738 | 11263 | @opindex dump-analyzer-exploded-nodes |
ddf6fe37 | 11264 | @item -fdump-analyzer-exploded-nodes |
d77de738 ML |
11265 | Emit diagnostics showing where nodes in the ``exploded graph'' are |
11266 | in relation to the program source. | |
11267 | ||
d77de738 | 11268 | @opindex dump-analyzer-exploded-nodes-2 |
ddf6fe37 | 11269 | @item -fdump-analyzer-exploded-nodes-2 |
d77de738 ML |
11270 | Dump a textual representation of the ``exploded graph'' to |
11271 | @file{@var{file}.eg.txt}. | |
11272 | ||
d77de738 | 11273 | @opindex dump-analyzer-exploded-nodes-3 |
ddf6fe37 | 11274 | @item -fdump-analyzer-exploded-nodes-3 |
d77de738 ML |
11275 | Dump a textual representation of the ``exploded graph'' to |
11276 | one dump file per node, to @file{@var{file}.eg-@var{id}.txt}. | |
11277 | This is typically a large number of dump files. | |
11278 | ||
d77de738 | 11279 | @opindex fdump-analyzer-exploded-paths |
ddf6fe37 | 11280 | @item -fdump-analyzer-exploded-paths |
d77de738 ML |
11281 | Dump a textual representation of the ``exploded path'' for each |
11282 | diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}. | |
11283 | ||
d77de738 | 11284 | @opindex dump-analyzer-feasibility |
ddf6fe37 | 11285 | @item -fdump-analyzer-feasibility |
d77de738 ML |
11286 | Dump internal details about the analyzer's search for feasible paths. |
11287 | The details are written in a form suitable for viewing with GraphViz | |
11288 | to filenames of the form @file{@var{file}.*.fg.dot}, | |
11289 | @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}. | |
11290 | ||
d77de738 | 11291 | @opindex fdump-analyzer-json |
ddf6fe37 | 11292 | @item -fdump-analyzer-json |
d77de738 ML |
11293 | Dump a compressed JSON representation of analyzer internals to |
11294 | @file{@var{file}.analyzer.json.gz}. The precise format is subject | |
11295 | to change. | |
11296 | ||
d77de738 | 11297 | @opindex fdump-analyzer-state-purge |
ddf6fe37 | 11298 | @item -fdump-analyzer-state-purge |
d77de738 ML |
11299 | As per @option{-fdump-analyzer-supergraph}, dump a representation of the |
11300 | ``supergraph'' suitable for viewing with GraphViz, but annotate the | |
11301 | graph with information on what state will be purged at each node. | |
11302 | The graph is written to @file{@var{file}.state-purge.dot}. | |
11303 | ||
d77de738 | 11304 | @opindex fdump-analyzer-supergraph |
ddf6fe37 | 11305 | @item -fdump-analyzer-supergraph |
d77de738 ML |
11306 | Dump representations of the ``supergraph'' suitable for viewing with |
11307 | GraphViz to @file{@var{file}.supergraph.dot} and to | |
11308 | @file{@var{file}.supergraph-eg.dot}. These show all of the | |
11309 | control flow graphs in the program, with interprocedural edges for | |
11310 | calls and returns. The second dump contains annotations showing nodes | |
11311 | in the ``exploded graph'' and diagnostics associated with them. | |
11312 | ||
d77de738 | 11313 | @opindex fdump-analyzer-untracked |
ddf6fe37 | 11314 | @item -fdump-analyzer-untracked |
d77de738 ML |
11315 | Emit custom warnings with internal details intended for analyzer developers. |
11316 | ||
11317 | @end table | |
11318 | ||
11319 | @node Debugging Options | |
11320 | @section Options for Debugging Your Program | |
11321 | @cindex options, debugging | |
11322 | @cindex debugging information options | |
11323 | ||
11324 | To tell GCC to emit extra information for use by a debugger, in almost | |
11325 | all cases you need only to add @option{-g} to your other options. Some debug | |
11326 | formats can co-exist (like DWARF with CTF) when each of them is enabled | |
11327 | explicitly by adding the respective command line option to your other options. | |
11328 | ||
11329 | GCC allows you to use @option{-g} with | |
11330 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
11331 | be surprising: some variables you declared may not exist | |
11332 | at all; flow of control may briefly move where you did not expect it; | |
11333 | some statements may not be executed because they compute constant | |
11334 | results or their values are already at hand; some statements may | |
11335 | execute in different places because they have been moved out of loops. | |
11336 | Nevertheless it is possible to debug optimized output. This makes | |
11337 | it reasonable to use the optimizer for programs that might have bugs. | |
11338 | ||
11339 | If you are not using some other optimization option, consider | |
11340 | using @option{-Og} (@pxref{Optimize Options}) with @option{-g}. | |
11341 | With no @option{-O} option at all, some compiler passes that collect | |
11342 | information useful for debugging do not run at all, so that | |
11343 | @option{-Og} may result in a better debugging experience. | |
11344 | ||
11345 | @table @gcctabopt | |
d77de738 | 11346 | @opindex g |
ddf6fe37 | 11347 | @item -g |
d77de738 ML |
11348 | Produce debugging information in the operating system's native format |
11349 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging | |
11350 | information. | |
11351 | ||
11352 | On most systems that use stabs format, @option{-g} enables use of extra | |
11353 | debugging information that only GDB can use; this extra information | |
11354 | makes debugging work better in GDB but probably makes other debuggers | |
11355 | crash or refuse to read the program. If you want to control for certain whether | |
11356 | to generate the extra information, use @option{-gvms} (see below). | |
11357 | ||
d77de738 | 11358 | @opindex ggdb |
ddf6fe37 | 11359 | @item -ggdb |
d77de738 ML |
11360 | Produce debugging information for use by GDB@. This means to use the |
11361 | most expressive format available (DWARF, stabs, or the native format | |
11362 | if neither of those are supported), including GDB extensions if at all | |
11363 | possible. | |
11364 | ||
ddf6fe37 | 11365 | @opindex gdwarf |
d77de738 ML |
11366 | @item -gdwarf |
11367 | @itemx -gdwarf-@var{version} | |
d77de738 ML |
11368 | Produce debugging information in DWARF format (if that is supported). |
11369 | The value of @var{version} may be either 2, 3, 4 or 5; the default | |
11370 | version for most targets is 5 (with the exception of VxWorks, TPF and | |
11371 | Darwin/Mac OS X, which default to version 2, and AIX, which defaults | |
11372 | to version 4). | |
11373 | ||
11374 | Note that with DWARF Version 2, some ports require and always | |
11375 | use some non-conflicting DWARF 3 extensions in the unwind tables. | |
11376 | ||
11377 | Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments} | |
11378 | for maximum benefit. Version 5 requires GDB 8.0 or higher. | |
11379 | ||
11380 | GCC no longer supports DWARF Version 1, which is substantially | |
11381 | different than Version 2 and later. For historical reasons, some | |
11382 | other DWARF-related options such as | |
11383 | @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2 | |
11384 | in their names, but apply to all currently-supported versions of DWARF. | |
11385 | ||
d77de738 | 11386 | @opindex gbtf |
ddf6fe37 | 11387 | @item -gbtf |
d77de738 ML |
11388 | Request BTF debug information. BTF is the default debugging format for the |
11389 | eBPF target. On other targets, like x86, BTF debug information can be | |
11390 | generated along with DWARF debug information when both of the debug formats are | |
11391 | enabled explicitly via their respective command line options. | |
11392 | ||
ddf6fe37 | 11393 | @opindex gctf |
d77de738 ML |
11394 | @item -gctf |
11395 | @itemx -gctf@var{level} | |
d77de738 ML |
11396 | Request CTF debug information and use level to specify how much CTF debug |
11397 | information should be produced. If @option{-gctf} is specified | |
11398 | without a value for level, the default level of CTF debug information is 2. | |
11399 | ||
11400 | CTF debug information can be generated along with DWARF debug information when | |
11401 | both of the debug formats are enabled explicitly via their respective command | |
11402 | line options. | |
11403 | ||
11404 | Level 0 produces no CTF debug information at all. Thus, @option{-gctf0} | |
11405 | negates @option{-gctf}. | |
11406 | ||
11407 | Level 1 produces CTF information for tracebacks only. This includes callsite | |
11408 | information, but does not include type information. | |
11409 | ||
11410 | Level 2 produces type information for entities (functions, data objects etc.) | |
11411 | at file-scope or global-scope only. | |
11412 | ||
d77de738 | 11413 | @opindex gvms |
ddf6fe37 | 11414 | @item -gvms |
d77de738 ML |
11415 | Produce debugging information in Alpha/VMS debug format (if that is |
11416 | supported). This is the format used by DEBUG on Alpha/VMS systems. | |
11417 | ||
2f7e7bfa MH |
11418 | @item -gcodeview |
11419 | @opindex gcodeview | |
11420 | Produce debugging information in CodeView debug format (if that is | |
11421 | supported). This is the format used by Microsoft Visual C++ on | |
11422 | Windows. | |
11423 | ||
d77de738 ML |
11424 | @item -g@var{level} |
11425 | @itemx -ggdb@var{level} | |
11426 | @itemx -gvms@var{level} | |
11427 | Request debugging information and also use @var{level} to specify how | |
11428 | much information. The default level is 2. | |
11429 | ||
11430 | Level 0 produces no debug information at all. Thus, @option{-g0} negates | |
11431 | @option{-g}. | |
11432 | ||
11433 | Level 1 produces minimal information, enough for making backtraces in | |
11434 | parts of the program that you don't plan to debug. This includes | |
11435 | descriptions of functions and external variables, and line number | |
11436 | tables, but no information about local variables. | |
11437 | ||
11438 | Level 3 includes extra information, such as all the macro definitions | |
11439 | present in the program. Some debuggers support macro expansion when | |
11440 | you use @option{-g3}. | |
11441 | ||
11442 | If you use multiple @option{-g} options, with or without level numbers, | |
11443 | the last such option is the one that is effective. | |
11444 | ||
11445 | @option{-gdwarf} does not accept a concatenated debug level, to avoid | |
11446 | confusion with @option{-gdwarf-@var{level}}. | |
11447 | Instead use an additional @option{-g@var{level}} option to change the | |
11448 | debug level for DWARF. | |
11449 | ||
d77de738 ML |
11450 | @opindex feliminate-unused-debug-symbols |
11451 | @opindex fno-eliminate-unused-debug-symbols | |
ddf6fe37 | 11452 | @item -fno-eliminate-unused-debug-symbols |
d77de738 ML |
11453 | By default, no debug information is produced for symbols that are not actually |
11454 | used. Use this option if you want debug information for all symbols. | |
11455 | ||
d77de738 | 11456 | @opindex femit-class-debug-always |
ddf6fe37 | 11457 | @item -femit-class-debug-always |
d77de738 ML |
11458 | Instead of emitting debugging information for a C++ class in only one |
11459 | object file, emit it in all object files using the class. This option | |
11460 | should be used only with debuggers that are unable to handle the way GCC | |
11461 | normally emits debugging information for classes because using this | |
11462 | option increases the size of debugging information by as much as a | |
11463 | factor of two. | |
11464 | ||
d77de738 ML |
11465 | @opindex fmerge-debug-strings |
11466 | @opindex fno-merge-debug-strings | |
ddf6fe37 | 11467 | @item -fno-merge-debug-strings |
d77de738 ML |
11468 | Direct the linker to not merge together strings in the debugging |
11469 | information that are identical in different object files. Merging is | |
11470 | not supported by all assemblers or linkers. Merging decreases the size | |
11471 | of the debug information in the output file at the cost of increasing | |
11472 | link processing time. Merging is enabled by default. | |
11473 | ||
d77de738 | 11474 | @opindex fdebug-prefix-map |
ddf6fe37 | 11475 | @item -fdebug-prefix-map=@var{old}=@var{new} |
d77de738 ML |
11476 | When compiling files residing in directory @file{@var{old}}, record |
11477 | debugging information describing them as if the files resided in | |
11478 | directory @file{@var{new}} instead. This can be used to replace a | |
11479 | build-time path with an install-time path in the debug info. It can | |
11480 | also be used to change an absolute path to a relative path by using | |
11481 | @file{.} for @var{new}. This can give more reproducible builds, which | |
11482 | are location independent, but may require an extra command to tell GDB | |
2eb0191a JJ |
11483 | where to find the source files. See also @option{-ffile-prefix-map} |
11484 | and @option{-fcanon-prefix-map}. | |
d77de738 | 11485 | |
d77de738 | 11486 | @opindex fvar-tracking |
ddf6fe37 | 11487 | @item -fvar-tracking |
d77de738 ML |
11488 | Run variable tracking pass. It computes where variables are stored at each |
11489 | position in code. Better debugging information is then generated | |
11490 | (if the debugging information format supports this information). | |
11491 | ||
11492 | It is enabled by default when compiling with optimization (@option{-Os}, | |
11493 | @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and | |
11494 | the debug info format supports it. | |
11495 | ||
d77de738 ML |
11496 | @opindex fvar-tracking-assignments |
11497 | @opindex fno-var-tracking-assignments | |
ddf6fe37 | 11498 | @item -fvar-tracking-assignments |
d77de738 ML |
11499 | Annotate assignments to user variables early in the compilation and |
11500 | attempt to carry the annotations over throughout the compilation all the | |
11501 | way to the end, in an attempt to improve debug information while | |
11502 | optimizing. Use of @option{-gdwarf-4} is recommended along with it. | |
11503 | ||
11504 | It can be enabled even if var-tracking is disabled, in which case | |
11505 | annotations are created and maintained, but discarded at the end. | |
11506 | By default, this flag is enabled together with @option{-fvar-tracking}, | |
11507 | except when selective scheduling is enabled. | |
11508 | ||
d77de738 | 11509 | @opindex gsplit-dwarf |
ddf6fe37 | 11510 | @item -gsplit-dwarf |
d77de738 ML |
11511 | If DWARF debugging information is enabled, separate as much debugging |
11512 | information as possible into a separate output file with the extension | |
11513 | @file{.dwo}. This option allows the build system to avoid linking files with | |
11514 | debug information. To be useful, this option requires a debugger capable of | |
11515 | reading @file{.dwo} files. | |
11516 | ||
d77de738 ML |
11517 | @opindex gdwarf32 |
11518 | @opindex gdwarf64 | |
ddf6fe37 AA |
11519 | @item -gdwarf32 |
11520 | @itemx -gdwarf64 | |
d77de738 ML |
11521 | If DWARF debugging information is enabled, the @option{-gdwarf32} selects |
11522 | the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit | |
11523 | DWARF format. The default is target specific, on most targets it is | |
11524 | @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but | |
11525 | can't support more than 2GiB of debug information in any of the DWARF | |
11526 | debug information sections. The 64-bit DWARF format allows larger debug | |
11527 | information and might not be well supported by all consumers yet. | |
11528 | ||
d77de738 | 11529 | @opindex gdescribe-dies |
ddf6fe37 | 11530 | @item -gdescribe-dies |
d77de738 ML |
11531 | Add description attributes to some DWARF DIEs that have no name attribute, |
11532 | such as artificial variables, external references and call site | |
11533 | parameter DIEs. | |
11534 | ||
d77de738 | 11535 | @opindex gpubnames |
ddf6fe37 | 11536 | @item -gpubnames |
d77de738 ML |
11537 | Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections. |
11538 | ||
d77de738 | 11539 | @opindex ggnu-pubnames |
ddf6fe37 | 11540 | @item -ggnu-pubnames |
d77de738 ML |
11541 | Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format |
11542 | suitable for conversion into a GDB@ index. This option is only useful | |
11543 | with a linker that can produce GDB@ index version 7. | |
11544 | ||
d77de738 ML |
11545 | @opindex fdebug-types-section |
11546 | @opindex fno-debug-types-section | |
ddf6fe37 | 11547 | @item -fdebug-types-section |
d77de738 ML |
11548 | When using DWARF Version 4 or higher, type DIEs can be put into |
11549 | their own @code{.debug_types} section instead of making them part of the | |
11550 | @code{.debug_info} section. It is more efficient to put them in a separate | |
11551 | comdat section since the linker can then remove duplicates. | |
11552 | But not all DWARF consumers support @code{.debug_types} sections yet | |
11553 | and on some objects @code{.debug_types} produces larger instead of smaller | |
11554 | debugging information. | |
11555 | ||
d77de738 ML |
11556 | @opindex grecord-gcc-switches |
11557 | @opindex gno-record-gcc-switches | |
ddf6fe37 AA |
11558 | @item -grecord-gcc-switches |
11559 | @itemx -gno-record-gcc-switches | |
d77de738 ML |
11560 | This switch causes the command-line options used to invoke the |
11561 | compiler that may affect code generation to be appended to the | |
11562 | DW_AT_producer attribute in DWARF debugging information. The options | |
11563 | are concatenated with spaces separating them from each other and from | |
11564 | the compiler version. | |
11565 | It is enabled by default. | |
11566 | See also @option{-frecord-gcc-switches} for another | |
11567 | way of storing compiler options into the object file. | |
11568 | ||
d77de738 | 11569 | @opindex gstrict-dwarf |
ddf6fe37 | 11570 | @item -gstrict-dwarf |
d77de738 ML |
11571 | Disallow using extensions of later DWARF standard version than selected |
11572 | with @option{-gdwarf-@var{version}}. On most targets using non-conflicting | |
11573 | DWARF extensions from later standard versions is allowed. | |
11574 | ||
d77de738 | 11575 | @opindex gno-strict-dwarf |
ddf6fe37 | 11576 | @item -gno-strict-dwarf |
d77de738 ML |
11577 | Allow using extensions of later DWARF standard version than selected with |
11578 | @option{-gdwarf-@var{version}}. | |
11579 | ||
d77de738 | 11580 | @opindex gas-loc-support |
ddf6fe37 | 11581 | @item -gas-loc-support |
d77de738 ML |
11582 | Inform the compiler that the assembler supports @code{.loc} directives. |
11583 | It may then use them for the assembler to generate DWARF2+ line number | |
11584 | tables. | |
11585 | ||
11586 | This is generally desirable, because assembler-generated line-number | |
11587 | tables are a lot more compact than those the compiler can generate | |
11588 | itself. | |
11589 | ||
11590 | This option will be enabled by default if, at GCC configure time, the | |
11591 | assembler was found to support such directives. | |
11592 | ||
d77de738 | 11593 | @opindex gno-as-loc-support |
ddf6fe37 | 11594 | @item -gno-as-loc-support |
d77de738 ML |
11595 | Force GCC to generate DWARF2+ line number tables internally, if DWARF2+ |
11596 | line number tables are to be generated. | |
11597 | ||
d77de738 | 11598 | @opindex gas-locview-support |
ddf6fe37 | 11599 | @item -gas-locview-support |
d77de738 ML |
11600 | Inform the compiler that the assembler supports @code{view} assignment |
11601 | and reset assertion checking in @code{.loc} directives. | |
11602 | ||
11603 | This option will be enabled by default if, at GCC configure time, the | |
11604 | assembler was found to support them. | |
11605 | ||
11606 | @item -gno-as-locview-support | |
11607 | Force GCC to assign view numbers internally, if | |
11608 | @option{-gvariable-location-views} are explicitly requested. | |
11609 | ||
d77de738 ML |
11610 | @opindex gcolumn-info |
11611 | @opindex gno-column-info | |
ddf6fe37 AA |
11612 | @item -gcolumn-info |
11613 | @itemx -gno-column-info | |
d77de738 ML |
11614 | Emit location column information into DWARF debugging information, rather |
11615 | than just file and line. | |
11616 | This option is enabled by default. | |
11617 | ||
d77de738 ML |
11618 | @opindex gstatement-frontiers |
11619 | @opindex gno-statement-frontiers | |
ddf6fe37 AA |
11620 | @item -gstatement-frontiers |
11621 | @itemx -gno-statement-frontiers | |
d77de738 ML |
11622 | This option causes GCC to create markers in the internal representation |
11623 | at the beginning of statements, and to keep them roughly in place | |
11624 | throughout compilation, using them to guide the output of @code{is_stmt} | |
11625 | markers in the line number table. This is enabled by default when | |
11626 | compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2}, | |
11627 | @dots{}), and outputting DWARF 2 debug information at the normal level. | |
11628 | ||
d77de738 ML |
11629 | @opindex gvariable-location-views |
11630 | @opindex gvariable-location-views=incompat5 | |
11631 | @opindex gno-variable-location-views | |
ddf6fe37 AA |
11632 | @item -gvariable-location-views |
11633 | @itemx -gvariable-location-views=incompat5 | |
11634 | @itemx -gno-variable-location-views | |
d77de738 ML |
11635 | Augment variable location lists with progressive view numbers implied |
11636 | from the line number table. This enables debug information consumers to | |
11637 | inspect state at certain points of the program, even if no instructions | |
11638 | associated with the corresponding source locations are present at that | |
11639 | point. If the assembler lacks support for view numbers in line number | |
11640 | tables, this will cause the compiler to emit the line number table, | |
11641 | which generally makes them somewhat less compact. The augmented line | |
11642 | number tables and location lists are fully backward-compatible, so they | |
11643 | can be consumed by debug information consumers that are not aware of | |
11644 | these augmentations, but they won't derive any benefit from them either. | |
11645 | ||
11646 | This is enabled by default when outputting DWARF 2 debug information at | |
11647 | the normal level, as long as there is assembler support, | |
11648 | @option{-fvar-tracking-assignments} is enabled and | |
11649 | @option{-gstrict-dwarf} is not. When assembler support is not | |
11650 | available, this may still be enabled, but it will force GCC to output | |
11651 | internal line number tables, and if | |
11652 | @option{-ginternal-reset-location-views} is not enabled, that will most | |
11653 | certainly lead to silently mismatching location views. | |
11654 | ||
11655 | There is a proposed representation for view numbers that is not backward | |
11656 | compatible with the location list format introduced in DWARF 5, that can | |
11657 | be enabled with @option{-gvariable-location-views=incompat5}. This | |
11658 | option may be removed in the future, is only provided as a reference | |
11659 | implementation of the proposed representation. Debug information | |
11660 | consumers are not expected to support this extended format, and they | |
11661 | would be rendered unable to decode location lists using it. | |
11662 | ||
d77de738 ML |
11663 | @opindex ginternal-reset-location-views |
11664 | @opindex gno-internal-reset-location-views | |
ddf6fe37 AA |
11665 | @item -ginternal-reset-location-views |
11666 | @itemx -gno-internal-reset-location-views | |
d77de738 ML |
11667 | Attempt to determine location views that can be omitted from location |
11668 | view lists. This requires the compiler to have very accurate insn | |
11669 | length estimates, which isn't always the case, and it may cause | |
11670 | incorrect view lists to be generated silently when using an assembler | |
11671 | that does not support location view lists. The GNU assembler will flag | |
11672 | any such error as a @code{view number mismatch}. This is only enabled | |
11673 | on ports that define a reliable estimation function. | |
11674 | ||
d77de738 ML |
11675 | @opindex ginline-points |
11676 | @opindex gno-inline-points | |
ddf6fe37 AA |
11677 | @item -ginline-points |
11678 | @itemx -gno-inline-points | |
d77de738 ML |
11679 | Generate extended debug information for inlined functions. Location |
11680 | view tracking markers are inserted at inlined entry points, so that | |
11681 | address and view numbers can be computed and output in debug | |
11682 | information. This can be enabled independently of location views, in | |
11683 | which case the view numbers won't be output, but it can only be enabled | |
11684 | along with statement frontiers, and it is only enabled by default if | |
11685 | location views are enabled. | |
11686 | ||
d77de738 | 11687 | @opindex gz |
ddf6fe37 | 11688 | @item -gz@r{[}=@var{type}@r{]} |
d77de738 ML |
11689 | Produce compressed debug sections in DWARF format, if that is supported. |
11690 | If @var{type} is not given, the default type depends on the capabilities | |
11691 | of the assembler and linker used. @var{type} may be one of | |
11692 | @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib | |
11693 | compression in ELF gABI format). If the linker doesn't support writing | |
11694 | compressed debug sections, the option is rejected. Otherwise, if the | |
11695 | assembler does not support them, @option{-gz} is silently ignored when | |
11696 | producing object files. | |
11697 | ||
d77de738 | 11698 | @opindex femit-struct-debug-baseonly |
ddf6fe37 | 11699 | @item -femit-struct-debug-baseonly |
d77de738 ML |
11700 | Emit debug information for struct-like types |
11701 | only when the base name of the compilation source file | |
11702 | matches the base name of file in which the struct is defined. | |
11703 | ||
11704 | This option substantially reduces the size of debugging information, | |
11705 | but at significant potential loss in type information to the debugger. | |
11706 | See @option{-femit-struct-debug-reduced} for a less aggressive option. | |
11707 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11708 | ||
11709 | This option works only with DWARF debug output. | |
11710 | ||
d77de738 | 11711 | @opindex femit-struct-debug-reduced |
ddf6fe37 | 11712 | @item -femit-struct-debug-reduced |
d77de738 ML |
11713 | Emit debug information for struct-like types |
11714 | only when the base name of the compilation source file | |
11715 | matches the base name of file in which the type is defined, | |
11716 | unless the struct is a template or defined in a system header. | |
11717 | ||
11718 | This option significantly reduces the size of debugging information, | |
11719 | with some potential loss in type information to the debugger. | |
11720 | See @option{-femit-struct-debug-baseonly} for a more aggressive option. | |
11721 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11722 | ||
11723 | This option works only with DWARF debug output. | |
11724 | ||
d77de738 | 11725 | @opindex femit-struct-debug-detailed |
ddf6fe37 | 11726 | @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} |
d77de738 ML |
11727 | Specify the struct-like types |
11728 | for which the compiler generates debug information. | |
11729 | The intent is to reduce duplicate struct debug information | |
11730 | between different object files within the same program. | |
11731 | ||
11732 | This option is a detailed version of | |
11733 | @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly}, | |
11734 | which serves for most needs. | |
11735 | ||
11736 | A specification has the syntax@* | |
11737 | [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none}) | |
11738 | ||
11739 | The optional first word limits the specification to | |
11740 | structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}). | |
11741 | A struct type is used directly when it is the type of a variable, member. | |
11742 | Indirect uses arise through pointers to structs. | |
11743 | That is, when use of an incomplete struct is valid, the use is indirect. | |
11744 | An example is | |
11745 | @samp{struct one direct; struct two * indirect;}. | |
11746 | ||
11747 | The optional second word limits the specification to | |
11748 | ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}). | |
11749 | Generic structs are a bit complicated to explain. | |
11750 | For C++, these are non-explicit specializations of template classes, | |
11751 | or non-template classes within the above. | |
11752 | Other programming languages have generics, | |
11753 | but @option{-femit-struct-debug-detailed} does not yet implement them. | |
11754 | ||
11755 | The third word specifies the source files for those | |
11756 | structs for which the compiler should emit debug information. | |
11757 | The values @samp{none} and @samp{any} have the normal meaning. | |
11758 | The value @samp{base} means that | |
11759 | the base of name of the file in which the type declaration appears | |
11760 | must match the base of the name of the main compilation file. | |
11761 | In practice, this means that when compiling @file{foo.c}, debug information | |
11762 | is generated for types declared in that file and @file{foo.h}, | |
11763 | but not other header files. | |
11764 | The value @samp{sys} means those types satisfying @samp{base} | |
11765 | or declared in system or compiler headers. | |
11766 | ||
11767 | You may need to experiment to determine the best settings for your application. | |
11768 | ||
11769 | The default is @option{-femit-struct-debug-detailed=all}. | |
11770 | ||
11771 | This option works only with DWARF debug output. | |
11772 | ||
d77de738 ML |
11773 | @opindex fdwarf2-cfi-asm |
11774 | @opindex fno-dwarf2-cfi-asm | |
ddf6fe37 | 11775 | @item -fno-dwarf2-cfi-asm |
d77de738 ML |
11776 | Emit DWARF unwind info as compiler generated @code{.eh_frame} section |
11777 | instead of using GAS @code{.cfi_*} directives. | |
11778 | ||
d77de738 ML |
11779 | @opindex feliminate-unused-debug-types |
11780 | @opindex fno-eliminate-unused-debug-types | |
ddf6fe37 | 11781 | @item -fno-eliminate-unused-debug-types |
d77de738 ML |
11782 | Normally, when producing DWARF output, GCC avoids producing debug symbol |
11783 | output for types that are nowhere used in the source file being compiled. | |
11784 | Sometimes it is useful to have GCC emit debugging | |
11785 | information for all types declared in a compilation | |
11786 | unit, regardless of whether or not they are actually used | |
11787 | in that compilation unit, for example | |
11788 | if, in the debugger, you want to cast a value to a type that is | |
11789 | not actually used in your program (but is declared). More often, | |
11790 | however, this results in a significant amount of wasted space. | |
11791 | @end table | |
11792 | ||
11793 | @node Optimize Options | |
11794 | @section Options That Control Optimization | |
11795 | @cindex optimize options | |
11796 | @cindex options, optimization | |
11797 | ||
11798 | These options control various sorts of optimizations. | |
11799 | ||
11800 | Without any optimization option, the compiler's goal is to reduce the | |
11801 | cost of compilation and to make debugging produce the expected | |
11802 | results. Statements are independent: if you stop the program with a | |
11803 | breakpoint between statements, you can then assign a new value to any | |
11804 | variable or change the program counter to any other statement in the | |
11805 | function and get exactly the results you expect from the source | |
11806 | code. | |
11807 | ||
11808 | Turning on optimization flags makes the compiler attempt to improve | |
11809 | the performance and/or code size at the expense of compilation time | |
11810 | and possibly the ability to debug the program. | |
11811 | ||
11812 | The compiler performs optimization based on the knowledge it has of the | |
11813 | program. Compiling multiple files at once to a single output file mode allows | |
11814 | the compiler to use information gained from all of the files when compiling | |
11815 | each of them. | |
11816 | ||
11817 | Not all optimizations are controlled directly by a flag. Only | |
11818 | optimizations that have a flag are listed in this section. | |
11819 | ||
11820 | Most optimizations are completely disabled at @option{-O0} or if an | |
11821 | @option{-O} level is not set on the command line, even if individual | |
11822 | optimization flags are specified. Similarly, @option{-Og} suppresses | |
11823 | many optimization passes. | |
11824 | ||
11825 | Depending on the target and how GCC was configured, a slightly different | |
11826 | set of optimizations may be enabled at each @option{-O} level than | |
11827 | those listed here. You can invoke GCC with @option{-Q --help=optimizers} | |
11828 | to find out the exact set of optimizations that are enabled at each level. | |
11829 | @xref{Overall Options}, for examples. | |
11830 | ||
11831 | @table @gcctabopt | |
d77de738 ML |
11832 | @opindex O |
11833 | @opindex O1 | |
ddf6fe37 AA |
11834 | @item -O |
11835 | @itemx -O1 | |
d77de738 ML |
11836 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
11837 | more memory for a large function. | |
11838 | ||
11839 | With @option{-O}, the compiler tries to reduce code size and execution | |
11840 | time, without performing any optimizations that take a great deal of | |
11841 | compilation time. | |
11842 | ||
11843 | @c Note that in addition to the default_options_table list in opts.cc, | |
11844 | @c several optimization flags default to true but control optimization | |
11845 | @c passes that are explicitly disabled at -O0. | |
11846 | ||
11847 | @option{-O} turns on the following optimization flags: | |
11848 | ||
11849 | @c Please keep the following list alphabetized. | |
43b72ede AA |
11850 | @gccoptlist{-fauto-inc-dec |
11851 | -fbranch-count-reg | |
11852 | -fcombine-stack-adjustments | |
11853 | -fcompare-elim | |
11854 | -fcprop-registers | |
11855 | -fdce | |
11856 | -fdefer-pop | |
11857 | -fdelayed-branch | |
11858 | -fdse | |
11859 | -fforward-propagate | |
11860 | -fguess-branch-probability | |
11861 | -fif-conversion | |
11862 | -fif-conversion2 | |
11863 | -finline-functions-called-once | |
11864 | -fipa-modref | |
11865 | -fipa-profile | |
11866 | -fipa-pure-const | |
11867 | -fipa-reference | |
11868 | -fipa-reference-addressable | |
11869 | -fmerge-constants | |
11870 | -fmove-loop-invariants | |
11871 | -fmove-loop-stores | |
11872 | -fomit-frame-pointer | |
11873 | -freorder-blocks | |
11874 | -fshrink-wrap | |
11875 | -fshrink-wrap-separate | |
11876 | -fsplit-wide-types | |
11877 | -fssa-backprop | |
11878 | -fssa-phiopt | |
11879 | -ftree-bit-ccp | |
11880 | -ftree-ccp | |
11881 | -ftree-ch | |
11882 | -ftree-coalesce-vars | |
11883 | -ftree-copy-prop | |
11884 | -ftree-dce | |
11885 | -ftree-dominator-opts | |
11886 | -ftree-dse | |
11887 | -ftree-forwprop | |
11888 | -ftree-fre | |
11889 | -ftree-phiprop | |
11890 | -ftree-pta | |
11891 | -ftree-scev-cprop | |
11892 | -ftree-sink | |
11893 | -ftree-slsr | |
11894 | -ftree-sra | |
11895 | -ftree-ter | |
d77de738 ML |
11896 | -funit-at-a-time} |
11897 | ||
d77de738 | 11898 | @opindex O2 |
ddf6fe37 | 11899 | @item -O2 |
d77de738 ML |
11900 | Optimize even more. GCC performs nearly all supported optimizations |
11901 | that do not involve a space-speed tradeoff. | |
11902 | As compared to @option{-O}, this option increases both compilation time | |
11903 | and the performance of the generated code. | |
11904 | ||
11905 | @option{-O2} turns on all optimization flags specified by @option{-O1}. It | |
11906 | also turns on the following optimization flags: | |
11907 | ||
11908 | @c Please keep the following list alphabetized! | |
43b72ede AA |
11909 | @gccoptlist{-falign-functions -falign-jumps |
11910 | -falign-labels -falign-loops | |
11911 | -fcaller-saves | |
11912 | -fcode-hoisting | |
11913 | -fcrossjumping | |
11914 | -fcse-follow-jumps -fcse-skip-blocks | |
11915 | -fdelete-null-pointer-checks | |
11916 | -fdevirtualize -fdevirtualize-speculatively | |
11917 | -fexpensive-optimizations | |
11918 | -ffinite-loops | |
11919 | -fgcse -fgcse-lm | |
11920 | -fhoist-adjacent-loads | |
11921 | -finline-functions | |
11922 | -finline-small-functions | |
11923 | -findirect-inlining | |
11924 | -fipa-bit-cp -fipa-cp -fipa-icf | |
11925 | -fipa-ra -fipa-sra -fipa-vrp | |
11926 | -fisolate-erroneous-paths-dereference | |
11927 | -flra-remat | |
11928 | -foptimize-sibling-calls | |
11929 | -foptimize-strlen | |
11930 | -fpartial-inlining | |
11931 | -fpeephole2 | |
11932 | -freorder-blocks-algorithm=stc | |
11933 | -freorder-blocks-and-partition -freorder-functions | |
11934 | -frerun-cse-after-loop | |
11935 | -fschedule-insns -fschedule-insns2 | |
11936 | -fsched-interblock -fsched-spec | |
11937 | -fstore-merging | |
11938 | -fstrict-aliasing | |
11939 | -fthread-jumps | |
11940 | -ftree-builtin-call-dce | |
11941 | -ftree-loop-vectorize | |
11942 | -ftree-pre | |
11943 | -ftree-slp-vectorize | |
11944 | -ftree-switch-conversion -ftree-tail-merge | |
11945 | -ftree-vrp | |
d77de738 ML |
11946 | -fvect-cost-model=very-cheap} |
11947 | ||
11948 | Please note the warning under @option{-fgcse} about | |
11949 | invoking @option{-O2} on programs that use computed gotos. | |
11950 | ||
d77de738 | 11951 | @opindex O3 |
ddf6fe37 | 11952 | @item -O3 |
d77de738 ML |
11953 | Optimize yet more. @option{-O3} turns on all optimizations specified |
11954 | by @option{-O2} and also turns on the following optimization flags: | |
11955 | ||
11956 | @c Please keep the following list alphabetized! | |
43b72ede | 11957 | @gccoptlist{-fgcse-after-reload |
d77de738 | 11958 | -fipa-cp-clone |
43b72ede AA |
11959 | -floop-interchange |
11960 | -floop-unroll-and-jam | |
11961 | -fpeel-loops | |
11962 | -fpredictive-commoning | |
11963 | -fsplit-loops | |
11964 | -fsplit-paths | |
11965 | -ftree-loop-distribution | |
11966 | -ftree-partial-pre | |
11967 | -funswitch-loops | |
11968 | -fvect-cost-model=dynamic | |
d77de738 ML |
11969 | -fversion-loops-for-strides} |
11970 | ||
d77de738 | 11971 | @opindex O0 |
ddf6fe37 | 11972 | @item -O0 |
d77de738 ML |
11973 | Reduce compilation time and make debugging produce the expected |
11974 | results. This is the default. | |
11975 | ||
d77de738 | 11976 | @opindex Os |
ddf6fe37 | 11977 | @item -Os |
d77de738 ML |
11978 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations |
11979 | except those that often increase code size: | |
11980 | ||
43b72ede AA |
11981 | @gccoptlist{-falign-functions -falign-jumps |
11982 | -falign-labels -falign-loops | |
d77de738 ML |
11983 | -fprefetch-loop-arrays -freorder-blocks-algorithm=stc} |
11984 | ||
11985 | It also enables @option{-finline-functions}, causes the compiler to tune for | |
11986 | code size rather than execution speed, and performs further optimizations | |
11987 | designed to reduce code size. | |
11988 | ||
d77de738 | 11989 | @opindex Ofast |
ddf6fe37 | 11990 | @item -Ofast |
d77de738 ML |
11991 | Disregard strict standards compliance. @option{-Ofast} enables all |
11992 | @option{-O3} optimizations. It also enables optimizations that are not | |
11993 | valid for all standard-compliant programs. | |
11994 | It turns on @option{-ffast-math}, @option{-fallow-store-data-races} | |
11995 | and the Fortran-specific @option{-fstack-arrays}, unless | |
11996 | @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}. | |
11997 | It turns off @option{-fsemantic-interposition}. | |
11998 | ||
d77de738 | 11999 | @opindex Og |
ddf6fe37 | 12000 | @item -Og |
d77de738 ML |
12001 | Optimize debugging experience. @option{-Og} should be the optimization |
12002 | level of choice for the standard edit-compile-debug cycle, offering | |
12003 | a reasonable level of optimization while maintaining fast compilation | |
12004 | and a good debugging experience. It is a better choice than @option{-O0} | |
12005 | for producing debuggable code because some compiler passes | |
12006 | that collect debug information are disabled at @option{-O0}. | |
12007 | ||
12008 | Like @option{-O0}, @option{-Og} completely disables a number of | |
12009 | optimization passes so that individual options controlling them have | |
12010 | no effect. Otherwise @option{-Og} enables all @option{-O1} | |
12011 | optimization flags except for those that may interfere with debugging: | |
12012 | ||
43b72ede AA |
12013 | @gccoptlist{-fbranch-count-reg -fdelayed-branch |
12014 | -fdse -fif-conversion -fif-conversion2 | |
12015 | -finline-functions-called-once | |
12016 | -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt | |
d77de738 ML |
12017 | -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} |
12018 | ||
d77de738 | 12019 | @opindex Oz |
ddf6fe37 | 12020 | @item -Oz |
d77de738 ML |
12021 | Optimize aggressively for size rather than speed. This may increase |
12022 | the number of instructions executed if those instructions require | |
12023 | fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os} | |
12024 | including enabling most @option{-O2} optimizations. | |
12025 | ||
12026 | @end table | |
12027 | ||
12028 | If you use multiple @option{-O} options, with or without level numbers, | |
12029 | the last such option is the one that is effective. | |
12030 | ||
12031 | Options of the form @option{-f@var{flag}} specify machine-independent | |
12032 | flags. Most flags have both positive and negative forms; the negative | |
12033 | form of @option{-ffoo} is @option{-fno-foo}. In the table | |
12034 | below, only one of the forms is listed---the one you typically | |
12035 | use. You can figure out the other form by either removing @samp{no-} | |
12036 | or adding it. | |
12037 | ||
12038 | The following options control specific optimizations. They are either | |
12039 | activated by @option{-O} options or are related to ones that are. You | |
12040 | can use the following flags in the rare cases when ``fine-tuning'' of | |
12041 | optimizations to be performed is desired. | |
12042 | ||
12043 | @table @gcctabopt | |
d77de738 ML |
12044 | @opindex fno-defer-pop |
12045 | @opindex fdefer-pop | |
ddf6fe37 | 12046 | @item -fno-defer-pop |
d77de738 ML |
12047 | For machines that must pop arguments after a function call, always pop |
12048 | the arguments as soon as each function returns. | |
12049 | At levels @option{-O1} and higher, @option{-fdefer-pop} is the default; | |
12050 | this allows the compiler to let arguments accumulate on the stack for several | |
12051 | function calls and pop them all at once. | |
12052 | ||
d77de738 | 12053 | @opindex fforward-propagate |
ddf6fe37 | 12054 | @item -fforward-propagate |
d77de738 ML |
12055 | Perform a forward propagation pass on RTL@. The pass tries to combine two |
12056 | instructions and checks if the result can be simplified. If loop unrolling | |
12057 | is active, two passes are performed and the second is scheduled after | |
12058 | loop unrolling. | |
12059 | ||
12060 | This option is enabled by default at optimization levels @option{-O1}, | |
12061 | @option{-O2}, @option{-O3}, @option{-Os}. | |
12062 | ||
d77de738 | 12063 | @opindex ffp-contract |
ddf6fe37 | 12064 | @item -ffp-contract=@var{style} |
d77de738 ML |
12065 | @option{-ffp-contract=off} disables floating-point expression contraction. |
12066 | @option{-ffp-contract=fast} enables floating-point expression contraction | |
12067 | such as forming of fused multiply-add operations if the target has | |
12068 | native support for them. | |
12069 | @option{-ffp-contract=on} enables floating-point expression contraction | |
12070 | if allowed by the language standard. This is currently not implemented | |
12071 | and treated equal to @option{-ffp-contract=off}. | |
12072 | ||
12073 | The default is @option{-ffp-contract=fast}. | |
12074 | ||
d77de738 | 12075 | @opindex fomit-frame-pointer |
ddf6fe37 | 12076 | @item -fomit-frame-pointer |
d77de738 ML |
12077 | Omit the frame pointer in functions that don't need one. This avoids the |
12078 | instructions to save, set up and restore the frame pointer; on many targets | |
12079 | it also makes an extra register available. | |
12080 | ||
12081 | On some targets this flag has no effect because the standard calling sequence | |
12082 | always uses a frame pointer, so it cannot be omitted. | |
12083 | ||
12084 | Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer | |
12085 | is used in all functions. Several targets always omit the frame pointer in | |
12086 | leaf functions. | |
12087 | ||
12088 | Enabled by default at @option{-O1} and higher. | |
12089 | ||
d77de738 | 12090 | @opindex foptimize-sibling-calls |
ddf6fe37 | 12091 | @item -foptimize-sibling-calls |
d77de738 ML |
12092 | Optimize sibling and tail recursive calls. |
12093 | ||
12094 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12095 | ||
d77de738 | 12096 | @opindex foptimize-strlen |
ddf6fe37 | 12097 | @item -foptimize-strlen |
d77de738 ML |
12098 | Optimize various standard C string functions (e.g.@: @code{strlen}, |
12099 | @code{strchr} or @code{strcpy}) and | |
12100 | their @code{_FORTIFY_SOURCE} counterparts into faster alternatives. | |
12101 | ||
12102 | Enabled at levels @option{-O2}, @option{-O3}. | |
12103 | ||
d77de738 ML |
12104 | @opindex fno-inline |
12105 | @opindex finline | |
ddf6fe37 | 12106 | @item -fno-inline |
d77de738 ML |
12107 | Do not expand any functions inline apart from those marked with |
12108 | the @code{always_inline} attribute. This is the default when not | |
12109 | optimizing. | |
12110 | ||
12111 | Single functions can be exempted from inlining by marking them | |
12112 | with the @code{noinline} attribute. | |
12113 | ||
d77de738 | 12114 | @opindex finline-small-functions |
ddf6fe37 | 12115 | @item -finline-small-functions |
d77de738 ML |
12116 | Integrate functions into their callers when their body is smaller than expected |
12117 | function call code (so overall size of program gets smaller). The compiler | |
12118 | heuristically decides which functions are simple enough to be worth integrating | |
12119 | in this way. This inlining applies to all functions, even those not declared | |
12120 | inline. | |
12121 | ||
12122 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12123 | ||
d77de738 | 12124 | @opindex findirect-inlining |
ddf6fe37 | 12125 | @item -findirect-inlining |
d77de738 ML |
12126 | Inline also indirect calls that are discovered to be known at compile |
12127 | time thanks to previous inlining. This option has any effect only | |
12128 | when inlining itself is turned on by the @option{-finline-functions} | |
12129 | or @option{-finline-small-functions} options. | |
12130 | ||
12131 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12132 | ||
d77de738 | 12133 | @opindex finline-functions |
ddf6fe37 | 12134 | @item -finline-functions |
d77de738 ML |
12135 | Consider all functions for inlining, even if they are not declared inline. |
12136 | The compiler heuristically decides which functions are worth integrating | |
12137 | in this way. | |
12138 | ||
12139 | If all calls to a given function are integrated, and the function is | |
12140 | declared @code{static}, then the function is normally not output as | |
12141 | assembler code in its own right. | |
12142 | ||
12143 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled | |
12144 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
12145 | ||
d77de738 | 12146 | @opindex finline-functions-called-once |
ddf6fe37 | 12147 | @item -finline-functions-called-once |
d77de738 ML |
12148 | Consider all @code{static} functions called once for inlining into their |
12149 | caller even if they are not marked @code{inline}. If a call to a given | |
12150 | function is integrated, then the function is not output as assembler code | |
12151 | in its own right. | |
12152 | ||
12153 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os}, | |
12154 | but not @option{-Og}. | |
12155 | ||
d77de738 | 12156 | @opindex fearly-inlining |
ddf6fe37 | 12157 | @item -fearly-inlining |
d77de738 ML |
12158 | Inline functions marked by @code{always_inline} and functions whose body seems |
12159 | smaller than the function call overhead early before doing | |
12160 | @option{-fprofile-generate} instrumentation and real inlining pass. Doing so | |
12161 | makes profiling significantly cheaper and usually inlining faster on programs | |
12162 | having large chains of nested wrapper functions. | |
12163 | ||
12164 | Enabled by default. | |
12165 | ||
d77de738 | 12166 | @opindex fipa-sra |
ddf6fe37 | 12167 | @item -fipa-sra |
d77de738 ML |
12168 | Perform interprocedural scalar replacement of aggregates, removal of |
12169 | unused parameters and replacement of parameters passed by reference | |
12170 | by parameters passed by value. | |
12171 | ||
12172 | Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}. | |
12173 | ||
d77de738 | 12174 | @opindex finline-limit |
ddf6fe37 | 12175 | @item -finline-limit=@var{n} |
d77de738 ML |
12176 | By default, GCC limits the size of functions that can be inlined. This flag |
12177 | allows coarse control of this limit. @var{n} is the size of functions that | |
12178 | can be inlined in number of pseudo instructions. | |
12179 | ||
12180 | Inlining is actually controlled by a number of parameters, which may be | |
12181 | specified individually by using @option{--param @var{name}=@var{value}}. | |
12182 | The @option{-finline-limit=@var{n}} option sets some of these parameters | |
12183 | as follows: | |
12184 | ||
12185 | @table @gcctabopt | |
12186 | @item max-inline-insns-single | |
12187 | is set to @var{n}/2. | |
12188 | @item max-inline-insns-auto | |
12189 | is set to @var{n}/2. | |
12190 | @end table | |
12191 | ||
12192 | See below for a documentation of the individual | |
12193 | parameters controlling inlining and for the defaults of these parameters. | |
12194 | ||
12195 | @emph{Note:} there may be no value to @option{-finline-limit} that results | |
12196 | in default behavior. | |
12197 | ||
12198 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
12199 | abstract measurement of function's size. In no way does it represent a count | |
12200 | of assembly instructions and as such its exact meaning might change from one | |
12201 | release to an another. | |
12202 | ||
d77de738 ML |
12203 | @opindex fno-keep-inline-dllexport |
12204 | @opindex fkeep-inline-dllexport | |
ddf6fe37 | 12205 | @item -fno-keep-inline-dllexport |
d77de738 ML |
12206 | This is a more fine-grained version of @option{-fkeep-inline-functions}, |
12207 | which applies only to functions that are declared using the @code{dllexport} | |
12208 | attribute or declspec. @xref{Function Attributes,,Declaring Attributes of | |
12209 | Functions}. | |
12210 | ||
d77de738 | 12211 | @opindex fkeep-inline-functions |
ddf6fe37 | 12212 | @item -fkeep-inline-functions |
d77de738 ML |
12213 | In C, emit @code{static} functions that are declared @code{inline} |
12214 | into the object file, even if the function has been inlined into all | |
12215 | of its callers. This switch does not affect functions using the | |
12216 | @code{extern inline} extension in GNU C90@. In C++, emit any and all | |
12217 | inline functions into the object file. | |
12218 | ||
d77de738 | 12219 | @opindex fkeep-static-functions |
ddf6fe37 | 12220 | @item -fkeep-static-functions |
d77de738 ML |
12221 | Emit @code{static} functions into the object file, even if the function |
12222 | is never used. | |
12223 | ||
d77de738 | 12224 | @opindex fkeep-static-consts |
ddf6fe37 | 12225 | @item -fkeep-static-consts |
d77de738 ML |
12226 | Emit variables declared @code{static const} when optimization isn't turned |
12227 | on, even if the variables aren't referenced. | |
12228 | ||
12229 | GCC enables this option by default. If you want to force the compiler to | |
12230 | check if a variable is referenced, regardless of whether or not | |
12231 | optimization is turned on, use the @option{-fno-keep-static-consts} option. | |
12232 | ||
d77de738 | 12233 | @opindex fmerge-constants |
ddf6fe37 | 12234 | @item -fmerge-constants |
d77de738 ML |
12235 | Attempt to merge identical constants (string constants and floating-point |
12236 | constants) across compilation units. | |
12237 | ||
12238 | This option is the default for optimized compilation if the assembler and | |
12239 | linker support it. Use @option{-fno-merge-constants} to inhibit this | |
12240 | behavior. | |
12241 | ||
12242 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12243 | ||
d77de738 | 12244 | @opindex fmerge-all-constants |
ddf6fe37 | 12245 | @item -fmerge-all-constants |
d77de738 ML |
12246 | Attempt to merge identical constants and identical variables. |
12247 | ||
12248 | This option implies @option{-fmerge-constants}. In addition to | |
12249 | @option{-fmerge-constants} this considers e.g.@: even constant initialized | |
12250 | arrays or initialized constant variables with integral or floating-point | |
12251 | types. Languages like C or C++ require each variable, including multiple | |
12252 | instances of the same variable in recursive calls, to have distinct locations, | |
12253 | so using this option results in non-conforming | |
12254 | behavior. | |
12255 | ||
d77de738 | 12256 | @opindex fmodulo-sched |
ddf6fe37 | 12257 | @item -fmodulo-sched |
d77de738 ML |
12258 | Perform swing modulo scheduling immediately before the first scheduling |
12259 | pass. This pass looks at innermost loops and reorders their | |
12260 | instructions by overlapping different iterations. | |
12261 | ||
d77de738 | 12262 | @opindex fmodulo-sched-allow-regmoves |
ddf6fe37 | 12263 | @item -fmodulo-sched-allow-regmoves |
d77de738 ML |
12264 | Perform more aggressive SMS-based modulo scheduling with register moves |
12265 | allowed. By setting this flag certain anti-dependences edges are | |
12266 | deleted, which triggers the generation of reg-moves based on the | |
12267 | life-range analysis. This option is effective only with | |
12268 | @option{-fmodulo-sched} enabled. | |
12269 | ||
d77de738 ML |
12270 | @opindex fno-branch-count-reg |
12271 | @opindex fbranch-count-reg | |
ddf6fe37 | 12272 | @item -fno-branch-count-reg |
d77de738 ML |
12273 | Disable the optimization pass that scans for opportunities to use |
12274 | ``decrement and branch'' instructions on a count register instead of | |
12275 | instruction sequences that decrement a register, compare it against zero, and | |
12276 | then branch based upon the result. This option is only meaningful on | |
12277 | architectures that support such instructions, which include x86, PowerPC, | |
12278 | IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option | |
12279 | doesn't remove the decrement and branch instructions from the generated | |
12280 | instruction stream introduced by other optimization passes. | |
12281 | ||
12282 | The default is @option{-fbranch-count-reg} at @option{-O1} and higher, | |
12283 | except for @option{-Og}. | |
12284 | ||
d77de738 ML |
12285 | @opindex fno-function-cse |
12286 | @opindex ffunction-cse | |
ddf6fe37 | 12287 | @item -fno-function-cse |
d77de738 ML |
12288 | Do not put function addresses in registers; make each instruction that |
12289 | calls a constant function contain the function's address explicitly. | |
12290 | ||
12291 | This option results in less efficient code, but some strange hacks | |
12292 | that alter the assembler output may be confused by the optimizations | |
12293 | performed when this option is not used. | |
12294 | ||
12295 | The default is @option{-ffunction-cse} | |
12296 | ||
d77de738 ML |
12297 | @opindex fno-zero-initialized-in-bss |
12298 | @opindex fzero-initialized-in-bss | |
ddf6fe37 | 12299 | @item -fno-zero-initialized-in-bss |
d77de738 ML |
12300 | If the target supports a BSS section, GCC by default puts variables that |
12301 | are initialized to zero into BSS@. This can save space in the resulting | |
12302 | code. | |
12303 | ||
12304 | This option turns off this behavior because some programs explicitly | |
12305 | rely on variables going to the data section---e.g., so that the | |
12306 | resulting executable can find the beginning of that section and/or make | |
12307 | assumptions based on that. | |
12308 | ||
12309 | The default is @option{-fzero-initialized-in-bss}. | |
12310 | ||
d77de738 | 12311 | @opindex fthread-jumps |
ddf6fe37 | 12312 | @item -fthread-jumps |
d77de738 ML |
12313 | Perform optimizations that check to see if a jump branches to a |
12314 | location where another comparison subsumed by the first is found. If | |
12315 | so, the first branch is redirected to either the destination of the | |
12316 | second branch or a point immediately following it, depending on whether | |
12317 | the condition is known to be true or false. | |
12318 | ||
12319 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12320 | ||
d77de738 | 12321 | @opindex fsplit-wide-types |
ddf6fe37 | 12322 | @item -fsplit-wide-types |
d77de738 ML |
12323 | When using a type that occupies multiple registers, such as @code{long |
12324 | long} on a 32-bit system, split the registers apart and allocate them | |
12325 | independently. This normally generates better code for those types, | |
12326 | but may make debugging more difficult. | |
12327 | ||
12328 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, | |
12329 | @option{-Os}. | |
12330 | ||
d77de738 | 12331 | @opindex fsplit-wide-types-early |
ddf6fe37 | 12332 | @item -fsplit-wide-types-early |
d77de738 ML |
12333 | Fully split wide types early, instead of very late. |
12334 | This option has no effect unless @option{-fsplit-wide-types} is turned on. | |
12335 | ||
12336 | This is the default on some targets. | |
12337 | ||
d77de738 | 12338 | @opindex fcse-follow-jumps |
ddf6fe37 | 12339 | @item -fcse-follow-jumps |
d77de738 ML |
12340 | In common subexpression elimination (CSE), scan through jump instructions |
12341 | when the target of the jump is not reached by any other path. For | |
12342 | example, when CSE encounters an @code{if} statement with an | |
12343 | @code{else} clause, CSE follows the jump when the condition | |
12344 | tested is false. | |
12345 | ||
12346 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12347 | ||
d77de738 | 12348 | @opindex fcse-skip-blocks |
ddf6fe37 | 12349 | @item -fcse-skip-blocks |
d77de738 ML |
12350 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
12351 | follow jumps that conditionally skip over blocks. When CSE | |
12352 | encounters a simple @code{if} statement with no else clause, | |
12353 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the | |
12354 | body of the @code{if}. | |
12355 | ||
12356 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12357 | ||
d77de738 | 12358 | @opindex frerun-cse-after-loop |
ddf6fe37 | 12359 | @item -frerun-cse-after-loop |
d77de738 ML |
12360 | Re-run common subexpression elimination after loop optimizations are |
12361 | performed. | |
12362 | ||
12363 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12364 | ||
d77de738 | 12365 | @opindex fgcse |
ddf6fe37 | 12366 | @item -fgcse |
d77de738 ML |
12367 | Perform a global common subexpression elimination pass. |
12368 | This pass also performs global constant and copy propagation. | |
12369 | ||
12370 | @emph{Note:} When compiling a program using computed gotos, a GCC | |
12371 | extension, you may get better run-time performance if you disable | |
12372 | the global common subexpression elimination pass by adding | |
12373 | @option{-fno-gcse} to the command line. | |
12374 | ||
12375 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12376 | ||
d77de738 | 12377 | @opindex fgcse-lm |
ddf6fe37 | 12378 | @item -fgcse-lm |
d77de738 ML |
12379 | When @option{-fgcse-lm} is enabled, global common subexpression elimination |
12380 | attempts to move loads that are only killed by stores into themselves. This | |
12381 | allows a loop containing a load/store sequence to be changed to a load outside | |
12382 | the loop, and a copy/store within the loop. | |
12383 | ||
12384 | Enabled by default when @option{-fgcse} is enabled. | |
12385 | ||
d77de738 | 12386 | @opindex fgcse-sm |
ddf6fe37 | 12387 | @item -fgcse-sm |
d77de738 ML |
12388 | When @option{-fgcse-sm} is enabled, a store motion pass is run after |
12389 | global common subexpression elimination. This pass attempts to move | |
12390 | stores out of loops. When used in conjunction with @option{-fgcse-lm}, | |
12391 | loops containing a load/store sequence can be changed to a load before | |
12392 | the loop and a store after the loop. | |
12393 | ||
12394 | Not enabled at any optimization level. | |
12395 | ||
d77de738 | 12396 | @opindex fgcse-las |
ddf6fe37 | 12397 | @item -fgcse-las |
d77de738 ML |
12398 | When @option{-fgcse-las} is enabled, the global common subexpression |
12399 | elimination pass eliminates redundant loads that come after stores to the | |
12400 | same memory location (both partial and full redundancies). | |
12401 | ||
12402 | Not enabled at any optimization level. | |
12403 | ||
d77de738 | 12404 | @opindex fgcse-after-reload |
ddf6fe37 | 12405 | @item -fgcse-after-reload |
d77de738 ML |
12406 | When @option{-fgcse-after-reload} is enabled, a redundant load elimination |
12407 | pass is performed after reload. The purpose of this pass is to clean up | |
12408 | redundant spilling. | |
12409 | ||
12410 | Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}. | |
12411 | ||
d77de738 | 12412 | @opindex faggressive-loop-optimizations |
ddf6fe37 | 12413 | @item -faggressive-loop-optimizations |
d77de738 ML |
12414 | This option tells the loop optimizer to use language constraints to |
12415 | derive bounds for the number of iterations of a loop. This assumes that | |
12416 | loop code does not invoke undefined behavior by for example causing signed | |
12417 | integer overflows or out-of-bound array accesses. The bounds for the | |
12418 | number of iterations of a loop are used to guide loop unrolling and peeling | |
12419 | and loop exit test optimizations. | |
12420 | This option is enabled by default. | |
12421 | ||
d77de738 | 12422 | @opindex funconstrained-commons |
ddf6fe37 | 12423 | @item -funconstrained-commons |
d77de738 ML |
12424 | This option tells the compiler that variables declared in common blocks |
12425 | (e.g.@: Fortran) may later be overridden with longer trailing arrays. This | |
12426 | prevents certain optimizations that depend on knowing the array bounds. | |
12427 | ||
d77de738 | 12428 | @opindex fcrossjumping |
ddf6fe37 | 12429 | @item -fcrossjumping |
d77de738 ML |
12430 | Perform cross-jumping transformation. |
12431 | This transformation unifies equivalent code and saves code size. The | |
12432 | resulting code may or may not perform better than without cross-jumping. | |
12433 | ||
12434 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12435 | ||
d77de738 | 12436 | @opindex fauto-inc-dec |
ddf6fe37 | 12437 | @item -fauto-inc-dec |
d77de738 ML |
12438 | Combine increments or decrements of addresses with memory accesses. |
12439 | This pass is always skipped on architectures that do not have | |
12440 | instructions to support this. Enabled by default at @option{-O1} and | |
12441 | higher on architectures that support this. | |
12442 | ||
d77de738 | 12443 | @opindex fdce |
ddf6fe37 | 12444 | @item -fdce |
d77de738 ML |
12445 | Perform dead code elimination (DCE) on RTL@. |
12446 | Enabled by default at @option{-O1} and higher. | |
12447 | ||
d77de738 | 12448 | @opindex fdse |
ddf6fe37 | 12449 | @item -fdse |
d77de738 ML |
12450 | Perform dead store elimination (DSE) on RTL@. |
12451 | Enabled by default at @option{-O1} and higher. | |
12452 | ||
d77de738 | 12453 | @opindex fif-conversion |
ddf6fe37 | 12454 | @item -fif-conversion |
d77de738 ML |
12455 | Attempt to transform conditional jumps into branch-less equivalents. This |
12456 | includes use of conditional moves, min, max, set flags and abs instructions, and | |
12457 | some tricks doable by standard arithmetics. The use of conditional execution | |
12458 | on chips where it is available is controlled by @option{-fif-conversion2}. | |
12459 | ||
12460 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12461 | not with @option{-Og}. | |
12462 | ||
d77de738 | 12463 | @opindex fif-conversion2 |
ddf6fe37 | 12464 | @item -fif-conversion2 |
d77de738 ML |
12465 | Use conditional execution (where available) to transform conditional jumps into |
12466 | branch-less equivalents. | |
12467 | ||
12468 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12469 | not with @option{-Og}. | |
12470 | ||
d77de738 | 12471 | @opindex fdeclone-ctor-dtor |
ddf6fe37 | 12472 | @item -fdeclone-ctor-dtor |
d77de738 ML |
12473 | The C++ ABI requires multiple entry points for constructors and |
12474 | destructors: one for a base subobject, one for a complete object, and | |
12475 | one for a virtual destructor that calls operator delete afterwards. | |
12476 | For a hierarchy with virtual bases, the base and complete variants are | |
12477 | clones, which means two copies of the function. With this option, the | |
12478 | base and complete variants are changed to be thunks that call a common | |
12479 | implementation. | |
12480 | ||
12481 | Enabled by @option{-Os}. | |
12482 | ||
d77de738 | 12483 | @opindex fdelete-null-pointer-checks |
ddf6fe37 | 12484 | @item -fdelete-null-pointer-checks |
d77de738 ML |
12485 | Assume that programs cannot safely dereference null pointers, and that |
12486 | no code or data element resides at address zero. | |
12487 | This option enables simple constant | |
12488 | folding optimizations at all optimization levels. In addition, other | |
12489 | optimization passes in GCC use this flag to control global dataflow | |
12490 | analyses that eliminate useless checks for null pointers; these assume | |
12491 | that a memory access to address zero always results in a trap, so | |
12492 | that if a pointer is checked after it has already been dereferenced, | |
12493 | it cannot be null. | |
12494 | ||
12495 | Note however that in some environments this assumption is not true. | |
12496 | Use @option{-fno-delete-null-pointer-checks} to disable this optimization | |
12497 | for programs that depend on that behavior. | |
12498 | ||
12499 | This option is enabled by default on most targets. On Nios II ELF, it | |
12500 | defaults to off. On AVR and MSP430, this option is completely disabled. | |
12501 | ||
12502 | Passes that use the dataflow information | |
12503 | are enabled independently at different optimization levels. | |
12504 | ||
d77de738 | 12505 | @opindex fdevirtualize |
ddf6fe37 | 12506 | @item -fdevirtualize |
d77de738 ML |
12507 | Attempt to convert calls to virtual functions to direct calls. This |
12508 | is done both within a procedure and interprocedurally as part of | |
12509 | indirect inlining (@option{-findirect-inlining}) and interprocedural constant | |
12510 | propagation (@option{-fipa-cp}). | |
12511 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12512 | ||
d77de738 | 12513 | @opindex fdevirtualize-speculatively |
ddf6fe37 | 12514 | @item -fdevirtualize-speculatively |
d77de738 ML |
12515 | Attempt to convert calls to virtual functions to speculative direct calls. |
12516 | Based on the analysis of the type inheritance graph, determine for a given call | |
12517 | the set of likely targets. If the set is small, preferably of size 1, change | |
12518 | the call into a conditional deciding between direct and indirect calls. The | |
12519 | speculative calls enable more optimizations, such as inlining. When they seem | |
12520 | useless after further optimization, they are converted back into original form. | |
12521 | ||
d77de738 | 12522 | @opindex fdevirtualize-at-ltrans |
ddf6fe37 | 12523 | @item -fdevirtualize-at-ltrans |
d77de738 ML |
12524 | Stream extra information needed for aggressive devirtualization when running |
12525 | the link-time optimizer in local transformation mode. | |
12526 | This option enables more devirtualization but | |
12527 | significantly increases the size of streamed data. For this reason it is | |
12528 | disabled by default. | |
12529 | ||
d77de738 | 12530 | @opindex fexpensive-optimizations |
ddf6fe37 | 12531 | @item -fexpensive-optimizations |
d77de738 ML |
12532 | Perform a number of minor optimizations that are relatively expensive. |
12533 | ||
12534 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12535 | ||
d77de738 | 12536 | @opindex free |
ddf6fe37 | 12537 | @item -free |
d77de738 ML |
12538 | Attempt to remove redundant extension instructions. This is especially |
12539 | helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit | |
12540 | registers after writing to their lower 32-bit half. | |
12541 | ||
9417b304 AKA |
12542 | Enabled for Alpha, AArch64, PowerPC, RISC-V, SPARC, h83000 and x86 at levels |
12543 | @option{-O2}, @option{-O3}, @option{-Os}. | |
d77de738 | 12544 | |
d77de738 ML |
12545 | @opindex fno-lifetime-dse |
12546 | @opindex flifetime-dse | |
ddf6fe37 | 12547 | @item -fno-lifetime-dse |
d77de738 ML |
12548 | In C++ the value of an object is only affected by changes within its |
12549 | lifetime: when the constructor begins, the object has an indeterminate | |
12550 | value, and any changes during the lifetime of the object are dead when | |
12551 | the object is destroyed. Normally dead store elimination will take | |
12552 | advantage of this; if your code relies on the value of the object | |
12553 | storage persisting beyond the lifetime of the object, you can use this | |
12554 | flag to disable this optimization. To preserve stores before the | |
12555 | constructor starts (e.g.@: because your operator new clears the object | |
12556 | storage) but still treat the object as dead after the destructor, you | |
12557 | can use @option{-flifetime-dse=1}. The default behavior can be | |
12558 | explicitly selected with @option{-flifetime-dse=2}. | |
12559 | @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}. | |
12560 | ||
d77de738 | 12561 | @opindex flive-range-shrinkage |
ddf6fe37 | 12562 | @item -flive-range-shrinkage |
d77de738 ML |
12563 | Attempt to decrease register pressure through register live range |
12564 | shrinkage. This is helpful for fast processors with small or moderate | |
12565 | size register sets. | |
12566 | ||
d77de738 | 12567 | @opindex fira-algorithm |
ddf6fe37 | 12568 | @item -fira-algorithm=@var{algorithm} |
d77de738 ML |
12569 | Use the specified coloring algorithm for the integrated register |
12570 | allocator. The @var{algorithm} argument can be @samp{priority}, which | |
12571 | specifies Chow's priority coloring, or @samp{CB}, which specifies | |
12572 | Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented | |
12573 | for all architectures, but for those targets that do support it, it is | |
12574 | the default because it generates better code. | |
12575 | ||
d77de738 | 12576 | @opindex fira-region |
ddf6fe37 | 12577 | @item -fira-region=@var{region} |
d77de738 ML |
12578 | Use specified regions for the integrated register allocator. The |
12579 | @var{region} argument should be one of the following: | |
12580 | ||
12581 | @table @samp | |
12582 | ||
12583 | @item all | |
12584 | Use all loops as register allocation regions. | |
12585 | This can give the best results for machines with a small and/or | |
12586 | irregular register set. | |
12587 | ||
12588 | @item mixed | |
12589 | Use all loops except for loops with small register pressure | |
12590 | as the regions. This value usually gives | |
12591 | the best results in most cases and for most architectures, | |
12592 | and is enabled by default when compiling with optimization for speed | |
12593 | (@option{-O}, @option{-O2}, @dots{}). | |
12594 | ||
12595 | @item one | |
12596 | Use all functions as a single region. | |
12597 | This typically results in the smallest code size, and is enabled by default for | |
12598 | @option{-Os} or @option{-O0}. | |
12599 | ||
12600 | @end table | |
12601 | ||
d77de738 | 12602 | @opindex fira-hoist-pressure |
ddf6fe37 | 12603 | @item -fira-hoist-pressure |
d77de738 ML |
12604 | Use IRA to evaluate register pressure in the code hoisting pass for |
12605 | decisions to hoist expressions. This option usually results in smaller | |
12606 | code, but it can slow the compiler down. | |
12607 | ||
12608 | This option is enabled at level @option{-Os} for all targets. | |
12609 | ||
d77de738 | 12610 | @opindex fira-loop-pressure |
ddf6fe37 | 12611 | @item -fira-loop-pressure |
d77de738 ML |
12612 | Use IRA to evaluate register pressure in loops for decisions to move |
12613 | loop invariants. This option usually results in generation | |
12614 | of faster and smaller code on machines with large register files (>= 32 | |
12615 | registers), but it can slow the compiler down. | |
12616 | ||
12617 | This option is enabled at level @option{-O3} for some targets. | |
12618 | ||
d77de738 ML |
12619 | @opindex fno-ira-share-save-slots |
12620 | @opindex fira-share-save-slots | |
ddf6fe37 | 12621 | @item -fno-ira-share-save-slots |
d77de738 ML |
12622 | Disable sharing of stack slots used for saving call-used hard |
12623 | registers living through a call. Each hard register gets a | |
12624 | separate stack slot, and as a result function stack frames are | |
12625 | larger. | |
12626 | ||
d77de738 ML |
12627 | @opindex fno-ira-share-spill-slots |
12628 | @opindex fira-share-spill-slots | |
ddf6fe37 | 12629 | @item -fno-ira-share-spill-slots |
d77de738 ML |
12630 | Disable sharing of stack slots allocated for pseudo-registers. Each |
12631 | pseudo-register that does not get a hard register gets a separate | |
12632 | stack slot, and as a result function stack frames are larger. | |
12633 | ||
d77de738 | 12634 | @opindex flra-remat |
ddf6fe37 | 12635 | @item -flra-remat |
d77de738 ML |
12636 | Enable CFG-sensitive rematerialization in LRA. Instead of loading |
12637 | values of spilled pseudos, LRA tries to rematerialize (recalculate) | |
12638 | values if it is profitable. | |
12639 | ||
12640 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12641 | ||
d77de738 | 12642 | @opindex fdelayed-branch |
ddf6fe37 | 12643 | @item -fdelayed-branch |
d77de738 ML |
12644 | If supported for the target machine, attempt to reorder instructions |
12645 | to exploit instruction slots available after delayed branch | |
12646 | instructions. | |
12647 | ||
12648 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, | |
12649 | but not at @option{-Og}. | |
12650 | ||
d77de738 | 12651 | @opindex fschedule-insns |
ddf6fe37 | 12652 | @item -fschedule-insns |
d77de738 ML |
12653 | If supported for the target machine, attempt to reorder instructions to |
12654 | eliminate execution stalls due to required data being unavailable. This | |
12655 | helps machines that have slow floating point or memory load instructions | |
12656 | by allowing other instructions to be issued until the result of the load | |
12657 | or floating-point instruction is required. | |
12658 | ||
12659 | Enabled at levels @option{-O2}, @option{-O3}. | |
12660 | ||
d77de738 | 12661 | @opindex fschedule-insns2 |
ddf6fe37 | 12662 | @item -fschedule-insns2 |
d77de738 ML |
12663 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
12664 | instruction scheduling after register allocation has been done. This is | |
12665 | especially useful on machines with a relatively small number of | |
12666 | registers and where memory load instructions take more than one cycle. | |
12667 | ||
12668 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12669 | ||
d77de738 ML |
12670 | @opindex fno-sched-interblock |
12671 | @opindex fsched-interblock | |
ddf6fe37 | 12672 | @item -fno-sched-interblock |
d77de738 ML |
12673 | Disable instruction scheduling across basic blocks, which |
12674 | is normally enabled when scheduling before register allocation, i.e.@: | |
12675 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12676 | ||
d77de738 ML |
12677 | @opindex fno-sched-spec |
12678 | @opindex fsched-spec | |
ddf6fe37 | 12679 | @item -fno-sched-spec |
d77de738 ML |
12680 | Disable speculative motion of non-load instructions, which |
12681 | is normally enabled when scheduling before register allocation, i.e.@: | |
12682 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12683 | ||
d77de738 | 12684 | @opindex fsched-pressure |
ddf6fe37 | 12685 | @item -fsched-pressure |
d77de738 ML |
12686 | Enable register pressure sensitive insn scheduling before register |
12687 | allocation. This only makes sense when scheduling before register | |
12688 | allocation is enabled, i.e.@: with @option{-fschedule-insns} or at | |
12689 | @option{-O2} or higher. Usage of this option can improve the | |
12690 | generated code and decrease its size by preventing register pressure | |
12691 | increase above the number of available hard registers and subsequent | |
12692 | spills in register allocation. | |
12693 | ||
d77de738 | 12694 | @opindex fsched-spec-load |
ddf6fe37 | 12695 | @item -fsched-spec-load |
d77de738 ML |
12696 | Allow speculative motion of some load instructions. This only makes |
12697 | sense when scheduling before register allocation, i.e.@: with | |
12698 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12699 | ||
d77de738 | 12700 | @opindex fsched-spec-load-dangerous |
ddf6fe37 | 12701 | @item -fsched-spec-load-dangerous |
d77de738 ML |
12702 | Allow speculative motion of more load instructions. This only makes |
12703 | sense when scheduling before register allocation, i.e.@: with | |
12704 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12705 | ||
ddf6fe37 | 12706 | @opindex fsched-stalled-insns |
d77de738 ML |
12707 | @item -fsched-stalled-insns |
12708 | @itemx -fsched-stalled-insns=@var{n} | |
d77de738 ML |
12709 | Define how many insns (if any) can be moved prematurely from the queue |
12710 | of stalled insns into the ready list during the second scheduling pass. | |
12711 | @option{-fno-sched-stalled-insns} means that no insns are moved | |
12712 | prematurely, @option{-fsched-stalled-insns=0} means there is no limit | |
12713 | on how many queued insns can be moved prematurely. | |
12714 | @option{-fsched-stalled-insns} without a value is equivalent to | |
12715 | @option{-fsched-stalled-insns=1}. | |
12716 | ||
ddf6fe37 | 12717 | @opindex fsched-stalled-insns-dep |
d77de738 ML |
12718 | @item -fsched-stalled-insns-dep |
12719 | @itemx -fsched-stalled-insns-dep=@var{n} | |
d77de738 ML |
12720 | Define how many insn groups (cycles) are examined for a dependency |
12721 | on a stalled insn that is a candidate for premature removal from the queue | |
12722 | of stalled insns. This has an effect only during the second scheduling pass, | |
12723 | and only if @option{-fsched-stalled-insns} is used. | |
12724 | @option{-fno-sched-stalled-insns-dep} is equivalent to | |
12725 | @option{-fsched-stalled-insns-dep=0}. | |
12726 | @option{-fsched-stalled-insns-dep} without a value is equivalent to | |
12727 | @option{-fsched-stalled-insns-dep=1}. | |
12728 | ||
d77de738 | 12729 | @opindex fsched2-use-superblocks |
ddf6fe37 | 12730 | @item -fsched2-use-superblocks |
d77de738 ML |
12731 | When scheduling after register allocation, use superblock scheduling. |
12732 | This allows motion across basic block boundaries, | |
12733 | resulting in faster schedules. This option is experimental, as not all machine | |
12734 | descriptions used by GCC model the CPU closely enough to avoid unreliable | |
12735 | results from the algorithm. | |
12736 | ||
12737 | This only makes sense when scheduling after register allocation, i.e.@: with | |
12738 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12739 | ||
d77de738 | 12740 | @opindex fsched-group-heuristic |
ddf6fe37 | 12741 | @item -fsched-group-heuristic |
d77de738 ML |
12742 | Enable the group heuristic in the scheduler. This heuristic favors |
12743 | the instruction that belongs to a schedule group. This is enabled | |
12744 | by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12745 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12746 | ||
d77de738 | 12747 | @opindex fsched-critical-path-heuristic |
ddf6fe37 | 12748 | @item -fsched-critical-path-heuristic |
d77de738 ML |
12749 | Enable the critical-path heuristic in the scheduler. This heuristic favors |
12750 | instructions on the critical path. This is enabled by default when | |
12751 | scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12752 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12753 | ||
d77de738 | 12754 | @opindex fsched-spec-insn-heuristic |
ddf6fe37 | 12755 | @item -fsched-spec-insn-heuristic |
d77de738 ML |
12756 | Enable the speculative instruction heuristic in the scheduler. This |
12757 | heuristic favors speculative instructions with greater dependency weakness. | |
12758 | This is enabled by default when scheduling is enabled, i.e.@: | |
12759 | with @option{-fschedule-insns} or @option{-fschedule-insns2} | |
12760 | or at @option{-O2} or higher. | |
12761 | ||
d77de738 | 12762 | @opindex fsched-rank-heuristic |
ddf6fe37 | 12763 | @item -fsched-rank-heuristic |
d77de738 ML |
12764 | Enable the rank heuristic in the scheduler. This heuristic favors |
12765 | the instruction belonging to a basic block with greater size or frequency. | |
12766 | This is enabled by default when scheduling is enabled, i.e.@: | |
12767 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12768 | at @option{-O2} or higher. | |
12769 | ||
d77de738 | 12770 | @opindex fsched-last-insn-heuristic |
ddf6fe37 | 12771 | @item -fsched-last-insn-heuristic |
d77de738 ML |
12772 | Enable the last-instruction heuristic in the scheduler. This heuristic |
12773 | favors the instruction that is less dependent on the last instruction | |
12774 | scheduled. This is enabled by default when scheduling is enabled, | |
12775 | i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12776 | at @option{-O2} or higher. | |
12777 | ||
d77de738 | 12778 | @opindex fsched-dep-count-heuristic |
ddf6fe37 | 12779 | @item -fsched-dep-count-heuristic |
d77de738 ML |
12780 | Enable the dependent-count heuristic in the scheduler. This heuristic |
12781 | favors the instruction that has more instructions depending on it. | |
12782 | This is enabled by default when scheduling is enabled, i.e.@: | |
12783 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12784 | at @option{-O2} or higher. | |
12785 | ||
d77de738 | 12786 | @opindex freschedule-modulo-scheduled-loops |
ddf6fe37 | 12787 | @item -freschedule-modulo-scheduled-loops |
d77de738 ML |
12788 | Modulo scheduling is performed before traditional scheduling. If a loop |
12789 | is modulo scheduled, later scheduling passes may change its schedule. | |
12790 | Use this option to control that behavior. | |
12791 | ||
d77de738 | 12792 | @opindex fselective-scheduling |
ddf6fe37 | 12793 | @item -fselective-scheduling |
d77de738 ML |
12794 | Schedule instructions using selective scheduling algorithm. Selective |
12795 | scheduling runs instead of the first scheduler pass. | |
12796 | ||
d77de738 | 12797 | @opindex fselective-scheduling2 |
ddf6fe37 | 12798 | @item -fselective-scheduling2 |
d77de738 ML |
12799 | Schedule instructions using selective scheduling algorithm. Selective |
12800 | scheduling runs instead of the second scheduler pass. | |
12801 | ||
d77de738 | 12802 | @opindex fsel-sched-pipelining |
ddf6fe37 | 12803 | @item -fsel-sched-pipelining |
d77de738 ML |
12804 | Enable software pipelining of innermost loops during selective scheduling. |
12805 | This option has no effect unless one of @option{-fselective-scheduling} or | |
12806 | @option{-fselective-scheduling2} is turned on. | |
12807 | ||
d77de738 | 12808 | @opindex fsel-sched-pipelining-outer-loops |
ddf6fe37 | 12809 | @item -fsel-sched-pipelining-outer-loops |
d77de738 ML |
12810 | When pipelining loops during selective scheduling, also pipeline outer loops. |
12811 | This option has no effect unless @option{-fsel-sched-pipelining} is turned on. | |
12812 | ||
d77de738 | 12813 | @opindex fsemantic-interposition |
ddf6fe37 | 12814 | @item -fsemantic-interposition |
d77de738 ML |
12815 | Some object formats, like ELF, allow interposing of symbols by the |
12816 | dynamic linker. | |
12817 | This means that for symbols exported from the DSO, the compiler cannot perform | |
12818 | interprocedural propagation, inlining and other optimizations in anticipation | |
12819 | that the function or variable in question may change. While this feature is | |
12820 | useful, for example, to rewrite memory allocation functions by a debugging | |
12821 | implementation, it is expensive in the terms of code quality. | |
12822 | With @option{-fno-semantic-interposition} the compiler assumes that | |
12823 | if interposition happens for functions the overwriting function will have | |
12824 | precisely the same semantics (and side effects). | |
12825 | Similarly if interposition happens | |
12826 | for variables, the constructor of the variable will be the same. The flag | |
12827 | has no effect for functions explicitly declared inline | |
12828 | (where it is never allowed for interposition to change semantics) | |
12829 | and for symbols explicitly declared weak. | |
12830 | ||
d77de738 | 12831 | @opindex fshrink-wrap |
ddf6fe37 | 12832 | @item -fshrink-wrap |
d77de738 ML |
12833 | Emit function prologues only before parts of the function that need it, |
12834 | rather than at the top of the function. This flag is enabled by default at | |
12835 | @option{-O} and higher. | |
12836 | ||
d77de738 | 12837 | @opindex fshrink-wrap-separate |
ddf6fe37 | 12838 | @item -fshrink-wrap-separate |
d77de738 ML |
12839 | Shrink-wrap separate parts of the prologue and epilogue separately, so that |
12840 | those parts are only executed when needed. | |
12841 | This option is on by default, but has no effect unless @option{-fshrink-wrap} | |
12842 | is also turned on and the target supports this. | |
12843 | ||
d77de738 | 12844 | @opindex fcaller-saves |
ddf6fe37 | 12845 | @item -fcaller-saves |
d77de738 ML |
12846 | Enable allocation of values to registers that are clobbered by |
12847 | function calls, by emitting extra instructions to save and restore the | |
12848 | registers around such calls. Such allocation is done only when it | |
12849 | seems to result in better code. | |
12850 | ||
12851 | This option is always enabled by default on certain machines, usually | |
12852 | those which have no call-preserved registers to use instead. | |
12853 | ||
12854 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12855 | ||
d77de738 | 12856 | @opindex fcombine-stack-adjustments |
ddf6fe37 | 12857 | @item -fcombine-stack-adjustments |
d77de738 ML |
12858 | Tracks stack adjustments (pushes and pops) and stack memory references |
12859 | and then tries to find ways to combine them. | |
12860 | ||
12861 | Enabled by default at @option{-O1} and higher. | |
12862 | ||
d77de738 | 12863 | @opindex fipa-ra |
ddf6fe37 | 12864 | @item -fipa-ra |
d77de738 ML |
12865 | Use caller save registers for allocation if those registers are not used by |
12866 | any called function. In that case it is not necessary to save and restore | |
12867 | them around calls. This is only possible if called functions are part of | |
12868 | same compilation unit as current function and they are compiled before it. | |
12869 | ||
12870 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option | |
12871 | is disabled if generated code will be instrumented for profiling | |
12872 | (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known | |
12873 | exactly (this happens on targets that do not expose prologues | |
12874 | and epilogues in RTL). | |
12875 | ||
d77de738 | 12876 | @opindex fconserve-stack |
ddf6fe37 | 12877 | @item -fconserve-stack |
d77de738 ML |
12878 | Attempt to minimize stack usage. The compiler attempts to use less |
12879 | stack space, even if that makes the program slower. This option | |
12880 | implies setting the @option{large-stack-frame} parameter to 100 | |
12881 | and the @option{large-stack-frame-growth} parameter to 400. | |
12882 | ||
d77de738 | 12883 | @opindex ftree-reassoc |
ddf6fe37 | 12884 | @item -ftree-reassoc |
d77de738 ML |
12885 | Perform reassociation on trees. This flag is enabled by default |
12886 | at @option{-O1} and higher. | |
12887 | ||
d77de738 | 12888 | @opindex fcode-hoisting |
ddf6fe37 | 12889 | @item -fcode-hoisting |
d77de738 ML |
12890 | Perform code hoisting. Code hoisting tries to move the |
12891 | evaluation of expressions executed on all paths to the function exit | |
12892 | as early as possible. This is especially useful as a code size | |
12893 | optimization, but it often helps for code speed as well. | |
12894 | This flag is enabled by default at @option{-O2} and higher. | |
12895 | ||
d77de738 | 12896 | @opindex ftree-pre |
ddf6fe37 | 12897 | @item -ftree-pre |
d77de738 ML |
12898 | Perform partial redundancy elimination (PRE) on trees. This flag is |
12899 | enabled by default at @option{-O2} and @option{-O3}. | |
12900 | ||
d77de738 | 12901 | @opindex ftree-partial-pre |
ddf6fe37 | 12902 | @item -ftree-partial-pre |
d77de738 ML |
12903 | Make partial redundancy elimination (PRE) more aggressive. This flag is |
12904 | enabled by default at @option{-O3}. | |
12905 | ||
d77de738 | 12906 | @opindex ftree-forwprop |
ddf6fe37 | 12907 | @item -ftree-forwprop |
d77de738 ML |
12908 | Perform forward propagation on trees. This flag is enabled by default |
12909 | at @option{-O1} and higher. | |
12910 | ||
d77de738 | 12911 | @opindex ftree-fre |
ddf6fe37 | 12912 | @item -ftree-fre |
d77de738 ML |
12913 | Perform full redundancy elimination (FRE) on trees. The difference |
12914 | between FRE and PRE is that FRE only considers expressions | |
12915 | that are computed on all paths leading to the redundant computation. | |
12916 | This analysis is faster than PRE, though it exposes fewer redundancies. | |
12917 | This flag is enabled by default at @option{-O1} and higher. | |
12918 | ||
d77de738 | 12919 | @opindex ftree-phiprop |
ddf6fe37 | 12920 | @item -ftree-phiprop |
d77de738 ML |
12921 | Perform hoisting of loads from conditional pointers on trees. This |
12922 | pass is enabled by default at @option{-O1} and higher. | |
12923 | ||
d77de738 | 12924 | @opindex fhoist-adjacent-loads |
ddf6fe37 | 12925 | @item -fhoist-adjacent-loads |
d77de738 ML |
12926 | Speculatively hoist loads from both branches of an if-then-else if the |
12927 | loads are from adjacent locations in the same structure and the target | |
12928 | architecture has a conditional move instruction. This flag is enabled | |
12929 | by default at @option{-O2} and higher. | |
12930 | ||
d77de738 | 12931 | @opindex ftree-copy-prop |
ddf6fe37 | 12932 | @item -ftree-copy-prop |
d77de738 ML |
12933 | Perform copy propagation on trees. This pass eliminates unnecessary |
12934 | copy operations. This flag is enabled by default at @option{-O1} and | |
12935 | higher. | |
12936 | ||
d77de738 | 12937 | @opindex fipa-pure-const |
ddf6fe37 | 12938 | @item -fipa-pure-const |
d77de738 ML |
12939 | Discover which functions are pure or constant. |
12940 | Enabled by default at @option{-O1} and higher. | |
12941 | ||
d77de738 | 12942 | @opindex fipa-reference |
ddf6fe37 | 12943 | @item -fipa-reference |
d77de738 ML |
12944 | Discover which static variables do not escape the |
12945 | compilation unit. | |
12946 | Enabled by default at @option{-O1} and higher. | |
12947 | ||
d77de738 | 12948 | @opindex fipa-reference-addressable |
ddf6fe37 | 12949 | @item -fipa-reference-addressable |
d77de738 ML |
12950 | Discover read-only, write-only and non-addressable static variables. |
12951 | Enabled by default at @option{-O1} and higher. | |
12952 | ||
d77de738 | 12953 | @opindex fipa-stack-alignment |
ddf6fe37 | 12954 | @item -fipa-stack-alignment |
d77de738 ML |
12955 | Reduce stack alignment on call sites if possible. |
12956 | Enabled by default. | |
12957 | ||
d77de738 | 12958 | @opindex fipa-pta |
ddf6fe37 | 12959 | @item -fipa-pta |
d77de738 ML |
12960 | Perform interprocedural pointer analysis and interprocedural modification |
12961 | and reference analysis. This option can cause excessive memory and | |
12962 | compile-time usage on large compilation units. It is not enabled by | |
12963 | default at any optimization level. | |
12964 | ||
d77de738 | 12965 | @opindex fipa-profile |
ddf6fe37 | 12966 | @item -fipa-profile |
d77de738 ML |
12967 | Perform interprocedural profile propagation. The functions called only from |
12968 | cold functions are marked as cold. Also functions executed once (such as | |
12969 | @code{cold}, @code{noreturn}, static constructors or destructors) are | |
12970 | identified. Cold functions and loop less parts of functions executed once are | |
12971 | then optimized for size. | |
12972 | Enabled by default at @option{-O1} and higher. | |
12973 | ||
d77de738 | 12974 | @opindex fipa-modref |
ddf6fe37 | 12975 | @item -fipa-modref |
d77de738 ML |
12976 | Perform interprocedural mod/ref analysis. This optimization analyzes the side |
12977 | effects of functions (memory locations that are modified or referenced) and | |
12978 | enables better optimization across the function call boundary. This flag is | |
12979 | enabled by default at @option{-O1} and higher. | |
12980 | ||
d77de738 | 12981 | @opindex fipa-cp |
ddf6fe37 | 12982 | @item -fipa-cp |
d77de738 ML |
12983 | Perform interprocedural constant propagation. |
12984 | This optimization analyzes the program to determine when values passed | |
12985 | to functions are constants and then optimizes accordingly. | |
12986 | This optimization can substantially increase performance | |
12987 | if the application has constants passed to functions. | |
12988 | This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}. | |
12989 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
12990 | ||
d77de738 | 12991 | @opindex fipa-cp-clone |
ddf6fe37 | 12992 | @item -fipa-cp-clone |
d77de738 ML |
12993 | Perform function cloning to make interprocedural constant propagation stronger. |
12994 | When enabled, interprocedural constant propagation performs function cloning | |
12995 | when externally visible function can be called with constant arguments. | |
12996 | Because this optimization can create multiple copies of functions, | |
12997 | it may significantly increase code size | |
12998 | (see @option{--param ipa-cp-unit-growth=@var{value}}). | |
12999 | This flag is enabled by default at @option{-O3}. | |
13000 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13001 | ||
d77de738 | 13002 | @opindex fipa-bit-cp |
ddf6fe37 | 13003 | @item -fipa-bit-cp |
d77de738 ML |
13004 | When enabled, perform interprocedural bitwise constant |
13005 | propagation. This flag is enabled by default at @option{-O2} and | |
13006 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
13007 | It requires that @option{-fipa-cp} is enabled. | |
13008 | ||
d77de738 | 13009 | @opindex fipa-vrp |
ddf6fe37 | 13010 | @item -fipa-vrp |
d77de738 ML |
13011 | When enabled, perform interprocedural propagation of value |
13012 | ranges. This flag is enabled by default at @option{-O2}. It requires | |
13013 | that @option{-fipa-cp} is enabled. | |
13014 | ||
d77de738 | 13015 | @opindex fipa-icf |
ddf6fe37 | 13016 | @item -fipa-icf |
d77de738 ML |
13017 | Perform Identical Code Folding for functions and read-only variables. |
13018 | The optimization reduces code size and may disturb unwind stacks by replacing | |
13019 | a function by equivalent one with a different name. The optimization works | |
13020 | more effectively with link-time optimization enabled. | |
13021 | ||
13022 | Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF | |
13023 | works on different levels and thus the optimizations are not same - there are | |
13024 | equivalences that are found only by GCC and equivalences found only by Gold. | |
13025 | ||
13026 | This flag is enabled by default at @option{-O2} and @option{-Os}. | |
13027 | ||
d77de738 | 13028 | @opindex flive-patching |
ddf6fe37 | 13029 | @item -flive-patching=@var{level} |
d77de738 ML |
13030 | Control GCC's optimizations to produce output suitable for live-patching. |
13031 | ||
13032 | If the compiler's optimization uses a function's body or information extracted | |
13033 | from its body to optimize/change another function, the latter is called an | |
13034 | impacted function of the former. If a function is patched, its impacted | |
13035 | functions should be patched too. | |
13036 | ||
13037 | The impacted functions are determined by the compiler's interprocedural | |
13038 | optimizations. For example, a caller is impacted when inlining a function | |
13039 | into its caller, | |
13040 | cloning a function and changing its caller to call this new clone, | |
13041 | or extracting a function's pureness/constness information to optimize | |
13042 | its direct or indirect callers, etc. | |
13043 | ||
13044 | Usually, the more IPA optimizations enabled, the larger the number of | |
13045 | impacted functions for each function. In order to control the number of | |
13046 | impacted functions and more easily compute the list of impacted function, | |
13047 | IPA optimizations can be partially enabled at two different levels. | |
13048 | ||
13049 | The @var{level} argument should be one of the following: | |
13050 | ||
13051 | @table @samp | |
13052 | ||
13053 | @item inline-clone | |
13054 | ||
13055 | Only enable inlining and cloning optimizations, which includes inlining, | |
13056 | cloning, interprocedural scalar replacement of aggregates and partial inlining. | |
13057 | As a result, when patching a function, all its callers and its clones' | |
13058 | callers are impacted, therefore need to be patched as well. | |
13059 | ||
13060 | @option{-flive-patching=inline-clone} disables the following optimization flags: | |
43b72ede AA |
13061 | @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra |
13062 | -fipa-icf -fipa-icf-functions -fipa-icf-variables | |
13063 | -fipa-bit-cp -fipa-vrp -fipa-pure-const | |
13064 | -fipa-reference-addressable | |
d77de738 ML |
13065 | -fipa-stack-alignment -fipa-modref} |
13066 | ||
13067 | @item inline-only-static | |
13068 | ||
13069 | Only enable inlining of static functions. | |
13070 | As a result, when patching a static function, all its callers are impacted | |
13071 | and so need to be patched as well. | |
13072 | ||
13073 | In addition to all the flags that @option{-flive-patching=inline-clone} | |
13074 | disables, | |
13075 | @option{-flive-patching=inline-only-static} disables the following additional | |
13076 | optimization flags: | |
13077 | @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp} | |
13078 | ||
13079 | @end table | |
13080 | ||
13081 | When @option{-flive-patching} is specified without any value, the default value | |
13082 | is @var{inline-clone}. | |
13083 | ||
13084 | This flag is disabled by default. | |
13085 | ||
13086 | Note that @option{-flive-patching} is not supported with link-time optimization | |
13087 | (@option{-flto}). | |
13088 | ||
d77de738 | 13089 | @opindex fisolate-erroneous-paths-dereference |
ddf6fe37 | 13090 | @item -fisolate-erroneous-paths-dereference |
d77de738 ML |
13091 | Detect paths that trigger erroneous or undefined behavior due to |
13092 | dereferencing a null pointer. Isolate those paths from the main control | |
13093 | flow and turn the statement with erroneous or undefined behavior into a trap. | |
13094 | This flag is enabled by default at @option{-O2} and higher and depends on | |
13095 | @option{-fdelete-null-pointer-checks} also being enabled. | |
13096 | ||
d77de738 | 13097 | @opindex fisolate-erroneous-paths-attribute |
ddf6fe37 | 13098 | @item -fisolate-erroneous-paths-attribute |
d77de738 ML |
13099 | Detect paths that trigger erroneous or undefined behavior due to a null value |
13100 | being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull} | |
13101 | attribute. Isolate those paths from the main control flow and turn the | |
13102 | statement with erroneous or undefined behavior into a trap. This is not | |
13103 | currently enabled, but may be enabled by @option{-O2} in the future. | |
13104 | ||
d77de738 | 13105 | @opindex ftree-sink |
ddf6fe37 | 13106 | @item -ftree-sink |
d77de738 ML |
13107 | Perform forward store motion on trees. This flag is |
13108 | enabled by default at @option{-O1} and higher. | |
13109 | ||
d77de738 | 13110 | @opindex ftree-bit-ccp |
ddf6fe37 | 13111 | @item -ftree-bit-ccp |
d77de738 ML |
13112 | Perform sparse conditional bit constant propagation on trees and propagate |
13113 | pointer alignment information. | |
13114 | This pass only operates on local scalar variables and is enabled by default | |
13115 | at @option{-O1} and higher, except for @option{-Og}. | |
13116 | It requires that @option{-ftree-ccp} is enabled. | |
13117 | ||
d77de738 | 13118 | @opindex ftree-ccp |
ddf6fe37 | 13119 | @item -ftree-ccp |
d77de738 ML |
13120 | Perform sparse conditional constant propagation (CCP) on trees. This |
13121 | pass only operates on local scalar variables and is enabled by default | |
13122 | at @option{-O1} and higher. | |
13123 | ||
d77de738 | 13124 | @opindex fssa-backprop |
ddf6fe37 | 13125 | @item -fssa-backprop |
d77de738 ML |
13126 | Propagate information about uses of a value up the definition chain |
13127 | in order to simplify the definitions. For example, this pass strips | |
13128 | sign operations if the sign of a value never matters. The flag is | |
13129 | enabled by default at @option{-O1} and higher. | |
13130 | ||
d77de738 | 13131 | @opindex fssa-phiopt |
ddf6fe37 | 13132 | @item -fssa-phiopt |
d77de738 ML |
13133 | Perform pattern matching on SSA PHI nodes to optimize conditional |
13134 | code. This pass is enabled by default at @option{-O1} and higher, | |
13135 | except for @option{-Og}. | |
13136 | ||
d77de738 | 13137 | @opindex ftree-switch-conversion |
ddf6fe37 | 13138 | @item -ftree-switch-conversion |
d77de738 ML |
13139 | Perform conversion of simple initializations in a switch to |
13140 | initializations from a scalar array. This flag is enabled by default | |
13141 | at @option{-O2} and higher. | |
13142 | ||
d77de738 | 13143 | @opindex ftree-tail-merge |
ddf6fe37 | 13144 | @item -ftree-tail-merge |
d77de738 ML |
13145 | Look for identical code sequences. When found, replace one with a jump to the |
13146 | other. This optimization is known as tail merging or cross jumping. This flag | |
13147 | is enabled by default at @option{-O2} and higher. The compilation time | |
13148 | in this pass can | |
13149 | be limited using @option{max-tail-merge-comparisons} parameter and | |
13150 | @option{max-tail-merge-iterations} parameter. | |
13151 | ||
d77de738 | 13152 | @opindex ftree-dce |
ddf6fe37 | 13153 | @item -ftree-dce |
d77de738 ML |
13154 | Perform dead code elimination (DCE) on trees. This flag is enabled by |
13155 | default at @option{-O1} and higher. | |
13156 | ||
d77de738 | 13157 | @opindex ftree-builtin-call-dce |
ddf6fe37 | 13158 | @item -ftree-builtin-call-dce |
d77de738 ML |
13159 | Perform conditional dead code elimination (DCE) for calls to built-in functions |
13160 | that may set @code{errno} but are otherwise free of side effects. This flag is | |
13161 | enabled by default at @option{-O2} and higher if @option{-Os} is not also | |
13162 | specified. | |
13163 | ||
d77de738 ML |
13164 | @opindex ffinite-loops |
13165 | @opindex fno-finite-loops | |
ddf6fe37 | 13166 | @item -ffinite-loops |
d77de738 ML |
13167 | Assume that a loop with an exit will eventually take the exit and not loop |
13168 | indefinitely. This allows the compiler to remove loops that otherwise have | |
13169 | no side-effects, not considering eventual endless looping as such. | |
13170 | ||
13171 | This option is enabled by default at @option{-O2} for C++ with -std=c++11 | |
13172 | or higher. | |
13173 | ||
d77de738 | 13174 | @opindex ftree-dominator-opts |
ddf6fe37 | 13175 | @item -ftree-dominator-opts |
d77de738 ML |
13176 | Perform a variety of simple scalar cleanups (constant/copy |
13177 | propagation, redundancy elimination, range propagation and expression | |
13178 | simplification) based on a dominator tree traversal. This also | |
13179 | performs jump threading (to reduce jumps to jumps). This flag is | |
13180 | enabled by default at @option{-O1} and higher. | |
13181 | ||
d77de738 | 13182 | @opindex ftree-dse |
ddf6fe37 | 13183 | @item -ftree-dse |
d77de738 ML |
13184 | Perform dead store elimination (DSE) on trees. A dead store is a store into |
13185 | a memory location that is later overwritten by another store without | |
13186 | any intervening loads. In this case the earlier store can be deleted. This | |
13187 | flag is enabled by default at @option{-O1} and higher. | |
13188 | ||
d77de738 | 13189 | @opindex ftree-ch |
ddf6fe37 | 13190 | @item -ftree-ch |
d77de738 ML |
13191 | Perform loop header copying on trees. This is beneficial since it increases |
13192 | effectiveness of code motion optimizations. It also saves one jump. This flag | |
13193 | is enabled by default at @option{-O1} and higher. It is not enabled | |
13194 | for @option{-Os}, since it usually increases code size. | |
13195 | ||
d77de738 | 13196 | @opindex ftree-loop-optimize |
ddf6fe37 | 13197 | @item -ftree-loop-optimize |
d77de738 ML |
13198 | Perform loop optimizations on trees. This flag is enabled by default |
13199 | at @option{-O1} and higher. | |
13200 | ||
d77de738 ML |
13201 | @opindex ftree-loop-linear |
13202 | @opindex floop-strip-mine | |
13203 | @opindex floop-block | |
ddf6fe37 AA |
13204 | @item -ftree-loop-linear |
13205 | @itemx -floop-strip-mine | |
13206 | @itemx -floop-block | |
d77de738 ML |
13207 | Perform loop nest optimizations. Same as |
13208 | @option{-floop-nest-optimize}. To use this code transformation, GCC has | |
13209 | to be configured with @option{--with-isl} to enable the Graphite loop | |
13210 | transformation infrastructure. | |
13211 | ||
d77de738 | 13212 | @opindex fgraphite-identity |
ddf6fe37 | 13213 | @item -fgraphite-identity |
d77de738 ML |
13214 | Enable the identity transformation for graphite. For every SCoP we generate |
13215 | the polyhedral representation and transform it back to gimple. Using | |
13216 | @option{-fgraphite-identity} we can check the costs or benefits of the | |
13217 | GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations | |
13218 | are also performed by the code generator isl, like index splitting and | |
13219 | dead code elimination in loops. | |
13220 | ||
d77de738 | 13221 | @opindex floop-nest-optimize |
ddf6fe37 | 13222 | @item -floop-nest-optimize |
d77de738 ML |
13223 | Enable the isl based loop nest optimizer. This is a generic loop nest |
13224 | optimizer based on the Pluto optimization algorithms. It calculates a loop | |
13225 | structure optimized for data-locality and parallelism. This option | |
13226 | is experimental. | |
13227 | ||
d77de738 | 13228 | @opindex floop-parallelize-all |
ddf6fe37 | 13229 | @item -floop-parallelize-all |
d77de738 ML |
13230 | Use the Graphite data dependence analysis to identify loops that can |
13231 | be parallelized. Parallelize all the loops that can be analyzed to | |
13232 | not contain loop carried dependences without checking that it is | |
13233 | profitable to parallelize the loops. | |
13234 | ||
d77de738 | 13235 | @opindex ftree-coalesce-vars |
ddf6fe37 | 13236 | @item -ftree-coalesce-vars |
d77de738 ML |
13237 | While transforming the program out of the SSA representation, attempt to |
13238 | reduce copying by coalescing versions of different user-defined | |
13239 | variables, instead of just compiler temporaries. This may severely | |
13240 | limit the ability to debug an optimized program compiled with | |
13241 | @option{-fno-var-tracking-assignments}. In the negated form, this flag | |
13242 | prevents SSA coalescing of user variables. This option is enabled by | |
13243 | default if optimization is enabled, and it does very little otherwise. | |
13244 | ||
d77de738 | 13245 | @opindex ftree-loop-if-convert |
ddf6fe37 | 13246 | @item -ftree-loop-if-convert |
d77de738 ML |
13247 | Attempt to transform conditional jumps in the innermost loops to |
13248 | branch-less equivalents. The intent is to remove control-flow from | |
13249 | the innermost loops in order to improve the ability of the | |
13250 | vectorization pass to handle these loops. This is enabled by default | |
13251 | if vectorization is enabled. | |
13252 | ||
d77de738 | 13253 | @opindex ftree-loop-distribution |
ddf6fe37 | 13254 | @item -ftree-loop-distribution |
d77de738 ML |
13255 | Perform loop distribution. This flag can improve cache performance on |
13256 | big loop bodies and allow further loop optimizations, like | |
13257 | parallelization or vectorization, to take place. For example, the loop | |
13258 | @smallexample | |
13259 | DO I = 1, N | |
13260 | A(I) = B(I) + C | |
13261 | D(I) = E(I) * F | |
13262 | ENDDO | |
13263 | @end smallexample | |
13264 | is transformed to | |
13265 | @smallexample | |
13266 | DO I = 1, N | |
13267 | A(I) = B(I) + C | |
13268 | ENDDO | |
13269 | DO I = 1, N | |
13270 | D(I) = E(I) * F | |
13271 | ENDDO | |
13272 | @end smallexample | |
13273 | This flag is enabled by default at @option{-O3}. | |
13274 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13275 | ||
d77de738 | 13276 | @opindex ftree-loop-distribute-patterns |
ddf6fe37 | 13277 | @item -ftree-loop-distribute-patterns |
d77de738 ML |
13278 | Perform loop distribution of patterns that can be code generated with |
13279 | calls to a library. This flag is enabled by default at @option{-O2} and | |
13280 | higher, and by @option{-fprofile-use} and @option{-fauto-profile}. | |
13281 | ||
13282 | This pass distributes the initialization loops and generates a call to | |
13283 | memset zero. For example, the loop | |
13284 | @smallexample | |
13285 | DO I = 1, N | |
13286 | A(I) = 0 | |
13287 | B(I) = A(I) + I | |
13288 | ENDDO | |
13289 | @end smallexample | |
13290 | is transformed to | |
13291 | @smallexample | |
13292 | DO I = 1, N | |
13293 | A(I) = 0 | |
13294 | ENDDO | |
13295 | DO I = 1, N | |
13296 | B(I) = A(I) + I | |
13297 | ENDDO | |
13298 | @end smallexample | |
13299 | and the initialization loop is transformed into a call to memset zero. | |
13300 | This flag is enabled by default at @option{-O3}. | |
13301 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13302 | ||
d77de738 | 13303 | @opindex floop-interchange |
ddf6fe37 | 13304 | @item -floop-interchange |
d77de738 ML |
13305 | Perform loop interchange outside of graphite. This flag can improve cache |
13306 | performance on loop nest and allow further loop optimizations, like | |
13307 | vectorization, to take place. For example, the loop | |
13308 | @smallexample | |
13309 | for (int i = 0; i < N; i++) | |
13310 | for (int j = 0; j < N; j++) | |
13311 | for (int k = 0; k < N; k++) | |
13312 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13313 | @end smallexample | |
13314 | is transformed to | |
13315 | @smallexample | |
13316 | for (int i = 0; i < N; i++) | |
13317 | for (int k = 0; k < N; k++) | |
13318 | for (int j = 0; j < N; j++) | |
13319 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13320 | @end smallexample | |
13321 | This flag is enabled by default at @option{-O3}. | |
13322 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13323 | ||
d77de738 | 13324 | @opindex floop-unroll-and-jam |
ddf6fe37 | 13325 | @item -floop-unroll-and-jam |
d77de738 ML |
13326 | Apply unroll and jam transformations on feasible loops. In a loop |
13327 | nest this unrolls the outer loop by some factor and fuses the resulting | |
13328 | multiple inner loops. This flag is enabled by default at @option{-O3}. | |
13329 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13330 | ||
d77de738 | 13331 | @opindex ftree-loop-im |
ddf6fe37 | 13332 | @item -ftree-loop-im |
d77de738 ML |
13333 | Perform loop invariant motion on trees. This pass moves only invariants that |
13334 | are hard to handle at RTL level (function calls, operations that expand to | |
13335 | nontrivial sequences of insns). With @option{-funswitch-loops} it also moves | |
13336 | operands of conditions that are invariant out of the loop, so that we can use | |
13337 | just trivial invariantness analysis in loop unswitching. The pass also includes | |
13338 | store motion. | |
13339 | ||
d77de738 | 13340 | @opindex ftree-loop-ivcanon |
ddf6fe37 | 13341 | @item -ftree-loop-ivcanon |
d77de738 ML |
13342 | Create a canonical counter for number of iterations in loops for which |
13343 | determining number of iterations requires complicated analysis. Later | |
13344 | optimizations then may determine the number easily. Useful especially | |
13345 | in connection with unrolling. | |
13346 | ||
d77de738 | 13347 | @opindex ftree-scev-cprop |
ddf6fe37 | 13348 | @item -ftree-scev-cprop |
d77de738 ML |
13349 | Perform final value replacement. If a variable is modified in a loop |
13350 | in such a way that its value when exiting the loop can be determined using | |
13351 | only its initial value and the number of loop iterations, replace uses of | |
13352 | the final value by such a computation, provided it is sufficiently cheap. | |
13353 | This reduces data dependencies and may allow further simplifications. | |
13354 | Enabled by default at @option{-O1} and higher. | |
13355 | ||
d77de738 | 13356 | @opindex fivopts |
ddf6fe37 | 13357 | @item -fivopts |
d77de738 ML |
13358 | Perform induction variable optimizations (strength reduction, induction |
13359 | variable merging and induction variable elimination) on trees. | |
13360 | ||
d77de738 | 13361 | @opindex ftree-parallelize-loops |
ddf6fe37 | 13362 | @item -ftree-parallelize-loops=n |
d77de738 ML |
13363 | Parallelize loops, i.e., split their iteration space to run in n threads. |
13364 | This is only possible for loops whose iterations are independent | |
13365 | and can be arbitrarily reordered. The optimization is only | |
13366 | profitable on multiprocessor machines, for loops that are CPU-intensive, | |
13367 | rather than constrained e.g.@: by memory bandwidth. This option | |
13368 | implies @option{-pthread}, and thus is only supported on targets | |
13369 | that have support for @option{-pthread}. | |
13370 | ||
d77de738 | 13371 | @opindex ftree-pta |
ddf6fe37 | 13372 | @item -ftree-pta |
d77de738 ML |
13373 | Perform function-local points-to analysis on trees. This flag is |
13374 | enabled by default at @option{-O1} and higher, except for @option{-Og}. | |
13375 | ||
d77de738 | 13376 | @opindex ftree-sra |
ddf6fe37 | 13377 | @item -ftree-sra |
d77de738 ML |
13378 | Perform scalar replacement of aggregates. This pass replaces structure |
13379 | references with scalars to prevent committing structures to memory too | |
13380 | early. This flag is enabled by default at @option{-O1} and higher, | |
13381 | except for @option{-Og}. | |
13382 | ||
d77de738 | 13383 | @opindex fstore-merging |
ddf6fe37 | 13384 | @item -fstore-merging |
d77de738 ML |
13385 | Perform merging of narrow stores to consecutive memory addresses. This pass |
13386 | merges contiguous stores of immediate values narrower than a word into fewer | |
13387 | wider stores to reduce the number of instructions. This is enabled by default | |
13388 | at @option{-O2} and higher as well as @option{-Os}. | |
13389 | ||
d77de738 | 13390 | @opindex ftree-ter |
ddf6fe37 | 13391 | @item -ftree-ter |
d77de738 ML |
13392 | Perform temporary expression replacement during the SSA->normal phase. Single |
13393 | use/single def temporaries are replaced at their use location with their | |
13394 | defining expression. This results in non-GIMPLE code, but gives the expanders | |
13395 | much more complex trees to work on resulting in better RTL generation. This is | |
13396 | enabled by default at @option{-O1} and higher. | |
13397 | ||
d77de738 | 13398 | @opindex ftree-slsr |
ddf6fe37 | 13399 | @item -ftree-slsr |
d77de738 ML |
13400 | Perform straight-line strength reduction on trees. This recognizes related |
13401 | expressions involving multiplications and replaces them by less expensive | |
13402 | calculations when possible. This is enabled by default at @option{-O1} and | |
13403 | higher. | |
13404 | ||
d77de738 | 13405 | @opindex ftree-vectorize |
ddf6fe37 | 13406 | @item -ftree-vectorize |
d77de738 ML |
13407 | Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize} |
13408 | and @option{-ftree-slp-vectorize} if not explicitly specified. | |
13409 | ||
d77de738 | 13410 | @opindex ftree-loop-vectorize |
ddf6fe37 | 13411 | @item -ftree-loop-vectorize |
d77de738 ML |
13412 | Perform loop vectorization on trees. This flag is enabled by default at |
13413 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13414 | and @option{-fauto-profile}. | |
13415 | ||
d77de738 | 13416 | @opindex ftree-slp-vectorize |
ddf6fe37 | 13417 | @item -ftree-slp-vectorize |
d77de738 ML |
13418 | Perform basic block vectorization on trees. This flag is enabled by default at |
13419 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13420 | and @option{-fauto-profile}. | |
13421 | ||
d77de738 | 13422 | @opindex ftrivial-auto-var-init |
ddf6fe37 | 13423 | @item -ftrivial-auto-var-init=@var{choice} |
d77de738 ML |
13424 | Initialize automatic variables with either a pattern or with zeroes to increase |
13425 | the security and predictability of a program by preventing uninitialized memory | |
13426 | disclosure and use. | |
13427 | GCC still considers an automatic variable that doesn't have an explicit | |
13428 | initializer as uninitialized, @option{-Wuninitialized} and | |
13429 | @option{-Wanalyzer-use-of-uninitialized-value} will still report | |
8f4634fb RB |
13430 | warning messages on such automatic variables and the compiler will |
13431 | perform optimization as if the variable were uninitialized. | |
d77de738 ML |
13432 | With this option, GCC will also initialize any padding of automatic variables |
13433 | that have structure or union types to zeroes. | |
13434 | However, the current implementation cannot initialize automatic variables that | |
13435 | are declared between the controlling expression and the first case of a | |
13436 | @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all | |
13437 | such cases. | |
13438 | ||
13439 | The three values of @var{choice} are: | |
13440 | ||
13441 | @itemize @bullet | |
13442 | @item | |
13443 | @samp{uninitialized} doesn't initialize any automatic variables. | |
13444 | This is C and C++'s default. | |
13445 | ||
13446 | @item | |
13447 | @samp{pattern} Initialize automatic variables with values which will likely | |
13448 | transform logic bugs into crashes down the line, are easily recognized in a | |
13449 | crash dump and without being values that programmers can rely on for useful | |
13450 | program semantics. | |
13451 | The current value is byte-repeatable pattern with byte "0xFE". | |
13452 | The values used for pattern initialization might be changed in the future. | |
13453 | ||
13454 | @item | |
13455 | @samp{zero} Initialize automatic variables with zeroes. | |
13456 | @end itemize | |
13457 | ||
13458 | The default is @samp{uninitialized}. | |
13459 | ||
13460 | You can control this behavior for a specific variable by using the variable | |
13461 | attribute @code{uninitialized} (@pxref{Variable Attributes}). | |
13462 | ||
d77de738 | 13463 | @opindex fvect-cost-model |
ddf6fe37 | 13464 | @item -fvect-cost-model=@var{model} |
d77de738 ML |
13465 | Alter the cost model used for vectorization. The @var{model} argument |
13466 | should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or | |
13467 | @samp{very-cheap}. | |
13468 | With the @samp{unlimited} model the vectorized code-path is assumed | |
13469 | to be profitable while with the @samp{dynamic} model a runtime check | |
13470 | guards the vectorized code-path to enable it only for iteration | |
13471 | counts that will likely execute faster than when executing the original | |
13472 | scalar loop. The @samp{cheap} model disables vectorization of | |
13473 | loops where doing so would be cost prohibitive for example due to | |
13474 | required runtime checks for data dependence or alignment but otherwise | |
13475 | is equal to the @samp{dynamic} model. The @samp{very-cheap} model only | |
13476 | allows vectorization if the vector code would entirely replace the | |
13477 | scalar code that is being vectorized. For example, if each iteration | |
13478 | of a vectorized loop would only be able to handle exactly four iterations | |
13479 | of the scalar loop, the @samp{very-cheap} model would only allow | |
13480 | vectorization if the scalar iteration count is known to be a multiple | |
13481 | of four. | |
13482 | ||
13483 | The default cost model depends on other optimization flags and is | |
13484 | either @samp{dynamic} or @samp{cheap}. | |
13485 | ||
d77de738 | 13486 | @opindex fsimd-cost-model |
ddf6fe37 | 13487 | @item -fsimd-cost-model=@var{model} |
d77de738 ML |
13488 | Alter the cost model used for vectorization of loops marked with the OpenMP |
13489 | simd directive. The @var{model} argument should be one of | |
13490 | @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model} | |
13491 | have the same meaning as described in @option{-fvect-cost-model} and by | |
13492 | default a cost model defined with @option{-fvect-cost-model} is used. | |
13493 | ||
d77de738 | 13494 | @opindex ftree-vrp |
ddf6fe37 | 13495 | @item -ftree-vrp |
d77de738 ML |
13496 | Perform Value Range Propagation on trees. This is similar to the |
13497 | constant propagation pass, but instead of values, ranges of values are | |
13498 | propagated. This allows the optimizers to remove unnecessary range | |
13499 | checks like array bound checks and null pointer checks. This is | |
13500 | enabled by default at @option{-O2} and higher. Null pointer check | |
13501 | elimination is only done if @option{-fdelete-null-pointer-checks} is | |
13502 | enabled. | |
13503 | ||
d77de738 | 13504 | @opindex fsplit-paths |
ddf6fe37 | 13505 | @item -fsplit-paths |
d77de738 ML |
13506 | Split paths leading to loop backedges. This can improve dead code |
13507 | elimination and common subexpression elimination. This is enabled by | |
13508 | default at @option{-O3} and above. | |
13509 | ||
d77de738 | 13510 | @opindex fsplit-ivs-in-unroller |
ddf6fe37 | 13511 | @item -fsplit-ivs-in-unroller |
d77de738 ML |
13512 | Enables expression of values of induction variables in later iterations |
13513 | of the unrolled loop using the value in the first iteration. This breaks | |
13514 | long dependency chains, thus improving efficiency of the scheduling passes. | |
13515 | ||
13516 | A combination of @option{-fweb} and CSE is often sufficient to obtain the | |
13517 | same effect. However, that is not reliable in cases where the loop body | |
13518 | is more complicated than a single basic block. It also does not work at all | |
13519 | on some architectures due to restrictions in the CSE pass. | |
13520 | ||
13521 | This optimization is enabled by default. | |
13522 | ||
d77de738 | 13523 | @opindex fvariable-expansion-in-unroller |
ddf6fe37 | 13524 | @item -fvariable-expansion-in-unroller |
d77de738 ML |
13525 | With this option, the compiler creates multiple copies of some |
13526 | local variables when unrolling a loop, which can result in superior code. | |
13527 | ||
13528 | This optimization is enabled by default for PowerPC targets, but disabled | |
13529 | by default otherwise. | |
13530 | ||
d77de738 | 13531 | @opindex fpartial-inlining |
ddf6fe37 | 13532 | @item -fpartial-inlining |
d77de738 ML |
13533 | Inline parts of functions. This option has any effect only |
13534 | when inlining itself is turned on by the @option{-finline-functions} | |
13535 | or @option{-finline-small-functions} options. | |
13536 | ||
13537 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13538 | ||
d77de738 | 13539 | @opindex fpredictive-commoning |
ddf6fe37 | 13540 | @item -fpredictive-commoning |
d77de738 ML |
13541 | Perform predictive commoning optimization, i.e., reusing computations |
13542 | (especially memory loads and stores) performed in previous | |
13543 | iterations of loops. | |
13544 | ||
13545 | This option is enabled at level @option{-O3}. | |
13546 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13547 | ||
d77de738 | 13548 | @opindex fprefetch-loop-arrays |
ddf6fe37 | 13549 | @item -fprefetch-loop-arrays |
d77de738 ML |
13550 | If supported by the target machine, generate instructions to prefetch |
13551 | memory to improve the performance of loops that access large arrays. | |
13552 | ||
13553 | This option may generate better or worse code; results are highly | |
13554 | dependent on the structure of loops within the source code. | |
13555 | ||
13556 | Disabled at level @option{-Os}. | |
13557 | ||
d77de738 ML |
13558 | @opindex fno-printf-return-value |
13559 | @opindex fprintf-return-value | |
ddf6fe37 | 13560 | @item -fno-printf-return-value |
d77de738 ML |
13561 | Do not substitute constants for known return value of formatted output |
13562 | functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and | |
13563 | @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This | |
13564 | transformation allows GCC to optimize or even eliminate branches based | |
13565 | on the known return value of these functions called with arguments that | |
13566 | are either constant, or whose values are known to be in a range that | |
13567 | makes determining the exact return value possible. For example, when | |
13568 | @option{-fprintf-return-value} is in effect, both the branch and the | |
13569 | body of the @code{if} statement (but not the call to @code{snprint}) | |
13570 | can be optimized away when @code{i} is a 32-bit or smaller integer | |
13571 | because the return value is guaranteed to be at most 8. | |
13572 | ||
13573 | @smallexample | |
13574 | char buf[9]; | |
13575 | if (snprintf (buf, "%08x", i) >= sizeof buf) | |
13576 | @dots{} | |
13577 | @end smallexample | |
13578 | ||
13579 | The @option{-fprintf-return-value} option relies on other optimizations | |
13580 | and yields best results with @option{-O2} and above. It works in tandem | |
13581 | with the @option{-Wformat-overflow} and @option{-Wformat-truncation} | |
13582 | options. The @option{-fprintf-return-value} option is enabled by default. | |
13583 | ||
d77de738 ML |
13584 | @opindex fno-peephole |
13585 | @opindex fpeephole | |
13586 | @opindex fno-peephole2 | |
13587 | @opindex fpeephole2 | |
ddf6fe37 AA |
13588 | @item -fno-peephole |
13589 | @itemx -fno-peephole2 | |
d77de738 ML |
13590 | Disable any machine-specific peephole optimizations. The difference |
13591 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they | |
13592 | are implemented in the compiler; some targets use one, some use the | |
13593 | other, a few use both. | |
13594 | ||
13595 | @option{-fpeephole} is enabled by default. | |
13596 | @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13597 | ||
d77de738 ML |
13598 | @opindex fno-guess-branch-probability |
13599 | @opindex fguess-branch-probability | |
ddf6fe37 | 13600 | @item -fno-guess-branch-probability |
d77de738 ML |
13601 | Do not guess branch probabilities using heuristics. |
13602 | ||
13603 | GCC uses heuristics to guess branch probabilities if they are | |
13604 | not provided by profiling feedback (@option{-fprofile-arcs}). These | |
13605 | heuristics are based on the control flow graph. If some branch probabilities | |
13606 | are specified by @code{__builtin_expect}, then the heuristics are | |
13607 | used to guess branch probabilities for the rest of the control flow graph, | |
13608 | taking the @code{__builtin_expect} info into account. The interactions | |
13609 | between the heuristics and @code{__builtin_expect} can be complex, and in | |
13610 | some cases, it may be useful to disable the heuristics so that the effects | |
13611 | of @code{__builtin_expect} are easier to understand. | |
13612 | ||
13613 | It is also possible to specify expected probability of the expression | |
13614 | with @code{__builtin_expect_with_probability} built-in function. | |
13615 | ||
13616 | The default is @option{-fguess-branch-probability} at levels | |
13617 | @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13618 | ||
d77de738 | 13619 | @opindex freorder-blocks |
ddf6fe37 | 13620 | @item -freorder-blocks |
d77de738 ML |
13621 | Reorder basic blocks in the compiled function in order to reduce number of |
13622 | taken branches and improve code locality. | |
13623 | ||
13624 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13625 | ||
d77de738 | 13626 | @opindex freorder-blocks-algorithm |
ddf6fe37 | 13627 | @item -freorder-blocks-algorithm=@var{algorithm} |
d77de738 ML |
13628 | Use the specified algorithm for basic block reordering. The |
13629 | @var{algorithm} argument can be @samp{simple}, which does not increase | |
13630 | code size (except sometimes due to secondary effects like alignment), | |
13631 | or @samp{stc}, the ``software trace cache'' algorithm, which tries to | |
13632 | put all often executed code together, minimizing the number of branches | |
13633 | executed by making extra copies of code. | |
13634 | ||
13635 | The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and | |
13636 | @samp{stc} at levels @option{-O2}, @option{-O3}. | |
13637 | ||
d77de738 | 13638 | @opindex freorder-blocks-and-partition |
ddf6fe37 | 13639 | @item -freorder-blocks-and-partition |
d77de738 ML |
13640 | In addition to reordering basic blocks in the compiled function, in order |
13641 | to reduce number of taken branches, partitions hot and cold basic blocks | |
13642 | into separate sections of the assembly and @file{.o} files, to improve | |
13643 | paging and cache locality performance. | |
13644 | ||
13645 | This optimization is automatically turned off in the presence of | |
13646 | exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined | |
13647 | section attribute and on any architecture that does not support named | |
13648 | sections. When @option{-fsplit-stack} is used this option is not | |
13649 | enabled by default (to avoid linker errors), but may be enabled | |
13650 | explicitly (if using a working linker). | |
13651 | ||
13652 | Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13653 | ||
d77de738 | 13654 | @opindex freorder-functions |
ddf6fe37 | 13655 | @item -freorder-functions |
d77de738 ML |
13656 | Reorder functions in the object file in order to |
13657 | improve code locality. This is implemented by using special | |
13658 | subsections @code{.text.hot} for most frequently executed functions and | |
13659 | @code{.text.unlikely} for unlikely executed functions. Reordering is done by | |
13660 | the linker so object file format must support named sections and linker must | |
13661 | place them in a reasonable way. | |
13662 | ||
13663 | This option isn't effective unless you either provide profile feedback | |
13664 | (see @option{-fprofile-arcs} for details) or manually annotate functions with | |
13665 | @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}). | |
13666 | ||
13667 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13668 | ||
d77de738 | 13669 | @opindex fstrict-aliasing |
ddf6fe37 | 13670 | @item -fstrict-aliasing |
d77de738 ML |
13671 | Allow the compiler to assume the strictest aliasing rules applicable to |
13672 | the language being compiled. For C (and C++), this activates | |
13673 | optimizations based on the type of expressions. In particular, an | |
13674 | object of one type is assumed never to reside at the same address as an | |
13675 | object of a different type, unless the types are almost the same. For | |
13676 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
13677 | @code{void*} or a @code{double}. A character type may alias any other | |
13678 | type. | |
13679 | ||
13680 | @anchor{Type-punning}Pay special attention to code like this: | |
13681 | @smallexample | |
13682 | union a_union @{ | |
13683 | int i; | |
13684 | double d; | |
13685 | @}; | |
13686 | ||
13687 | int f() @{ | |
13688 | union a_union t; | |
13689 | t.d = 3.0; | |
13690 | return t.i; | |
13691 | @} | |
13692 | @end smallexample | |
13693 | The practice of reading from a different union member than the one most | |
13694 | recently written to (called ``type-punning'') is common. Even with | |
13695 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory | |
13696 | is accessed through the union type. So, the code above works as | |
13697 | expected. @xref{Structures unions enumerations and bit-fields | |
13698 | implementation}. However, this code might not: | |
13699 | @smallexample | |
13700 | int f() @{ | |
13701 | union a_union t; | |
13702 | int* ip; | |
13703 | t.d = 3.0; | |
13704 | ip = &t.i; | |
13705 | return *ip; | |
13706 | @} | |
13707 | @end smallexample | |
13708 | ||
13709 | Similarly, access by taking the address, casting the resulting pointer | |
13710 | and dereferencing the result has undefined behavior, even if the cast | |
13711 | uses a union type, e.g.: | |
13712 | @smallexample | |
13713 | int f() @{ | |
13714 | double d = 3.0; | |
13715 | return ((union a_union *) &d)->i; | |
13716 | @} | |
13717 | @end smallexample | |
13718 | ||
13719 | The @option{-fstrict-aliasing} option is enabled at levels | |
13720 | @option{-O2}, @option{-O3}, @option{-Os}. | |
13721 | ||
d77de738 | 13722 | @opindex fipa-strict-aliasing |
ddf6fe37 | 13723 | @item -fipa-strict-aliasing |
d77de738 ML |
13724 | Controls whether rules of @option{-fstrict-aliasing} are applied across |
13725 | function boundaries. Note that if multiple functions gets inlined into a | |
13726 | single function the memory accesses are no longer considered to be crossing a | |
13727 | function boundary. | |
13728 | ||
13729 | The @option{-fipa-strict-aliasing} option is enabled by default and is | |
13730 | effective only in combination with @option{-fstrict-aliasing}. | |
13731 | ||
ddf6fe37 | 13732 | @opindex falign-functions |
d77de738 ML |
13733 | @item -falign-functions |
13734 | @itemx -falign-functions=@var{n} | |
13735 | @itemx -falign-functions=@var{n}:@var{m} | |
13736 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2} | |
13737 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13738 | Align the start of functions to the next power-of-two greater than or |
13739 | equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at | |
13740 | least the first @var{m} bytes of the function can be fetched by the CPU | |
13741 | without crossing an @var{n}-byte alignment boundary. | |
13742 | ||
13743 | If @var{m} is not specified, it defaults to @var{n}. | |
13744 | ||
13745 | Examples: @option{-falign-functions=32} aligns functions to the next | |
13746 | 32-byte boundary, @option{-falign-functions=24} aligns to the next | |
13747 | 32-byte boundary only if this can be done by skipping 23 bytes or less, | |
13748 | @option{-falign-functions=32:7} aligns to the next | |
13749 | 32-byte boundary only if this can be done by skipping 6 bytes or less. | |
13750 | ||
13751 | The second pair of @var{n2}:@var{m2} values allows you to specify | |
13752 | a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to | |
13753 | the next 64-byte boundary if this can be done by skipping 6 bytes or less, | |
13754 | otherwise aligns to the next 32-byte boundary if this can be done | |
13755 | by skipping 2 bytes or less. | |
13756 | If @var{m2} is not specified, it defaults to @var{n2}. | |
13757 | ||
13758 | Some assemblers only support this flag when @var{n} is a power of two; | |
13759 | in that case, it is rounded up. | |
13760 | ||
13761 | @option{-fno-align-functions} and @option{-falign-functions=1} are | |
13762 | equivalent and mean that functions are not aligned. | |
13763 | ||
13764 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13765 | The maximum allowed @var{n} option value is 65536. | |
13766 | ||
13767 | Enabled at levels @option{-O2}, @option{-O3}. | |
13768 | ||
13769 | @item -flimit-function-alignment | |
13770 | If this option is enabled, the compiler tries to avoid unnecessarily | |
13771 | overaligning functions. It attempts to instruct the assembler to align | |
13772 | by the amount specified by @option{-falign-functions}, but not to | |
13773 | skip more bytes than the size of the function. | |
13774 | ||
ddf6fe37 | 13775 | @opindex falign-labels |
d77de738 ML |
13776 | @item -falign-labels |
13777 | @itemx -falign-labels=@var{n} | |
13778 | @itemx -falign-labels=@var{n}:@var{m} | |
13779 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2} | |
13780 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13781 | Align all branch targets to a power-of-two boundary. |
13782 | ||
13783 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13784 | @option{-fno-align-labels} and @option{-falign-labels=1} are | |
13785 | equivalent and mean that labels are not aligned. | |
13786 | ||
13787 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and | |
13788 | are greater than this value, then their values are used instead. | |
13789 | ||
13790 | If @var{n} is not specified or is zero, use a machine-dependent default | |
13791 | which is very likely to be @samp{1}, meaning no alignment. | |
13792 | The maximum allowed @var{n} option value is 65536. | |
13793 | ||
13794 | Enabled at levels @option{-O2}, @option{-O3}. | |
13795 | ||
ddf6fe37 | 13796 | @opindex falign-loops |
d77de738 ML |
13797 | @item -falign-loops |
13798 | @itemx -falign-loops=@var{n} | |
13799 | @itemx -falign-loops=@var{n}:@var{m} | |
13800 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2} | |
13801 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13802 | Align loops to a power-of-two boundary. If the loops are executed |
13803 | many times, this makes up for any execution of the dummy padding | |
13804 | instructions. | |
13805 | ||
13806 | If @option{-falign-labels} is greater than this value, then its value | |
13807 | is used instead. | |
13808 | ||
13809 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13810 | @option{-fno-align-loops} and @option{-falign-loops=1} are | |
13811 | equivalent and mean that loops are not aligned. | |
13812 | The maximum allowed @var{n} option value is 65536. | |
13813 | ||
13814 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13815 | ||
13816 | Enabled at levels @option{-O2}, @option{-O3}. | |
13817 | ||
ddf6fe37 | 13818 | @opindex falign-jumps |
d77de738 ML |
13819 | @item -falign-jumps |
13820 | @itemx -falign-jumps=@var{n} | |
13821 | @itemx -falign-jumps=@var{n}:@var{m} | |
13822 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2} | |
13823 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13824 | Align branch targets to a power-of-two boundary, for branch targets |
13825 | where the targets can only be reached by jumping. In this case, | |
13826 | no dummy operations need be executed. | |
13827 | ||
13828 | If @option{-falign-labels} is greater than this value, then its value | |
13829 | is used instead. | |
13830 | ||
13831 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13832 | @option{-fno-align-jumps} and @option{-falign-jumps=1} are | |
13833 | equivalent and mean that loops are not aligned. | |
13834 | ||
13835 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13836 | The maximum allowed @var{n} option value is 65536. | |
13837 | ||
13838 | Enabled at levels @option{-O2}, @option{-O3}. | |
13839 | ||
d77de738 | 13840 | @opindex fno-allocation-dce |
ddf6fe37 | 13841 | @item -fno-allocation-dce |
d77de738 ML |
13842 | Do not remove unused C++ allocations in dead code elimination. |
13843 | ||
d77de738 | 13844 | @opindex fallow-store-data-races |
ddf6fe37 | 13845 | @item -fallow-store-data-races |
d77de738 ML |
13846 | Allow the compiler to perform optimizations that may introduce new data races |
13847 | on stores, without proving that the variable cannot be concurrently accessed | |
13848 | by other threads. Does not affect optimization of local data. It is safe to | |
13849 | use this option if it is known that global data will not be accessed by | |
13850 | multiple threads. | |
13851 | ||
13852 | Examples of optimizations enabled by @option{-fallow-store-data-races} include | |
13853 | hoisting or if-conversions that may cause a value that was already in memory | |
13854 | to be re-written with that same value. Such re-writing is safe in a single | |
13855 | threaded context but may be unsafe in a multi-threaded context. Note that on | |
13856 | some processors, if-conversions may be required in order to enable | |
13857 | vectorization. | |
13858 | ||
13859 | Enabled at level @option{-Ofast}. | |
13860 | ||
d77de738 | 13861 | @opindex funit-at-a-time |
ddf6fe37 | 13862 | @item -funit-at-a-time |
d77de738 ML |
13863 | This option is left for compatibility reasons. @option{-funit-at-a-time} |
13864 | has no effect, while @option{-fno-unit-at-a-time} implies | |
13865 | @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}. | |
13866 | ||
13867 | Enabled by default. | |
13868 | ||
d77de738 ML |
13869 | @opindex fno-toplevel-reorder |
13870 | @opindex ftoplevel-reorder | |
ddf6fe37 | 13871 | @item -fno-toplevel-reorder |
d77de738 ML |
13872 | Do not reorder top-level functions, variables, and @code{asm} |
13873 | statements. Output them in the same order that they appear in the | |
13874 | input file. When this option is used, unreferenced static variables | |
13875 | are not removed. This option is intended to support existing code | |
13876 | that relies on a particular ordering. For new code, it is better to | |
13877 | use attributes when possible. | |
13878 | ||
13879 | @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and | |
13880 | also at @option{-O0} if @option{-fsection-anchors} is explicitly requested. | |
13881 | Additionally @option{-fno-toplevel-reorder} implies | |
13882 | @option{-fno-section-anchors}. | |
13883 | ||
d77de738 | 13884 | @opindex funreachable-traps |
ddf6fe37 | 13885 | @item -funreachable-traps |
d77de738 ML |
13886 | With this option, the compiler turns calls to |
13887 | @code{__builtin_unreachable} into traps, instead of using them for | |
13888 | optimization. This also affects any such calls implicitly generated | |
13889 | by the compiler. | |
13890 | ||
13891 | This option has the same effect as @option{-fsanitize=unreachable | |
13892 | -fsanitize-trap=unreachable}, but does not affect the values of those | |
13893 | options. If @option{-fsanitize=unreachable} is enabled, that option | |
13894 | takes priority over this one. | |
13895 | ||
13896 | This option is enabled by default at @option{-O0} and @option{-Og}. | |
13897 | ||
d77de738 | 13898 | @opindex fweb |
ddf6fe37 | 13899 | @item -fweb |
d77de738 ML |
13900 | Constructs webs as commonly used for register allocation purposes and assign |
13901 | each web individual pseudo register. This allows the register allocation pass | |
13902 | to operate on pseudos directly, but also strengthens several other optimization | |
13903 | passes, such as CSE, loop optimizer and trivial dead code remover. It can, | |
13904 | however, make debugging impossible, since variables no longer stay in a | |
13905 | ``home register''. | |
13906 | ||
13907 | Enabled by default with @option{-funroll-loops}. | |
13908 | ||
d77de738 | 13909 | @opindex fwhole-program |
ddf6fe37 | 13910 | @item -fwhole-program |
d77de738 ML |
13911 | Assume that the current compilation unit represents the whole program being |
13912 | compiled. All public functions and variables with the exception of @code{main} | |
13913 | and those merged by attribute @code{externally_visible} become static functions | |
13914 | and in effect are optimized more aggressively by interprocedural optimizers. | |
13915 | ||
39ebd3a9 JH |
13916 | With @option{-flto} this option has a limited use. In most cases the |
13917 | precise list of symbols used or exported from the binary is known the | |
13918 | resolution info passed to the link-time optimizer by the linker plugin. It is | |
13919 | still useful if no linker plugin is used or during incremental link step when | |
13920 | final code is produced (with @option{-flto} | |
13921 | @option{-flinker-output=nolto-rel}). | |
d77de738 | 13922 | |
d77de738 | 13923 | @opindex flto |
ddf6fe37 | 13924 | @item -flto[=@var{n}] |
d77de738 ML |
13925 | This option runs the standard link-time optimizer. When invoked |
13926 | with source code, it generates GIMPLE (one of GCC's internal | |
13927 | representations) and writes it to special ELF sections in the object | |
13928 | file. When the object files are linked together, all the function | |
13929 | bodies are read from these ELF sections and instantiated as if they | |
13930 | had been part of the same translation unit. | |
13931 | ||
13932 | To use the link-time optimizer, @option{-flto} and optimization | |
13933 | options should be specified at compile time and during the final link. | |
13934 | It is recommended that you compile all the files participating in the | |
13935 | same link with the same options and also specify those options at | |
13936 | link time. | |
13937 | For example: | |
13938 | ||
13939 | @smallexample | |
13940 | gcc -c -O2 -flto foo.c | |
13941 | gcc -c -O2 -flto bar.c | |
13942 | gcc -o myprog -flto -O2 foo.o bar.o | |
13943 | @end smallexample | |
13944 | ||
13945 | The first two invocations to GCC save a bytecode representation | |
13946 | of GIMPLE into special ELF sections inside @file{foo.o} and | |
13947 | @file{bar.o}. The final invocation reads the GIMPLE bytecode from | |
13948 | @file{foo.o} and @file{bar.o}, merges the two files into a single | |
13949 | internal image, and compiles the result as usual. Since both | |
13950 | @file{foo.o} and @file{bar.o} are merged into a single image, this | |
13951 | causes all the interprocedural analyses and optimizations in GCC to | |
13952 | work across the two files as if they were a single one. This means, | |
13953 | for example, that the inliner is able to inline functions in | |
13954 | @file{bar.o} into functions in @file{foo.o} and vice-versa. | |
13955 | ||
13956 | Another (simpler) way to enable link-time optimization is: | |
13957 | ||
13958 | @smallexample | |
13959 | gcc -o myprog -flto -O2 foo.c bar.c | |
13960 | @end smallexample | |
13961 | ||
13962 | The above generates bytecode for @file{foo.c} and @file{bar.c}, | |
13963 | merges them together into a single GIMPLE representation and optimizes | |
13964 | them as usual to produce @file{myprog}. | |
13965 | ||
13966 | The important thing to keep in mind is that to enable link-time | |
13967 | optimizations you need to use the GCC driver to perform the link step. | |
13968 | GCC automatically performs link-time optimization if any of the | |
13969 | objects involved were compiled with the @option{-flto} command-line option. | |
13970 | You can always override | |
13971 | the automatic decision to do link-time optimization | |
13972 | by passing @option{-fno-lto} to the link command. | |
13973 | ||
13974 | To make whole program optimization effective, it is necessary to make | |
13975 | certain whole program assumptions. The compiler needs to know | |
13976 | what functions and variables can be accessed by libraries and runtime | |
13977 | outside of the link-time optimized unit. When supported by the linker, | |
13978 | the linker plugin (see @option{-fuse-linker-plugin}) passes information | |
13979 | to the compiler about used and externally visible symbols. When | |
13980 | the linker plugin is not available, @option{-fwhole-program} should be | |
13981 | used to allow the compiler to make these assumptions, which leads | |
13982 | to more aggressive optimization decisions. | |
13983 | ||
13984 | When a file is compiled with @option{-flto} without | |
13985 | @option{-fuse-linker-plugin}, the generated object file is larger than | |
13986 | a regular object file because it contains GIMPLE bytecodes and the usual | |
13987 | final code (see @option{-ffat-lto-objects}). This means that | |
13988 | object files with LTO information can be linked as normal object | |
13989 | files; if @option{-fno-lto} is passed to the linker, no | |
13990 | interprocedural optimizations are applied. Note that when | |
13991 | @option{-fno-fat-lto-objects} is enabled the compile stage is faster | |
13992 | but you cannot perform a regular, non-LTO link on them. | |
13993 | ||
13994 | When producing the final binary, GCC only | |
13995 | applies link-time optimizations to those files that contain bytecode. | |
13996 | Therefore, you can mix and match object files and libraries with | |
13997 | GIMPLE bytecodes and final object code. GCC automatically selects | |
13998 | which files to optimize in LTO mode and which files to link without | |
13999 | further processing. | |
14000 | ||
14001 | Generally, options specified at link time override those | |
14002 | specified at compile time, although in some cases GCC attempts to infer | |
14003 | link-time options from the settings used to compile the input files. | |
14004 | ||
14005 | If you do not specify an optimization level option @option{-O} at | |
14006 | link time, then GCC uses the highest optimization level | |
14007 | used when compiling the object files. Note that it is generally | |
14008 | ineffective to specify an optimization level option only at link time and | |
14009 | not at compile time, for two reasons. First, compiling without | |
14010 | optimization suppresses compiler passes that gather information | |
14011 | needed for effective optimization at link time. Second, some early | |
14012 | optimization passes can be performed only at compile time and | |
14013 | not at link time. | |
14014 | ||
14015 | There are some code generation flags preserved by GCC when | |
14016 | generating bytecodes, as they need to be used during the final link. | |
14017 | Currently, the following options and their settings are taken from | |
14018 | the first object file that explicitly specifies them: | |
14019 | @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions}, | |
14020 | @option{-fgnu-tm} and all the @option{-m} target flags. | |
14021 | ||
14022 | The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and | |
14023 | @option{-fPIE} are combined based on the following scheme: | |
14024 | ||
14025 | @smallexample | |
14026 | @option{-fPIC} + @option{-fpic} = @option{-fpic} | |
14027 | @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic} | |
14028 | @option{-fpic/-fPIC} + (no option) = (no option) | |
14029 | @option{-fPIC} + @option{-fPIE} = @option{-fPIE} | |
14030 | @option{-fpic} + @option{-fPIE} = @option{-fpie} | |
14031 | @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie} | |
14032 | @end smallexample | |
14033 | ||
14034 | Certain ABI-changing flags are required to match in all compilation units, | |
14035 | and trying to override this at link time with a conflicting value | |
14036 | is ignored. This includes options such as @option{-freg-struct-return} | |
14037 | and @option{-fpcc-struct-return}. | |
14038 | ||
14039 | Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow}, | |
14040 | @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing} | |
14041 | are passed through to the link stage and merged conservatively for | |
14042 | conflicting translation units. Specifically | |
14043 | @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take | |
14044 | precedence; and for example @option{-ffp-contract=off} takes precedence | |
14045 | over @option{-ffp-contract=fast}. You can override them at link time. | |
14046 | ||
14047 | Diagnostic options such as @option{-Wstringop-overflow} are passed | |
14048 | through to the link stage and their setting matches that of the | |
14049 | compile-step at function granularity. Note that this matters only | |
14050 | for diagnostics emitted during optimization. Note that code | |
14051 | transforms such as inlining can lead to warnings being enabled | |
14052 | or disabled for regions if code not consistent with the setting | |
14053 | at compile time. | |
14054 | ||
14055 | When you need to pass options to the assembler via @option{-Wa} or | |
14056 | @option{-Xassembler} make sure to either compile such translation | |
14057 | units with @option{-fno-lto} or consistently use the same assembler | |
14058 | options on all translation units. You can alternatively also | |
14059 | specify assembler options at LTO link time. | |
14060 | ||
14061 | To enable debug info generation you need to supply @option{-g} at | |
14062 | compile time. If any of the input files at link time were built | |
14063 | with debug info generation enabled the link will enable debug info | |
14064 | generation as well. Any elaborate debug info settings | |
14065 | like the dwarf level @option{-gdwarf-5} need to be explicitly repeated | |
14066 | at the linker command line and mixing different settings in different | |
14067 | translation units is discouraged. | |
14068 | ||
14069 | If LTO encounters objects with C linkage declared with incompatible | |
14070 | types in separate translation units to be linked together (undefined | |
14071 | behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be | |
14072 | issued. The behavior is still undefined at run time. Similar | |
14073 | diagnostics may be raised for other languages. | |
14074 | ||
14075 | Another feature of LTO is that it is possible to apply interprocedural | |
14076 | optimizations on files written in different languages: | |
14077 | ||
14078 | @smallexample | |
14079 | gcc -c -flto foo.c | |
14080 | g++ -c -flto bar.cc | |
14081 | gfortran -c -flto baz.f90 | |
14082 | g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran | |
14083 | @end smallexample | |
14084 | ||
14085 | Notice that the final link is done with @command{g++} to get the C++ | |
14086 | runtime libraries and @option{-lgfortran} is added to get the Fortran | |
14087 | runtime libraries. In general, when mixing languages in LTO mode, you | |
14088 | should use the same link command options as when mixing languages in a | |
14089 | regular (non-LTO) compilation. | |
14090 | ||
14091 | If object files containing GIMPLE bytecode are stored in a library archive, say | |
14092 | @file{libfoo.a}, it is possible to extract and use them in an LTO link if you | |
14093 | are using a linker with plugin support. To create static libraries suitable | |
14094 | for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar} | |
14095 | and @command{ranlib}; | |
14096 | to show the symbols of object files with GIMPLE bytecode, use | |
14097 | @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib} | |
14098 | and @command{nm} have been compiled with plugin support. At link time, use the | |
14099 | flag @option{-fuse-linker-plugin} to ensure that the library participates in | |
14100 | the LTO optimization process: | |
14101 | ||
14102 | @smallexample | |
14103 | gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo | |
14104 | @end smallexample | |
14105 | ||
14106 | With the linker plugin enabled, the linker extracts the needed | |
14107 | GIMPLE files from @file{libfoo.a} and passes them on to the running GCC | |
14108 | to make them part of the aggregated GIMPLE image to be optimized. | |
14109 | ||
14110 | If you are not using a linker with plugin support and/or do not | |
14111 | enable the linker plugin, then the objects inside @file{libfoo.a} | |
14112 | are extracted and linked as usual, but they do not participate | |
14113 | in the LTO optimization process. In order to make a static library suitable | |
14114 | for both LTO optimization and usual linkage, compile its object files with | |
14115 | @option{-flto} @option{-ffat-lto-objects}. | |
14116 | ||
14117 | Link-time optimizations do not require the presence of the whole program to | |
14118 | operate. If the program does not require any symbols to be exported, it is | |
14119 | possible to combine @option{-flto} and @option{-fwhole-program} to allow | |
14120 | the interprocedural optimizers to use more aggressive assumptions which may | |
14121 | lead to improved optimization opportunities. | |
14122 | Use of @option{-fwhole-program} is not needed when linker plugin is | |
14123 | active (see @option{-fuse-linker-plugin}). | |
14124 | ||
14125 | The current implementation of LTO makes no | |
14126 | attempt to generate bytecode that is portable between different | |
14127 | types of hosts. The bytecode files are versioned and there is a | |
14128 | strict version check, so bytecode files generated in one version of | |
14129 | GCC do not work with an older or newer version of GCC. | |
14130 | ||
14131 | Link-time optimization does not work well with generation of debugging | |
14132 | information on systems other than those using a combination of ELF and | |
14133 | DWARF. | |
14134 | ||
14135 | If you specify the optional @var{n}, the optimization and code | |
14136 | generation done at link time is executed in parallel using @var{n} | |
14137 | parallel jobs by utilizing an installed @command{make} program. The | |
14138 | environment variable @env{MAKE} may be used to override the program | |
14139 | used. | |
14140 | ||
14141 | You can also specify @option{-flto=jobserver} to use GNU make's | |
14142 | job server mode to determine the number of parallel jobs. This | |
14143 | is useful when the Makefile calling GCC is already executing in parallel. | |
14144 | You must prepend a @samp{+} to the command recipe in the parent Makefile | |
14145 | for this to work. This option likely only works if @env{MAKE} is | |
14146 | GNU make. Even without the option value, GCC tries to automatically | |
14147 | detect a running GNU make's job server. | |
14148 | ||
14149 | Use @option{-flto=auto} to use GNU make's job server, if available, | |
14150 | or otherwise fall back to autodetection of the number of CPU threads | |
14151 | present in your system. | |
14152 | ||
d77de738 | 14153 | @opindex flto-partition |
ddf6fe37 | 14154 | @item -flto-partition=@var{alg} |
d77de738 ML |
14155 | Specify the partitioning algorithm used by the link-time optimizer. |
14156 | The value is either @samp{1to1} to specify a partitioning mirroring | |
14157 | the original source files or @samp{balanced} to specify partitioning | |
14158 | into equally sized chunks (whenever possible) or @samp{max} to create | |
14159 | new partition for every symbol where possible. Specifying @samp{none} | |
14160 | as an algorithm disables partitioning and streaming completely. | |
14161 | The default value is @samp{balanced}. While @samp{1to1} can be used | |
14162 | as an workaround for various code ordering issues, the @samp{max} | |
14163 | partitioning is intended for internal testing only. | |
14164 | The value @samp{one} specifies that exactly one partition should be | |
14165 | used while the value @samp{none} bypasses partitioning and executes | |
14166 | the link-time optimization step directly from the WPA phase. | |
14167 | ||
d77de738 | 14168 | @opindex flto-compression-level |
ddf6fe37 | 14169 | @item -flto-compression-level=@var{n} |
d77de738 ML |
14170 | This option specifies the level of compression used for intermediate |
14171 | language written to LTO object files, and is only meaningful in | |
14172 | conjunction with LTO mode (@option{-flto}). GCC currently supports two | |
14173 | LTO compression algorithms. For zstd, valid values are 0 (no compression) | |
14174 | to 19 (maximum compression), while zlib supports values from 0 to 9. | |
14175 | Values outside this range are clamped to either minimum or maximum | |
14176 | of the supported values. If the option is not given, | |
14177 | a default balanced compression setting is used. | |
14178 | ||
d77de738 | 14179 | @opindex fuse-linker-plugin |
ddf6fe37 | 14180 | @item -fuse-linker-plugin |
d77de738 ML |
14181 | Enables the use of a linker plugin during link-time optimization. This |
14182 | option relies on plugin support in the linker, which is available in gold | |
14183 | or in GNU ld 2.21 or newer. | |
14184 | ||
14185 | This option enables the extraction of object files with GIMPLE bytecode out | |
14186 | of library archives. This improves the quality of optimization by exposing | |
14187 | more code to the link-time optimizer. This information specifies what | |
14188 | symbols can be accessed externally (by non-LTO object or during dynamic | |
14189 | linking). Resulting code quality improvements on binaries (and shared | |
14190 | libraries that use hidden visibility) are similar to @option{-fwhole-program}. | |
14191 | See @option{-flto} for a description of the effect of this flag and how to | |
14192 | use it. | |
14193 | ||
14194 | This option is enabled by default when LTO support in GCC is enabled | |
14195 | and GCC was configured for use with | |
14196 | a linker supporting plugins (GNU ld 2.21 or newer or gold). | |
14197 | ||
d77de738 | 14198 | @opindex ffat-lto-objects |
ddf6fe37 | 14199 | @item -ffat-lto-objects |
d77de738 ML |
14200 | Fat LTO objects are object files that contain both the intermediate language |
14201 | and the object code. This makes them usable for both LTO linking and normal | |
14202 | linking. This option is effective only when compiling with @option{-flto} | |
14203 | and is ignored at link time. | |
14204 | ||
14205 | @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but | |
14206 | requires the complete toolchain to be aware of LTO. It requires a linker with | |
14207 | linker plugin support for basic functionality. Additionally, | |
14208 | @command{nm}, @command{ar} and @command{ranlib} | |
14209 | need to support linker plugins to allow a full-featured build environment | |
14210 | (capable of building static libraries etc). GCC provides the @command{gcc-ar}, | |
14211 | @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options | |
14212 | to these tools. With non fat LTO makefiles need to be modified to use them. | |
14213 | ||
14214 | Note that modern binutils provide plugin auto-load mechanism. | |
14215 | Installing the linker plugin into @file{$libdir/bfd-plugins} has the same | |
14216 | effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and | |
14217 | @command{gcc-ranlib}). | |
14218 | ||
14219 | The default is @option{-fno-fat-lto-objects} on targets with linker plugin | |
14220 | support. | |
14221 | ||
d77de738 | 14222 | @opindex fcompare-elim |
ddf6fe37 | 14223 | @item -fcompare-elim |
d77de738 ML |
14224 | After register allocation and post-register allocation instruction splitting, |
14225 | identify arithmetic instructions that compute processor flags similar to a | |
14226 | comparison operation based on that arithmetic. If possible, eliminate the | |
14227 | explicit comparison operation. | |
14228 | ||
14229 | This pass only applies to certain targets that cannot explicitly represent | |
14230 | the comparison operation before register allocation is complete. | |
14231 | ||
14232 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14233 | ||
d77de738 | 14234 | @opindex fcprop-registers |
ddf6fe37 | 14235 | @item -fcprop-registers |
d77de738 ML |
14236 | After register allocation and post-register allocation instruction splitting, |
14237 | perform a copy-propagation pass to try to reduce scheduling dependencies | |
14238 | and occasionally eliminate the copy. | |
14239 | ||
14240 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14241 | ||
d77de738 | 14242 | @opindex fprofile-correction |
ddf6fe37 | 14243 | @item -fprofile-correction |
d77de738 ML |
14244 | Profiles collected using an instrumented binary for multi-threaded programs may |
14245 | be inconsistent due to missed counter updates. When this option is specified, | |
14246 | GCC uses heuristics to correct or smooth out such inconsistencies. By | |
14247 | default, GCC emits an error message when an inconsistent profile is detected. | |
14248 | ||
14249 | This option is enabled by @option{-fauto-profile}. | |
14250 | ||
d77de738 | 14251 | @opindex fprofile-partial-training |
ddf6fe37 | 14252 | @item -fprofile-partial-training |
d77de738 ML |
14253 | With @code{-fprofile-use} all portions of programs not executed during train |
14254 | run are optimized agressively for size rather than speed. In some cases it is | |
14255 | not practical to train all possible hot paths in the program. (For | |
14256 | example, program may contain functions specific for a given hardware and | |
14257 | trianing may not cover all hardware configurations program is run on.) With | |
14258 | @code{-fprofile-partial-training} profile feedback will be ignored for all | |
14259 | functions not executed during the train run leading them to be optimized as if | |
14260 | they were compiled without profile feedback. This leads to better performance | |
14261 | when train run is not representative but also leads to significantly bigger | |
14262 | code. | |
14263 | ||
ddf6fe37 | 14264 | @opindex fprofile-use |
d77de738 ML |
14265 | @item -fprofile-use |
14266 | @itemx -fprofile-use=@var{path} | |
d77de738 ML |
14267 | Enable profile feedback-directed optimizations, |
14268 | and the following optimizations, many of which | |
14269 | are generally profitable only with profile feedback available: | |
14270 | ||
43b72ede AA |
14271 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14272 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14273 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14274 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14275 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14276 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14277 | -fprofile-reorder-functions} |
14278 | ||
14279 | Before you can use this option, you must first generate profiling information. | |
14280 | @xref{Instrumentation Options}, for information about the | |
14281 | @option{-fprofile-generate} option. | |
14282 | ||
14283 | By default, GCC emits an error message if the feedback profiles do not | |
14284 | match the source code. This error can be turned into a warning by using | |
14285 | @option{-Wno-error=coverage-mismatch}. Note this may result in poorly | |
14286 | optimized code. Additionally, by default, GCC also emits a warning message if | |
14287 | the feedback profiles do not exist (see @option{-Wmissing-profile}). | |
14288 | ||
14289 | If @var{path} is specified, GCC looks at the @var{path} to find | |
14290 | the profile feedback data files. See @option{-fprofile-dir}. | |
14291 | ||
ddf6fe37 | 14292 | @opindex fauto-profile |
d77de738 ML |
14293 | @item -fauto-profile |
14294 | @itemx -fauto-profile=@var{path} | |
d77de738 ML |
14295 | Enable sampling-based feedback-directed optimizations, |
14296 | and the following optimizations, | |
14297 | many of which are generally profitable only with profile feedback available: | |
14298 | ||
43b72ede AA |
14299 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14300 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14301 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14302 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14303 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14304 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14305 | -fprofile-correction} |
14306 | ||
14307 | @var{path} is the name of a file containing AutoFDO profile information. | |
14308 | If omitted, it defaults to @file{fbdata.afdo} in the current directory. | |
14309 | ||
14310 | Producing an AutoFDO profile data file requires running your program | |
14311 | with the @command{perf} utility on a supported GNU/Linux target system. | |
14312 | For more information, see @uref{https://perf.wiki.kernel.org/}. | |
14313 | ||
14314 | E.g. | |
14315 | @smallexample | |
14316 | perf record -e br_inst_retired:near_taken -b -o perf.data \ | |
14317 | -- your_program | |
14318 | @end smallexample | |
14319 | ||
14320 | Then use the @command{create_gcov} tool to convert the raw profile data | |
14321 | to a format that can be used by GCC.@ You must also supply the | |
14322 | unstripped binary for your program to this tool. | |
14323 | See @uref{https://github.com/google/autofdo}. | |
14324 | ||
14325 | E.g. | |
14326 | @smallexample | |
14327 | create_gcov --binary=your_program.unstripped --profile=perf.data \ | |
14328 | --gcov=profile.afdo | |
14329 | @end smallexample | |
14330 | @end table | |
14331 | ||
14332 | The following options control compiler behavior regarding floating-point | |
14333 | arithmetic. These options trade off between speed and | |
14334 | correctness. All must be specifically enabled. | |
14335 | ||
14336 | @table @gcctabopt | |
d77de738 | 14337 | @opindex ffloat-store |
ddf6fe37 | 14338 | @item -ffloat-store |
d77de738 ML |
14339 | Do not store floating-point variables in registers, and inhibit other |
14340 | options that might change whether a floating-point value is taken from a | |
14341 | register or memory. | |
14342 | ||
14343 | @cindex floating-point precision | |
14344 | This option prevents undesirable excess precision on machines such as | |
14345 | the 68000 where the floating registers (of the 68881) keep more | |
14346 | precision than a @code{double} is supposed to have. Similarly for the | |
14347 | x86 architecture. For most programs, the excess precision does only | |
14348 | good, but a few programs rely on the precise definition of IEEE floating | |
14349 | point. Use @option{-ffloat-store} for such programs, after modifying | |
14350 | them to store all pertinent intermediate computations into variables. | |
14351 | ||
d77de738 | 14352 | @opindex fexcess-precision |
ddf6fe37 | 14353 | @item -fexcess-precision=@var{style} |
d77de738 ML |
14354 | This option allows further control over excess precision on machines |
14355 | where floating-point operations occur in a format with more precision or | |
14356 | range than the IEEE standard and interchange floating-point types. By | |
14357 | default, @option{-fexcess-precision=fast} is in effect; this means that | |
14358 | operations may be carried out in a wider precision than the types specified | |
14359 | in the source if that would result in faster code, and it is unpredictable | |
14360 | when rounding to the types specified in the source code takes place. | |
14361 | When compiling C or C++, if @option{-fexcess-precision=standard} is specified | |
14362 | then excess precision follows the rules specified in ISO C99 or C++; in particular, | |
14363 | both casts and assignments cause values to be rounded to their | |
14364 | semantic types (whereas @option{-ffloat-store} only affects | |
14365 | assignments). This option is enabled by default for C or C++ if a strict | |
14366 | conformance option such as @option{-std=c99} or @option{-std=c++17} is used. | |
14367 | @option{-ffast-math} enables @option{-fexcess-precision=fast} by default | |
14368 | regardless of whether a strict conformance option is used. | |
14369 | ||
14370 | @opindex mfpmath | |
14371 | @option{-fexcess-precision=standard} is not implemented for languages | |
14372 | other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse} | |
14373 | or @option{-mfpmath=sse+387} is specified; in the former case, IEEE | |
14374 | semantics apply without excess precision, and in the latter, rounding | |
14375 | is unpredictable. | |
14376 | ||
d77de738 | 14377 | @opindex ffast-math |
ddf6fe37 | 14378 | @item -ffast-math |
d77de738 ML |
14379 | Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, |
14380 | @option{-ffinite-math-only}, @option{-fno-rounding-math}, | |
14381 | @option{-fno-signaling-nans}, @option{-fcx-limited-range} and | |
14382 | @option{-fexcess-precision=fast}. | |
14383 | ||
14384 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. | |
14385 | ||
14386 | This option is not turned on by any @option{-O} option besides | |
14387 | @option{-Ofast} since it can result in incorrect output for programs | |
14388 | that depend on an exact implementation of IEEE or ISO rules/specifications | |
14389 | for math functions. It may, however, yield faster code for programs | |
14390 | that do not require the guarantees of these specifications. | |
14391 | ||
d77de738 ML |
14392 | @opindex fno-math-errno |
14393 | @opindex fmath-errno | |
ddf6fe37 | 14394 | @item -fno-math-errno |
d77de738 ML |
14395 | Do not set @code{errno} after calling math functions that are executed |
14396 | with a single instruction, e.g., @code{sqrt}. A program that relies on | |
14397 | IEEE exceptions for math error handling may want to use this flag | |
14398 | for speed while maintaining IEEE arithmetic compatibility. | |
14399 | ||
14400 | This option is not 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. It may, however, yield faster code for programs | |
14404 | that do not require the guarantees of these specifications. | |
14405 | ||
14406 | The default is @option{-fmath-errno}. | |
14407 | ||
14408 | On Darwin systems, the math library never sets @code{errno}. There is | |
14409 | therefore no reason for the compiler to consider the possibility that | |
14410 | it might, and @option{-fno-math-errno} is the default. | |
14411 | ||
d77de738 | 14412 | @opindex funsafe-math-optimizations |
ddf6fe37 | 14413 | @item -funsafe-math-optimizations |
d77de738 ML |
14414 | |
14415 | Allow optimizations for floating-point arithmetic that (a) assume | |
14416 | that arguments and results are valid and (b) may violate IEEE or | |
14417 | ANSI standards. When used at link time, it may include libraries | |
14418 | or startup files that change the default FPU control word or other | |
14419 | similar optimizations. | |
14420 | ||
14421 | This option is not turned on by any @option{-O} option since | |
14422 | it can result in incorrect output for programs that depend on | |
14423 | an exact implementation of IEEE or ISO rules/specifications for | |
14424 | math functions. It may, however, yield faster code for programs | |
14425 | that do not require the guarantees of these specifications. | |
14426 | Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math}, | |
14427 | @option{-fassociative-math} and @option{-freciprocal-math}. | |
14428 | ||
14429 | The default is @option{-fno-unsafe-math-optimizations}. | |
14430 | ||
d77de738 | 14431 | @opindex fassociative-math |
ddf6fe37 | 14432 | @item -fassociative-math |
d77de738 ML |
14433 | |
14434 | Allow re-association of operands in series of floating-point operations. | |
14435 | This violates the ISO C and C++ language standard by possibly changing | |
14436 | computation result. NOTE: re-ordering may change the sign of zero as | |
14437 | well as ignore NaNs and inhibit or create underflow or overflow (and | |
14438 | thus cannot be used on code that relies on rounding behavior like | |
14439 | @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons | |
14440 | and thus may not be used when ordered comparisons are required. | |
14441 | This option requires that both @option{-fno-signed-zeros} and | |
14442 | @option{-fno-trapping-math} be in effect. Moreover, it doesn't make | |
14443 | much sense with @option{-frounding-math}. For Fortran the option | |
14444 | is automatically enabled when both @option{-fno-signed-zeros} and | |
14445 | @option{-fno-trapping-math} are in effect. | |
14446 | ||
14447 | The default is @option{-fno-associative-math}. | |
14448 | ||
d77de738 | 14449 | @opindex freciprocal-math |
ddf6fe37 | 14450 | @item -freciprocal-math |
d77de738 ML |
14451 | |
14452 | Allow the reciprocal of a value to be used instead of dividing by | |
14453 | the value if this enables optimizations. For example @code{x / y} | |
14454 | can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)} | |
14455 | is subject to common subexpression elimination. Note that this loses | |
14456 | precision and increases the number of flops operating on the value. | |
14457 | ||
14458 | The default is @option{-fno-reciprocal-math}. | |
14459 | ||
d77de738 | 14460 | @opindex ffinite-math-only |
ddf6fe37 | 14461 | @item -ffinite-math-only |
d77de738 ML |
14462 | Allow optimizations for floating-point arithmetic that assume |
14463 | that arguments and results are not NaNs or +-Infs. | |
14464 | ||
14465 | This option is not turned on by any @option{-O} option since | |
14466 | it can result in incorrect output for programs that depend on | |
14467 | an exact implementation of IEEE or ISO rules/specifications for | |
14468 | math functions. It may, however, yield faster code for programs | |
14469 | that do not require the guarantees of these specifications. | |
14470 | ||
14471 | The default is @option{-fno-finite-math-only}. | |
14472 | ||
d77de738 ML |
14473 | @opindex fno-signed-zeros |
14474 | @opindex fsigned-zeros | |
ddf6fe37 | 14475 | @item -fno-signed-zeros |
d77de738 ML |
14476 | Allow optimizations for floating-point arithmetic that ignore the |
14477 | signedness of zero. IEEE arithmetic specifies the behavior of | |
14478 | distinct +0.0 and @minus{}0.0 values, which then prohibits simplification | |
14479 | of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}). | |
14480 | This option implies that the sign of a zero result isn't significant. | |
14481 | ||
14482 | The default is @option{-fsigned-zeros}. | |
14483 | ||
d77de738 ML |
14484 | @opindex fno-trapping-math |
14485 | @opindex ftrapping-math | |
ddf6fe37 | 14486 | @item -fno-trapping-math |
d77de738 ML |
14487 | Compile code assuming that floating-point operations cannot generate |
14488 | user-visible traps. These traps include division by zero, overflow, | |
14489 | underflow, inexact result and invalid operation. This option requires | |
14490 | that @option{-fno-signaling-nans} be in effect. Setting this option may | |
14491 | allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example. | |
14492 | ||
14493 | This option should never be turned on by any @option{-O} option since | |
14494 | it can result in incorrect output for programs that depend on | |
14495 | an exact implementation of IEEE or ISO rules/specifications for | |
14496 | math functions. | |
14497 | ||
14498 | The default is @option{-ftrapping-math}. | |
14499 | ||
14500 | Future versions of GCC may provide finer control of this setting | |
14501 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14502 | will be used along with @option{-frounding-math} to specify the | |
14503 | default state for @code{FENV_ACCESS}. | |
14504 | ||
d77de738 | 14505 | @opindex frounding-math |
ddf6fe37 | 14506 | @item -frounding-math |
d77de738 ML |
14507 | Disable transformations and optimizations that assume default floating-point |
14508 | rounding behavior. This is round-to-zero for all floating point | |
14509 | to integer conversions, and round-to-nearest for all other arithmetic | |
14510 | truncations. This option should be specified for programs that change | |
14511 | the FP rounding mode dynamically, or that may be executed with a | |
14512 | non-default rounding mode. This option disables constant folding of | |
14513 | floating-point expressions at compile time (which may be affected by | |
14514 | rounding mode) and arithmetic transformations that are unsafe in the | |
14515 | presence of sign-dependent rounding modes. | |
14516 | ||
14517 | The default is @option{-fno-rounding-math}. | |
14518 | ||
14519 | This option is experimental and does not currently guarantee to | |
14520 | disable all GCC optimizations that are affected by rounding mode. | |
14521 | Future versions of GCC may provide finer control of this setting | |
14522 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14523 | will be used along with @option{-ftrapping-math} to specify the | |
14524 | default state for @code{FENV_ACCESS}. | |
14525 | ||
d77de738 | 14526 | @opindex fsignaling-nans |
ddf6fe37 | 14527 | @item -fsignaling-nans |
d77de738 ML |
14528 | Compile code assuming that IEEE signaling NaNs may generate user-visible |
14529 | traps during floating-point operations. Setting this option disables | |
14530 | optimizations that may change the number of exceptions visible with | |
14531 | signaling NaNs. This option implies @option{-ftrapping-math}. | |
14532 | ||
14533 | This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to | |
14534 | be defined. | |
14535 | ||
14536 | The default is @option{-fno-signaling-nans}. | |
14537 | ||
14538 | This option is experimental and does not currently guarantee to | |
14539 | disable all GCC optimizations that affect signaling NaN behavior. | |
14540 | ||
d77de738 ML |
14541 | @opindex fno-fp-int-builtin-inexact |
14542 | @opindex ffp-int-builtin-inexact | |
ddf6fe37 | 14543 | @item -fno-fp-int-builtin-inexact |
d77de738 ML |
14544 | Do not allow the built-in functions @code{ceil}, @code{floor}, |
14545 | @code{round} and @code{trunc}, and their @code{float} and @code{long | |
14546 | double} variants, to generate code that raises the ``inexact'' | |
14547 | floating-point exception for noninteger arguments. ISO C99 and C11 | |
14548 | allow these functions to raise the ``inexact'' exception, but ISO/IEC | |
14549 | TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into | |
14550 | ISO C2X, does not allow these functions to do so. | |
14551 | ||
14552 | The default is @option{-ffp-int-builtin-inexact}, allowing the | |
14553 | exception to be raised, unless C2X or a later C standard is selected. | |
14554 | This option does nothing unless @option{-ftrapping-math} is in effect. | |
14555 | ||
14556 | Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions | |
14557 | generate a call to a library function then the ``inexact'' exception | |
14558 | may be raised if the library implementation does not follow TS 18661. | |
14559 | ||
d77de738 | 14560 | @opindex fsingle-precision-constant |
ddf6fe37 | 14561 | @item -fsingle-precision-constant |
d77de738 ML |
14562 | Treat floating-point constants as single precision instead of |
14563 | implicitly converting them to double-precision constants. | |
14564 | ||
d77de738 | 14565 | @opindex fcx-limited-range |
ddf6fe37 | 14566 | @item -fcx-limited-range |
d77de738 ML |
14567 | When enabled, this option states that a range reduction step is not |
14568 | needed when performing complex division. Also, there is no checking | |
14569 | whether the result of a complex multiplication or division is @code{NaN | |
14570 | + I*NaN}, with an attempt to rescue the situation in that case. The | |
14571 | default is @option{-fno-cx-limited-range}, but is enabled by | |
14572 | @option{-ffast-math}. | |
14573 | ||
14574 | This option controls the default setting of the ISO C99 | |
14575 | @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to | |
14576 | all languages. | |
14577 | ||
d77de738 | 14578 | @opindex fcx-fortran-rules |
ddf6fe37 | 14579 | @item -fcx-fortran-rules |
d77de738 ML |
14580 | Complex multiplication and division follow Fortran rules. Range |
14581 | reduction is done as part of complex division, but there is no checking | |
14582 | whether the result of a complex multiplication or division is @code{NaN | |
14583 | + I*NaN}, with an attempt to rescue the situation in that case. | |
14584 | ||
14585 | The default is @option{-fno-cx-fortran-rules}. | |
14586 | ||
14587 | @end table | |
14588 | ||
14589 | The following options control optimizations that may improve | |
14590 | performance, but are not enabled by any @option{-O} options. This | |
14591 | section includes experimental options that may produce broken code. | |
14592 | ||
14593 | @table @gcctabopt | |
d77de738 | 14594 | @opindex fbranch-probabilities |
ddf6fe37 | 14595 | @item -fbranch-probabilities |
d77de738 ML |
14596 | After running a program compiled with @option{-fprofile-arcs} |
14597 | (@pxref{Instrumentation Options}), | |
14598 | you can compile it a second time using | |
14599 | @option{-fbranch-probabilities}, to improve optimizations based on | |
14600 | the number of times each branch was taken. When a program | |
14601 | compiled with @option{-fprofile-arcs} exits, it saves arc execution | |
14602 | counts to a file called @file{@var{sourcename}.gcda} for each source | |
14603 | file. The information in this data file is very dependent on the | |
14604 | structure of the generated code, so you must use the same source code | |
14605 | and the same optimization options for both compilations. | |
14606 | See details about the file naming in @option{-fprofile-arcs}. | |
14607 | ||
14608 | With @option{-fbranch-probabilities}, GCC puts a | |
14609 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
14610 | These can be used to improve optimization. Currently, they are only | |
14611 | used in one place: in @file{reorg.cc}, instead of guessing which path a | |
14612 | branch is most likely to take, the @samp{REG_BR_PROB} values are used to | |
14613 | exactly determine which path is taken more often. | |
14614 | ||
14615 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14616 | ||
d77de738 | 14617 | @opindex fprofile-values |
ddf6fe37 | 14618 | @item -fprofile-values |
d77de738 ML |
14619 | If combined with @option{-fprofile-arcs}, it adds code so that some |
14620 | data about values of expressions in the program is gathered. | |
14621 | ||
14622 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14623 | from profiling values of expressions for usage in optimizations. | |
14624 | ||
14625 | Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and | |
14626 | @option{-fauto-profile}. | |
14627 | ||
d77de738 | 14628 | @opindex fprofile-reorder-functions |
ddf6fe37 | 14629 | @item -fprofile-reorder-functions |
d77de738 ML |
14630 | Function reordering based on profile instrumentation collects |
14631 | first time of execution of a function and orders these functions | |
14632 | in ascending order. | |
14633 | ||
14634 | Enabled with @option{-fprofile-use}. | |
14635 | ||
d77de738 | 14636 | @opindex fvpt |
ddf6fe37 | 14637 | @item -fvpt |
d77de738 ML |
14638 | If combined with @option{-fprofile-arcs}, this option instructs the compiler |
14639 | to add code to gather information about values of expressions. | |
14640 | ||
14641 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14642 | and actually performs the optimizations based on them. | |
14643 | Currently the optimizations include specialization of division operations | |
14644 | using the knowledge about the value of the denominator. | |
14645 | ||
14646 | Enabled with @option{-fprofile-use} and @option{-fauto-profile}. | |
14647 | ||
d77de738 | 14648 | @opindex frename-registers |
ddf6fe37 | 14649 | @item -frename-registers |
d77de738 ML |
14650 | Attempt to avoid false dependencies in scheduled code by making use |
14651 | of registers left over after register allocation. This optimization | |
14652 | most benefits processors with lots of registers. Depending on the | |
14653 | debug information format adopted by the target, however, it can | |
14654 | make debugging impossible, since variables no longer stay in | |
14655 | a ``home register''. | |
14656 | ||
14657 | Enabled by default with @option{-funroll-loops}. | |
14658 | ||
d77de738 | 14659 | @opindex fschedule-fusion |
ddf6fe37 | 14660 | @item -fschedule-fusion |
d77de738 ML |
14661 | Performs a target dependent pass over the instruction stream to schedule |
14662 | instructions of same type together because target machine can execute them | |
14663 | more efficiently if they are adjacent to each other in the instruction flow. | |
14664 | ||
14665 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14666 | ||
d77de738 | 14667 | @opindex ftracer |
ddf6fe37 | 14668 | @item -ftracer |
d77de738 ML |
14669 | Perform tail duplication to enlarge superblock size. This transformation |
14670 | simplifies the control flow of the function allowing other optimizations to do | |
14671 | a better job. | |
14672 | ||
14673 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14674 | ||
d77de738 | 14675 | @opindex funroll-loops |
ddf6fe37 | 14676 | @item -funroll-loops |
d77de738 ML |
14677 | Unroll loops whose number of iterations can be determined at compile time or |
14678 | upon entry to the loop. @option{-funroll-loops} implies | |
14679 | @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}. | |
14680 | It also turns on complete loop peeling (i.e.@: complete removal of loops with | |
14681 | a small constant number of iterations). This option makes code larger, and may | |
14682 | or may not make it run faster. | |
14683 | ||
14684 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14685 | ||
d77de738 | 14686 | @opindex funroll-all-loops |
ddf6fe37 | 14687 | @item -funroll-all-loops |
d77de738 ML |
14688 | Unroll all loops, even if their number of iterations is uncertain when |
14689 | the loop is entered. This usually makes programs run more slowly. | |
14690 | @option{-funroll-all-loops} implies the same options as | |
14691 | @option{-funroll-loops}. | |
14692 | ||
d77de738 | 14693 | @opindex fpeel-loops |
ddf6fe37 | 14694 | @item -fpeel-loops |
d77de738 ML |
14695 | Peels loops for which there is enough information that they do not |
14696 | roll much (from profile feedback or static analysis). It also turns on | |
14697 | complete loop peeling (i.e.@: complete removal of loops with small constant | |
14698 | number of iterations). | |
14699 | ||
14700 | Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}. | |
14701 | ||
d77de738 | 14702 | @opindex fmove-loop-invariants |
ddf6fe37 | 14703 | @item -fmove-loop-invariants |
d77de738 ML |
14704 | Enables the loop invariant motion pass in the RTL loop optimizer. Enabled |
14705 | at level @option{-O1} and higher, except for @option{-Og}. | |
14706 | ||
d77de738 | 14707 | @opindex fmove-loop-stores |
ddf6fe37 | 14708 | @item -fmove-loop-stores |
d77de738 ML |
14709 | Enables the loop store motion pass in the GIMPLE loop optimizer. This |
14710 | moves invariant stores to after the end of the loop in exchange for | |
14711 | carrying the stored value in a register across the iteration. | |
14712 | Note for this option to have an effect @option{-ftree-loop-im} has to | |
14713 | be enabled as well. Enabled at level @option{-O1} and higher, except | |
14714 | for @option{-Og}. | |
14715 | ||
d77de738 | 14716 | @opindex fsplit-loops |
ddf6fe37 | 14717 | @item -fsplit-loops |
d77de738 ML |
14718 | Split a loop into two if it contains a condition that's always true |
14719 | for one side of the iteration space and false for the other. | |
14720 | ||
14721 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14722 | ||
d77de738 | 14723 | @opindex funswitch-loops |
ddf6fe37 | 14724 | @item -funswitch-loops |
d77de738 ML |
14725 | Move branches with loop invariant conditions out of the loop, with duplicates |
14726 | of the loop on both branches (modified according to result of the condition). | |
14727 | ||
14728 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14729 | ||
d77de738 | 14730 | @opindex fversion-loops-for-strides |
ddf6fe37 | 14731 | @item -fversion-loops-for-strides |
d77de738 ML |
14732 | If a loop iterates over an array with a variable stride, create another |
14733 | version of the loop that assumes the stride is always one. For example: | |
14734 | ||
14735 | @smallexample | |
14736 | for (int i = 0; i < n; ++i) | |
14737 | x[i * stride] = @dots{}; | |
14738 | @end smallexample | |
14739 | ||
14740 | becomes: | |
14741 | ||
14742 | @smallexample | |
14743 | if (stride == 1) | |
14744 | for (int i = 0; i < n; ++i) | |
14745 | x[i] = @dots{}; | |
14746 | else | |
14747 | for (int i = 0; i < n; ++i) | |
14748 | x[i * stride] = @dots{}; | |
14749 | @end smallexample | |
14750 | ||
14751 | This is particularly useful for assumed-shape arrays in Fortran where | |
14752 | (for example) it allows better vectorization assuming contiguous accesses. | |
14753 | This flag is enabled by default at @option{-O3}. | |
14754 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14755 | ||
d77de738 ML |
14756 | @opindex ffunction-sections |
14757 | @opindex fdata-sections | |
ddf6fe37 AA |
14758 | @item -ffunction-sections |
14759 | @itemx -fdata-sections | |
d77de738 ML |
14760 | Place each function or data item into its own section in the output |
14761 | file if the target supports arbitrary sections. The name of the | |
14762 | function or the name of the data item determines the section's name | |
14763 | in the output file. | |
14764 | ||
14765 | Use these options on systems where the linker can perform optimizations to | |
14766 | improve locality of reference in the instruction space. Most systems using the | |
14767 | ELF object format have linkers with such optimizations. On AIX, the linker | |
14768 | rearranges sections (CSECTs) based on the call graph. The performance impact | |
14769 | varies. | |
14770 | ||
14771 | Together with a linker garbage collection (linker @option{--gc-sections} | |
14772 | option) these options may lead to smaller statically-linked executables (after | |
14773 | stripping). | |
14774 | ||
14775 | On ELF/DWARF systems these options do not degenerate the quality of the debug | |
14776 | information. There could be issues with other object files/debug info formats. | |
14777 | ||
14778 | Only use these options when there are significant benefits from doing so. When | |
14779 | you specify these options, the assembler and linker create larger object and | |
14780 | executable files and are also slower. These options affect code generation. | |
14781 | They prevent optimizations by the compiler and assembler using relative | |
14782 | locations inside a translation unit since the locations are unknown until | |
14783 | link time. An example of such an optimization is relaxing calls to short call | |
14784 | instructions. | |
14785 | ||
d77de738 | 14786 | @opindex fstdarg-opt |
ddf6fe37 | 14787 | @item -fstdarg-opt |
d77de738 ML |
14788 | Optimize the prologue of variadic argument functions with respect to usage of |
14789 | those arguments. | |
14790 | ||
d77de738 | 14791 | @opindex fsection-anchors |
ddf6fe37 | 14792 | @item -fsection-anchors |
d77de738 ML |
14793 | Try to reduce the number of symbolic address calculations by using |
14794 | shared ``anchor'' symbols to address nearby objects. This transformation | |
14795 | can help to reduce the number of GOT entries and GOT accesses on some | |
14796 | targets. | |
14797 | ||
14798 | For example, the implementation of the following function @code{foo}: | |
14799 | ||
14800 | @smallexample | |
14801 | static int a, b, c; | |
14802 | int foo (void) @{ return a + b + c; @} | |
14803 | @end smallexample | |
14804 | ||
14805 | @noindent | |
14806 | usually calculates the addresses of all three variables, but if you | |
14807 | compile it with @option{-fsection-anchors}, it accesses the variables | |
14808 | from a common anchor point instead. The effect is similar to the | |
14809 | following pseudocode (which isn't valid C): | |
14810 | ||
14811 | @smallexample | |
14812 | int foo (void) | |
14813 | @{ | |
14814 | register int *xr = &x; | |
14815 | return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; | |
14816 | @} | |
14817 | @end smallexample | |
14818 | ||
14819 | Not all targets support this option. | |
14820 | ||
d77de738 | 14821 | @opindex fzero-call-used-regs |
ddf6fe37 | 14822 | @item -fzero-call-used-regs=@var{choice} |
d77de738 ML |
14823 | Zero call-used registers at function return to increase program |
14824 | security by either mitigating Return-Oriented Programming (ROP) | |
14825 | attacks or preventing information leakage through registers. | |
14826 | ||
14827 | The possible values of @var{choice} are the same as for the | |
14828 | @code{zero_call_used_regs} attribute (@pxref{Function Attributes}). | |
14829 | The default is @samp{skip}. | |
14830 | ||
14831 | You can control this behavior for a specific function by using the function | |
14832 | attribute @code{zero_call_used_regs} (@pxref{Function Attributes}). | |
14833 | ||
d77de738 | 14834 | @opindex param |
ddf6fe37 | 14835 | @item --param @var{name}=@var{value} |
d77de738 ML |
14836 | In some places, GCC uses various constants to control the amount of |
14837 | optimization that is done. For example, GCC does not inline functions | |
14838 | that contain more than a certain number of instructions. You can | |
14839 | control some of these constants on the command line using the | |
14840 | @option{--param} option. | |
14841 | ||
14842 | The names of specific parameters, and the meaning of the values, are | |
14843 | tied to the internals of the compiler, and are subject to change | |
14844 | without notice in future releases. | |
14845 | ||
c381327d GP |
14846 | In order to get the minimal, maximal and default values of a parameter, |
14847 | use the @option{--help=param -Q} options. | |
d77de738 ML |
14848 | |
14849 | In each case, the @var{value} is an integer. The following choices | |
14850 | of @var{name} are recognized for all targets: | |
14851 | ||
14852 | @table @gcctabopt | |
14853 | @item predictable-branch-outcome | |
14854 | When branch is predicted to be taken with probability lower than this threshold | |
14855 | (in percent), then it is considered well predictable. | |
14856 | ||
14857 | @item max-rtl-if-conversion-insns | |
14858 | RTL if-conversion tries to remove conditional branches around a block and | |
14859 | replace them with conditionally executed instructions. This parameter | |
14860 | gives the maximum number of instructions in a block which should be | |
14861 | considered for if-conversion. The compiler will | |
14862 | also use other heuristics to decide whether if-conversion is likely to be | |
14863 | profitable. | |
14864 | ||
14865 | @item max-rtl-if-conversion-predictable-cost | |
14866 | RTL if-conversion will try to remove conditional branches around a block | |
14867 | and replace them with conditionally executed instructions. These parameters | |
14868 | give the maximum permissible cost for the sequence that would be generated | |
14869 | by if-conversion depending on whether the branch is statically determined | |
14870 | to be predictable or not. The units for this parameter are the same as | |
14871 | those for the GCC internal seq_cost metric. The compiler will try to | |
14872 | provide a reasonable default for this parameter using the BRANCH_COST | |
14873 | target macro. | |
14874 | ||
14875 | @item max-crossjump-edges | |
14876 | The maximum number of incoming edges to consider for cross-jumping. | |
14877 | The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in | |
14878 | the number of edges incoming to each block. Increasing values mean | |
14879 | more aggressive optimization, making the compilation time increase with | |
14880 | probably small improvement in executable size. | |
14881 | ||
14882 | @item min-crossjump-insns | |
14883 | The minimum number of instructions that must be matched at the end | |
14884 | of two blocks before cross-jumping is performed on them. This | |
14885 | value is ignored in the case where all instructions in the block being | |
14886 | cross-jumped from are matched. | |
14887 | ||
14888 | @item max-grow-copy-bb-insns | |
14889 | The maximum code size expansion factor when copying basic blocks | |
14890 | instead of jumping. The expansion is relative to a jump instruction. | |
14891 | ||
14892 | @item max-goto-duplication-insns | |
14893 | The maximum number of instructions to duplicate to a block that jumps | |
14894 | to a computed goto. To avoid @math{O(N^2)} behavior in a number of | |
14895 | passes, GCC factors computed gotos early in the compilation process, | |
14896 | and unfactors them as late as possible. Only computed jumps at the | |
14897 | end of a basic blocks with no more than max-goto-duplication-insns are | |
14898 | unfactored. | |
14899 | ||
14900 | @item max-delay-slot-insn-search | |
14901 | The maximum number of instructions to consider when looking for an | |
14902 | instruction to fill a delay slot. If more than this arbitrary number of | |
14903 | instructions are searched, the time savings from filling the delay slot | |
14904 | are minimal, so stop searching. Increasing values mean more | |
14905 | aggressive optimization, making the compilation time increase with probably | |
14906 | small improvement in execution time. | |
14907 | ||
14908 | @item max-delay-slot-live-search | |
14909 | When trying to fill delay slots, the maximum number of instructions to | |
14910 | consider when searching for a block with valid live register | |
14911 | information. Increasing this arbitrarily chosen value means more | |
14912 | aggressive optimization, increasing the compilation time. This parameter | |
14913 | should be removed when the delay slot code is rewritten to maintain the | |
14914 | control-flow graph. | |
14915 | ||
14916 | @item max-gcse-memory | |
14917 | The approximate maximum amount of memory in @code{kB} that can be allocated in | |
14918 | order to perform the global common subexpression elimination | |
14919 | optimization. If more memory than specified is required, the | |
14920 | optimization is not done. | |
14921 | ||
14922 | @item max-gcse-insertion-ratio | |
14923 | If the ratio of expression insertions to deletions is larger than this value | |
14924 | for any expression, then RTL PRE inserts or removes the expression and thus | |
14925 | leaves partially redundant computations in the instruction stream. | |
14926 | ||
14927 | @item max-pending-list-length | |
14928 | The maximum number of pending dependencies scheduling allows | |
14929 | before flushing the current state and starting over. Large functions | |
14930 | with few branches or calls can create excessively large lists which | |
14931 | needlessly consume memory and resources. | |
14932 | ||
14933 | @item max-modulo-backtrack-attempts | |
14934 | The maximum number of backtrack attempts the scheduler should make | |
14935 | when modulo scheduling a loop. Larger values can exponentially increase | |
14936 | compilation time. | |
14937 | ||
14938 | @item max-inline-functions-called-once-loop-depth | |
14939 | Maximal loop depth of a call considered by inline heuristics that tries to | |
14940 | inline all functions called once. | |
14941 | ||
14942 | @item max-inline-functions-called-once-insns | |
14943 | Maximal estimated size of functions produced while inlining functions called | |
14944 | once. | |
14945 | ||
14946 | @item max-inline-insns-single | |
14947 | Several parameters control the tree inliner used in GCC@. This number sets the | |
14948 | maximum number of instructions (counted in GCC's internal representation) in a | |
14949 | single function that the tree inliner considers for inlining. This only | |
14950 | affects functions declared inline and methods implemented in a class | |
14951 | declaration (C++). | |
14952 | ||
14953 | ||
14954 | @item max-inline-insns-auto | |
14955 | When you use @option{-finline-functions} (included in @option{-O3}), | |
14956 | a lot of functions that would otherwise not be considered for inlining | |
14957 | by the compiler are investigated. To those functions, a different | |
14958 | (more restrictive) limit compared to functions declared inline can | |
14959 | be applied (@option{--param max-inline-insns-auto}). | |
14960 | ||
14961 | @item max-inline-insns-small | |
14962 | This is bound applied to calls which are considered relevant with | |
14963 | @option{-finline-small-functions}. | |
14964 | ||
14965 | @item max-inline-insns-size | |
14966 | This is bound applied to calls which are optimized for size. Small growth | |
14967 | may be desirable to anticipate optimization oppurtunities exposed by inlining. | |
14968 | ||
14969 | @item uninlined-function-insns | |
14970 | Number of instructions accounted by inliner for function overhead such as | |
14971 | function prologue and epilogue. | |
14972 | ||
14973 | @item uninlined-function-time | |
14974 | Extra time accounted by inliner for function overhead such as time needed to | |
14975 | execute function prologue and epilogue. | |
14976 | ||
14977 | @item inline-heuristics-hint-percent | |
14978 | The scale (in percents) applied to @option{inline-insns-single}, | |
14979 | @option{inline-insns-single-O2}, @option{inline-insns-auto} | |
14980 | when inline heuristics hints that inlining is | |
14981 | very profitable (will enable later optimizations). | |
14982 | ||
14983 | @item uninlined-thunk-insns | |
14984 | @item uninlined-thunk-time | |
14985 | Same as @option{--param uninlined-function-insns} and | |
14986 | @option{--param uninlined-function-time} but applied to function thunks. | |
14987 | ||
14988 | @item inline-min-speedup | |
14989 | When estimated performance improvement of caller + callee runtime exceeds this | |
14990 | threshold (in percent), the function can be inlined regardless of the limit on | |
14991 | @option{--param max-inline-insns-single} and @option{--param | |
14992 | max-inline-insns-auto}. | |
14993 | ||
14994 | @item large-function-insns | |
14995 | The limit specifying really large functions. For functions larger than this | |
14996 | limit after inlining, inlining is constrained by | |
14997 | @option{--param large-function-growth}. This parameter is useful primarily | |
14998 | to avoid extreme compilation time caused by non-linear algorithms used by the | |
14999 | back end. | |
15000 | ||
15001 | @item large-function-growth | |
15002 | Specifies maximal growth of large function caused by inlining in percents. | |
15003 | For example, parameter value 100 limits large function growth to 2.0 times | |
15004 | the original size. | |
15005 | ||
15006 | @item large-unit-insns | |
15007 | The limit specifying large translation unit. Growth caused by inlining of | |
15008 | units larger than this limit is limited by @option{--param inline-unit-growth}. | |
15009 | For small units this might be too tight. | |
15010 | For example, consider a unit consisting of function A | |
15011 | that is inline and B that just calls A three times. If B is small relative to | |
15012 | A, the growth of unit is 300\% and yet such inlining is very sane. For very | |
15013 | large units consisting of small inlineable functions, however, the overall unit | |
15014 | growth limit is needed to avoid exponential explosion of code size. Thus for | |
15015 | smaller units, the size is increased to @option{--param large-unit-insns} | |
15016 | before applying @option{--param inline-unit-growth}. | |
15017 | ||
15018 | @item lazy-modules | |
15019 | Maximum number of concurrently open C++ module files when lazy loading. | |
15020 | ||
15021 | @item inline-unit-growth | |
15022 | Specifies maximal overall growth of the compilation unit caused by inlining. | |
15023 | For example, parameter value 20 limits unit growth to 1.2 times the original | |
15024 | size. Cold functions (either marked cold via an attribute or by profile | |
15025 | feedback) are not accounted into the unit size. | |
15026 | ||
15027 | @item ipa-cp-unit-growth | |
15028 | Specifies maximal overall growth of the compilation unit caused by | |
15029 | interprocedural constant propagation. For example, parameter value 10 limits | |
15030 | unit growth to 1.1 times the original size. | |
15031 | ||
15032 | @item ipa-cp-large-unit-insns | |
15033 | The size of translation unit that IPA-CP pass considers large. | |
15034 | ||
15035 | @item large-stack-frame | |
15036 | The limit specifying large stack frames. While inlining the algorithm is trying | |
15037 | to not grow past this limit too much. | |
15038 | ||
15039 | @item large-stack-frame-growth | |
15040 | Specifies maximal growth of large stack frames caused by inlining in percents. | |
15041 | For example, parameter value 1000 limits large stack frame growth to 11 times | |
15042 | the original size. | |
15043 | ||
15044 | @item max-inline-insns-recursive | |
15045 | @itemx max-inline-insns-recursive-auto | |
15046 | Specifies the maximum number of instructions an out-of-line copy of a | |
15047 | self-recursive inline | |
15048 | function can grow into by performing recursive inlining. | |
15049 | ||
15050 | @option{--param max-inline-insns-recursive} applies to functions | |
15051 | declared inline. | |
15052 | For functions not declared inline, recursive inlining | |
15053 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15054 | enabled; @option{--param max-inline-insns-recursive-auto} applies instead. | |
15055 | ||
15056 | @item max-inline-recursive-depth | |
15057 | @itemx max-inline-recursive-depth-auto | |
15058 | Specifies the maximum recursion depth used for recursive inlining. | |
15059 | ||
15060 | @option{--param max-inline-recursive-depth} applies to functions | |
15061 | declared inline. For functions not declared inline, recursive inlining | |
15062 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15063 | enabled; @option{--param max-inline-recursive-depth-auto} applies instead. | |
15064 | ||
15065 | @item min-inline-recursive-probability | |
15066 | Recursive inlining is profitable only for function having deep recursion | |
15067 | in average and can hurt for function having little recursion depth by | |
15068 | increasing the prologue size or complexity of function body to other | |
15069 | optimizers. | |
15070 | ||
15071 | When profile feedback is available (see @option{-fprofile-generate}) the actual | |
15072 | recursion depth can be guessed from the probability that function recurses | |
15073 | via a given call expression. This parameter limits inlining only to call | |
15074 | expressions whose probability exceeds the given threshold (in percents). | |
15075 | ||
15076 | @item early-inlining-insns | |
15077 | Specify growth that the early inliner can make. In effect it increases | |
15078 | the amount of inlining for code having a large abstraction penalty. | |
15079 | ||
15080 | @item max-early-inliner-iterations | |
15081 | Limit of iterations of the early inliner. This basically bounds | |
15082 | the number of nested indirect calls the early inliner can resolve. | |
15083 | Deeper chains are still handled by late inlining. | |
15084 | ||
15085 | @item comdat-sharing-probability | |
15086 | Probability (in percent) that C++ inline function with comdat visibility | |
15087 | are shared across multiple compilation units. | |
15088 | ||
15089 | @item modref-max-bases | |
15090 | @item modref-max-refs | |
15091 | @item modref-max-accesses | |
15092 | Specifies the maximal number of base pointers, references and accesses stored | |
15093 | for a single function by mod/ref analysis. | |
15094 | ||
15095 | @item modref-max-tests | |
15096 | Specifies the maxmal number of tests alias oracle can perform to disambiguate | |
15097 | memory locations using the mod/ref information. This parameter ought to be | |
15098 | bigger than @option{--param modref-max-bases} and @option{--param | |
15099 | modref-max-refs}. | |
15100 | ||
15101 | @item modref-max-depth | |
15102 | Specifies the maximum depth of DFS walk used by modref escape analysis. | |
15103 | Setting to 0 disables the analysis completely. | |
15104 | ||
15105 | @item modref-max-escape-points | |
15106 | Specifies the maximum number of escape points tracked by modref per SSA-name. | |
15107 | ||
15108 | @item modref-max-adjustments | |
15109 | Specifies the maximum number the access range is enlarged during modref dataflow | |
15110 | analysis. | |
15111 | ||
15112 | @item profile-func-internal-id | |
15113 | A parameter to control whether to use function internal id in profile | |
15114 | database lookup. If the value is 0, the compiler uses an id that | |
15115 | is based on function assembler name and filename, which makes old profile | |
15116 | data more tolerant to source changes such as function reordering etc. | |
15117 | ||
15118 | @item min-vect-loop-bound | |
15119 | The minimum number of iterations under which loops are not vectorized | |
15120 | when @option{-ftree-vectorize} is used. The number of iterations after | |
15121 | vectorization needs to be greater than the value specified by this option | |
15122 | to allow vectorization. | |
15123 | ||
15124 | @item gcse-cost-distance-ratio | |
15125 | Scaling factor in calculation of maximum distance an expression | |
15126 | can be moved by GCSE optimizations. This is currently supported only in the | |
15127 | code hoisting pass. The bigger the ratio, the more aggressive code hoisting | |
15128 | is with simple expressions, i.e., the expressions that have cost | |
15129 | less than @option{gcse-unrestricted-cost}. Specifying 0 disables | |
15130 | hoisting of simple expressions. | |
15131 | ||
15132 | @item gcse-unrestricted-cost | |
15133 | Cost, roughly measured as the cost of a single typical machine | |
15134 | instruction, at which GCSE optimizations do not constrain | |
15135 | the distance an expression can travel. This is currently | |
15136 | supported only in the code hoisting pass. The lesser the cost, | |
15137 | the more aggressive code hoisting is. Specifying 0 | |
15138 | allows all expressions to travel unrestricted distances. | |
15139 | ||
15140 | @item max-hoist-depth | |
15141 | The depth of search in the dominator tree for expressions to hoist. | |
15142 | This is used to avoid quadratic behavior in hoisting algorithm. | |
15143 | The value of 0 does not limit on the search, but may slow down compilation | |
15144 | of huge functions. | |
15145 | ||
15146 | @item max-tail-merge-comparisons | |
15147 | The maximum amount of similar bbs to compare a bb with. This is used to | |
15148 | avoid quadratic behavior in tree tail merging. | |
15149 | ||
15150 | @item max-tail-merge-iterations | |
15151 | The maximum amount of iterations of the pass over the function. This is used to | |
15152 | limit compilation time in tree tail merging. | |
15153 | ||
15154 | @item store-merging-allow-unaligned | |
15155 | Allow the store merging pass to introduce unaligned stores if it is legal to | |
15156 | do so. | |
15157 | ||
15158 | @item max-stores-to-merge | |
15159 | The maximum number of stores to attempt to merge into wider stores in the store | |
15160 | merging pass. | |
15161 | ||
15162 | @item max-store-chains-to-track | |
15163 | The maximum number of store chains to track at the same time in the attempt | |
15164 | to merge them into wider stores in the store merging pass. | |
15165 | ||
15166 | @item max-stores-to-track | |
15167 | The maximum number of stores to track at the same time in the attemt to | |
15168 | to merge them into wider stores in the store merging pass. | |
15169 | ||
15170 | @item max-unrolled-insns | |
15171 | The maximum number of instructions that a loop may have to be unrolled. | |
15172 | If a loop is unrolled, this parameter also determines how many times | |
15173 | the loop code is unrolled. | |
15174 | ||
15175 | @item max-average-unrolled-insns | |
15176 | The maximum number of instructions biased by probabilities of their execution | |
15177 | that a loop may have to be unrolled. If a loop is unrolled, | |
15178 | this parameter also determines how many times the loop code is unrolled. | |
15179 | ||
15180 | @item max-unroll-times | |
15181 | The maximum number of unrollings of a single loop. | |
15182 | ||
15183 | @item max-peeled-insns | |
15184 | The maximum number of instructions that a loop may have to be peeled. | |
15185 | If a loop is peeled, this parameter also determines how many times | |
15186 | the loop code is peeled. | |
15187 | ||
15188 | @item max-peel-times | |
15189 | The maximum number of peelings of a single loop. | |
15190 | ||
15191 | @item max-peel-branches | |
15192 | The maximum number of branches on the hot path through the peeled sequence. | |
15193 | ||
15194 | @item max-completely-peeled-insns | |
15195 | The maximum number of insns of a completely peeled loop. | |
15196 | ||
15197 | @item max-completely-peel-times | |
15198 | The maximum number of iterations of a loop to be suitable for complete peeling. | |
15199 | ||
15200 | @item max-completely-peel-loop-nest-depth | |
15201 | The maximum depth of a loop nest suitable for complete peeling. | |
15202 | ||
15203 | @item max-unswitch-insns | |
15204 | The maximum number of insns of an unswitched loop. | |
15205 | ||
5b50850c RB |
15206 | @item max-unswitch-depth |
15207 | The maximum depth of a loop nest to be unswitched. | |
15208 | ||
d77de738 ML |
15209 | @item lim-expensive |
15210 | The minimum cost of an expensive expression in the loop invariant motion. | |
15211 | ||
15212 | @item min-loop-cond-split-prob | |
15213 | When FDO profile information is available, @option{min-loop-cond-split-prob} | |
15214 | specifies minimum threshold for probability of semi-invariant condition | |
15215 | statement to trigger loop split. | |
15216 | ||
15217 | @item iv-consider-all-candidates-bound | |
15218 | Bound on number of candidates for induction variables, below which | |
15219 | all candidates are considered for each use in induction variable | |
15220 | optimizations. If there are more candidates than this, | |
15221 | only the most relevant ones are considered to avoid quadratic time complexity. | |
15222 | ||
15223 | @item iv-max-considered-uses | |
15224 | The induction variable optimizations give up on loops that contain more | |
15225 | induction variable uses. | |
15226 | ||
15227 | @item iv-always-prune-cand-set-bound | |
15228 | If the number of candidates in the set is smaller than this value, | |
15229 | always try to remove unnecessary ivs from the set | |
15230 | when adding a new one. | |
15231 | ||
15232 | @item avg-loop-niter | |
15233 | Average number of iterations of a loop. | |
15234 | ||
15235 | @item dse-max-object-size | |
15236 | Maximum size (in bytes) of objects tracked bytewise by dead store elimination. | |
15237 | Larger values may result in larger compilation times. | |
15238 | ||
15239 | @item dse-max-alias-queries-per-store | |
15240 | Maximum number of queries into the alias oracle per store. | |
15241 | Larger values result in larger compilation times and may result in more | |
15242 | removed dead stores. | |
15243 | ||
15244 | @item scev-max-expr-size | |
15245 | Bound on size of expressions used in the scalar evolutions analyzer. | |
15246 | Large expressions slow the analyzer. | |
15247 | ||
15248 | @item scev-max-expr-complexity | |
15249 | Bound on the complexity of the expressions in the scalar evolutions analyzer. | |
15250 | Complex expressions slow the analyzer. | |
15251 | ||
15252 | @item max-tree-if-conversion-phi-args | |
15253 | Maximum number of arguments in a PHI supported by TREE if conversion | |
15254 | unless the loop is marked with simd pragma. | |
15255 | ||
15256 | @item vect-max-layout-candidates | |
15257 | The maximum number of possible vector layouts (such as permutations) | |
15258 | to consider when optimizing to-be-vectorized code. | |
15259 | ||
15260 | @item vect-max-version-for-alignment-checks | |
15261 | The maximum number of run-time checks that can be performed when | |
15262 | doing loop versioning for alignment in the vectorizer. | |
15263 | ||
15264 | @item vect-max-version-for-alias-checks | |
15265 | The maximum number of run-time checks that can be performed when | |
15266 | doing loop versioning for alias in the vectorizer. | |
15267 | ||
15268 | @item vect-max-peeling-for-alignment | |
15269 | The maximum number of loop peels to enhance access alignment | |
15270 | for vectorizer. Value -1 means no limit. | |
15271 | ||
15272 | @item max-iterations-to-track | |
15273 | The maximum number of iterations of a loop the brute-force algorithm | |
15274 | for analysis of the number of iterations of the loop tries to evaluate. | |
15275 | ||
15276 | @item hot-bb-count-fraction | |
15277 | The denominator n of fraction 1/n of the maximal execution count of a | |
15278 | basic block in the entire program that a basic block needs to at least | |
15279 | have in order to be considered hot. The default is 10000, which means | |
15280 | that a basic block is considered hot if its execution count is greater | |
15281 | than 1/10000 of the maximal execution count. 0 means that it is never | |
15282 | considered hot. Used in non-LTO mode. | |
15283 | ||
15284 | @item hot-bb-count-ws-permille | |
15285 | The number of most executed permilles, ranging from 0 to 1000, of the | |
15286 | profiled execution of the entire program to which the execution count | |
15287 | of a basic block must be part of in order to be considered hot. The | |
15288 | default is 990, which means that a basic block is considered hot if | |
15289 | its execution count contributes to the upper 990 permilles, or 99.0%, | |
15290 | of the profiled execution of the entire program. 0 means that it is | |
15291 | never considered hot. Used in LTO mode. | |
15292 | ||
15293 | @item hot-bb-frequency-fraction | |
15294 | The denominator n of fraction 1/n of the execution frequency of the | |
15295 | entry block of a function that a basic block of this function needs | |
15296 | to at least have in order to be considered hot. The default is 1000, | |
15297 | which means that a basic block is considered hot in a function if it | |
15298 | is executed more frequently than 1/1000 of the frequency of the entry | |
15299 | block of the function. 0 means that it is never considered hot. | |
15300 | ||
15301 | @item unlikely-bb-count-fraction | |
15302 | The denominator n of fraction 1/n of the number of profiled runs of | |
15303 | the entire program below which the execution count of a basic block | |
15304 | must be in order for the basic block to be considered unlikely executed. | |
15305 | The default is 20, which means that a basic block is considered unlikely | |
15306 | executed if it is executed in fewer than 1/20, or 5%, of the runs of | |
15307 | the program. 0 means that it is always considered unlikely executed. | |
15308 | ||
15309 | @item max-predicted-iterations | |
15310 | The maximum number of loop iterations we predict statically. This is useful | |
15311 | in cases where a function contains a single loop with known bound and | |
15312 | another loop with unknown bound. | |
15313 | The known number of iterations is predicted correctly, while | |
15314 | the unknown number of iterations average to roughly 10. This means that the | |
15315 | loop without bounds appears artificially cold relative to the other one. | |
15316 | ||
15317 | @item builtin-expect-probability | |
15318 | Control the probability of the expression having the specified value. This | |
15319 | parameter takes a percentage (i.e.@: 0 ... 100) as input. | |
15320 | ||
15321 | @item builtin-string-cmp-inline-length | |
15322 | The maximum length of a constant string for a builtin string cmp call | |
15323 | eligible for inlining. | |
15324 | ||
15325 | @item align-threshold | |
15326 | ||
15327 | Select fraction of the maximal frequency of executions of a basic block in | |
15328 | a function to align the basic block. | |
15329 | ||
15330 | @item align-loop-iterations | |
15331 | ||
15332 | A loop expected to iterate at least the selected number of iterations is | |
15333 | aligned. | |
15334 | ||
15335 | @item tracer-dynamic-coverage | |
15336 | @itemx tracer-dynamic-coverage-feedback | |
15337 | ||
15338 | This value is used to limit superblock formation once the given percentage of | |
15339 | executed instructions is covered. This limits unnecessary code size | |
15340 | expansion. | |
15341 | ||
15342 | The @option{tracer-dynamic-coverage-feedback} parameter | |
15343 | is used only when profile | |
15344 | feedback is available. The real profiles (as opposed to statically estimated | |
15345 | ones) are much less balanced allowing the threshold to be larger value. | |
15346 | ||
15347 | @item tracer-max-code-growth | |
15348 | Stop tail duplication once code growth has reached given percentage. This is | |
15349 | a rather artificial limit, as most of the duplicates are eliminated later in | |
15350 | cross jumping, so it may be set to much higher values than is the desired code | |
15351 | growth. | |
15352 | ||
15353 | @item tracer-min-branch-ratio | |
15354 | ||
15355 | Stop reverse growth when the reverse probability of best edge is less than this | |
15356 | threshold (in percent). | |
15357 | ||
15358 | @item tracer-min-branch-probability | |
15359 | @itemx tracer-min-branch-probability-feedback | |
15360 | ||
15361 | Stop forward growth if the best edge has probability lower than this | |
15362 | threshold. | |
15363 | ||
15364 | Similarly to @option{tracer-dynamic-coverage} two parameters are | |
15365 | provided. @option{tracer-min-branch-probability-feedback} is used for | |
15366 | compilation with profile feedback and @option{tracer-min-branch-probability} | |
15367 | compilation without. The value for compilation with profile feedback | |
15368 | needs to be more conservative (higher) in order to make tracer | |
15369 | effective. | |
15370 | ||
15371 | @item stack-clash-protection-guard-size | |
15372 | Specify the size of the operating system provided stack guard as | |
15373 | 2 raised to @var{num} bytes. Higher values may reduce the | |
15374 | number of explicit probes, but a value larger than the operating system | |
15375 | provided guard will leave code vulnerable to stack clash style attacks. | |
15376 | ||
15377 | @item stack-clash-protection-probe-interval | |
15378 | Stack clash protection involves probing stack space as it is allocated. This | |
15379 | param controls the maximum distance between probes into the stack as 2 raised | |
15380 | to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value | |
15381 | larger than the operating system provided guard will leave code vulnerable to | |
15382 | stack clash style attacks. | |
15383 | ||
15384 | @item max-cse-path-length | |
15385 | ||
15386 | The maximum number of basic blocks on path that CSE considers. | |
15387 | ||
15388 | @item max-cse-insns | |
15389 | The maximum number of instructions CSE processes before flushing. | |
15390 | ||
15391 | @item ggc-min-expand | |
15392 | ||
15393 | GCC uses a garbage collector to manage its own memory allocation. This | |
15394 | parameter specifies the minimum percentage by which the garbage | |
15395 | collector's heap should be allowed to expand between collections. | |
15396 | Tuning this may improve compilation speed; it has no effect on code | |
15397 | generation. | |
15398 | ||
15399 | The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when | |
15400 | RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is | |
15401 | the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If | |
15402 | GCC is not able to calculate RAM on a particular platform, the lower | |
15403 | bound of 30% is used. Setting this parameter and | |
15404 | @option{ggc-min-heapsize} to zero causes a full collection to occur at | |
15405 | every opportunity. This is extremely slow, but can be useful for | |
15406 | debugging. | |
15407 | ||
15408 | @item ggc-min-heapsize | |
15409 | ||
15410 | Minimum size of the garbage collector's heap before it begins bothering | |
15411 | to collect garbage. The first collection occurs after the heap expands | |
15412 | by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, | |
15413 | tuning this may improve compilation speed, and has no effect on code | |
15414 | generation. | |
15415 | ||
15416 | The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that | |
15417 | tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but | |
15418 | with a lower bound of 4096 (four megabytes) and an upper bound of | |
15419 | 131072 (128 megabytes). If GCC is not able to calculate RAM on a | |
15420 | particular platform, the lower bound is used. Setting this parameter | |
15421 | very large effectively disables garbage collection. Setting this | |
15422 | parameter and @option{ggc-min-expand} to zero causes a full collection | |
15423 | to occur at every opportunity. | |
15424 | ||
15425 | @item max-reload-search-insns | |
15426 | The maximum number of instruction reload should look backward for equivalent | |
15427 | register. Increasing values mean more aggressive optimization, making the | |
15428 | compilation time increase with probably slightly better performance. | |
15429 | ||
15430 | @item max-cselib-memory-locations | |
15431 | The maximum number of memory locations cselib should take into account. | |
15432 | Increasing values mean more aggressive optimization, making the compilation time | |
15433 | increase with probably slightly better performance. | |
15434 | ||
15435 | @item max-sched-ready-insns | |
15436 | The maximum number of instructions ready to be issued the scheduler should | |
15437 | consider at any given time during the first scheduling pass. Increasing | |
15438 | values mean more thorough searches, making the compilation time increase | |
15439 | with probably little benefit. | |
15440 | ||
15441 | @item max-sched-region-blocks | |
15442 | The maximum number of blocks in a region to be considered for | |
15443 | interblock scheduling. | |
15444 | ||
15445 | @item max-pipeline-region-blocks | |
15446 | The maximum number of blocks in a region to be considered for | |
15447 | pipelining in the selective scheduler. | |
15448 | ||
15449 | @item max-sched-region-insns | |
15450 | The maximum number of insns in a region to be considered for | |
15451 | interblock scheduling. | |
15452 | ||
15453 | @item max-pipeline-region-insns | |
15454 | The maximum number of insns in a region to be considered for | |
15455 | pipelining in the selective scheduler. | |
15456 | ||
15457 | @item min-spec-prob | |
15458 | The minimum probability (in percents) of reaching a source block | |
15459 | for interblock speculative scheduling. | |
15460 | ||
15461 | @item max-sched-extend-regions-iters | |
15462 | The maximum number of iterations through CFG to extend regions. | |
15463 | A value of 0 disables region extensions. | |
15464 | ||
15465 | @item max-sched-insn-conflict-delay | |
15466 | The maximum conflict delay for an insn to be considered for speculative motion. | |
15467 | ||
15468 | @item sched-spec-prob-cutoff | |
15469 | The minimal probability of speculation success (in percents), so that | |
15470 | speculative insns are scheduled. | |
15471 | ||
15472 | @item sched-state-edge-prob-cutoff | |
15473 | The minimum probability an edge must have for the scheduler to save its | |
15474 | state across it. | |
15475 | ||
15476 | @item sched-mem-true-dep-cost | |
15477 | Minimal distance (in CPU cycles) between store and load targeting same | |
15478 | memory locations. | |
15479 | ||
15480 | @item selsched-max-lookahead | |
15481 | The maximum size of the lookahead window of selective scheduling. It is a | |
15482 | depth of search for available instructions. | |
15483 | ||
15484 | @item selsched-max-sched-times | |
15485 | The maximum number of times that an instruction is scheduled during | |
15486 | selective scheduling. This is the limit on the number of iterations | |
15487 | through which the instruction may be pipelined. | |
15488 | ||
15489 | @item selsched-insns-to-rename | |
15490 | The maximum number of best instructions in the ready list that are considered | |
15491 | for renaming in the selective scheduler. | |
15492 | ||
15493 | @item sms-min-sc | |
15494 | The minimum value of stage count that swing modulo scheduler | |
15495 | generates. | |
15496 | ||
15497 | @item max-last-value-rtl | |
15498 | The maximum size measured as number of RTLs that can be recorded in an expression | |
15499 | in combiner for a pseudo register as last known value of that register. | |
15500 | ||
15501 | @item max-combine-insns | |
15502 | The maximum number of instructions the RTL combiner tries to combine. | |
15503 | ||
15504 | @item integer-share-limit | |
15505 | Small integer constants can use a shared data structure, reducing the | |
15506 | compiler's memory usage and increasing its speed. This sets the maximum | |
15507 | value of a shared integer constant. | |
15508 | ||
15509 | @item ssp-buffer-size | |
15510 | The minimum size of buffers (i.e.@: arrays) that receive stack smashing | |
15511 | protection when @option{-fstack-protector} is used. | |
15512 | ||
15513 | @item min-size-for-stack-sharing | |
15514 | The minimum size of variables taking part in stack slot sharing when not | |
15515 | optimizing. | |
15516 | ||
15517 | @item max-jump-thread-duplication-stmts | |
15518 | Maximum number of statements allowed in a block that needs to be | |
15519 | duplicated when threading jumps. | |
15520 | ||
15521 | @item max-jump-thread-paths | |
15522 | The maximum number of paths to consider when searching for jump threading | |
15523 | opportunities. When arriving at a block, incoming edges are only considered | |
15524 | if the number of paths to be searched so far multiplied by the number of | |
15525 | incoming edges does not exhaust the specified maximum number of paths to | |
15526 | consider. | |
15527 | ||
15528 | @item max-fields-for-field-sensitive | |
15529 | Maximum number of fields in a structure treated in | |
15530 | a field sensitive manner during pointer analysis. | |
15531 | ||
15532 | @item prefetch-latency | |
15533 | Estimate on average number of instructions that are executed before | |
15534 | prefetch finishes. The distance prefetched ahead is proportional | |
15535 | to this constant. Increasing this number may also lead to less | |
15536 | streams being prefetched (see @option{simultaneous-prefetches}). | |
15537 | ||
15538 | @item simultaneous-prefetches | |
15539 | Maximum number of prefetches that can run at the same time. | |
15540 | ||
15541 | @item l1-cache-line-size | |
15542 | The size of cache line in L1 data cache, in bytes. | |
15543 | ||
15544 | @item l1-cache-size | |
15545 | The size of L1 data cache, in kilobytes. | |
15546 | ||
15547 | @item l2-cache-size | |
15548 | The size of L2 data cache, in kilobytes. | |
15549 | ||
15550 | @item prefetch-dynamic-strides | |
15551 | Whether the loop array prefetch pass should issue software prefetch hints | |
15552 | for strides that are non-constant. In some cases this may be | |
15553 | beneficial, though the fact the stride is non-constant may make it | |
15554 | hard to predict when there is clear benefit to issuing these hints. | |
15555 | ||
15556 | Set to 1 if the prefetch hints should be issued for non-constant | |
15557 | strides. Set to 0 if prefetch hints should be issued only for strides that | |
15558 | are known to be constant and below @option{prefetch-minimum-stride}. | |
15559 | ||
15560 | @item prefetch-minimum-stride | |
15561 | Minimum constant stride, in bytes, to start using prefetch hints for. If | |
15562 | the stride is less than this threshold, prefetch hints will not be issued. | |
15563 | ||
15564 | This setting is useful for processors that have hardware prefetchers, in | |
15565 | which case there may be conflicts between the hardware prefetchers and | |
15566 | the software prefetchers. If the hardware prefetchers have a maximum | |
15567 | stride they can handle, it should be used here to improve the use of | |
15568 | software prefetchers. | |
15569 | ||
15570 | A value of -1 means we don't have a threshold and therefore | |
15571 | prefetch hints can be issued for any constant stride. | |
15572 | ||
15573 | This setting is only useful for strides that are known and constant. | |
15574 | ||
15575 | @item destructive-interference-size | |
15576 | @item constructive-interference-size | |
15577 | The values for the C++17 variables | |
15578 | @code{std::hardware_destructive_interference_size} and | |
15579 | @code{std::hardware_constructive_interference_size}. The destructive | |
15580 | interference size is the minimum recommended offset between two | |
15581 | independent concurrently-accessed objects; the constructive | |
15582 | interference size is the maximum recommended size of contiguous memory | |
15583 | accessed together. Typically both will be the size of an L1 cache | |
15584 | line for the target, in bytes. For a generic target covering a range of L1 | |
15585 | cache line sizes, typically the constructive interference size will be | |
15586 | the small end of the range and the destructive size will be the large | |
15587 | end. | |
15588 | ||
15589 | The destructive interference size is intended to be used for layout, | |
15590 | and thus has ABI impact. The default value is not expected to be | |
15591 | stable, and on some targets varies with @option{-mtune}, so use of | |
15592 | this variable in a context where ABI stability is important, such as | |
15593 | the public interface of a library, is strongly discouraged; if it is | |
15594 | used in that context, users can stabilize the value using this | |
15595 | option. | |
15596 | ||
15597 | The constructive interference size is less sensitive, as it is | |
15598 | typically only used in a @samp{static_assert} to make sure that a type | |
15599 | fits within a cache line. | |
15600 | ||
15601 | See also @option{-Winterference-size}. | |
15602 | ||
15603 | @item loop-interchange-max-num-stmts | |
15604 | The maximum number of stmts in a loop to be interchanged. | |
15605 | ||
15606 | @item loop-interchange-stride-ratio | |
15607 | The minimum ratio between stride of two loops for interchange to be profitable. | |
15608 | ||
15609 | @item min-insn-to-prefetch-ratio | |
15610 | The minimum ratio between the number of instructions and the | |
15611 | number of prefetches to enable prefetching in a loop. | |
15612 | ||
15613 | @item prefetch-min-insn-to-mem-ratio | |
15614 | The minimum ratio between the number of instructions and the | |
15615 | number of memory references to enable prefetching in a loop. | |
15616 | ||
15617 | @item use-canonical-types | |
15618 | Whether the compiler should use the ``canonical'' type system. | |
15619 | Should always be 1, which uses a more efficient internal | |
15620 | mechanism for comparing types in C++ and Objective-C++. However, if | |
15621 | bugs in the canonical type system are causing compilation failures, | |
15622 | set this value to 0 to disable canonical types. | |
15623 | ||
15624 | @item switch-conversion-max-branch-ratio | |
15625 | Switch initialization conversion refuses to create arrays that are | |
15626 | bigger than @option{switch-conversion-max-branch-ratio} times the number of | |
15627 | branches in the switch. | |
15628 | ||
15629 | @item max-partial-antic-length | |
15630 | Maximum length of the partial antic set computed during the tree | |
15631 | partial redundancy elimination optimization (@option{-ftree-pre}) when | |
15632 | optimizing at @option{-O3} and above. For some sorts of source code | |
15633 | the enhanced partial redundancy elimination optimization can run away, | |
15634 | consuming all of the memory available on the host machine. This | |
15635 | parameter sets a limit on the length of the sets that are computed, | |
15636 | which prevents the runaway behavior. Setting a value of 0 for | |
15637 | this parameter allows an unlimited set length. | |
15638 | ||
15639 | @item rpo-vn-max-loop-depth | |
15640 | Maximum loop depth that is value-numbered optimistically. | |
15641 | When the limit hits the innermost | |
15642 | @var{rpo-vn-max-loop-depth} loops and the outermost loop in the | |
15643 | loop nest are value-numbered optimistically and the remaining ones not. | |
15644 | ||
15645 | @item sccvn-max-alias-queries-per-access | |
15646 | Maximum number of alias-oracle queries we perform when looking for | |
15647 | redundancies for loads and stores. If this limit is hit the search | |
15648 | is aborted and the load or store is not considered redundant. The | |
15649 | number of queries is algorithmically limited to the number of | |
15650 | stores on all paths from the load to the function entry. | |
15651 | ||
15652 | @item ira-max-loops-num | |
15653 | IRA uses regional register allocation by default. If a function | |
15654 | contains more loops than the number given by this parameter, only at most | |
15655 | the given number of the most frequently-executed loops form regions | |
15656 | for regional register allocation. | |
15657 | ||
15658 | @item ira-max-conflict-table-size | |
15659 | Although IRA uses a sophisticated algorithm to compress the conflict | |
15660 | table, the table can still require excessive amounts of memory for | |
15661 | huge functions. If the conflict table for a function could be more | |
15662 | than the size in MB given by this parameter, the register allocator | |
15663 | instead uses a faster, simpler, and lower-quality | |
15664 | algorithm that does not require building a pseudo-register conflict table. | |
15665 | ||
15666 | @item ira-loop-reserved-regs | |
15667 | IRA can be used to evaluate more accurate register pressure in loops | |
15668 | for decisions to move loop invariants (see @option{-O3}). The number | |
15669 | of available registers reserved for some other purposes is given | |
15670 | by this parameter. Default of the parameter | |
15671 | is the best found from numerous experiments. | |
15672 | ||
15673 | @item ira-consider-dup-in-all-alts | |
15674 | Make IRA to consider matching constraint (duplicated operand number) | |
15675 | heavily in all available alternatives for preferred register class. | |
15676 | If it is set as zero, it means IRA only respects the matching | |
15677 | constraint when it's in the only available alternative with an | |
15678 | appropriate register class. Otherwise, it means IRA will check all | |
15679 | available alternatives for preferred register class even if it has | |
15680 | found some choice with an appropriate register class and respect the | |
15681 | found qualified matching constraint. | |
15682 | ||
9847c753 ML |
15683 | @item ira-simple-lra-insn-threshold |
15684 | Approximate function insn number in 1K units triggering simple local RA. | |
15685 | ||
d77de738 ML |
15686 | @item lra-inheritance-ebb-probability-cutoff |
15687 | LRA tries to reuse values reloaded in registers in subsequent insns. | |
15688 | This optimization is called inheritance. EBB is used as a region to | |
15689 | do this optimization. The parameter defines a minimal fall-through | |
15690 | edge probability in percentage used to add BB to inheritance EBB in | |
15691 | LRA. The default value was chosen | |
15692 | from numerous runs of SPEC2000 on x86-64. | |
15693 | ||
15694 | @item loop-invariant-max-bbs-in-loop | |
15695 | Loop invariant motion can be very expensive, both in compilation time and | |
15696 | in amount of needed compile-time memory, with very large loops. Loops | |
15697 | with more basic blocks than this parameter won't have loop invariant | |
15698 | motion optimization performed on them. | |
15699 | ||
15700 | @item loop-max-datarefs-for-datadeps | |
15701 | Building data dependencies is expensive for very large loops. This | |
15702 | parameter limits the number of data references in loops that are | |
15703 | considered for data dependence analysis. These large loops are no | |
15704 | handled by the optimizations using loop data dependencies. | |
15705 | ||
15706 | @item max-vartrack-size | |
15707 | Sets a maximum number of hash table slots to use during variable | |
15708 | tracking dataflow analysis of any function. If this limit is exceeded | |
15709 | with variable tracking at assignments enabled, analysis for that | |
15710 | function is retried without it, after removing all debug insns from | |
15711 | the function. If the limit is exceeded even without debug insns, var | |
15712 | tracking analysis is completely disabled for the function. Setting | |
15713 | the parameter to zero makes it unlimited. | |
15714 | ||
15715 | @item max-vartrack-expr-depth | |
15716 | Sets a maximum number of recursion levels when attempting to map | |
15717 | variable names or debug temporaries to value expressions. This trades | |
15718 | compilation time for more complete debug information. If this is set too | |
15719 | low, value expressions that are available and could be represented in | |
15720 | debug information may end up not being used; setting this higher may | |
15721 | enable the compiler to find more complex debug expressions, but compile | |
15722 | time and memory use may grow. | |
15723 | ||
15724 | @item max-debug-marker-count | |
15725 | Sets a threshold on the number of debug markers (e.g.@: begin stmt | |
15726 | markers) to avoid complexity explosion at inlining or expanding to RTL. | |
15727 | If a function has more such gimple stmts than the set limit, such stmts | |
15728 | will be dropped from the inlined copy of a function, and from its RTL | |
15729 | expansion. | |
15730 | ||
15731 | @item min-nondebug-insn-uid | |
15732 | Use uids starting at this parameter for nondebug insns. The range below | |
15733 | the parameter is reserved exclusively for debug insns created by | |
15734 | @option{-fvar-tracking-assignments}, but debug insns may get | |
15735 | (non-overlapping) uids above it if the reserved range is exhausted. | |
15736 | ||
10478270 MJ |
15737 | @item ipa-sra-deref-prob-threshold |
15738 | IPA-SRA replaces a pointer which is known not be NULL with one or more | |
15739 | new parameters only when the probability (in percent, relative to | |
15740 | function entry) of it being dereferenced is higher than this parameter. | |
15741 | ||
d77de738 ML |
15742 | @item ipa-sra-ptr-growth-factor |
15743 | IPA-SRA replaces a pointer to an aggregate with one or more new | |
15744 | parameters only when their cumulative size is less or equal to | |
15745 | @option{ipa-sra-ptr-growth-factor} times the size of the original | |
15746 | pointer parameter. | |
15747 | ||
69363825 ML |
15748 | @item ipa-sra-ptrwrap-growth-factor |
15749 | Additional maximum allowed growth of total size of new parameters | |
15750 | that ipa-sra replaces a pointer to an aggregate with, | |
049dccd0 MJ |
15751 | if it points to a local variable that the caller only writes to and |
15752 | passes it as an argument to other functions. | |
69363825 | 15753 | |
d77de738 ML |
15754 | @item ipa-sra-max-replacements |
15755 | Maximum pieces of an aggregate that IPA-SRA tracks. As a | |
15756 | consequence, it is also the maximum number of replacements of a formal | |
15757 | parameter. | |
15758 | ||
15759 | @item sra-max-scalarization-size-Ospeed | |
15760 | @itemx sra-max-scalarization-size-Osize | |
15761 | The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to | |
15762 | replace scalar parts of aggregates with uses of independent scalar | |
15763 | variables. These parameters control the maximum size, in storage units, | |
15764 | of aggregate which is considered for replacement when compiling for | |
15765 | speed | |
15766 | (@option{sra-max-scalarization-size-Ospeed}) or size | |
15767 | (@option{sra-max-scalarization-size-Osize}) respectively. | |
15768 | ||
15769 | @item sra-max-propagations | |
15770 | The maximum number of artificial accesses that Scalar Replacement of | |
15771 | Aggregates (SRA) will track, per one local variable, in order to | |
15772 | facilitate copy propagation. | |
15773 | ||
15774 | @item tm-max-aggregate-size | |
15775 | When making copies of thread-local variables in a transaction, this | |
15776 | parameter specifies the size in bytes after which variables are | |
15777 | saved with the logging functions as opposed to save/restore code | |
15778 | sequence pairs. This option only applies when using | |
15779 | @option{-fgnu-tm}. | |
15780 | ||
15781 | @item graphite-max-nb-scop-params | |
15782 | To avoid exponential effects in the Graphite loop transforms, the | |
15783 | number of parameters in a Static Control Part (SCoP) is bounded. | |
15784 | A value of zero can be used to lift | |
15785 | the bound. A variable whose value is unknown at compilation time and | |
15786 | defined outside a SCoP is a parameter of the SCoP. | |
15787 | ||
15788 | @item loop-block-tile-size | |
15789 | Loop blocking or strip mining transforms, enabled with | |
15790 | @option{-floop-block} or @option{-floop-strip-mine}, strip mine each | |
15791 | loop in the loop nest by a given number of iterations. The strip | |
15792 | length can be changed using the @option{loop-block-tile-size} | |
15793 | parameter. | |
15794 | ||
15795 | @item ipa-jump-function-lookups | |
15796 | Specifies number of statements visited during jump function offset discovery. | |
15797 | ||
15798 | @item ipa-cp-value-list-size | |
15799 | IPA-CP attempts to track all possible values and types passed to a function's | |
15800 | parameter in order to propagate them and perform devirtualization. | |
15801 | @option{ipa-cp-value-list-size} is the maximum number of values and types it | |
15802 | stores per one formal parameter of a function. | |
15803 | ||
15804 | @item ipa-cp-eval-threshold | |
15805 | IPA-CP calculates its own score of cloning profitability heuristics | |
15806 | and performs those cloning opportunities with scores that exceed | |
15807 | @option{ipa-cp-eval-threshold}. | |
15808 | ||
15809 | @item ipa-cp-max-recursive-depth | |
15810 | Maximum depth of recursive cloning for self-recursive function. | |
15811 | ||
15812 | @item ipa-cp-min-recursive-probability | |
15813 | Recursive cloning only when the probability of call being executed exceeds | |
15814 | the parameter. | |
15815 | ||
15816 | @item ipa-cp-profile-count-base | |
15817 | When using @option{-fprofile-use} option, IPA-CP will consider the measured | |
15818 | execution count of a call graph edge at this percentage position in their | |
15819 | histogram as the basis for its heuristics calculation. | |
15820 | ||
15821 | @item ipa-cp-recursive-freq-factor | |
15822 | The number of times interprocedural copy propagation expects recursive | |
15823 | functions to call themselves. | |
15824 | ||
15825 | @item ipa-cp-recursion-penalty | |
15826 | Percentage penalty the recursive functions will receive when they | |
15827 | are evaluated for cloning. | |
15828 | ||
15829 | @item ipa-cp-single-call-penalty | |
15830 | Percentage penalty functions containing a single call to another | |
15831 | function will receive when they are evaluated for cloning. | |
15832 | ||
15833 | @item ipa-max-agg-items | |
15834 | IPA-CP is also capable to propagate a number of scalar values passed | |
15835 | in an aggregate. @option{ipa-max-agg-items} controls the maximum | |
15836 | number of such values per one parameter. | |
15837 | ||
15838 | @item ipa-cp-loop-hint-bonus | |
15839 | When IPA-CP determines that a cloning candidate would make the number | |
15840 | of iterations of a loop known, it adds a bonus of | |
15841 | @option{ipa-cp-loop-hint-bonus} to the profitability score of | |
15842 | the candidate. | |
15843 | ||
15844 | @item ipa-max-loop-predicates | |
15845 | The maximum number of different predicates IPA will use to describe when | |
15846 | loops in a function have known properties. | |
15847 | ||
15848 | @item ipa-max-aa-steps | |
15849 | During its analysis of function bodies, IPA-CP employs alias analysis | |
15850 | in order to track values pointed to by function parameters. In order | |
15851 | not spend too much time analyzing huge functions, it gives up and | |
15852 | consider all memory clobbered after examining | |
15853 | @option{ipa-max-aa-steps} statements modifying memory. | |
15854 | ||
15855 | @item ipa-max-switch-predicate-bounds | |
15856 | Maximal number of boundary endpoints of case ranges of switch statement. | |
15857 | For switch exceeding this limit, IPA-CP will not construct cloning cost | |
15858 | predicate, which is used to estimate cloning benefit, for default case | |
15859 | of the switch statement. | |
15860 | ||
15861 | @item ipa-max-param-expr-ops | |
15862 | IPA-CP will analyze conditional statement that references some function | |
15863 | parameter to estimate benefit for cloning upon certain constant value. | |
15864 | But if number of operations in a parameter expression exceeds | |
15865 | @option{ipa-max-param-expr-ops}, the expression is treated as complicated | |
15866 | one, and is not handled by IPA analysis. | |
15867 | ||
15868 | @item lto-partitions | |
15869 | Specify desired number of partitions produced during WHOPR compilation. | |
15870 | The number of partitions should exceed the number of CPUs used for compilation. | |
15871 | ||
15872 | @item lto-min-partition | |
15873 | Size of minimal partition for WHOPR (in estimated instructions). | |
15874 | This prevents expenses of splitting very small programs into too many | |
15875 | partitions. | |
15876 | ||
15877 | @item lto-max-partition | |
15878 | Size of max partition for WHOPR (in estimated instructions). | |
15879 | to provide an upper bound for individual size of partition. | |
15880 | Meant to be used only with balanced partitioning. | |
15881 | ||
15882 | @item lto-max-streaming-parallelism | |
15883 | Maximal number of parallel processes used for LTO streaming. | |
15884 | ||
15885 | @item cxx-max-namespaces-for-diagnostic-help | |
15886 | The maximum number of namespaces to consult for suggestions when C++ | |
15887 | name lookup fails for an identifier. | |
15888 | ||
15889 | @item sink-frequency-threshold | |
15890 | The maximum relative execution frequency (in percents) of the target block | |
15891 | relative to a statement's original block to allow statement sinking of a | |
15892 | statement. Larger numbers result in more aggressive statement sinking. | |
15893 | A small positive adjustment is applied for | |
15894 | statements with memory operands as those are even more profitable so sink. | |
15895 | ||
15896 | @item max-stores-to-sink | |
15897 | The maximum number of conditional store pairs that can be sunk. Set to 0 | |
15898 | if either vectorization (@option{-ftree-vectorize}) or if-conversion | |
15899 | (@option{-ftree-loop-if-convert}) is disabled. | |
15900 | ||
15901 | @item case-values-threshold | |
15902 | The smallest number of different values for which it is best to use a | |
15903 | jump-table instead of a tree of conditional branches. If the value is | |
15904 | 0, use the default for the machine. | |
15905 | ||
15906 | @item jump-table-max-growth-ratio-for-size | |
15907 | The maximum code size growth ratio when expanding | |
15908 | into a jump table (in percent). The parameter is used when | |
15909 | optimizing for size. | |
15910 | ||
15911 | @item jump-table-max-growth-ratio-for-speed | |
15912 | The maximum code size growth ratio when expanding | |
15913 | into a jump table (in percent). The parameter is used when | |
15914 | optimizing for speed. | |
15915 | ||
15916 | @item tree-reassoc-width | |
15917 | Set the maximum number of instructions executed in parallel in | |
15918 | reassociated tree. This parameter overrides target dependent | |
15919 | heuristics used by default if has non zero value. | |
15920 | ||
15921 | @item sched-pressure-algorithm | |
15922 | Choose between the two available implementations of | |
15923 | @option{-fsched-pressure}. Algorithm 1 is the original implementation | |
15924 | and is the more likely to prevent instructions from being reordered. | |
15925 | Algorithm 2 was designed to be a compromise between the relatively | |
15926 | conservative approach taken by algorithm 1 and the rather aggressive | |
15927 | approach taken by the default scheduler. It relies more heavily on | |
15928 | having a regular register file and accurate register pressure classes. | |
15929 | See @file{haifa-sched.cc} in the GCC sources for more details. | |
15930 | ||
15931 | The default choice depends on the target. | |
15932 | ||
15933 | @item max-slsr-cand-scan | |
15934 | Set the maximum number of existing candidates that are considered when | |
15935 | seeking a basis for a new straight-line strength reduction candidate. | |
15936 | ||
15937 | @item asan-globals | |
15938 | Enable buffer overflow detection for global objects. This kind | |
15939 | of protection is enabled by default if you are using | |
15940 | @option{-fsanitize=address} option. | |
15941 | To disable global objects protection use @option{--param asan-globals=0}. | |
15942 | ||
15943 | @item asan-stack | |
15944 | Enable buffer overflow detection for stack objects. This kind of | |
15945 | protection is enabled by default when using @option{-fsanitize=address}. | |
15946 | To disable stack protection use @option{--param asan-stack=0} option. | |
15947 | ||
15948 | @item asan-instrument-reads | |
15949 | Enable buffer overflow detection for memory reads. This kind of | |
15950 | protection is enabled by default when using @option{-fsanitize=address}. | |
15951 | To disable memory reads protection use | |
15952 | @option{--param asan-instrument-reads=0}. | |
15953 | ||
15954 | @item asan-instrument-writes | |
15955 | Enable buffer overflow detection for memory writes. This kind of | |
15956 | protection is enabled by default when using @option{-fsanitize=address}. | |
15957 | To disable memory writes protection use | |
15958 | @option{--param asan-instrument-writes=0} option. | |
15959 | ||
15960 | @item asan-memintrin | |
15961 | Enable detection for built-in functions. This kind of protection | |
15962 | is enabled by default when using @option{-fsanitize=address}. | |
15963 | To disable built-in functions protection use | |
15964 | @option{--param asan-memintrin=0}. | |
15965 | ||
15966 | @item asan-use-after-return | |
15967 | Enable detection of use-after-return. This kind of protection | |
15968 | is enabled by default when using the @option{-fsanitize=address} option. | |
15969 | To disable it use @option{--param asan-use-after-return=0}. | |
15970 | ||
15971 | Note: By default the check is disabled at run time. To enable it, | |
15972 | add @code{detect_stack_use_after_return=1} to the environment variable | |
15973 | @env{ASAN_OPTIONS}. | |
15974 | ||
15975 | @item asan-instrumentation-with-call-threshold | |
15976 | If number of memory accesses in function being instrumented | |
15977 | is greater or equal to this number, use callbacks instead of inline checks. | |
15978 | E.g. to disable inline code use | |
15979 | @option{--param asan-instrumentation-with-call-threshold=0}. | |
15980 | ||
545c9f8b | 15981 | @item asan-kernel-mem-intrinsic-prefix |
f56ed5b3 SL |
15982 | If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove} |
15983 | with @samp{__asan_} or @samp{__hwasan_} | |
15984 | for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress}, | |
15985 | respectively. | |
545c9f8b | 15986 | |
d77de738 ML |
15987 | @item hwasan-instrument-stack |
15988 | Enable hwasan instrumentation of statically sized stack-allocated variables. | |
15989 | This kind of instrumentation is enabled by default when using | |
15990 | @option{-fsanitize=hwaddress} and disabled by default when using | |
15991 | @option{-fsanitize=kernel-hwaddress}. | |
15992 | To disable stack instrumentation use | |
15993 | @option{--param hwasan-instrument-stack=0}, and to enable it use | |
15994 | @option{--param hwasan-instrument-stack=1}. | |
15995 | ||
15996 | @item hwasan-random-frame-tag | |
15997 | When using stack instrumentation, decide tags for stack variables using a | |
15998 | deterministic sequence beginning at a random tag for each frame. With this | |
15999 | parameter unset tags are chosen using the same sequence but beginning from 1. | |
16000 | This is enabled by default for @option{-fsanitize=hwaddress} and unavailable | |
16001 | for @option{-fsanitize=kernel-hwaddress}. | |
16002 | To disable it use @option{--param hwasan-random-frame-tag=0}. | |
16003 | ||
16004 | @item hwasan-instrument-allocas | |
16005 | Enable hwasan instrumentation of dynamically sized stack-allocated variables. | |
16006 | This kind of instrumentation is enabled by default when using | |
16007 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16008 | @option{-fsanitize=kernel-hwaddress}. | |
16009 | To disable instrumentation of such variables use | |
16010 | @option{--param hwasan-instrument-allocas=0}, and to enable it use | |
16011 | @option{--param hwasan-instrument-allocas=1}. | |
16012 | ||
16013 | @item hwasan-instrument-reads | |
16014 | Enable hwasan checks on memory reads. Instrumentation of reads is enabled by | |
16015 | default for both @option{-fsanitize=hwaddress} and | |
16016 | @option{-fsanitize=kernel-hwaddress}. | |
16017 | To disable checking memory reads use | |
16018 | @option{--param hwasan-instrument-reads=0}. | |
16019 | ||
16020 | @item hwasan-instrument-writes | |
16021 | Enable hwasan checks on memory writes. Instrumentation of writes is enabled by | |
16022 | default for both @option{-fsanitize=hwaddress} and | |
16023 | @option{-fsanitize=kernel-hwaddress}. | |
16024 | To disable checking memory writes use | |
16025 | @option{--param hwasan-instrument-writes=0}. | |
16026 | ||
16027 | @item hwasan-instrument-mem-intrinsics | |
16028 | Enable hwasan instrumentation of builtin functions. Instrumentation of these | |
16029 | builtin functions is enabled by default for both @option{-fsanitize=hwaddress} | |
16030 | and @option{-fsanitize=kernel-hwaddress}. | |
16031 | To disable instrumentation of builtin functions use | |
16032 | @option{--param hwasan-instrument-mem-intrinsics=0}. | |
16033 | ||
16034 | @item use-after-scope-direct-emission-threshold | |
16035 | If the size of a local variable in bytes is smaller or equal to this | |
16036 | number, directly poison (or unpoison) shadow memory instead of using | |
16037 | run-time callbacks. | |
16038 | ||
16039 | @item tsan-distinguish-volatile | |
16040 | Emit special instrumentation for accesses to volatiles. | |
16041 | ||
16042 | @item tsan-instrument-func-entry-exit | |
16043 | Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit(). | |
16044 | ||
16045 | @item max-fsm-thread-path-insns | |
16046 | Maximum number of instructions to copy when duplicating blocks on a | |
16047 | finite state automaton jump thread path. | |
16048 | ||
16049 | @item threader-debug | |
16050 | threader-debug=[none|all] Enables verbose dumping of the threader solver. | |
16051 | ||
16052 | @item parloops-chunk-size | |
16053 | Chunk size of omp schedule for loops parallelized by parloops. | |
16054 | ||
16055 | @item parloops-schedule | |
16056 | Schedule type of omp schedule for loops parallelized by parloops (static, | |
16057 | dynamic, guided, auto, runtime). | |
16058 | ||
16059 | @item parloops-min-per-thread | |
16060 | The minimum number of iterations per thread of an innermost parallelized | |
16061 | loop for which the parallelized variant is preferred over the single threaded | |
16062 | one. Note that for a parallelized loop nest the | |
16063 | minimum number of iterations of the outermost loop per thread is two. | |
16064 | ||
16065 | @item max-ssa-name-query-depth | |
16066 | Maximum depth of recursion when querying properties of SSA names in things | |
16067 | like fold routines. One level of recursion corresponds to following a | |
16068 | use-def chain. | |
16069 | ||
16070 | @item max-speculative-devirt-maydefs | |
16071 | The maximum number of may-defs we analyze when looking for a must-def | |
16072 | specifying the dynamic type of an object that invokes a virtual call | |
16073 | we may be able to devirtualize speculatively. | |
16074 | ||
d77de738 ML |
16075 | @item ranger-debug |
16076 | Specifies the type of debug output to be issued for ranges. | |
16077 | ||
d77de738 ML |
16078 | @item unroll-jam-min-percent |
16079 | The minimum percentage of memory references that must be optimized | |
16080 | away for the unroll-and-jam transformation to be considered profitable. | |
16081 | ||
16082 | @item unroll-jam-max-unroll | |
16083 | The maximum number of times the outer loop should be unrolled by | |
16084 | the unroll-and-jam transformation. | |
16085 | ||
16086 | @item max-rtl-if-conversion-unpredictable-cost | |
16087 | Maximum permissible cost for the sequence that would be generated | |
16088 | by the RTL if-conversion pass for a branch that is considered unpredictable. | |
16089 | ||
16090 | @item max-variable-expansions-in-unroller | |
16091 | If @option{-fvariable-expansion-in-unroller} is used, the maximum number | |
16092 | of times that an individual variable will be expanded during loop unrolling. | |
16093 | ||
16094 | @item partial-inlining-entry-probability | |
16095 | Maximum probability of the entry BB of split region | |
16096 | (in percent relative to entry BB of the function) | |
16097 | to make partial inlining happen. | |
16098 | ||
16099 | @item max-tracked-strlens | |
16100 | Maximum number of strings for which strlen optimization pass will | |
16101 | track string lengths. | |
16102 | ||
16103 | @item gcse-after-reload-partial-fraction | |
16104 | The threshold ratio for performing partial redundancy | |
16105 | elimination after reload. | |
16106 | ||
16107 | @item gcse-after-reload-critical-fraction | |
16108 | The threshold ratio of critical edges execution count that | |
16109 | permit performing redundancy elimination after reload. | |
16110 | ||
16111 | @item max-loop-header-insns | |
16112 | The maximum number of insns in loop header duplicated | |
16113 | by the copy loop headers pass. | |
16114 | ||
16115 | @item vect-epilogues-nomask | |
16116 | Enable loop epilogue vectorization using smaller vector size. | |
16117 | ||
16118 | @item vect-partial-vector-usage | |
16119 | Controls when the loop vectorizer considers using partial vector loads | |
16120 | and stores as an alternative to falling back to scalar code. 0 stops | |
16121 | the vectorizer from ever using partial vector loads and stores. 1 allows | |
16122 | partial vector loads and stores if vectorization removes the need for the | |
16123 | code to iterate. 2 allows partial vector loads and stores in all loops. | |
16124 | The parameter only has an effect on targets that support partial | |
16125 | vector loads and stores. | |
16126 | ||
16127 | @item vect-inner-loop-cost-factor | |
16128 | The maximum factor which the loop vectorizer applies to the cost of statements | |
16129 | in an inner loop relative to the loop being vectorized. The factor applied | |
16130 | is the maximum of the estimated number of iterations of the inner loop and | |
16131 | this parameter. The default value of this parameter is 50. | |
16132 | ||
16133 | @item vect-induction-float | |
16134 | Enable loop vectorization of floating point inductions. | |
16135 | ||
cbe32d38 ML |
16136 | @item vrp-sparse-threshold |
16137 | Maximum number of basic blocks before VRP uses a sparse bitmap cache. | |
16138 | ||
16139 | @item vrp-switch-limit | |
16140 | Maximum number of outgoing edges in a switch before VRP will not process it. | |
16141 | ||
16142 | @item vrp-vector-threshold | |
16143 | Maximum number of basic blocks for VRP to use a basic cache vector. | |
16144 | ||
d77de738 ML |
16145 | @item avoid-fma-max-bits |
16146 | Maximum number of bits for which we avoid creating FMAs. | |
16147 | ||
16148 | @item sms-loop-average-count-threshold | |
16149 | A threshold on the average loop count considered by the swing modulo scheduler. | |
16150 | ||
16151 | @item sms-dfa-history | |
16152 | The number of cycles the swing modulo scheduler considers when checking | |
16153 | conflicts using DFA. | |
16154 | ||
16155 | @item graphite-allow-codegen-errors | |
16156 | Whether codegen errors should be ICEs when @option{-fchecking}. | |
16157 | ||
16158 | @item sms-max-ii-factor | |
16159 | A factor for tuning the upper bound that swing modulo scheduler | |
16160 | uses for scheduling a loop. | |
16161 | ||
16162 | @item lra-max-considered-reload-pseudos | |
16163 | The max number of reload pseudos which are considered during | |
16164 | spilling a non-reload pseudo. | |
16165 | ||
16166 | @item max-pow-sqrt-depth | |
16167 | Maximum depth of sqrt chains to use when synthesizing exponentiation | |
16168 | by a real constant. | |
16169 | ||
16170 | @item max-dse-active-local-stores | |
16171 | Maximum number of active local stores in RTL dead store elimination. | |
16172 | ||
16173 | @item asan-instrument-allocas | |
16174 | Enable asan allocas/VLAs protection. | |
16175 | ||
16176 | @item max-iterations-computation-cost | |
16177 | Bound on the cost of an expression to compute the number of iterations. | |
16178 | ||
16179 | @item max-isl-operations | |
16180 | Maximum number of isl operations, 0 means unlimited. | |
16181 | ||
16182 | @item graphite-max-arrays-per-scop | |
16183 | Maximum number of arrays per scop. | |
16184 | ||
16185 | @item max-vartrack-reverse-op-size | |
16186 | Max. size of loc list for which reverse ops should be added. | |
16187 | ||
16188 | @item fsm-scale-path-stmts | |
16189 | Scale factor to apply to the number of statements in a threading path | |
7c9f20fc RB |
16190 | crossing a loop backedge when comparing to |
16191 | @option{--param=max-jump-thread-duplication-stmts}. | |
d77de738 ML |
16192 | |
16193 | @item uninit-control-dep-attempts | |
16194 | Maximum number of nested calls to search for control dependencies | |
16195 | during uninitialized variable analysis. | |
16196 | ||
d77de738 ML |
16197 | @item sched-autopref-queue-depth |
16198 | Hardware autoprefetcher scheduler model control flag. | |
16199 | Number of lookahead cycles the model looks into; at ' | |
16200 | ' only enable instruction sorting heuristic. | |
16201 | ||
16202 | @item loop-versioning-max-inner-insns | |
16203 | The maximum number of instructions that an inner loop can have | |
16204 | before the loop versioning pass considers it too big to copy. | |
16205 | ||
16206 | @item loop-versioning-max-outer-insns | |
16207 | The maximum number of instructions that an outer loop can have | |
16208 | before the loop versioning pass considers it too big to copy, | |
16209 | discounting any instructions in inner loops that directly benefit | |
16210 | from versioning. | |
16211 | ||
16212 | @item ssa-name-def-chain-limit | |
16213 | The maximum number of SSA_NAME assignments to follow in determining | |
16214 | a property of a variable such as its value. This limits the number | |
16215 | of iterations or recursive calls GCC performs when optimizing certain | |
16216 | statements or when determining their validity prior to issuing | |
16217 | diagnostics. | |
16218 | ||
16219 | @item store-merging-max-size | |
16220 | Maximum size of a single store merging region in bytes. | |
16221 | ||
16222 | @item hash-table-verification-limit | |
16223 | The number of elements for which hash table verification is done | |
16224 | for each searched element. | |
16225 | ||
16226 | @item max-find-base-term-values | |
16227 | Maximum number of VALUEs handled during a single find_base_term call. | |
16228 | ||
16229 | @item analyzer-max-enodes-per-program-point | |
16230 | The maximum number of exploded nodes per program point within | |
16231 | the analyzer, before terminating analysis of that point. | |
16232 | ||
16233 | @item analyzer-max-constraints | |
16234 | The maximum number of constraints per state. | |
16235 | ||
16236 | @item analyzer-min-snodes-for-call-summary | |
16237 | The minimum number of supernodes within a function for the | |
16238 | analyzer to consider summarizing its effects at call sites. | |
16239 | ||
16240 | @item analyzer-max-enodes-for-full-dump | |
16241 | The maximum depth of exploded nodes that should appear in a dot dump | |
16242 | before switching to a less verbose format. | |
16243 | ||
16244 | @item analyzer-max-recursion-depth | |
16245 | The maximum number of times a callsite can appear in a call stack | |
16246 | within the analyzer, before terminating analysis of a call that would | |
16247 | recurse deeper. | |
16248 | ||
16249 | @item analyzer-max-svalue-depth | |
16250 | The maximum depth of a symbolic value, before approximating | |
16251 | the value as unknown. | |
16252 | ||
16253 | @item analyzer-max-infeasible-edges | |
16254 | The maximum number of infeasible edges to reject before declaring | |
16255 | a diagnostic as infeasible. | |
16256 | ||
16257 | @item gimple-fe-computed-hot-bb-threshold | |
16258 | The number of executions of a basic block which is considered hot. | |
16259 | The parameter is used only in GIMPLE FE. | |
16260 | ||
16261 | @item analyzer-bb-explosion-factor | |
16262 | The maximum number of 'after supernode' exploded nodes within the analyzer | |
16263 | per supernode, before terminating analysis. | |
16264 | ||
16265 | @item ranger-logical-depth | |
16266 | Maximum depth of logical expression evaluation ranger will look through | |
16267 | when evaluating outgoing edge ranges. | |
16268 | ||
9fd6d83a ML |
16269 | @item ranger-recompute-depth |
16270 | Maximum depth of instruction chains to consider for recomputation | |
16271 | in the outgoing range calculator. | |
16272 | ||
d77de738 ML |
16273 | @item relation-block-limit |
16274 | Maximum number of relations the oracle will register in a basic block. | |
16275 | ||
16276 | @item min-pagesize | |
16277 | Minimum page size for warning purposes. | |
16278 | ||
16279 | @item openacc-kernels | |
16280 | Specify mode of OpenACC `kernels' constructs handling. | |
16281 | With @option{--param=openacc-kernels=decompose}, OpenACC `kernels' | |
16282 | constructs are decomposed into parts, a sequence of compute | |
16283 | constructs, each then handled individually. | |
16284 | This is work in progress. | |
16285 | With @option{--param=openacc-kernels=parloops}, OpenACC `kernels' | |
16286 | constructs are handled by the @samp{parloops} pass, en bloc. | |
16287 | This is the current default. | |
16288 | ||
16289 | @item openacc-privatization | |
4ace81b6 SL |
16290 | Control whether the @option{-fopt-info-omp-note} and applicable |
16291 | @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics. | |
d77de738 ML |
16292 | With @option{--param=openacc-privatization=quiet}, don't diagnose. |
16293 | This is the current default. | |
16294 | With @option{--param=openacc-privatization=noisy}, do diagnose. | |
16295 | ||
16296 | @end table | |
16297 | ||
16298 | The following choices of @var{name} are available on AArch64 targets: | |
16299 | ||
16300 | @table @gcctabopt | |
16301 | @item aarch64-sve-compare-costs | |
16302 | When vectorizing for SVE, consider using ``unpacked'' vectors for | |
16303 | smaller elements and use the cost model to pick the cheapest approach. | |
16304 | Also use the cost model to choose between SVE and Advanced SIMD vectorization. | |
16305 | ||
16306 | Using unpacked vectors includes storing smaller elements in larger | |
16307 | containers and accessing elements with extending loads and truncating | |
16308 | stores. | |
16309 | ||
16310 | @item aarch64-float-recp-precision | |
16311 | The number of Newton iterations for calculating the reciprocal for float type. | |
16312 | The precision of division is proportional to this param when division | |
16313 | approximation is enabled. The default value is 1. | |
16314 | ||
16315 | @item aarch64-double-recp-precision | |
16316 | The number of Newton iterations for calculating the reciprocal for double type. | |
16317 | The precision of division is propotional to this param when division | |
16318 | approximation is enabled. The default value is 2. | |
16319 | ||
16320 | @item aarch64-autovec-preference | |
16321 | Force an ISA selection strategy for auto-vectorization. Accepts values from | |
16322 | 0 to 4, inclusive. | |
16323 | @table @samp | |
16324 | @item 0 | |
16325 | Use the default heuristics. | |
16326 | @item 1 | |
16327 | Use only Advanced SIMD for auto-vectorization. | |
16328 | @item 2 | |
16329 | Use only SVE for auto-vectorization. | |
16330 | @item 3 | |
16331 | Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are | |
16332 | deemed equal. | |
16333 | @item 4 | |
16334 | Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal. | |
16335 | @end table | |
16336 | The default value is 0. | |
16337 | ||
16338 | @item aarch64-loop-vect-issue-rate-niters | |
16339 | The tuning for some AArch64 CPUs tries to take both latencies and issue | |
16340 | rates into account when deciding whether a loop should be vectorized | |
16341 | using SVE, vectorized using Advanced SIMD, or not vectorized at all. | |
16342 | If this parameter is set to @var{n}, GCC will not use this heuristic | |
16343 | for loops that are known to execute in fewer than @var{n} Advanced | |
16344 | SIMD iterations. | |
16345 | ||
16346 | @item aarch64-vect-unroll-limit | |
16347 | The vectorizer will use available tuning information to determine whether it | |
16348 | would be beneficial to unroll the main vectorized loop and by how much. This | |
16349 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
16350 | loop. The default value is four. | |
16351 | ||
16352 | @end table | |
16353 | ||
16354 | The following choices of @var{name} are available on i386 and x86_64 targets: | |
16355 | ||
16356 | @table @gcctabopt | |
16357 | @item x86-stlf-window-ninsns | |
16358 | Instructions number above which STFL stall penalty can be compensated. | |
16359 | ||
60101899 RB |
16360 | @item x86-stv-max-visits |
16361 | The maximum number of use and def visits when discovering a STV chain before | |
16362 | the discovery is aborted. | |
16363 | ||
d77de738 ML |
16364 | @end table |
16365 | ||
16366 | @end table | |
16367 | ||
16368 | @node Instrumentation Options | |
16369 | @section Program Instrumentation Options | |
16370 | @cindex instrumentation options | |
16371 | @cindex program instrumentation options | |
16372 | @cindex run-time error checking options | |
16373 | @cindex profiling options | |
16374 | @cindex options, program instrumentation | |
16375 | @cindex options, run-time error checking | |
16376 | @cindex options, profiling | |
16377 | ||
16378 | GCC supports a number of command-line options that control adding | |
16379 | run-time instrumentation to the code it normally generates. | |
16380 | For example, one purpose of instrumentation is collect profiling | |
16381 | statistics for use in finding program hot spots, code coverage | |
16382 | analysis, or profile-guided optimizations. | |
16383 | Another class of program instrumentation is adding run-time checking | |
16384 | to detect programming errors like invalid pointer | |
16385 | dereferences or out-of-bounds array accesses, as well as deliberately | |
16386 | hostile attacks such as stack smashing or C++ vtable hijacking. | |
16387 | There is also a general hook which can be used to implement other | |
16388 | forms of tracing or function-level instrumentation for debug or | |
16389 | program analysis purposes. | |
16390 | ||
16391 | @table @gcctabopt | |
16392 | @cindex @command{prof} | |
16393 | @cindex @command{gprof} | |
d77de738 ML |
16394 | @opindex p |
16395 | @opindex pg | |
ddf6fe37 AA |
16396 | @item -p |
16397 | @itemx -pg | |
d77de738 ML |
16398 | Generate extra code to write profile information suitable for the |
16399 | analysis program @command{prof} (for @option{-p}) or @command{gprof} | |
16400 | (for @option{-pg}). You must use this option when compiling | |
16401 | the source files you want data about, and you must also use it when | |
16402 | linking. | |
16403 | ||
16404 | You can use the function attribute @code{no_instrument_function} to | |
16405 | suppress profiling of individual functions when compiling with these options. | |
16406 | @xref{Common Function Attributes}. | |
16407 | ||
d77de738 | 16408 | @opindex fprofile-arcs |
ddf6fe37 | 16409 | @item -fprofile-arcs |
d77de738 ML |
16410 | Add code so that program flow @dfn{arcs} are instrumented. During |
16411 | execution the program records how many times each branch and call is | |
16412 | executed and how many times it is taken or returns. On targets that support | |
16413 | constructors with priority support, profiling properly handles constructors, | |
16414 | destructors and C++ constructors (and destructors) of classes which are used | |
16415 | as a type of a global variable. | |
16416 | ||
16417 | When the compiled | |
16418 | program exits it saves this data to a file called | |
16419 | @file{@var{auxname}.gcda} for each source file. The data may be used for | |
16420 | profile-directed optimizations (@option{-fbranch-probabilities}), or for | |
16421 | test coverage analysis (@option{-ftest-coverage}). Each object file's | |
16422 | @var{auxname} is generated from the name of the output file, if | |
16423 | explicitly specified and it is not the final executable, otherwise it is | |
16424 | the basename of the source file. In both cases any suffix is removed | |
16425 | (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or | |
16426 | @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}). | |
16427 | ||
16428 | Note that if a command line directly links source files, the corresponding | |
16429 | @var{.gcda} files will be prefixed with the unsuffixed name of the output file. | |
16430 | E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and | |
16431 | @file{binary-b.gcda} files. | |
16432 | ||
16433 | @xref{Cross-profiling}. | |
16434 | ||
16435 | @cindex @command{gcov} | |
d77de738 | 16436 | @opindex coverage |
ddf6fe37 | 16437 | @item --coverage |
d77de738 ML |
16438 | |
16439 | This option is used to compile and link code instrumented for coverage | |
16440 | analysis. The option is a synonym for @option{-fprofile-arcs} | |
16441 | @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when | |
16442 | linking). See the documentation for those options for more details. | |
16443 | ||
16444 | @itemize | |
16445 | ||
16446 | @item | |
16447 | Compile the source files with @option{-fprofile-arcs} plus optimization | |
16448 | and code generation options. For test coverage analysis, use the | |
16449 | additional @option{-ftest-coverage} option. You do not need to profile | |
16450 | every source file in a program. | |
16451 | ||
16452 | @item | |
16453 | Compile the source files additionally with @option{-fprofile-abs-path} | |
16454 | to create absolute path names in the @file{.gcno} files. This allows | |
16455 | @command{gcov} to find the correct sources in projects where compilations | |
16456 | occur with different working directories. | |
16457 | ||
16458 | @item | |
16459 | Link your object files with @option{-lgcov} or @option{-fprofile-arcs} | |
16460 | (the latter implies the former). | |
16461 | ||
16462 | @item | |
16463 | Run the program on a representative workload to generate the arc profile | |
16464 | information. This may be repeated any number of times. You can run | |
16465 | concurrent instances of your program, and provided that the file system | |
16466 | supports locking, the data files will be correctly updated. Unless | |
16467 | a strict ISO C dialect option is in effect, @code{fork} calls are | |
16468 | detected and correctly handled without double counting. | |
16469 | ||
16470 | Moreover, an object file can be recompiled multiple times | |
16471 | and the corresponding @file{.gcda} file merges as long as | |
16472 | the source file and the compiler options are unchanged. | |
16473 | ||
16474 | @item | |
16475 | For profile-directed optimizations, compile the source files again with | |
16476 | the same optimization and code generation options plus | |
16477 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
16478 | Control Optimization}). | |
16479 | ||
16480 | @item | |
16481 | For test coverage analysis, use @command{gcov} to produce human readable | |
16482 | information from the @file{.gcno} and @file{.gcda} files. Refer to the | |
16483 | @command{gcov} documentation for further information. | |
16484 | ||
16485 | @end itemize | |
16486 | ||
16487 | With @option{-fprofile-arcs}, for each function of your program GCC | |
16488 | creates a program flow graph, then finds a spanning tree for the graph. | |
16489 | Only arcs that are not on the spanning tree have to be instrumented: the | |
16490 | compiler adds code to count the number of times that these arcs are | |
16491 | executed. When an arc is the only exit or only entrance to a block, the | |
16492 | instrumentation code can be added to the block; otherwise, a new basic | |
16493 | block must be created to hold the instrumentation code. | |
16494 | ||
16495 | @need 2000 | |
d77de738 | 16496 | @opindex ftest-coverage |
ddf6fe37 | 16497 | @item -ftest-coverage |
d77de738 ML |
16498 | Produce a notes file that the @command{gcov} code-coverage utility |
16499 | (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to | |
16500 | show program coverage. Each source file's note file is called | |
16501 | @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option | |
16502 | above for a description of @var{auxname} and instructions on how to | |
16503 | generate test coverage data. Coverage data matches the source files | |
16504 | more closely if you do not optimize. | |
16505 | ||
d77de738 | 16506 | @opindex fprofile-abs-path |
ddf6fe37 | 16507 | @item -fprofile-abs-path |
d77de738 ML |
16508 | Automatically convert relative source file names to absolute path names |
16509 | in the @file{.gcno} files. This allows @command{gcov} to find the correct | |
16510 | sources in projects where compilations occur with different working | |
16511 | directories. | |
16512 | ||
d77de738 | 16513 | @opindex fprofile-dir |
ddf6fe37 | 16514 | @item -fprofile-dir=@var{path} |
d77de738 ML |
16515 | |
16516 | Set the directory to search for the profile data files in to @var{path}. | |
16517 | This option affects only the profile data generated by | |
16518 | @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs} | |
16519 | and used by @option{-fprofile-use} and @option{-fbranch-probabilities} | |
16520 | and its related options. Both absolute and relative paths can be used. | |
16521 | By default, GCC uses the current directory as @var{path}, thus the | |
16522 | profile data file appears in the same directory as the object file. | |
16523 | In order to prevent the file name clashing, if the object file name is | |
16524 | not an absolute path, we mangle the absolute path of the | |
16525 | @file{@var{sourcename}.gcda} file and use it as the file name of a | |
16526 | @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}. | |
16527 | See similar option @option{-fprofile-note}. | |
16528 | ||
16529 | When an executable is run in a massive parallel environment, it is recommended | |
16530 | to save profile to different folders. That can be done with variables | |
16531 | in @var{path} that are exported during run-time: | |
16532 | ||
16533 | @table @gcctabopt | |
16534 | ||
16535 | @item %p | |
16536 | process ID. | |
16537 | ||
16538 | @item %q@{VAR@} | |
16539 | value of environment variable @var{VAR} | |
16540 | ||
16541 | @end table | |
16542 | ||
ddf6fe37 | 16543 | @opindex fprofile-generate |
d77de738 ML |
16544 | @item -fprofile-generate |
16545 | @itemx -fprofile-generate=@var{path} | |
d77de738 ML |
16546 | |
16547 | Enable options usually used for instrumenting application to produce | |
16548 | profile useful for later recompilation with profile feedback based | |
16549 | optimization. You must use @option{-fprofile-generate} both when | |
16550 | compiling and when linking your program. | |
16551 | ||
16552 | The following options are enabled: | |
16553 | @option{-fprofile-arcs}, @option{-fprofile-values}, | |
16554 | @option{-finline-functions}, and @option{-fipa-bit-cp}. | |
16555 | ||
16556 | If @var{path} is specified, GCC looks at the @var{path} to find | |
16557 | the profile feedback data files. See @option{-fprofile-dir}. | |
16558 | ||
16559 | To optimize the program based on the collected profile information, use | |
16560 | @option{-fprofile-use}. @xref{Optimize Options}, for more information. | |
16561 | ||
ddf6fe37 | 16562 | @opindex fprofile-info-section |
d77de738 ML |
16563 | @item -fprofile-info-section |
16564 | @itemx -fprofile-info-section=@var{name} | |
d77de738 ML |
16565 | |
16566 | Register the profile information in the specified section instead of using a | |
16567 | constructor/destructor. The section name is @var{name} if it is specified, | |
16568 | otherwise the section name defaults to @code{.gcov_info}. A pointer to the | |
16569 | profile information generated by @option{-fprofile-arcs} is placed in the | |
16570 | specified section for each translation unit. This option disables the profile | |
16571 | information registration through a constructor and it disables the profile | |
16572 | information processing through a destructor. This option is not intended to be | |
16573 | used in hosted environments such as GNU/Linux. It targets freestanding | |
16574 | environments (for example embedded systems) with limited resources which do not | |
16575 | support constructors/destructors or the C library file I/O. | |
16576 | ||
16577 | The linker could collect the input sections in a continuous memory block and | |
16578 | define start and end symbols. A GNU linker script example which defines a | |
16579 | linker output section follows: | |
16580 | ||
16581 | @smallexample | |
16582 | .gcov_info : | |
16583 | @{ | |
16584 | PROVIDE (__gcov_info_start = .); | |
16585 | KEEP (*(.gcov_info)) | |
16586 | PROVIDE (__gcov_info_end = .); | |
16587 | @} | |
16588 | @end smallexample | |
16589 | ||
16590 | The program could dump the profiling information registered in this linker set | |
16591 | for example like this: | |
16592 | ||
16593 | @smallexample | |
16594 | #include <gcov.h> | |
16595 | #include <stdio.h> | |
16596 | #include <stdlib.h> | |
16597 | ||
16598 | extern const struct gcov_info *const __gcov_info_start[]; | |
16599 | extern const struct gcov_info *const __gcov_info_end[]; | |
16600 | ||
16601 | static void | |
16602 | dump (const void *d, unsigned n, void *arg) | |
16603 | @{ | |
16604 | const unsigned char *c = d; | |
16605 | ||
16606 | for (unsigned i = 0; i < n; ++i) | |
16607 | printf ("%02x", c[i]); | |
16608 | @} | |
16609 | ||
16610 | static void | |
16611 | filename (const char *f, void *arg) | |
16612 | @{ | |
16613 | __gcov_filename_to_gcfn (f, dump, arg ); | |
16614 | @} | |
16615 | ||
16616 | static void * | |
16617 | allocate (unsigned length, void *arg) | |
16618 | @{ | |
16619 | return malloc (length); | |
16620 | @} | |
16621 | ||
16622 | static void | |
16623 | dump_gcov_info (void) | |
16624 | @{ | |
16625 | const struct gcov_info *const *info = __gcov_info_start; | |
16626 | const struct gcov_info *const *end = __gcov_info_end; | |
16627 | ||
16628 | /* Obfuscate variable to prevent compiler optimizations. */ | |
16629 | __asm__ ("" : "+r" (info)); | |
16630 | ||
16631 | while (info != end) | |
16632 | @{ | |
16633 | void *arg = NULL; | |
16634 | __gcov_info_to_gcda (*info, filename, dump, allocate, arg); | |
16635 | putchar ('\n'); | |
16636 | ++info; | |
16637 | @} | |
16638 | @} | |
16639 | ||
16640 | int | |
16641 | main (void) | |
16642 | @{ | |
16643 | dump_gcov_info (); | |
16644 | return 0; | |
16645 | @} | |
16646 | @end smallexample | |
16647 | ||
16648 | The @command{merge-stream} subcommand of @command{gcov-tool} may be used to | |
16649 | deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and | |
16650 | @code{__gcov_info_to_gcda} functions and merge the profile information into | |
16651 | @file{.gcda} files on the host filesystem. | |
16652 | ||
d77de738 | 16653 | @opindex fprofile-note |
ddf6fe37 | 16654 | @item -fprofile-note=@var{path} |
d77de738 ML |
16655 | |
16656 | If @var{path} is specified, GCC saves @file{.gcno} file into @var{path} | |
16657 | location. If you combine the option with multiple source files, | |
16658 | the @file{.gcno} file will be overwritten. | |
16659 | ||
d77de738 | 16660 | @opindex fprofile-prefix-path |
ddf6fe37 | 16661 | @item -fprofile-prefix-path=@var{path} |
d77de738 ML |
16662 | |
16663 | This option can be used in combination with | |
16664 | @option{profile-generate=}@var{profile_dir} and | |
16665 | @option{profile-use=}@var{profile_dir} to inform GCC where is the base | |
16666 | directory of built source tree. By default @var{profile_dir} will contain | |
16667 | files with mangled absolute paths of all object files in the built project. | |
16668 | This is not desirable when directory used to build the instrumented binary | |
16669 | differs from the directory used to build the binary optimized with profile | |
16670 | feedback because the profile data will not be found during the optimized build. | |
16671 | In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path} | |
16672 | pointing to the base directory of the build can be used to strip the irrelevant | |
16673 | part of the path and keep all file names relative to the main build directory. | |
16674 | ||
d77de738 | 16675 | @opindex fprofile-prefix-map |
ddf6fe37 | 16676 | @item -fprofile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
16677 | When compiling files residing in directory @file{@var{old}}, record |
16678 | profiling information (with @option{--coverage}) | |
16679 | describing them as if the files resided in | |
16680 | directory @file{@var{new}} instead. | |
2eb0191a | 16681 | See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}. |
d77de738 | 16682 | |
d77de738 | 16683 | @opindex fprofile-update |
ddf6fe37 | 16684 | @item -fprofile-update=@var{method} |
d77de738 ML |
16685 | |
16686 | Alter the update method for an application instrumented for profile | |
16687 | feedback based optimization. The @var{method} argument should be one of | |
16688 | @samp{single}, @samp{atomic} or @samp{prefer-atomic}. | |
16689 | The first one is useful for single-threaded applications, | |
16690 | while the second one prevents profile corruption by emitting thread-safe code. | |
16691 | ||
16692 | @strong{Warning:} When an application does not properly join all threads | |
16693 | (or creates an detached thread), a profile file can be still corrupted. | |
16694 | ||
16695 | Using @samp{prefer-atomic} would be transformed either to @samp{atomic}, | |
16696 | when supported by a target, or to @samp{single} otherwise. The GCC driver | |
16697 | automatically selects @samp{prefer-atomic} when @option{-pthread} | |
16698 | is present in the command line. | |
16699 | ||
d77de738 | 16700 | @opindex fprofile-filter-files |
ddf6fe37 | 16701 | @item -fprofile-filter-files=@var{regex} |
d77de738 ML |
16702 | |
16703 | Instrument only functions from files whose name matches | |
16704 | any of the regular expressions (separated by semi-colons). | |
16705 | ||
16706 | For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument | |
16707 | only @file{main.c} and all C files starting with 'module'. | |
16708 | ||
d77de738 | 16709 | @opindex fprofile-exclude-files |
ddf6fe37 | 16710 | @item -fprofile-exclude-files=@var{regex} |
d77de738 ML |
16711 | |
16712 | Instrument only functions from files whose name does not match | |
16713 | any of the regular expressions (separated by semi-colons). | |
16714 | ||
16715 | For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation | |
16716 | of all files that are located in the @file{/usr/} folder. | |
16717 | ||
d77de738 | 16718 | @opindex fprofile-reproducible |
ddf6fe37 | 16719 | @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} |
d77de738 ML |
16720 | Control level of reproducibility of profile gathered by |
16721 | @code{-fprofile-generate}. This makes it possible to rebuild program | |
16722 | with same outcome which is useful, for example, for distribution | |
16723 | packages. | |
16724 | ||
16725 | With @option{-fprofile-reproducible=serial} the profile gathered by | |
16726 | @option{-fprofile-generate} is reproducible provided the trained program | |
16727 | behaves the same at each invocation of the train run, it is not | |
16728 | multi-threaded and profile data streaming is always done in the same | |
16729 | order. Note that profile streaming happens at the end of program run but | |
16730 | also before @code{fork} function is invoked. | |
16731 | ||
16732 | Note that it is quite common that execution counts of some part of | |
16733 | programs depends, for example, on length of temporary file names or | |
16734 | memory space randomization (that may affect hash-table collision rate). | |
16735 | Such non-reproducible part of programs may be annotated by | |
16736 | @code{no_instrument_function} function attribute. @command{gcov-dump} with | |
16737 | @option{-l} can be used to dump gathered data and verify that they are | |
16738 | indeed reproducible. | |
16739 | ||
16740 | With @option{-fprofile-reproducible=parallel-runs} collected profile | |
16741 | stays reproducible regardless the order of streaming of the data into | |
16742 | gcda files. This setting makes it possible to run multiple instances of | |
16743 | instrumented program in parallel (such as with @code{make -j}). This | |
16744 | reduces quality of gathered data, in particular of indirect call | |
16745 | profiling. | |
16746 | ||
d77de738 | 16747 | @opindex fsanitize=address |
ddf6fe37 | 16748 | @item -fsanitize=address |
d77de738 ML |
16749 | Enable AddressSanitizer, a fast memory error detector. |
16750 | Memory access instructions are instrumented to detect | |
16751 | out-of-bounds and use-after-free bugs. | |
16752 | The option enables @option{-fsanitize-address-use-after-scope}. | |
16753 | See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for | |
16754 | more details. The run-time behavior can be influenced using the | |
16755 | @env{ASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
16756 | the available options are shown at startup of the instrumented program. See | |
16757 | @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} | |
16758 | for a list of supported options. | |
16759 | The option cannot be combined with @option{-fsanitize=thread} or | |
16760 | @option{-fsanitize=hwaddress}. Note that the only target | |
16761 | @option{-fsanitize=hwaddress} is currently supported on is AArch64. | |
16762 | ||
6a07798c MP |
16763 | To get more accurate stack traces, it is possible to use options such as |
16764 | @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent | |
16765 | most function inlining), @option{-fno-optimize-sibling-calls} (which prevents | |
16766 | optimizing sibling and tail recursive calls; this option is implicit for | |
16767 | @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which | |
16768 | disables Identical Code Folding for functions). Since multiple runs of the | |
16769 | program may yield backtraces with different addresses due to ASLR (Address | |
16770 | Space Layout Randomization), it may be desirable to turn ASLR off. On Linux, | |
16771 | this can be achieved with @samp{setarch `uname -m` -R ./prog}. | |
16772 | ||
d77de738 | 16773 | @opindex fsanitize=kernel-address |
f33d7a88 | 16774 | @item -fsanitize=kernel-address |
d77de738 | 16775 | Enable AddressSanitizer for Linux kernel. |
a0bf71be | 16776 | See @uref{https://github.com/google/kernel-sanitizers} for more details. |
d77de738 | 16777 | |
d77de738 | 16778 | @opindex fsanitize=hwaddress |
f33d7a88 | 16779 | @item -fsanitize=hwaddress |
d77de738 ML |
16780 | Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to |
16781 | ignore the top byte of a pointer to allow the detection of memory errors with | |
16782 | a low memory overhead. | |
16783 | Memory access instructions are instrumented to detect out-of-bounds and | |
16784 | use-after-free bugs. | |
16785 | The option enables @option{-fsanitize-address-use-after-scope}. | |
16786 | See | |
16787 | @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html} | |
16788 | for more details. The run-time behavior can be influenced using the | |
16789 | @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
16790 | the available options are shown at startup of the instrumented program. | |
16791 | The option cannot be combined with @option{-fsanitize=thread} or | |
16792 | @option{-fsanitize=address}, and is currently only available on AArch64. | |
16793 | ||
d77de738 | 16794 | @opindex fsanitize=kernel-hwaddress |
ddf6fe37 | 16795 | @item -fsanitize=kernel-hwaddress |
d77de738 ML |
16796 | Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel. |
16797 | Similar to @option{-fsanitize=kernel-address} but using an alternate | |
16798 | instrumentation method, and similar to @option{-fsanitize=hwaddress} but with | |
16799 | instrumentation differences necessary for compiling the Linux kernel. | |
16800 | These differences are to avoid hwasan library initialization calls and to | |
16801 | account for the stack pointer having a different value in its top byte. | |
16802 | ||
16803 | @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}. | |
16804 | Instrumenting the stack and alloca calls are not on by default but are still | |
16805 | possible by specifying the command-line options | |
16806 | @option{--param hwasan-instrument-stack=1} and | |
16807 | @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame | |
16808 | tag is not implemented for kernel instrumentation. | |
16809 | ||
d77de738 | 16810 | @opindex fsanitize=pointer-compare |
ddf6fe37 | 16811 | @item -fsanitize=pointer-compare |
d77de738 ML |
16812 | Instrument comparison operation (<, <=, >, >=) with pointer operands. |
16813 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
16814 | @option{-fsanitize=address} | |
16815 | The option cannot be combined with @option{-fsanitize=thread}. | |
16816 | Note: By default the check is disabled at run time. To enable it, | |
16817 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
16818 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
16819 | invalid operation only when both pointers are non-null. | |
16820 | ||
d77de738 | 16821 | @opindex fsanitize=pointer-subtract |
ddf6fe37 | 16822 | @item -fsanitize=pointer-subtract |
d77de738 ML |
16823 | Instrument subtraction with pointer operands. |
16824 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
16825 | @option{-fsanitize=address} | |
16826 | The option cannot be combined with @option{-fsanitize=thread}. | |
16827 | Note: By default the check is disabled at run time. To enable it, | |
16828 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
16829 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
16830 | invalid operation only when both pointers are non-null. | |
16831 | ||
d77de738 | 16832 | @opindex fsanitize=shadow-call-stack |
ddf6fe37 | 16833 | @item -fsanitize=shadow-call-stack |
d77de738 ML |
16834 | Enable ShadowCallStack, a security enhancement mechanism used to protect |
16835 | programs against return address overwrites (e.g. stack buffer overflows.) | |
16836 | It works by saving a function's return address to a separately allocated | |
16837 | shadow call stack in the function prologue and restoring the return address | |
16838 | from the shadow call stack in the function epilogue. Instrumentation only | |
16839 | occurs in functions that need to save the return address to the stack. | |
16840 | ||
16841 | Currently it only supports the aarch64 platform. It is specifically | |
16842 | designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option. | |
16843 | For the user space programs, runtime support is not currently provided | |
16844 | in libc and libgcc. Users who want to use this feature in user space need | |
16845 | to provide their own support for the runtime. It should be noted that | |
16846 | this may cause the ABI rules to be broken. | |
16847 | ||
16848 | On aarch64, the instrumentation makes use of the platform register @code{x18}. | |
16849 | This generally means that any code that may run on the same thread as code | |
16850 | compiled with ShadowCallStack must be compiled with the flag | |
16851 | @option{-ffixed-x18}, otherwise functions compiled without | |
16852 | @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow | |
16853 | stack pointer. | |
16854 | ||
16855 | Also, because there is no userspace runtime support, code compiled with | |
16856 | ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions} | |
16857 | to turn off exceptions. | |
16858 | ||
16859 | See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more | |
16860 | details. | |
16861 | ||
d77de738 | 16862 | @opindex fsanitize=thread |
ddf6fe37 | 16863 | @item -fsanitize=thread |
d77de738 ML |
16864 | Enable ThreadSanitizer, a fast data race detector. |
16865 | Memory access instructions are instrumented to detect | |
16866 | data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more | |
16867 | details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS} | |
16868 | environment variable; see | |
16869 | @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of | |
16870 | supported options. | |
16871 | The option cannot be combined with @option{-fsanitize=address}, | |
16872 | @option{-fsanitize=leak}. | |
16873 | ||
16874 | Note that sanitized atomic builtins cannot throw exceptions when | |
16875 | operating on invalid memory addresses with non-call exceptions | |
16876 | (@option{-fnon-call-exceptions}). | |
16877 | ||
d77de738 | 16878 | @opindex fsanitize=leak |
ddf6fe37 | 16879 | @item -fsanitize=leak |
d77de738 | 16880 | Enable LeakSanitizer, a memory leak detector. |
c5c4fdac JG |
16881 | This option only matters for linking of executables. |
16882 | The executable is linked against a library that overrides @code{malloc} | |
d77de738 ML |
16883 | and other allocator functions. See |
16884 | @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more | |
16885 | details. The run-time behavior can be influenced using the | |
16886 | @env{LSAN_OPTIONS} environment variable. | |
16887 | The option cannot be combined with @option{-fsanitize=thread}. | |
16888 | ||
d77de738 | 16889 | @opindex fsanitize=undefined |
ddf6fe37 | 16890 | @item -fsanitize=undefined |
d77de738 ML |
16891 | Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. |
16892 | Various computations are instrumented to detect undefined behavior | |
16893 | at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the | |
16894 | @env{UBSAN_OPTIONS} environment variable. Current suboptions are: | |
16895 | ||
16896 | @table @gcctabopt | |
16897 | ||
d77de738 | 16898 | @opindex fsanitize=shift |
ddf6fe37 | 16899 | @item -fsanitize=shift |
d77de738 ML |
16900 | This option enables checking that the result of a shift operation is |
16901 | not undefined. Note that what exactly is considered undefined differs | |
16902 | slightly between C and C++, as well as between ISO C90 and C99, etc. | |
16903 | This option has two suboptions, @option{-fsanitize=shift-base} and | |
16904 | @option{-fsanitize=shift-exponent}. | |
16905 | ||
d77de738 | 16906 | @opindex fsanitize=shift-exponent |
ddf6fe37 | 16907 | @item -fsanitize=shift-exponent |
d77de738 ML |
16908 | This option enables checking that the second argument of a shift operation |
16909 | is not negative and is smaller than the precision of the promoted first | |
16910 | argument. | |
16911 | ||
d77de738 | 16912 | @opindex fsanitize=shift-base |
ddf6fe37 | 16913 | @item -fsanitize=shift-base |
d77de738 ML |
16914 | If the second argument of a shift operation is within range, check that the |
16915 | result of a shift operation is not undefined. Note that what exactly is | |
16916 | considered undefined differs slightly between C and C++, as well as between | |
16917 | ISO C90 and C99, etc. | |
16918 | ||
d77de738 | 16919 | @opindex fsanitize=integer-divide-by-zero |
ddf6fe37 | 16920 | @item -fsanitize=integer-divide-by-zero |
d77de738 ML |
16921 | Detect integer division by zero. |
16922 | ||
d77de738 | 16923 | @opindex fsanitize=unreachable |
ddf6fe37 | 16924 | @item -fsanitize=unreachable |
d77de738 ML |
16925 | With this option, the compiler turns the @code{__builtin_unreachable} |
16926 | call into a diagnostics message call instead. When reaching the | |
16927 | @code{__builtin_unreachable} call, the behavior is undefined. | |
16928 | ||
d77de738 | 16929 | @opindex fsanitize=vla-bound |
ddf6fe37 | 16930 | @item -fsanitize=vla-bound |
d77de738 ML |
16931 | This option instructs the compiler to check that the size of a variable |
16932 | length array is positive. | |
16933 | ||
d77de738 | 16934 | @opindex fsanitize=null |
ddf6fe37 | 16935 | @item -fsanitize=null |
d77de738 ML |
16936 | This option enables pointer checking. Particularly, the application |
16937 | built with this option turned on will issue an error message when it | |
16938 | tries to dereference a NULL pointer, or if a reference (possibly an | |
16939 | rvalue reference) is bound to a NULL pointer, or if a method is invoked | |
16940 | on an object pointed by a NULL pointer. | |
16941 | ||
d77de738 | 16942 | @opindex fsanitize=return |
ddf6fe37 | 16943 | @item -fsanitize=return |
d77de738 ML |
16944 | This option enables return statement checking. Programs |
16945 | built with this option turned on will issue an error message | |
16946 | when the end of a non-void function is reached without actually | |
16947 | returning a value. This option works in C++ only. | |
16948 | ||
d77de738 | 16949 | @opindex fsanitize=signed-integer-overflow |
ddf6fe37 | 16950 | @item -fsanitize=signed-integer-overflow |
d77de738 ML |
16951 | This option enables signed integer overflow checking. We check that |
16952 | the result of @code{+}, @code{*}, and both unary and binary @code{-} | |
16953 | does not overflow in the signed arithmetics. This also detects | |
16954 | @code{INT_MIN / -1} signed division. Note, integer promotion | |
16955 | rules must be taken into account. That is, the following is not an | |
16956 | overflow: | |
16957 | @smallexample | |
16958 | signed char a = SCHAR_MAX; | |
16959 | a++; | |
16960 | @end smallexample | |
16961 | ||
d77de738 | 16962 | @opindex fsanitize=bounds |
ddf6fe37 | 16963 | @item -fsanitize=bounds |
d77de738 ML |
16964 | This option enables instrumentation of array bounds. Various out of bounds |
16965 | accesses are detected. Flexible array members, flexible array member-like | |
c7728805 JJ |
16966 | arrays, and initializers of variables with static storage are not |
16967 | instrumented, with the exception of flexible array member-like arrays | |
16968 | for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=} | |
16969 | options or @code{strict_flex_array} attributes say they shouldn't be treated | |
16970 | like flexible array member-like arrays. | |
d77de738 | 16971 | |
d77de738 | 16972 | @opindex fsanitize=bounds-strict |
ddf6fe37 | 16973 | @item -fsanitize=bounds-strict |
d77de738 | 16974 | This option enables strict instrumentation of array bounds. Most out of bounds |
c7728805 JJ |
16975 | accesses are detected, including flexible array member-like arrays. |
16976 | Initializers of variables with static storage are not instrumented. | |
d77de738 | 16977 | |
d77de738 | 16978 | @opindex fsanitize=alignment |
ddf6fe37 | 16979 | @item -fsanitize=alignment |
d77de738 ML |
16980 | |
16981 | This option enables checking of alignment of pointers when they are | |
16982 | dereferenced, or when a reference is bound to insufficiently aligned target, | |
16983 | or when a method or constructor is invoked on insufficiently aligned object. | |
16984 | ||
d77de738 | 16985 | @opindex fsanitize=object-size |
ddf6fe37 | 16986 | @item -fsanitize=object-size |
d77de738 | 16987 | This option enables instrumentation of memory references using the |
7283380a SP |
16988 | @code{__builtin_dynamic_object_size} function. Various out of bounds |
16989 | pointer accesses are detected. | |
d77de738 | 16990 | |
d77de738 | 16991 | @opindex fsanitize=float-divide-by-zero |
ddf6fe37 | 16992 | @item -fsanitize=float-divide-by-zero |
d77de738 ML |
16993 | Detect floating-point division by zero. Unlike other similar options, |
16994 | @option{-fsanitize=float-divide-by-zero} is not enabled by | |
16995 | @option{-fsanitize=undefined}, since floating-point division by zero can | |
16996 | be a legitimate way of obtaining infinities and NaNs. | |
16997 | ||
d77de738 | 16998 | @opindex fsanitize=float-cast-overflow |
ddf6fe37 | 16999 | @item -fsanitize=float-cast-overflow |
d77de738 ML |
17000 | This option enables floating-point type to integer conversion checking. |
17001 | We check that the result of the conversion does not overflow. | |
17002 | Unlike other similar options, @option{-fsanitize=float-cast-overflow} is | |
17003 | not enabled by @option{-fsanitize=undefined}. | |
17004 | This option does not work well with @code{FE_INVALID} exceptions enabled. | |
17005 | ||
d77de738 | 17006 | @opindex fsanitize=nonnull-attribute |
ddf6fe37 | 17007 | @item -fsanitize=nonnull-attribute |
d77de738 ML |
17008 | |
17009 | This option enables instrumentation of calls, checking whether null values | |
17010 | are not passed to arguments marked as requiring a non-null value by the | |
17011 | @code{nonnull} function attribute. | |
17012 | ||
d77de738 | 17013 | @opindex fsanitize=returns-nonnull-attribute |
ddf6fe37 | 17014 | @item -fsanitize=returns-nonnull-attribute |
d77de738 ML |
17015 | |
17016 | This option enables instrumentation of return statements in functions | |
17017 | marked with @code{returns_nonnull} function attribute, to detect returning | |
17018 | of null values from such functions. | |
17019 | ||
d77de738 | 17020 | @opindex fsanitize=bool |
ddf6fe37 | 17021 | @item -fsanitize=bool |
d77de738 ML |
17022 | |
17023 | This option enables instrumentation of loads from bool. If a value other | |
17024 | than 0/1 is loaded, a run-time error is issued. | |
17025 | ||
d77de738 | 17026 | @opindex fsanitize=enum |
ddf6fe37 | 17027 | @item -fsanitize=enum |
d77de738 ML |
17028 | |
17029 | This option enables instrumentation of loads from an enum type. If | |
17030 | a value outside the range of values for the enum type is loaded, | |
17031 | a run-time error is issued. | |
17032 | ||
d77de738 | 17033 | @opindex fsanitize=vptr |
ddf6fe37 | 17034 | @item -fsanitize=vptr |
d77de738 ML |
17035 | |
17036 | This option enables instrumentation of C++ member function calls, member | |
17037 | accesses and some conversions between pointers to base and derived classes, | |
17038 | to verify the referenced object has the correct dynamic type. | |
17039 | ||
d77de738 | 17040 | @opindex fsanitize=pointer-overflow |
ddf6fe37 | 17041 | @item -fsanitize=pointer-overflow |
d77de738 ML |
17042 | |
17043 | This option enables instrumentation of pointer arithmetics. If the pointer | |
17044 | arithmetics overflows, a run-time error is issued. | |
17045 | ||
d77de738 | 17046 | @opindex fsanitize=builtin |
ddf6fe37 | 17047 | @item -fsanitize=builtin |
d77de738 ML |
17048 | |
17049 | This option enables instrumentation of arguments to selected builtin | |
17050 | functions. If an invalid value is passed to such arguments, a run-time | |
17051 | error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz} | |
17052 | or @code{__builtin_clz} invokes undefined behavior and is diagnosed | |
17053 | by this option. | |
17054 | ||
17055 | @end table | |
17056 | ||
17057 | Note that sanitizers tend to increase the rate of false positive | |
17058 | warnings, most notably those around @option{-Wmaybe-uninitialized}. | |
17059 | We recommend against combining @option{-Werror} and [the use of] | |
17060 | sanitizers. | |
17061 | ||
17062 | While @option{-ftrapv} causes traps for signed overflows to be emitted, | |
17063 | @option{-fsanitize=undefined} gives a diagnostic message. | |
17064 | This currently works only for the C family of languages. | |
17065 | ||
d77de738 | 17066 | @opindex fno-sanitize=all |
ddf6fe37 | 17067 | @item -fno-sanitize=all |
d77de738 ML |
17068 | |
17069 | This option disables all previously enabled sanitizers. | |
17070 | @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used | |
17071 | together. | |
17072 | ||
d77de738 | 17073 | @opindex fasan-shadow-offset |
ddf6fe37 | 17074 | @item -fasan-shadow-offset=@var{number} |
d77de738 ML |
17075 | This option forces GCC to use custom shadow offset in AddressSanitizer checks. |
17076 | It is useful for experimenting with different shadow memory layouts in | |
17077 | Kernel AddressSanitizer. | |
17078 | ||
d77de738 | 17079 | @opindex fsanitize-sections |
ddf6fe37 | 17080 | @item -fsanitize-sections=@var{s1},@var{s2},... |
d77de738 ML |
17081 | Sanitize global variables in selected user-defined sections. @var{si} may |
17082 | contain wildcards. | |
17083 | ||
d77de738 ML |
17084 | @opindex fsanitize-recover |
17085 | @opindex fno-sanitize-recover | |
ddf6fe37 | 17086 | @item -fsanitize-recover@r{[}=@var{opts}@r{]} |
d77de738 ML |
17087 | @option{-fsanitize-recover=} controls error recovery mode for sanitizers |
17088 | mentioned in comma-separated list of @var{opts}. Enabling this option | |
17089 | for a sanitizer component causes it to attempt to continue | |
17090 | running the program as if no error happened. This means multiple | |
17091 | runtime errors can be reported in a single program run, and the exit | |
17092 | code of the program may indicate success even when errors | |
17093 | have been reported. The @option{-fno-sanitize-recover=} option | |
17094 | can be used to alter | |
17095 | this behavior: only the first detected error is reported | |
17096 | and program then exits with a non-zero exit code. | |
17097 | ||
17098 | Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions | |
17099 | except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}), | |
17100 | @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero}, | |
17101 | @option{-fsanitize=bounds-strict}, | |
17102 | @option{-fsanitize=kernel-address} and @option{-fsanitize=address}. | |
17103 | For these sanitizers error recovery is turned on by default, | |
17104 | except @option{-fsanitize=address}, for which this feature is experimental. | |
17105 | @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also | |
17106 | accepted, the former enables recovery for all sanitizers that support it, | |
17107 | the latter disables recovery for all sanitizers that support it. | |
17108 | ||
17109 | Even if a recovery mode is turned on the compiler side, it needs to be also | |
17110 | enabled on the runtime library side, otherwise the failures are still fatal. | |
17111 | The runtime library defaults to @code{halt_on_error=0} for | |
17112 | ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for | |
17113 | AddressSanitizer is @code{halt_on_error=1}. This can be overridden through | |
17114 | setting the @code{halt_on_error} flag in the corresponding environment variable. | |
17115 | ||
17116 | Syntax without an explicit @var{opts} parameter is deprecated. It is | |
17117 | equivalent to specifying an @var{opts} list of: | |
17118 | ||
17119 | @smallexample | |
17120 | undefined,float-cast-overflow,float-divide-by-zero,bounds-strict | |
17121 | @end smallexample | |
17122 | ||
d77de738 | 17123 | @opindex fsanitize-address-use-after-scope |
ddf6fe37 | 17124 | @item -fsanitize-address-use-after-scope |
d77de738 ML |
17125 | Enable sanitization of local variables to detect use-after-scope bugs. |
17126 | The option sets @option{-fstack-reuse} to @samp{none}. | |
17127 | ||
d77de738 ML |
17128 | @opindex fsanitize-trap |
17129 | @opindex fno-sanitize-trap | |
ddf6fe37 | 17130 | @item -fsanitize-trap@r{[}=@var{opts}@r{]} |
d77de738 ML |
17131 | The @option{-fsanitize-trap=} option instructs the compiler to |
17132 | report for sanitizers mentioned in comma-separated list of @var{opts} | |
17133 | undefined behavior using @code{__builtin_trap} rather than a @code{libubsan} | |
17134 | library routine. If this option is enabled for certain sanitizer, | |
17135 | it takes precedence over the @option{-fsanitizer-recover=} for that | |
17136 | sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless | |
17137 | of whether recovery is enabled or disabled using @option{-fsanitize-recover=}. | |
17138 | ||
17139 | The advantage of this is that the @code{libubsan} library is not needed | |
17140 | and is not linked in, so this is usable even in freestanding environments. | |
17141 | ||
17142 | Currently this feature works with @option{-fsanitize=undefined} (and its suboptions | |
17143 | except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow}, | |
17144 | @option{-fsanitize=float-divide-by-zero} and | |
17145 | @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also | |
17146 | specified, which enables it for @code{undefined} suboptions, | |
17147 | @option{-fsanitize=float-cast-overflow}, | |
17148 | @option{-fsanitize=float-divide-by-zero} and | |
17149 | @option{-fsanitize=bounds-strict}. | |
17150 | If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used | |
17151 | and @code{-fsanitize=vptr} is enabled on the command line, the | |
17152 | instrumentation is silently ignored as the instrumentation always needs | |
17153 | @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed. | |
17154 | ||
d77de738 | 17155 | @opindex fsanitize-undefined-trap-on-error |
ddf6fe37 | 17156 | @item -fsanitize-undefined-trap-on-error |
d77de738 ML |
17157 | The @option{-fsanitize-undefined-trap-on-error} option is deprecated |
17158 | equivalent of @option{-fsanitize-trap=all}. | |
17159 | ||
d77de738 | 17160 | @opindex fsanitize-coverage=trace-pc |
ddf6fe37 | 17161 | @item -fsanitize-coverage=trace-pc |
d77de738 ML |
17162 | Enable coverage-guided fuzzing code instrumentation. |
17163 | Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block. | |
17164 | ||
d77de738 | 17165 | @opindex fsanitize-coverage=trace-cmp |
ddf6fe37 | 17166 | @item -fsanitize-coverage=trace-cmp |
d77de738 ML |
17167 | Enable dataflow guided fuzzing code instrumentation. |
17168 | Inserts a call to @code{__sanitizer_cov_trace_cmp1}, | |
17169 | @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or | |
17170 | @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands | |
17171 | variable or @code{__sanitizer_cov_trace_const_cmp1}, | |
17172 | @code{__sanitizer_cov_trace_const_cmp2}, | |
17173 | @code{__sanitizer_cov_trace_const_cmp4} or | |
17174 | @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one | |
17175 | operand constant, @code{__sanitizer_cov_trace_cmpf} or | |
17176 | @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and | |
17177 | @code{__sanitizer_cov_trace_switch} for switch statements. | |
17178 | ||
d77de738 | 17179 | @opindex fcf-protection |
ddf6fe37 | 17180 | @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} |
d77de738 ML |
17181 | Enable code instrumentation of control-flow transfers to increase |
17182 | program security by checking that target addresses of control-flow | |
17183 | transfer instructions (such as indirect function call, function return, | |
17184 | indirect jump) are valid. This prevents diverting the flow of control | |
17185 | to an unexpected target. This is intended to protect against such | |
17186 | threats as Return-oriented Programming (ROP), and similarly | |
17187 | call/jmp-oriented programming (COP/JOP). | |
17188 | ||
17189 | The value @code{branch} tells the compiler to implement checking of | |
17190 | validity of control-flow transfer at the point of indirect branch | |
17191 | instructions, i.e.@: call/jmp instructions. The value @code{return} | |
17192 | implements checking of validity at the point of returning from a | |
17193 | function. The value @code{full} is an alias for specifying both | |
17194 | @code{branch} and @code{return}. The value @code{none} turns off | |
17195 | instrumentation. | |
17196 | ||
17197 | The value @code{check} is used for the final link with link-time | |
17198 | optimization (LTO). An error is issued if LTO object files are | |
17199 | compiled with different @option{-fcf-protection} values. The | |
17200 | value @code{check} is ignored at the compile time. | |
17201 | ||
17202 | The macro @code{__CET__} is defined when @option{-fcf-protection} is | |
17203 | used. The first bit of @code{__CET__} is set to 1 for the value | |
17204 | @code{branch} and the second bit of @code{__CET__} is set to 1 for | |
17205 | the @code{return}. | |
17206 | ||
17207 | You can also use the @code{nocf_check} attribute to identify | |
17208 | which functions and calls should be skipped from instrumentation | |
17209 | (@pxref{Function Attributes}). | |
17210 | ||
17211 | Currently the x86 GNU/Linux target provides an implementation based | |
17212 | on Intel Control-flow Enforcement Technology (CET) which works for | |
17213 | i686 processor or newer. | |
17214 | ||
d77de738 | 17215 | @opindex fharden-compares |
ddf6fe37 | 17216 | @item -fharden-compares |
d77de738 ML |
17217 | For every logical test that survives gimple optimizations and is |
17218 | @emph{not} the condition in a conditional branch (for example, | |
17219 | conditions tested for conditional moves, or to store in boolean | |
17220 | variables), emit extra code to compute and verify the reversed | |
17221 | condition, and to call @code{__builtin_trap} if the results do not | |
17222 | match. Use with @samp{-fharden-conditional-branches} to cover all | |
17223 | conditionals. | |
17224 | ||
d77de738 | 17225 | @opindex fharden-conditional-branches |
ddf6fe37 | 17226 | @item -fharden-conditional-branches |
d77de738 ML |
17227 | For every non-vectorized conditional branch that survives gimple |
17228 | optimizations, emit extra code to compute and verify the reversed | |
17229 | condition, and to call @code{__builtin_trap} if the result is | |
17230 | unexpected. Use with @samp{-fharden-compares} to cover all | |
17231 | conditionals. | |
17232 | ||
d77de738 | 17233 | @opindex fstack-protector |
ddf6fe37 | 17234 | @item -fstack-protector |
d77de738 ML |
17235 | Emit extra code to check for buffer overflows, such as stack smashing |
17236 | attacks. This is done by adding a guard variable to functions with | |
17237 | vulnerable objects. This includes functions that call @code{alloca}, and | |
17238 | functions with buffers larger than or equal to 8 bytes. The guards are | |
17239 | initialized when a function is entered and then checked when the function | |
17240 | exits. If a guard check fails, an error message is printed and the program | |
17241 | exits. Only variables that are actually allocated on the stack are | |
17242 | considered, optimized away variables or variables allocated in registers | |
17243 | don't count. | |
17244 | ||
d77de738 | 17245 | @opindex fstack-protector-all |
ddf6fe37 | 17246 | @item -fstack-protector-all |
d77de738 ML |
17247 | Like @option{-fstack-protector} except that all functions are protected. |
17248 | ||
d77de738 | 17249 | @opindex fstack-protector-strong |
ddf6fe37 | 17250 | @item -fstack-protector-strong |
d77de738 ML |
17251 | Like @option{-fstack-protector} but includes additional functions to |
17252 | be protected --- those that have local array definitions, or have | |
17253 | references to local frame addresses. Only variables that are actually | |
17254 | allocated on the stack are considered, optimized away variables or variables | |
17255 | allocated in registers don't count. | |
17256 | ||
d77de738 | 17257 | @opindex fstack-protector-explicit |
ddf6fe37 | 17258 | @item -fstack-protector-explicit |
d77de738 ML |
17259 | Like @option{-fstack-protector} but only protects those functions which |
17260 | have the @code{stack_protect} attribute. | |
17261 | ||
d77de738 | 17262 | @opindex fstack-check |
ddf6fe37 | 17263 | @item -fstack-check |
d77de738 ML |
17264 | Generate code to verify that you do not go beyond the boundary of the |
17265 | stack. You should specify this flag if you are running in an | |
17266 | environment with multiple threads, but you only rarely need to specify it in | |
17267 | a single-threaded environment since stack overflow is automatically | |
17268 | detected on nearly all systems if there is only one stack. | |
17269 | ||
17270 | Note that this switch does not actually cause checking to be done; the | |
17271 | operating system or the language runtime must do that. The switch causes | |
17272 | generation of code to ensure that they see the stack being extended. | |
17273 | ||
17274 | You can additionally specify a string parameter: @samp{no} means no | |
17275 | checking, @samp{generic} means force the use of old-style checking, | |
17276 | @samp{specific} means use the best checking method and is equivalent | |
17277 | to bare @option{-fstack-check}. | |
17278 | ||
17279 | Old-style checking is a generic mechanism that requires no specific | |
17280 | target support in the compiler but comes with the following drawbacks: | |
17281 | ||
17282 | @enumerate | |
17283 | @item | |
17284 | Modified allocation strategy for large objects: they are always | |
17285 | allocated dynamically if their size exceeds a fixed threshold. Note this | |
17286 | may change the semantics of some code. | |
17287 | ||
17288 | @item | |
17289 | Fixed limit on the size of the static frame of functions: when it is | |
17290 | topped by a particular function, stack checking is not reliable and | |
17291 | a warning is issued by the compiler. | |
17292 | ||
17293 | @item | |
17294 | Inefficiency: because of both the modified allocation strategy and the | |
17295 | generic implementation, code performance is hampered. | |
17296 | @end enumerate | |
17297 | ||
17298 | Note that old-style stack checking is also the fallback method for | |
17299 | @samp{specific} if no target support has been added in the compiler. | |
17300 | ||
17301 | @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion | |
17302 | and stack overflows. @samp{specific} is an excellent choice when compiling | |
17303 | Ada code. It is not generally sufficient to protect against stack-clash | |
17304 | attacks. To protect against those you want @samp{-fstack-clash-protection}. | |
17305 | ||
d77de738 | 17306 | @opindex fstack-clash-protection |
ddf6fe37 | 17307 | @item -fstack-clash-protection |
d77de738 ML |
17308 | Generate code to prevent stack clash style attacks. When this option is |
17309 | enabled, the compiler will only allocate one page of stack space at a time | |
17310 | and each page is accessed immediately after allocation. Thus, it prevents | |
17311 | allocations from jumping over any stack guard page provided by the | |
17312 | operating system. | |
17313 | ||
17314 | Most targets do not fully support stack clash protection. However, on | |
17315 | those targets @option{-fstack-clash-protection} will protect dynamic stack | |
17316 | allocations. @option{-fstack-clash-protection} may also provide limited | |
17317 | protection for static stack allocations if the target supports | |
17318 | @option{-fstack-check=specific}. | |
17319 | ||
d77de738 ML |
17320 | @opindex fstack-limit-register |
17321 | @opindex fstack-limit-symbol | |
17322 | @opindex fno-stack-limit | |
ddf6fe37 AA |
17323 | @item -fstack-limit-register=@var{reg} |
17324 | @itemx -fstack-limit-symbol=@var{sym} | |
17325 | @itemx -fno-stack-limit | |
d77de738 ML |
17326 | Generate code to ensure that the stack does not grow beyond a certain value, |
17327 | either the value of a register or the address of a symbol. If a larger | |
17328 | stack is required, a signal is raised at run time. For most targets, | |
17329 | the signal is raised before the stack overruns the boundary, so | |
17330 | it is possible to catch the signal without taking special precautions. | |
17331 | ||
17332 | For instance, if the stack starts at absolute address @samp{0x80000000} | |
17333 | and grows downwards, you can use the flags | |
17334 | @option{-fstack-limit-symbol=__stack_limit} and | |
17335 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
17336 | of 128KB@. Note that this may only work with the GNU linker. | |
17337 | ||
17338 | You can locally override stack limit checking by using the | |
17339 | @code{no_stack_limit} function attribute (@pxref{Function Attributes}). | |
17340 | ||
d77de738 | 17341 | @opindex fsplit-stack |
ddf6fe37 | 17342 | @item -fsplit-stack |
d77de738 ML |
17343 | Generate code to automatically split the stack before it overflows. |
17344 | The resulting program has a discontiguous stack which can only | |
17345 | overflow if the program is unable to allocate any more memory. This | |
17346 | is most useful when running threaded programs, as it is no longer | |
17347 | necessary to calculate a good stack size to use for each thread. This | |
17348 | is currently only implemented for the x86 targets running | |
17349 | GNU/Linux. | |
17350 | ||
17351 | When code compiled with @option{-fsplit-stack} calls code compiled | |
17352 | without @option{-fsplit-stack}, there may not be much stack space | |
17353 | available for the latter code to run. If compiling all code, | |
17354 | including library code, with @option{-fsplit-stack} is not an option, | |
17355 | then the linker can fix up these calls so that the code compiled | |
17356 | without @option{-fsplit-stack} always has a large stack. Support for | |
17357 | this is implemented in the gold linker in GNU binutils release 2.21 | |
17358 | and later. | |
17359 | ||
d77de738 | 17360 | @opindex fvtable-verify |
ddf6fe37 | 17361 | @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} |
d77de738 ML |
17362 | This option is only available when compiling C++ code. |
17363 | It turns on (or off, if using @option{-fvtable-verify=none}) the security | |
17364 | feature that verifies at run time, for every virtual call, that | |
17365 | the vtable pointer through which the call is made is valid for the type of | |
17366 | the object, and has not been corrupted or overwritten. If an invalid vtable | |
17367 | pointer is detected at run time, an error is reported and execution of the | |
17368 | program is immediately halted. | |
17369 | ||
17370 | This option causes run-time data structures to be built at program startup, | |
17371 | which are used for verifying the vtable pointers. | |
17372 | The options @samp{std} and @samp{preinit} | |
17373 | control the timing of when these data structures are built. In both cases the | |
17374 | data structures are built before execution reaches @code{main}. Using | |
17375 | @option{-fvtable-verify=std} causes the data structures to be built after | |
17376 | shared libraries have been loaded and initialized. | |
17377 | @option{-fvtable-verify=preinit} causes them to be built before shared | |
17378 | libraries have been loaded and initialized. | |
17379 | ||
17380 | If this option appears multiple times in the command line with different | |
17381 | values specified, @samp{none} takes highest priority over both @samp{std} and | |
17382 | @samp{preinit}; @samp{preinit} takes priority over @samp{std}. | |
17383 | ||
d77de738 | 17384 | @opindex fvtv-debug |
ddf6fe37 | 17385 | @item -fvtv-debug |
d77de738 ML |
17386 | When used in conjunction with @option{-fvtable-verify=std} or |
17387 | @option{-fvtable-verify=preinit}, causes debug versions of the | |
17388 | runtime functions for the vtable verification feature to be called. | |
17389 | This flag also causes the compiler to log information about which | |
17390 | vtable pointers it finds for each class. | |
17391 | This information is written to a file named @file{vtv_set_ptr_data.log} | |
17392 | in the directory named by the environment variable @env{VTV_LOGS_DIR} | |
17393 | if that is defined or the current working directory otherwise. | |
17394 | ||
17395 | Note: This feature @emph{appends} data to the log file. If you want a fresh log | |
17396 | file, be sure to delete any existing one. | |
17397 | ||
d77de738 | 17398 | @opindex fvtv-counts |
ddf6fe37 | 17399 | @item -fvtv-counts |
d77de738 ML |
17400 | This is a debugging flag. When used in conjunction with |
17401 | @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this | |
17402 | causes the compiler to keep track of the total number of virtual calls | |
17403 | it encounters and the number of verifications it inserts. It also | |
17404 | counts the number of calls to certain run-time library functions | |
17405 | that it inserts and logs this information for each compilation unit. | |
17406 | The compiler writes this information to a file named | |
17407 | @file{vtv_count_data.log} in the directory named by the environment | |
17408 | variable @env{VTV_LOGS_DIR} if that is defined or the current working | |
17409 | directory otherwise. It also counts the size of the vtable pointer sets | |
17410 | for each class, and writes this information to @file{vtv_class_set_sizes.log} | |
17411 | in the same directory. | |
17412 | ||
17413 | Note: This feature @emph{appends} data to the log files. To get fresh log | |
17414 | files, be sure to delete any existing ones. | |
17415 | ||
d77de738 | 17416 | @opindex finstrument-functions |
ddf6fe37 | 17417 | @item -finstrument-functions |
d77de738 ML |
17418 | Generate instrumentation calls for entry and exit to functions. Just |
17419 | after function entry and just before function exit, the following | |
17420 | profiling functions are called with the address of the current | |
17421 | function and its call site. (On some platforms, | |
17422 | @code{__builtin_return_address} does not work beyond the current | |
17423 | function, so the call site information may not be available to the | |
17424 | profiling functions otherwise.) | |
17425 | ||
17426 | @smallexample | |
17427 | void __cyg_profile_func_enter (void *this_fn, | |
17428 | void *call_site); | |
17429 | void __cyg_profile_func_exit (void *this_fn, | |
17430 | void *call_site); | |
17431 | @end smallexample | |
17432 | ||
17433 | The first argument is the address of the start of the current function, | |
17434 | which may be looked up exactly in the symbol table. | |
17435 | ||
17436 | This instrumentation is also done for functions expanded inline in other | |
17437 | functions. The profiling calls indicate where, conceptually, the | |
17438 | inline function is entered and exited. This means that addressable | |
17439 | versions of such functions must be available. If all your uses of a | |
17440 | function are expanded inline, this may mean an additional expansion of | |
17441 | code size. If you use @code{extern inline} in your C code, an | |
17442 | addressable version of such functions must be provided. (This is | |
17443 | normally the case anyway, but if you get lucky and the optimizer always | |
17444 | expands the functions inline, you might have gotten away without | |
17445 | providing static copies.) | |
17446 | ||
17447 | A function may be given the attribute @code{no_instrument_function}, in | |
17448 | which case this instrumentation is not done. This can be used, for | |
17449 | example, for the profiling functions listed above, high-priority | |
17450 | interrupt routines, and any functions from which the profiling functions | |
17451 | cannot safely be called (perhaps signal handlers, if the profiling | |
17452 | routines generate output or allocate memory). | |
17453 | @xref{Common Function Attributes}. | |
17454 | ||
9c19597c | 17455 | @opindex finstrument-functions-once |
ddf6fe37 | 17456 | @item -finstrument-functions-once |
d77de738 ML |
17457 | This is similar to @option{-finstrument-functions}, but the profiling |
17458 | functions are called only once per instrumented function, i.e. the first | |
17459 | profiling function is called after the first entry into the instrumented | |
17460 | function and the second profiling function is called before the exit | |
17461 | corresponding to this first entry. | |
17462 | ||
17463 | The definition of @code{once} for the purpose of this option is a little | |
17464 | vague because the implementation is not protected against data races. | |
17465 | As a result, the implementation only guarantees that the profiling | |
17466 | functions are called at @emph{least} once per process and at @emph{most} | |
17467 | once per thread, but the calls are always paired, that is to say, if a | |
17468 | thread calls the first function, then it will call the second function, | |
17469 | unless it never reaches the exit of the instrumented function. | |
17470 | ||
d77de738 | 17471 | @opindex finstrument-functions-exclude-file-list |
ddf6fe37 | 17472 | @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} |
d77de738 ML |
17473 | |
17474 | Set the list of functions that are excluded from instrumentation (see | |
17475 | the description of @option{-finstrument-functions}). If the file that | |
17476 | contains a function definition matches with one of @var{file}, then | |
17477 | that function is not instrumented. The match is done on substrings: | |
17478 | if the @var{file} parameter is a substring of the file name, it is | |
17479 | considered to be a match. | |
17480 | ||
17481 | For example: | |
17482 | ||
17483 | @smallexample | |
17484 | -finstrument-functions-exclude-file-list=/bits/stl,include/sys | |
17485 | @end smallexample | |
17486 | ||
17487 | @noindent | |
17488 | excludes any inline function defined in files whose pathnames | |
17489 | contain @file{/bits/stl} or @file{include/sys}. | |
17490 | ||
17491 | If, for some reason, you want to include letter @samp{,} in one of | |
17492 | @var{sym}, write @samp{\,}. For example, | |
17493 | @option{-finstrument-functions-exclude-file-list='\,\,tmp'} | |
17494 | (note the single quote surrounding the option). | |
17495 | ||
d77de738 | 17496 | @opindex finstrument-functions-exclude-function-list |
ddf6fe37 | 17497 | @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} |
d77de738 ML |
17498 | |
17499 | This is similar to @option{-finstrument-functions-exclude-file-list}, | |
17500 | but this option sets the list of function names to be excluded from | |
17501 | instrumentation. The function name to be matched is its user-visible | |
17502 | name, such as @code{vector<int> blah(const vector<int> &)}, not the | |
17503 | internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The | |
17504 | match is done on substrings: if the @var{sym} parameter is a substring | |
17505 | of the function name, it is considered to be a match. For C99 and C++ | |
17506 | extended identifiers, the function name must be given in UTF-8, not | |
17507 | using universal character names. | |
17508 | ||
d77de738 | 17509 | @opindex fpatchable-function-entry |
ddf6fe37 | 17510 | @item -fpatchable-function-entry=@var{N}[,@var{M}] |
d77de738 ML |
17511 | Generate @var{N} NOPs right at the beginning |
17512 | of each function, with the function entry point before the @var{M}th NOP. | |
17513 | If @var{M} is omitted, it defaults to @code{0} so the | |
17514 | function entry points to the address just at the first NOP. | |
17515 | The NOP instructions reserve extra space which can be used to patch in | |
17516 | any desired instrumentation at run time, provided that the code segment | |
17517 | is writable. The amount of space is controllable indirectly via | |
17518 | the number of NOPs; the NOP instruction used corresponds to the instruction | |
17519 | emitted by the internal GCC back-end interface @code{gen_nop}. This behavior | |
17520 | is target-specific and may also depend on the architecture variant and/or | |
17521 | other compilation options. | |
17522 | ||
17523 | For run-time identification, the starting addresses of these areas, | |
17524 | which correspond to their respective function entries minus @var{M}, | |
17525 | are additionally collected in the @code{__patchable_function_entries} | |
17526 | section of the resulting binary. | |
17527 | ||
17528 | Note that the value of @code{__attribute__ ((patchable_function_entry | |
17529 | (N,M)))} takes precedence over command-line option | |
17530 | @option{-fpatchable-function-entry=N,M}. This can be used to increase | |
17531 | the area size or to remove it completely on a single function. | |
17532 | If @code{N=0}, no pad location is recorded. | |
17533 | ||
17534 | The NOP instructions are inserted at---and maybe before, depending on | |
17535 | @var{M}---the function entry address, even before the prologue. On | |
17536 | PowerPC with the ELFv2 ABI, for a function with dual entry points, | |
17537 | the local entry point is this function entry address. | |
17538 | ||
17539 | The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the | |
17540 | ELFv2 ABI, for a function with dual entry points, the supported values | |
17541 | for @var{M} are 0, 2, 6 and 14. | |
17542 | @end table | |
17543 | ||
17544 | ||
17545 | @node Preprocessor Options | |
17546 | @section Options Controlling the Preprocessor | |
17547 | @cindex preprocessor options | |
17548 | @cindex options, preprocessor | |
17549 | ||
17550 | These options control the C preprocessor, which is run on each C source | |
17551 | file before actual compilation. | |
17552 | ||
17553 | If you use the @option{-E} option, nothing is done except preprocessing. | |
17554 | Some of these options make sense only together with @option{-E} because | |
17555 | they cause the preprocessor output to be unsuitable for actual | |
17556 | compilation. | |
17557 | ||
17558 | In addition to the options listed here, there are a number of options | |
17559 | to control search paths for include files documented in | |
17560 | @ref{Directory Options}. | |
17561 | Options to control preprocessor diagnostics are listed in | |
17562 | @ref{Warning Options}. | |
17563 | ||
17564 | @table @gcctabopt | |
17565 | @include cppopts.texi | |
17566 | ||
d77de738 | 17567 | @opindex Wp |
ddf6fe37 | 17568 | @item -Wp,@var{option} |
d77de738 ML |
17569 | You can use @option{-Wp,@var{option}} to bypass the compiler driver |
17570 | and pass @var{option} directly through to the preprocessor. If | |
17571 | @var{option} contains commas, it is split into multiple options at the | |
17572 | commas. However, many options are modified, translated or interpreted | |
17573 | by the compiler driver before being passed to the preprocessor, and | |
17574 | @option{-Wp} forcibly bypasses this phase. The preprocessor's direct | |
17575 | interface is undocumented and subject to change, so whenever possible | |
17576 | you should avoid using @option{-Wp} and let the driver handle the | |
17577 | options instead. | |
17578 | ||
d77de738 | 17579 | @opindex Xpreprocessor |
ddf6fe37 | 17580 | @item -Xpreprocessor @var{option} |
d77de738 ML |
17581 | Pass @var{option} as an option to the preprocessor. You can use this to |
17582 | supply system-specific preprocessor options that GCC does not | |
17583 | recognize. | |
17584 | ||
17585 | If you want to pass an option that takes an argument, you must use | |
17586 | @option{-Xpreprocessor} twice, once for the option and once for the argument. | |
17587 | ||
d77de738 | 17588 | @opindex no-integrated-cpp |
ddf6fe37 | 17589 | @item -no-integrated-cpp |
d77de738 ML |
17590 | Perform preprocessing as a separate pass before compilation. |
17591 | By default, GCC performs preprocessing as an integrated part of | |
17592 | input tokenization and parsing. | |
17593 | If this option is provided, the appropriate language front end | |
17594 | (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++, | |
17595 | and Objective-C, respectively) is instead invoked twice, | |
17596 | once for preprocessing only and once for actual compilation | |
17597 | of the preprocessed input. | |
17598 | This option may be useful in conjunction with the @option{-B} or | |
17599 | @option{-wrapper} options to specify an alternate preprocessor or | |
17600 | perform additional processing of the program source between | |
17601 | normal preprocessing and compilation. | |
17602 | ||
d77de738 | 17603 | @opindex flarge-source-files |
ddf6fe37 | 17604 | @item -flarge-source-files |
d77de738 ML |
17605 | Adjust GCC to expect large source files, at the expense of slower |
17606 | compilation and higher memory usage. | |
17607 | ||
17608 | Specifically, GCC normally tracks both column numbers and line numbers | |
17609 | within source files and it normally prints both of these numbers in | |
17610 | diagnostics. However, once it has processed a certain number of source | |
17611 | lines, it stops tracking column numbers and only tracks line numbers. | |
17612 | This means that diagnostics for later lines do not include column numbers. | |
17613 | It also means that options like @option{-Wmisleading-indentation} cease to work | |
17614 | at that point, although the compiler prints a note if this happens. | |
17615 | Passing @option{-flarge-source-files} significantly increases the number | |
17616 | of source lines that GCC can process before it stops tracking columns. | |
17617 | ||
17618 | @end table | |
17619 | ||
17620 | @node Assembler Options | |
17621 | @section Passing Options to the Assembler | |
17622 | ||
17623 | @c prevent bad page break with this line | |
17624 | You can pass options to the assembler. | |
17625 | ||
17626 | @table @gcctabopt | |
d77de738 | 17627 | @opindex Wa |
ddf6fe37 | 17628 | @item -Wa,@var{option} |
d77de738 ML |
17629 | Pass @var{option} as an option to the assembler. If @var{option} |
17630 | contains commas, it is split into multiple options at the commas. | |
17631 | ||
d77de738 | 17632 | @opindex Xassembler |
ddf6fe37 | 17633 | @item -Xassembler @var{option} |
d77de738 ML |
17634 | Pass @var{option} as an option to the assembler. You can use this to |
17635 | supply system-specific assembler options that GCC does not | |
17636 | recognize. | |
17637 | ||
17638 | If you want to pass an option that takes an argument, you must use | |
17639 | @option{-Xassembler} twice, once for the option and once for the argument. | |
17640 | ||
17641 | @end table | |
17642 | ||
17643 | @node Link Options | |
17644 | @section Options for Linking | |
17645 | @cindex link options | |
17646 | @cindex options, linking | |
17647 | ||
17648 | These options come into play when the compiler links object files into | |
17649 | an executable output file. They are meaningless if the compiler is | |
17650 | not doing a link step. | |
17651 | ||
17652 | @table @gcctabopt | |
17653 | @cindex file names | |
17654 | @item @var{object-file-name} | |
17655 | A file name that does not end in a special recognized suffix is | |
17656 | considered to name an object file or library. (Object files are | |
17657 | distinguished from libraries by the linker according to the file | |
17658 | contents.) If linking is done, these object files are used as input | |
17659 | to the linker. | |
17660 | ||
d77de738 ML |
17661 | @opindex c |
17662 | @opindex S | |
17663 | @opindex E | |
ddf6fe37 AA |
17664 | @item -c |
17665 | @itemx -S | |
17666 | @itemx -E | |
d77de738 ML |
17667 | If any of these options is used, then the linker is not run, and |
17668 | object file names should not be used as arguments. @xref{Overall | |
17669 | Options}. | |
17670 | ||
d77de738 | 17671 | @opindex flinker-output |
ddf6fe37 | 17672 | @item -flinker-output=@var{type} |
d77de738 ML |
17673 | This option controls code generation of the link-time optimizer. By |
17674 | default the linker output is automatically determined by the linker | |
17675 | plugin. For debugging the compiler and if incremental linking with a | |
17676 | non-LTO object file is desired, it may be useful to control the type | |
17677 | manually. | |
17678 | ||
17679 | If @var{type} is @samp{exec}, code generation produces a static | |
17680 | binary. In this case @option{-fpic} and @option{-fpie} are both | |
17681 | disabled. | |
17682 | ||
17683 | If @var{type} is @samp{dyn}, code generation produces a shared | |
17684 | library. In this case @option{-fpic} or @option{-fPIC} is preserved, | |
17685 | but not enabled automatically. This allows to build shared libraries | |
17686 | without position-independent code on architectures where this is | |
17687 | possible, i.e.@: on x86. | |
17688 | ||
17689 | If @var{type} is @samp{pie}, code generation produces an @option{-fpie} | |
17690 | executable. This results in similar optimizations as @samp{exec} | |
17691 | except that @option{-fpie} is not disabled if specified at compilation | |
17692 | time. | |
17693 | ||
17694 | If @var{type} is @samp{rel}, the compiler assumes that incremental linking is | |
17695 | done. The sections containing intermediate code for link-time optimization are | |
17696 | merged, pre-optimized, and output to the resulting object file. In addition, if | |
17697 | @option{-ffat-lto-objects} is specified, binary code is produced for future | |
17698 | non-LTO linking. The object file produced by incremental linking is smaller | |
17699 | than a static library produced from the same object files. At link time the | |
17700 | result of incremental linking also loads faster than a static | |
17701 | library assuming that the majority of objects in the library are used. | |
17702 | ||
17703 | Finally @samp{nolto-rel} configures the compiler for incremental linking where | |
17704 | code generation is forced, a final binary is produced, and the intermediate | |
17705 | code for later link-time optimization is stripped. When multiple object files | |
17706 | are linked together the resulting code is better optimized than with | |
17707 | link-time optimizations disabled (for example, cross-module inlining | |
17708 | happens), but most of benefits of whole program optimizations are lost. | |
17709 | ||
17710 | During the incremental link (by @option{-r}) the linker plugin defaults to | |
17711 | @option{rel}. With current interfaces to GNU Binutils it is however not | |
17712 | possible to incrementally link LTO objects and non-LTO objects into a single | |
17713 | mixed object file. If any of object files in incremental link cannot | |
17714 | be used for link-time optimization, the linker plugin issues a warning and | |
17715 | uses @samp{nolto-rel}. To maintain whole program optimization, it is | |
17716 | recommended to link such objects into static library instead. Alternatively it | |
17717 | is possible to use H.J. Lu's binutils with support for mixed objects. | |
17718 | ||
d77de738 | 17719 | @opindex fuse-ld=bfd |
ddf6fe37 | 17720 | @item -fuse-ld=bfd |
d77de738 ML |
17721 | Use the @command{bfd} linker instead of the default linker. |
17722 | ||
d77de738 | 17723 | @opindex fuse-ld=gold |
ddf6fe37 | 17724 | @item -fuse-ld=gold |
d77de738 ML |
17725 | Use the @command{gold} linker instead of the default linker. |
17726 | ||
d77de738 | 17727 | @opindex fuse-ld=lld |
ddf6fe37 | 17728 | @item -fuse-ld=lld |
d77de738 ML |
17729 | Use the LLVM @command{lld} linker instead of the default linker. |
17730 | ||
d77de738 | 17731 | @opindex fuse-ld=mold |
ddf6fe37 | 17732 | @item -fuse-ld=mold |
d77de738 ML |
17733 | Use the Modern Linker (@command{mold}) instead of the default linker. |
17734 | ||
17735 | @cindex Libraries | |
ddf6fe37 | 17736 | @opindex l |
d77de738 ML |
17737 | @item -l@var{library} |
17738 | @itemx -l @var{library} | |
d77de738 ML |
17739 | Search the library named @var{library} when linking. (The second |
17740 | alternative with the library as a separate argument is only for | |
17741 | POSIX compliance and is not recommended.) | |
17742 | ||
17743 | The @option{-l} option is passed directly to the linker by GCC. Refer | |
17744 | to your linker documentation for exact details. The general | |
17745 | description below applies to the GNU linker. | |
17746 | ||
17747 | The linker searches a standard list of directories for the library. | |
17748 | The directories searched include several standard system directories | |
17749 | plus any that you specify with @option{-L}. | |
17750 | ||
17751 | Static libraries are archives of object files, and have file names | |
17752 | like @file{lib@var{library}.a}. Some targets also support shared | |
17753 | libraries, which typically have names like @file{lib@var{library}.so}. | |
17754 | If both static and shared libraries are found, the linker gives | |
17755 | preference to linking with the shared library unless the | |
17756 | @option{-static} option is used. | |
17757 | ||
17758 | It makes a difference where in the command you write this option; the | |
17759 | linker searches and processes libraries and object files in the order they | |
17760 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
17761 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
17762 | to functions in @samp{z}, those functions may not be loaded. | |
17763 | ||
d77de738 | 17764 | @opindex lobjc |
ddf6fe37 | 17765 | @item -lobjc |
d77de738 ML |
17766 | You need this special case of the @option{-l} option in order to |
17767 | link an Objective-C or Objective-C++ program. | |
17768 | ||
d77de738 | 17769 | @opindex nostartfiles |
ddf6fe37 | 17770 | @item -nostartfiles |
d77de738 ML |
17771 | Do not use the standard system startup files when linking. |
17772 | The standard system libraries are used normally, unless @option{-nostdlib}, | |
17773 | @option{-nolibc}, or @option{-nodefaultlibs} is used. | |
17774 | ||
d77de738 | 17775 | @opindex nodefaultlibs |
ddf6fe37 | 17776 | @item -nodefaultlibs |
d77de738 ML |
17777 | Do not use the standard system libraries when linking. |
17778 | Only the libraries you specify are passed to the linker, and options | |
17779 | specifying linkage of the system libraries, such as @option{-static-libgcc} | |
17780 | or @option{-shared-libgcc}, are ignored. | |
17781 | The standard startup files are used normally, unless @option{-nostartfiles} | |
17782 | is used. | |
17783 | ||
17784 | The compiler may generate calls to @code{memcmp}, | |
17785 | @code{memset}, @code{memcpy} and @code{memmove}. | |
17786 | These entries are usually resolved by entries in | |
17787 | libc. These entry points should be supplied through some other | |
17788 | mechanism when this option is specified. | |
17789 | ||
d77de738 | 17790 | @opindex nolibc |
ddf6fe37 | 17791 | @item -nolibc |
d77de738 ML |
17792 | Do not use the C library or system libraries tightly coupled with it when |
17793 | linking. Still link with the startup files, @file{libgcc} or toolchain | |
17794 | provided language support libraries such as @file{libgnat}, @file{libgfortran} | |
17795 | or @file{libstdc++} unless options preventing their inclusion are used as | |
17796 | well. This typically removes @option{-lc} from the link command line, as well | |
17797 | as system libraries that normally go with it and become meaningless when | |
17798 | absence of a C library is assumed, for example @option{-lpthread} or | |
17799 | @option{-lm} in some configurations. This is intended for bare-board | |
17800 | targets when there is indeed no C library available. | |
17801 | ||
d77de738 | 17802 | @opindex nostdlib |
ddf6fe37 | 17803 | @item -nostdlib |
d77de738 ML |
17804 | Do not use the standard system startup files or libraries when linking. |
17805 | No startup files and only the libraries you specify are passed to | |
17806 | the linker, and options specifying linkage of the system libraries, such as | |
17807 | @option{-static-libgcc} or @option{-shared-libgcc}, are ignored. | |
17808 | ||
17809 | The compiler may generate calls to @code{memcmp}, @code{memset}, | |
17810 | @code{memcpy} and @code{memmove}. | |
17811 | These entries are usually resolved by entries in | |
17812 | libc. These entry points should be supplied through some other | |
17813 | mechanism when this option is specified. | |
17814 | ||
17815 | @cindex @option{-lgcc}, use with @option{-nostdlib} | |
17816 | @cindex @option{-nostdlib} and unresolved references | |
17817 | @cindex unresolved references and @option{-nostdlib} | |
17818 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
17819 | @cindex @option{-nodefaultlibs} and unresolved references | |
17820 | @cindex unresolved references and @option{-nodefaultlibs} | |
17821 | One of the standard libraries bypassed by @option{-nostdlib} and | |
17822 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
17823 | which GCC uses to overcome shortcomings of particular machines, or special | |
17824 | needs for some languages. | |
17825 | (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler | |
17826 | Collection (GCC) Internals}, | |
17827 | for more discussion of @file{libgcc.a}.) | |
17828 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
17829 | other standard libraries. In other words, when you specify @option{-nostdlib} | |
17830 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
17831 | This ensures that you have no unresolved references to internal GCC | |
17832 | library subroutines. | |
17833 | (An example of such an internal subroutine is @code{__main}, used to ensure C++ | |
17834 | constructors are called; @pxref{Collect2,,@code{collect2}, gccint, | |
17835 | GNU Compiler Collection (GCC) Internals}.) | |
17836 | ||
d77de738 | 17837 | @opindex nostdlib++ |
ddf6fe37 | 17838 | @item -nostdlib++ |
d77de738 ML |
17839 | Do not implicitly link with standard C++ libraries. |
17840 | ||
d77de738 ML |
17841 | @opindex e |
17842 | @opindex entry | |
ddf6fe37 AA |
17843 | @item -e @var{entry} |
17844 | @itemx --entry=@var{entry} | |
d77de738 ML |
17845 | |
17846 | Specify that the program entry point is @var{entry}. The argument is | |
17847 | interpreted by the linker; the GNU linker accepts either a symbol name | |
17848 | or an address. | |
17849 | ||
d77de738 | 17850 | @opindex pie |
ddf6fe37 | 17851 | @item -pie |
d77de738 ML |
17852 | Produce a dynamically linked position independent executable on targets |
17853 | that support it. For predictable results, you must also specify the same | |
17854 | set of options used for compilation (@option{-fpie}, @option{-fPIE}, | |
17855 | or model suboptions) when you specify this linker option. | |
17856 | ||
d77de738 | 17857 | @opindex no-pie |
ddf6fe37 | 17858 | @item -no-pie |
d77de738 ML |
17859 | Don't produce a dynamically linked position independent executable. |
17860 | ||
d77de738 | 17861 | @opindex static-pie |
ddf6fe37 | 17862 | @item -static-pie |
d77de738 ML |
17863 | Produce a static position independent executable on targets that support |
17864 | it. A static position independent executable is similar to a static | |
17865 | executable, but can be loaded at any address without a dynamic linker. | |
17866 | For predictable results, you must also specify the same set of options | |
17867 | used for compilation (@option{-fpie}, @option{-fPIE}, or model | |
17868 | suboptions) when you specify this linker option. | |
17869 | ||
d77de738 | 17870 | @opindex pthread |
ddf6fe37 | 17871 | @item -pthread |
d77de738 ML |
17872 | Link with the POSIX threads library. This option is supported on |
17873 | GNU/Linux targets, most other Unix derivatives, and also on | |
17874 | x86 Cygwin and MinGW targets. On some targets this option also sets | |
17875 | flags for the preprocessor, so it should be used consistently for both | |
17876 | compilation and linking. | |
17877 | ||
d77de738 | 17878 | @opindex r |
ddf6fe37 | 17879 | @item -r |
d77de738 ML |
17880 | Produce a relocatable object as output. This is also known as partial |
17881 | linking. | |
17882 | ||
d77de738 | 17883 | @opindex rdynamic |
ddf6fe37 | 17884 | @item -rdynamic |
d77de738 ML |
17885 | Pass the flag @option{-export-dynamic} to the ELF linker, on targets |
17886 | that support it. This instructs the linker to add all symbols, not | |
17887 | only used ones, to the dynamic symbol table. This option is needed | |
17888 | for some uses of @code{dlopen} or to allow obtaining backtraces | |
17889 | from within a program. | |
17890 | ||
d77de738 | 17891 | @opindex s |
ddf6fe37 | 17892 | @item -s |
d77de738 ML |
17893 | Remove all symbol table and relocation information from the executable. |
17894 | ||
d77de738 | 17895 | @opindex static |
ddf6fe37 | 17896 | @item -static |
d77de738 ML |
17897 | On systems that support dynamic linking, this overrides @option{-pie} |
17898 | and prevents linking with the shared libraries. On other systems, this | |
17899 | option has no effect. | |
17900 | ||
d77de738 | 17901 | @opindex shared |
ddf6fe37 | 17902 | @item -shared |
d77de738 ML |
17903 | Produce a shared object which can then be linked with other objects to |
17904 | form an executable. Not all systems support this option. For predictable | |
17905 | results, you must also specify the same set of options used for compilation | |
17906 | (@option{-fpic}, @option{-fPIC}, or model suboptions) when | |
17907 | you specify this linker option.@footnote{On some systems, @samp{gcc -shared} | |
17908 | needs to build supplementary stub code for constructors to work. On | |
17909 | multi-libbed systems, @samp{gcc -shared} must select the correct support | |
17910 | libraries to link against. Failing to supply the correct flags may lead | |
17911 | to subtle defects. Supplying them in cases where they are not necessary | |
b799acef RB |
17912 | is innocuous. @option{-shared} suppresses the addition of startup code |
17913 | to alter the floating-point environment as done with @option{-ffast-math}, | |
17914 | @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.} | |
d77de738 | 17915 | |
d77de738 ML |
17916 | @opindex shared-libgcc |
17917 | @opindex static-libgcc | |
ddf6fe37 AA |
17918 | @item -shared-libgcc |
17919 | @itemx -static-libgcc | |
d77de738 ML |
17920 | On systems that provide @file{libgcc} as a shared library, these options |
17921 | force the use of either the shared or static version, respectively. | |
17922 | If no shared version of @file{libgcc} was built when the compiler was | |
17923 | configured, these options have no effect. | |
17924 | ||
17925 | There are several situations in which an application should use the | |
17926 | shared @file{libgcc} instead of the static version. The most common | |
17927 | of these is when the application wishes to throw and catch exceptions | |
17928 | across different shared libraries. In that case, each of the libraries | |
17929 | as well as the application itself should use the shared @file{libgcc}. | |
17930 | ||
17931 | Therefore, the G++ driver automatically adds @option{-shared-libgcc} | |
17932 | whenever you build a shared library or a main executable, because C++ | |
17933 | programs typically use exceptions, so this is the right thing to do. | |
17934 | ||
17935 | If, instead, you use the GCC driver to create shared libraries, you may | |
17936 | find that they are not always linked with the shared @file{libgcc}. | |
17937 | If GCC finds, at its configuration time, that you have a non-GNU linker | |
17938 | or a GNU linker that does not support option @option{--eh-frame-hdr}, | |
17939 | it links the shared version of @file{libgcc} into shared libraries | |
17940 | by default. Otherwise, it takes advantage of the linker and optimizes | |
17941 | away the linking with the shared version of @file{libgcc}, linking with | |
17942 | the static version of libgcc by default. This allows exceptions to | |
17943 | propagate through such shared libraries, without incurring relocation | |
17944 | costs at library load time. | |
17945 | ||
17946 | However, if a library or main executable is supposed to throw or catch | |
17947 | exceptions, you must link it using the G++ driver, or using the option | |
17948 | @option{-shared-libgcc}, such that it is linked with the shared | |
17949 | @file{libgcc}. | |
17950 | ||
d77de738 | 17951 | @opindex static-libasan |
ddf6fe37 | 17952 | @item -static-libasan |
d77de738 ML |
17953 | When the @option{-fsanitize=address} option is used to link a program, |
17954 | the GCC driver automatically links against @option{libasan}. If | |
17955 | @file{libasan} is available as a shared library, and the @option{-static} | |
17956 | option is not used, then this links against the shared version of | |
17957 | @file{libasan}. The @option{-static-libasan} option directs the GCC | |
17958 | driver to link @file{libasan} statically, without necessarily linking | |
17959 | other libraries statically. | |
17960 | ||
d77de738 | 17961 | @opindex static-libtsan |
ddf6fe37 | 17962 | @item -static-libtsan |
d77de738 ML |
17963 | When the @option{-fsanitize=thread} option is used to link a program, |
17964 | the GCC driver automatically links against @option{libtsan}. If | |
17965 | @file{libtsan} is available as a shared library, and the @option{-static} | |
17966 | option is not used, then this links against the shared version of | |
17967 | @file{libtsan}. The @option{-static-libtsan} option directs the GCC | |
17968 | driver to link @file{libtsan} statically, without necessarily linking | |
17969 | other libraries statically. | |
17970 | ||
d77de738 | 17971 | @opindex static-liblsan |
ddf6fe37 | 17972 | @item -static-liblsan |
d77de738 ML |
17973 | When the @option{-fsanitize=leak} option is used to link a program, |
17974 | the GCC driver automatically links against @option{liblsan}. If | |
17975 | @file{liblsan} is available as a shared library, and the @option{-static} | |
17976 | option is not used, then this links against the shared version of | |
17977 | @file{liblsan}. The @option{-static-liblsan} option directs the GCC | |
17978 | driver to link @file{liblsan} statically, without necessarily linking | |
17979 | other libraries statically. | |
17980 | ||
d77de738 | 17981 | @opindex static-libubsan |
ddf6fe37 | 17982 | @item -static-libubsan |
d77de738 ML |
17983 | When the @option{-fsanitize=undefined} option is used to link a program, |
17984 | the GCC driver automatically links against @option{libubsan}. If | |
17985 | @file{libubsan} is available as a shared library, and the @option{-static} | |
17986 | option is not used, then this links against the shared version of | |
17987 | @file{libubsan}. The @option{-static-libubsan} option directs the GCC | |
17988 | driver to link @file{libubsan} statically, without necessarily linking | |
17989 | other libraries statically. | |
17990 | ||
d77de738 | 17991 | @opindex static-libstdc++ |
ddf6fe37 | 17992 | @item -static-libstdc++ |
d77de738 ML |
17993 | When the @command{g++} program is used to link a C++ program, it |
17994 | normally automatically links against @option{libstdc++}. If | |
17995 | @file{libstdc++} is available as a shared library, and the | |
17996 | @option{-static} option is not used, then this links against the | |
17997 | shared version of @file{libstdc++}. That is normally fine. However, it | |
17998 | is sometimes useful to freeze the version of @file{libstdc++} used by | |
17999 | the program without going all the way to a fully static link. The | |
18000 | @option{-static-libstdc++} option directs the @command{g++} driver to | |
18001 | link @file{libstdc++} statically, without necessarily linking other | |
18002 | libraries statically. | |
18003 | ||
d77de738 | 18004 | @opindex symbolic |
ddf6fe37 | 18005 | @item -symbolic |
d77de738 ML |
18006 | Bind references to global symbols when building a shared object. Warn |
18007 | about any unresolved references (unless overridden by the link editor | |
18008 | option @option{-Xlinker -z -Xlinker defs}). Only a few systems support | |
18009 | this option. | |
18010 | ||
d77de738 ML |
18011 | @opindex T |
18012 | @cindex linker script | |
f33d7a88 | 18013 | @item -T @var{script} |
d77de738 ML |
18014 | Use @var{script} as the linker script. This option is supported by most |
18015 | systems using the GNU linker. On some targets, such as bare-board | |
18016 | targets without an operating system, the @option{-T} option may be required | |
18017 | when linking to avoid references to undefined symbols. | |
18018 | ||
d77de738 | 18019 | @opindex Xlinker |
ddf6fe37 | 18020 | @item -Xlinker @var{option} |
d77de738 ML |
18021 | Pass @var{option} as an option to the linker. You can use this to |
18022 | supply system-specific linker options that GCC does not recognize. | |
18023 | ||
18024 | If you want to pass an option that takes a separate argument, you must use | |
18025 | @option{-Xlinker} twice, once for the option and once for the argument. | |
18026 | For example, to pass @option{-assert definitions}, you must write | |
18027 | @option{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
18028 | @option{-Xlinker "-assert definitions"}, because this passes the entire | |
18029 | string as a single argument, which is not what the linker expects. | |
18030 | ||
18031 | When using the GNU linker, it is usually more convenient to pass | |
18032 | arguments to linker options using the @option{@var{option}=@var{value}} | |
18033 | syntax than as separate arguments. For example, you can specify | |
18034 | @option{-Xlinker -Map=output.map} rather than | |
18035 | @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support | |
18036 | this syntax for command-line options. | |
18037 | ||
d77de738 | 18038 | @opindex Wl |
ddf6fe37 | 18039 | @item -Wl,@var{option} |
d77de738 ML |
18040 | Pass @var{option} as an option to the linker. If @var{option} contains |
18041 | commas, it is split into multiple options at the commas. You can use this | |
18042 | syntax to pass an argument to the option. | |
18043 | For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the | |
18044 | linker. When using the GNU linker, you can also get the same effect with | |
18045 | @option{-Wl,-Map=output.map}. | |
18046 | ||
d77de738 | 18047 | @opindex u |
ddf6fe37 | 18048 | @item -u @var{symbol} |
d77de738 ML |
18049 | Pretend the symbol @var{symbol} is undefined, to force linking of |
18050 | library modules to define it. You can use @option{-u} multiple times with | |
18051 | different symbols to force loading of additional library modules. | |
18052 | ||
d77de738 | 18053 | @opindex z |
ddf6fe37 | 18054 | @item -z @var{keyword} |
d77de738 ML |
18055 | @option{-z} is passed directly on to the linker along with the keyword |
18056 | @var{keyword}. See the section in the documentation of your linker for | |
18057 | permitted values and their meanings. | |
18058 | @end table | |
18059 | ||
18060 | @node Directory Options | |
18061 | @section Options for Directory Search | |
18062 | @cindex directory options | |
18063 | @cindex options, directory search | |
18064 | @cindex search path | |
18065 | ||
18066 | These options specify directories to search for header files, for | |
18067 | libraries and for parts of the compiler: | |
18068 | ||
18069 | @table @gcctabopt | |
18070 | @include cppdiropts.texi | |
18071 | ||
d77de738 | 18072 | @opindex iplugindir= |
ddf6fe37 | 18073 | @item -iplugindir=@var{dir} |
d77de738 ML |
18074 | Set the directory to search for plugins that are passed |
18075 | by @option{-fplugin=@var{name}} instead of | |
18076 | @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant | |
18077 | to be used by the user, but only passed by the driver. | |
18078 | ||
d77de738 | 18079 | @opindex L |
ddf6fe37 | 18080 | @item -L@var{dir} |
d77de738 ML |
18081 | Add directory @var{dir} to the list of directories to be searched |
18082 | for @option{-l}. | |
18083 | ||
d77de738 | 18084 | @opindex B |
ddf6fe37 | 18085 | @item -B@var{prefix} |
d77de738 ML |
18086 | This option specifies where to find the executables, libraries, |
18087 | include files, and data files of the compiler itself. | |
18088 | ||
18089 | The compiler driver program runs one or more of the subprograms | |
18090 | @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries | |
18091 | @var{prefix} as a prefix for each program it tries to run, both with and | |
18092 | without @samp{@var{machine}/@var{version}/} for the corresponding target | |
18093 | machine and compiler version. | |
18094 | ||
18095 | For each subprogram to be run, the compiler driver first tries the | |
18096 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} | |
18097 | is not specified, the driver tries two standard prefixes, | |
18098 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of | |
18099 | those results in a file name that is found, the unmodified program | |
18100 | name is searched for using the directories specified in your | |
18101 | @env{PATH} environment variable. | |
18102 | ||
18103 | The compiler checks to see if the path provided by @option{-B} | |
18104 | refers to a directory, and if necessary it adds a directory | |
18105 | separator character at the end of the path. | |
18106 | ||
18107 | @option{-B} prefixes that effectively specify directory names also apply | |
18108 | to libraries in the linker, because the compiler translates these | |
18109 | options into @option{-L} options for the linker. They also apply to | |
18110 | include files in the preprocessor, because the compiler translates these | |
18111 | options into @option{-isystem} options for the preprocessor. In this case, | |
18112 | the compiler appends @samp{include} to the prefix. | |
18113 | ||
18114 | The runtime support file @file{libgcc.a} can also be searched for using | |
18115 | the @option{-B} prefix, if needed. If it is not found there, the two | |
18116 | standard prefixes above are tried, and that is all. The file is left | |
18117 | out of the link if it is not found by those means. | |
18118 | ||
18119 | Another way to specify a prefix much like the @option{-B} prefix is to use | |
18120 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment | |
18121 | Variables}. | |
18122 | ||
18123 | As a special kludge, if the path provided by @option{-B} is | |
18124 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to | |
18125 | 9, then it is replaced by @file{[dir/]include}. This is to help | |
18126 | with boot-strapping the compiler. | |
18127 | ||
d77de738 | 18128 | @opindex no-canonical-prefixes |
ddf6fe37 | 18129 | @item -no-canonical-prefixes |
d77de738 ML |
18130 | Do not expand any symbolic links, resolve references to @samp{/../} |
18131 | or @samp{/./}, or make the path absolute when generating a relative | |
18132 | prefix. | |
18133 | ||
d77de738 | 18134 | @opindex sysroot |
ddf6fe37 | 18135 | @item --sysroot=@var{dir} |
d77de738 ML |
18136 | Use @var{dir} as the logical root directory for headers and libraries. |
18137 | For example, if the compiler normally searches for headers in | |
18138 | @file{/usr/include} and libraries in @file{/usr/lib}, it instead | |
18139 | searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}. | |
18140 | ||
18141 | If you use both this option and the @option{-isysroot} option, then | |
18142 | the @option{--sysroot} option applies to libraries, but the | |
18143 | @option{-isysroot} option applies to header files. | |
18144 | ||
18145 | The GNU linker (beginning with version 2.16) has the necessary support | |
18146 | for this option. If your linker does not support this option, the | |
18147 | header file aspect of @option{--sysroot} still works, but the | |
18148 | library aspect does not. | |
18149 | ||
d77de738 | 18150 | @opindex no-sysroot-suffix |
ddf6fe37 | 18151 | @item --no-sysroot-suffix |
d77de738 ML |
18152 | For some targets, a suffix is added to the root directory specified |
18153 | with @option{--sysroot}, depending on the other options used, so that | |
18154 | headers may for example be found in | |
18155 | @file{@var{dir}/@var{suffix}/usr/include} instead of | |
18156 | @file{@var{dir}/usr/include}. This option disables the addition of | |
18157 | such a suffix. | |
18158 | ||
18159 | @end table | |
18160 | ||
18161 | @node Code Gen Options | |
18162 | @section Options for Code Generation Conventions | |
18163 | @cindex code generation conventions | |
18164 | @cindex options, code generation | |
18165 | @cindex run-time options | |
18166 | ||
18167 | These machine-independent options control the interface conventions | |
18168 | used in code generation. | |
18169 | ||
18170 | Most of them have both positive and negative forms; the negative form | |
18171 | of @option{-ffoo} is @option{-fno-foo}. In the table below, only | |
18172 | one of the forms is listed---the one that is not the default. You | |
18173 | can figure out the other form by either removing @samp{no-} or adding | |
18174 | it. | |
18175 | ||
18176 | @table @gcctabopt | |
d77de738 | 18177 | @opindex fstack_reuse |
ddf6fe37 | 18178 | @item -fstack-reuse=@var{reuse-level} |
d77de738 ML |
18179 | This option controls stack space reuse for user declared local/auto variables |
18180 | and compiler generated temporaries. @var{reuse_level} can be @samp{all}, | |
18181 | @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all | |
18182 | local variables and temporaries, @samp{named_vars} enables the reuse only for | |
18183 | user defined local variables with names, and @samp{none} disables stack reuse | |
18184 | completely. The default value is @samp{all}. The option is needed when the | |
18185 | program extends the lifetime of a scoped local variable or a compiler generated | |
18186 | temporary beyond the end point defined by the language. When a lifetime of | |
18187 | a variable ends, and if the variable lives in memory, the optimizing compiler | |
18188 | has the freedom to reuse its stack space with other temporaries or scoped | |
18189 | local variables whose live range does not overlap with it. Legacy code extending | |
18190 | local lifetime is likely to break with the stack reuse optimization. | |
18191 | ||
18192 | For example, | |
18193 | ||
18194 | @smallexample | |
18195 | int *p; | |
18196 | @{ | |
18197 | int local1; | |
18198 | ||
18199 | p = &local1; | |
18200 | local1 = 10; | |
18201 | .... | |
18202 | @} | |
18203 | @{ | |
18204 | int local2; | |
18205 | local2 = 20; | |
18206 | ... | |
18207 | @} | |
18208 | ||
18209 | if (*p == 10) // out of scope use of local1 | |
18210 | @{ | |
18211 | ||
18212 | @} | |
18213 | @end smallexample | |
18214 | ||
18215 | Another example: | |
18216 | @smallexample | |
18217 | ||
18218 | struct A | |
18219 | @{ | |
18220 | A(int k) : i(k), j(k) @{ @} | |
18221 | int i; | |
18222 | int j; | |
18223 | @}; | |
18224 | ||
18225 | A *ap; | |
18226 | ||
18227 | void foo(const A& ar) | |
18228 | @{ | |
18229 | ap = &ar; | |
18230 | @} | |
18231 | ||
18232 | void bar() | |
18233 | @{ | |
18234 | foo(A(10)); // temp object's lifetime ends when foo returns | |
18235 | ||
18236 | @{ | |
18237 | A a(20); | |
18238 | .... | |
18239 | @} | |
18240 | ap->i+= 10; // ap references out of scope temp whose space | |
18241 | // is reused with a. What is the value of ap->i? | |
18242 | @} | |
18243 | ||
18244 | @end smallexample | |
18245 | ||
18246 | The lifetime of a compiler generated temporary is well defined by the C++ | |
18247 | standard. When a lifetime of a temporary ends, and if the temporary lives | |
18248 | in memory, the optimizing compiler has the freedom to reuse its stack | |
18249 | space with other temporaries or scoped local variables whose live range | |
18250 | does not overlap with it. However some of the legacy code relies on | |
18251 | the behavior of older compilers in which temporaries' stack space is | |
18252 | not reused, the aggressive stack reuse can lead to runtime errors. This | |
18253 | option is used to control the temporary stack reuse optimization. | |
18254 | ||
d77de738 | 18255 | @opindex ftrapv |
ddf6fe37 | 18256 | @item -ftrapv |
d77de738 ML |
18257 | This option generates traps for signed overflow on addition, subtraction, |
18258 | multiplication operations. | |
18259 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18260 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18261 | @option{-fwrapv} being effective. Note that only active options override, so | |
18262 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18263 | results in @option{-ftrapv} being effective. | |
18264 | ||
d77de738 | 18265 | @opindex fwrapv |
ddf6fe37 | 18266 | @item -fwrapv |
d77de738 ML |
18267 | This option instructs the compiler to assume that signed arithmetic |
18268 | overflow of addition, subtraction and multiplication wraps around | |
18269 | using twos-complement representation. This flag enables some optimizations | |
18270 | and disables others. | |
18271 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18272 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18273 | @option{-fwrapv} being effective. Note that only active options override, so | |
18274 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18275 | results in @option{-ftrapv} being effective. | |
18276 | ||
d77de738 | 18277 | @opindex fwrapv-pointer |
ddf6fe37 | 18278 | @item -fwrapv-pointer |
d77de738 ML |
18279 | This option instructs the compiler to assume that pointer arithmetic |
18280 | overflow on addition and subtraction wraps around using twos-complement | |
18281 | representation. This flag disables some optimizations which assume | |
18282 | pointer overflow is invalid. | |
18283 | ||
d77de738 | 18284 | @opindex fstrict-overflow |
ddf6fe37 | 18285 | @item -fstrict-overflow |
d77de738 ML |
18286 | This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when |
18287 | negated implies @option{-fwrapv} @option{-fwrapv-pointer}. | |
18288 | ||
d77de738 | 18289 | @opindex fexceptions |
ddf6fe37 | 18290 | @item -fexceptions |
d77de738 ML |
18291 | Enable exception handling. Generates extra code needed to propagate |
18292 | exceptions. For some targets, this implies GCC generates frame | |
18293 | unwind information for all functions, which can produce significant data | |
18294 | size overhead, although it does not affect execution. If you do not | |
18295 | specify this option, GCC enables it by default for languages like | |
18296 | C++ that normally require exception handling, and disables it for | |
18297 | languages like C that do not normally require it. However, you may need | |
18298 | to enable this option when compiling C code that needs to interoperate | |
18299 | properly with exception handlers written in C++. You may also wish to | |
18300 | disable this option if you are compiling older C++ programs that don't | |
18301 | use exception handling. | |
18302 | ||
d77de738 | 18303 | @opindex fnon-call-exceptions |
ddf6fe37 | 18304 | @item -fnon-call-exceptions |
d77de738 ML |
18305 | Generate code that allows trapping instructions to throw exceptions. |
18306 | Note that this requires platform-specific runtime support that does | |
18307 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
18308 | instructions to throw exceptions, i.e.@: memory references or floating-point | |
18309 | instructions. It does not allow exceptions to be thrown from | |
18310 | arbitrary signal handlers such as @code{SIGALRM}. This enables | |
18311 | @option{-fexceptions}. | |
18312 | ||
d77de738 | 18313 | @opindex fdelete-dead-exceptions |
ddf6fe37 | 18314 | @item -fdelete-dead-exceptions |
d77de738 ML |
18315 | Consider that instructions that may throw exceptions but don't otherwise |
18316 | contribute to the execution of the program can be optimized away. | |
18317 | This does not affect calls to functions except those with the | |
18318 | @code{pure} or @code{const} attributes. | |
18319 | This option is enabled by default for the Ada and C++ compilers, as permitted by | |
18320 | the language specifications. | |
18321 | Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels. | |
18322 | ||
d77de738 | 18323 | @opindex funwind-tables |
ddf6fe37 | 18324 | @item -funwind-tables |
d77de738 ML |
18325 | Similar to @option{-fexceptions}, except that it just generates any needed |
18326 | static data, but does not affect the generated code in any other way. | |
18327 | You normally do not need to enable this option; instead, a language processor | |
18328 | that needs this handling enables it on your behalf. | |
18329 | ||
d77de738 | 18330 | @opindex fasynchronous-unwind-tables |
ddf6fe37 | 18331 | @item -fasynchronous-unwind-tables |
d77de738 ML |
18332 | Generate unwind table in DWARF format, if supported by target machine. The |
18333 | table is exact at each instruction boundary, so it can be used for stack | |
18334 | unwinding from asynchronous events (such as debugger or garbage collector). | |
18335 | ||
d77de738 ML |
18336 | @opindex fno-gnu-unique |
18337 | @opindex fgnu-unique | |
ddf6fe37 | 18338 | @item -fno-gnu-unique |
d77de738 ML |
18339 | On systems with recent GNU assembler and C library, the C++ compiler |
18340 | uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions | |
18341 | of template static data members and static local variables in inline | |
18342 | functions are unique even in the presence of @code{RTLD_LOCAL}; this | |
18343 | is necessary to avoid problems with a library used by two different | |
18344 | @code{RTLD_LOCAL} plugins depending on a definition in one of them and | |
18345 | therefore disagreeing with the other one about the binding of the | |
18346 | symbol. But this causes @code{dlclose} to be ignored for affected | |
18347 | DSOs; if your program relies on reinitialization of a DSO via | |
18348 | @code{dlclose} and @code{dlopen}, you can use | |
18349 | @option{-fno-gnu-unique}. | |
18350 | ||
d77de738 | 18351 | @opindex fpcc-struct-return |
ddf6fe37 | 18352 | @item -fpcc-struct-return |
d77de738 ML |
18353 | Return ``short'' @code{struct} and @code{union} values in memory like |
18354 | longer ones, rather than in registers. This convention is less | |
18355 | efficient, but it has the advantage of allowing intercallability between | |
18356 | GCC-compiled files and files compiled with other compilers, particularly | |
18357 | the Portable C Compiler (pcc). | |
18358 | ||
18359 | The precise convention for returning structures in memory depends | |
18360 | on the target configuration macros. | |
18361 | ||
18362 | Short structures and unions are those whose size and alignment match | |
18363 | that of some integer type. | |
18364 | ||
18365 | @strong{Warning:} code compiled with the @option{-fpcc-struct-return} | |
18366 | switch is not binary compatible with code compiled with the | |
18367 | @option{-freg-struct-return} switch. | |
18368 | Use it to conform to a non-default application binary interface. | |
18369 | ||
d77de738 | 18370 | @opindex freg-struct-return |
ddf6fe37 | 18371 | @item -freg-struct-return |
d77de738 ML |
18372 | Return @code{struct} and @code{union} values in registers when possible. |
18373 | This is more efficient for small structures than | |
18374 | @option{-fpcc-struct-return}. | |
18375 | ||
18376 | If you specify neither @option{-fpcc-struct-return} nor | |
18377 | @option{-freg-struct-return}, GCC defaults to whichever convention is | |
18378 | standard for the target. If there is no standard convention, GCC | |
18379 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is | |
18380 | the principal compiler. In those cases, we can choose the standard, and | |
18381 | we chose the more efficient register return alternative. | |
18382 | ||
18383 | @strong{Warning:} code compiled with the @option{-freg-struct-return} | |
18384 | switch is not binary compatible with code compiled with the | |
18385 | @option{-fpcc-struct-return} switch. | |
18386 | Use it to conform to a non-default application binary interface. | |
18387 | ||
d77de738 | 18388 | @opindex fshort-enums |
ddf6fe37 | 18389 | @item -fshort-enums |
d77de738 ML |
18390 | Allocate to an @code{enum} type only as many bytes as it needs for the |
18391 | declared range of possible values. Specifically, the @code{enum} type | |
18392 | is equivalent to the smallest integer type that has enough room. | |
d8a656d5 JW |
18393 | This option has no effect for an enumeration type with a fixed underlying |
18394 | type. | |
d77de738 ML |
18395 | |
18396 | @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate | |
18397 | code that is not binary compatible with code generated without that switch. | |
18398 | Use it to conform to a non-default application binary interface. | |
18399 | ||
d77de738 | 18400 | @opindex fshort-wchar |
ddf6fe37 | 18401 | @item -fshort-wchar |
d77de738 ML |
18402 | Override the underlying type for @code{wchar_t} to be @code{short |
18403 | unsigned int} instead of the default for the target. This option is | |
18404 | useful for building programs to run under WINE@. | |
18405 | ||
18406 | @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate | |
18407 | code that is not binary compatible with code generated without that switch. | |
18408 | Use it to conform to a non-default application binary interface. | |
18409 | ||
d77de738 ML |
18410 | @opindex fcommon |
18411 | @opindex fno-common | |
18412 | @cindex tentative definitions | |
f33d7a88 | 18413 | @item -fcommon |
d77de738 ML |
18414 | In C code, this option controls the placement of global variables |
18415 | defined without an initializer, known as @dfn{tentative definitions} | |
18416 | in the C standard. Tentative definitions are distinct from declarations | |
18417 | of a variable with the @code{extern} keyword, which do not allocate storage. | |
18418 | ||
18419 | The default is @option{-fno-common}, which specifies that the compiler places | |
18420 | uninitialized global variables in the BSS section of the object file. | |
18421 | This inhibits the merging of tentative definitions by the linker so you get a | |
18422 | multiple-definition error if the same variable is accidentally defined in more | |
18423 | than one compilation unit. | |
18424 | ||
18425 | The @option{-fcommon} places uninitialized global variables in a common block. | |
18426 | This allows the linker to resolve all tentative definitions of the same variable | |
18427 | in different compilation units to the same object, or to a non-tentative | |
18428 | definition. This behavior is inconsistent with C++, and on many targets implies | |
18429 | a speed and code size penalty on global variable references. It is mainly | |
18430 | useful to enable legacy code to link without errors. | |
18431 | ||
d77de738 ML |
18432 | @opindex fno-ident |
18433 | @opindex fident | |
ddf6fe37 | 18434 | @item -fno-ident |
d77de738 ML |
18435 | Ignore the @code{#ident} directive. |
18436 | ||
d77de738 | 18437 | @opindex finhibit-size-directive |
ddf6fe37 | 18438 | @item -finhibit-size-directive |
d77de738 ML |
18439 | Don't output a @code{.size} assembler directive, or anything else that |
18440 | would cause trouble if the function is split in the middle, and the | |
18441 | two halves are placed at locations far apart in memory. This option is | |
18442 | used when compiling @file{crtstuff.c}; you should not need to use it | |
18443 | for anything else. | |
18444 | ||
d77de738 | 18445 | @opindex fverbose-asm |
ddf6fe37 | 18446 | @item -fverbose-asm |
d77de738 ML |
18447 | Put extra commentary information in the generated assembly code to |
18448 | make it more readable. This option is generally only of use to those | |
18449 | who actually need to read the generated assembly code (perhaps while | |
18450 | debugging the compiler itself). | |
18451 | ||
18452 | @option{-fno-verbose-asm}, the default, causes the | |
18453 | extra information to be omitted and is useful when comparing two assembler | |
18454 | files. | |
18455 | ||
18456 | The added comments include: | |
18457 | ||
18458 | @itemize @bullet | |
18459 | ||
18460 | @item | |
18461 | information on the compiler version and command-line options, | |
18462 | ||
18463 | @item | |
18464 | the source code lines associated with the assembly instructions, | |
18465 | in the form FILENAME:LINENUMBER:CONTENT OF LINE, | |
18466 | ||
18467 | @item | |
18468 | hints on which high-level expressions correspond to | |
18469 | the various assembly instruction operands. | |
18470 | ||
18471 | @end itemize | |
18472 | ||
18473 | For example, given this C source file: | |
18474 | ||
18475 | @smallexample | |
18476 | int test (int n) | |
18477 | @{ | |
18478 | int i; | |
18479 | int total = 0; | |
18480 | ||
18481 | for (i = 0; i < n; i++) | |
18482 | total += i * i; | |
18483 | ||
18484 | return total; | |
18485 | @} | |
18486 | @end smallexample | |
18487 | ||
18488 | compiling to (x86_64) assembly via @option{-S} and emitting the result | |
18489 | direct to stdout via @option{-o} @option{-} | |
18490 | ||
18491 | @smallexample | |
18492 | gcc -S test.c -fverbose-asm -Os -o - | |
18493 | @end smallexample | |
18494 | ||
18495 | gives output similar to this: | |
18496 | ||
18497 | @smallexample | |
18498 | .file "test.c" | |
18499 | # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu) | |
18500 | [...snip...] | |
18501 | # options passed: | |
18502 | [...snip...] | |
18503 | ||
18504 | .text | |
18505 | .globl test | |
18506 | .type test, @@function | |
18507 | test: | |
18508 | .LFB0: | |
18509 | .cfi_startproc | |
18510 | # test.c:4: int total = 0; | |
18511 | xorl %eax, %eax # <retval> | |
18512 | # test.c:6: for (i = 0; i < n; i++) | |
18513 | xorl %edx, %edx # i | |
18514 | .L2: | |
18515 | # test.c:6: for (i = 0; i < n; i++) | |
18516 | cmpl %edi, %edx # n, i | |
18517 | jge .L5 #, | |
18518 | # test.c:7: total += i * i; | |
18519 | movl %edx, %ecx # i, tmp92 | |
18520 | imull %edx, %ecx # i, tmp92 | |
18521 | # test.c:6: for (i = 0; i < n; i++) | |
18522 | incl %edx # i | |
18523 | # test.c:7: total += i * i; | |
18524 | addl %ecx, %eax # tmp92, <retval> | |
18525 | jmp .L2 # | |
18526 | .L5: | |
18527 | # test.c:10: @} | |
18528 | ret | |
18529 | .cfi_endproc | |
18530 | .LFE0: | |
18531 | .size test, .-test | |
18532 | .ident "GCC: (GNU) 7.0.0 20160809 (experimental)" | |
18533 | .section .note.GNU-stack,"",@@progbits | |
18534 | @end smallexample | |
18535 | ||
18536 | The comments are intended for humans rather than machines and hence the | |
18537 | precise format of the comments is subject to change. | |
18538 | ||
d77de738 | 18539 | @opindex frecord-gcc-switches |
ddf6fe37 | 18540 | @item -frecord-gcc-switches |
d77de738 ML |
18541 | This switch causes the command line used to invoke the |
18542 | compiler to be recorded into the object file that is being created. | |
18543 | This switch is only implemented on some targets and the exact format | |
18544 | of the recording is target and binary file format dependent, but it | |
18545 | usually takes the form of a section containing ASCII text. This | |
18546 | switch is related to the @option{-fverbose-asm} switch, but that | |
18547 | switch only records information in the assembler output file as | |
18548 | comments, so it never reaches the object file. | |
18549 | See also @option{-grecord-gcc-switches} for another | |
18550 | way of storing compiler options into the object file. | |
18551 | ||
d77de738 ML |
18552 | @opindex fpic |
18553 | @cindex global offset table | |
18554 | @cindex PIC | |
f33d7a88 | 18555 | @item -fpic |
d77de738 ML |
18556 | Generate position-independent code (PIC) suitable for use in a shared |
18557 | library, if supported for the target machine. Such code accesses all | |
18558 | constant addresses through a global offset table (GOT)@. The dynamic | |
18559 | loader resolves the GOT entries when the program starts (the dynamic | |
18560 | loader is not part of GCC; it is part of the operating system). If | |
18561 | the GOT size for the linked executable exceeds a machine-specific | |
18562 | maximum size, you get an error message from the linker indicating that | |
18563 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} | |
18564 | instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k | |
18565 | on the m68k and RS/6000. The x86 has no such limit.) | |
18566 | ||
18567 | Position-independent code requires special support, and therefore works | |
18568 | only on certain machines. For the x86, GCC supports PIC for System V | |
18569 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
18570 | position-independent. | |
18571 | ||
18572 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18573 | are defined to 1. | |
18574 | ||
d77de738 | 18575 | @opindex fPIC |
ddf6fe37 | 18576 | @item -fPIC |
d77de738 ML |
18577 | If supported for the target machine, emit position-independent code, |
18578 | suitable for dynamic linking and avoiding any limit on the size of the | |
18579 | global offset table. This option makes a difference on AArch64, m68k, | |
18580 | PowerPC and SPARC@. | |
18581 | ||
18582 | Position-independent code requires special support, and therefore works | |
18583 | only on certain machines. | |
18584 | ||
18585 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18586 | are defined to 2. | |
18587 | ||
d77de738 ML |
18588 | @opindex fpie |
18589 | @opindex fPIE | |
ddf6fe37 AA |
18590 | @item -fpie |
18591 | @itemx -fPIE | |
d77de738 ML |
18592 | These options are similar to @option{-fpic} and @option{-fPIC}, but the |
18593 | generated position-independent code can be only linked into executables. | |
18594 | Usually these options are used to compile code that will be linked using | |
18595 | the @option{-pie} GCC option. | |
18596 | ||
18597 | @option{-fpie} and @option{-fPIE} both define the macros | |
18598 | @code{__pie__} and @code{__PIE__}. The macros have the value 1 | |
18599 | for @option{-fpie} and 2 for @option{-fPIE}. | |
18600 | ||
d77de738 ML |
18601 | @opindex fno-plt |
18602 | @opindex fplt | |
ddf6fe37 | 18603 | @item -fno-plt |
d77de738 ML |
18604 | Do not use the PLT for external function calls in position-independent code. |
18605 | Instead, load the callee address at call sites from the GOT and branch to it. | |
18606 | This leads to more efficient code by eliminating PLT stubs and exposing | |
18607 | GOT loads to optimizations. On architectures such as 32-bit x86 where | |
18608 | PLT stubs expect the GOT pointer in a specific register, this gives more | |
18609 | register allocation freedom to the compiler. | |
18610 | Lazy binding requires use of the PLT; | |
18611 | with @option{-fno-plt} all external symbols are resolved at load time. | |
18612 | ||
18613 | Alternatively, the function attribute @code{noplt} can be used to avoid calls | |
18614 | through the PLT for specific external functions. | |
18615 | ||
18616 | In position-dependent code, a few targets also convert calls to | |
18617 | functions that are marked to not use the PLT to use the GOT instead. | |
18618 | ||
d77de738 ML |
18619 | @opindex fno-jump-tables |
18620 | @opindex fjump-tables | |
ddf6fe37 | 18621 | @item -fno-jump-tables |
d77de738 ML |
18622 | Do not use jump tables for switch statements even where it would be |
18623 | more efficient than other code generation strategies. This option is | |
18624 | of use in conjunction with @option{-fpic} or @option{-fPIC} for | |
18625 | building code that forms part of a dynamic linker and cannot | |
18626 | reference the address of a jump table. On some targets, jump tables | |
18627 | do not require a GOT and this option is not needed. | |
18628 | ||
d77de738 ML |
18629 | @opindex fno-bit-tests |
18630 | @opindex fbit-tests | |
ddf6fe37 | 18631 | @item -fno-bit-tests |
d77de738 ML |
18632 | Do not use bit tests for switch statements even where it would be |
18633 | more efficient than other code generation strategies. | |
18634 | ||
d77de738 | 18635 | @opindex ffixed |
ddf6fe37 | 18636 | @item -ffixed-@var{reg} |
d77de738 ML |
18637 | Treat the register named @var{reg} as a fixed register; generated code |
18638 | should never refer to it (except perhaps as a stack pointer, frame | |
18639 | pointer or in some other fixed role). | |
18640 | ||
18641 | @var{reg} must be the name of a register. The register names accepted | |
18642 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
18643 | macro in the machine description macro file. | |
18644 | ||
18645 | This flag does not have a negative form, because it specifies a | |
18646 | three-way choice. | |
18647 | ||
d77de738 | 18648 | @opindex fcall-used |
ddf6fe37 | 18649 | @item -fcall-used-@var{reg} |
d77de738 ML |
18650 | Treat the register named @var{reg} as an allocable register that is |
18651 | clobbered by function calls. It may be allocated for temporaries or | |
18652 | variables that do not live across a call. Functions compiled this way | |
18653 | do not save and restore the register @var{reg}. | |
18654 | ||
18655 | It is an error to use this flag with the frame pointer or stack pointer. | |
18656 | Use of this flag for other registers that have fixed pervasive roles in | |
18657 | the machine's execution model produces disastrous results. | |
18658 | ||
18659 | This flag does not have a negative form, because it specifies a | |
18660 | three-way choice. | |
18661 | ||
d77de738 | 18662 | @opindex fcall-saved |
ddf6fe37 | 18663 | @item -fcall-saved-@var{reg} |
d77de738 ML |
18664 | Treat the register named @var{reg} as an allocable register saved by |
18665 | functions. It may be allocated even for temporaries or variables that | |
18666 | live across a call. Functions compiled this way save and restore | |
18667 | the register @var{reg} if they use it. | |
18668 | ||
18669 | It is an error to use this flag with the frame pointer or stack pointer. | |
18670 | Use of this flag for other registers that have fixed pervasive roles in | |
18671 | the machine's execution model produces disastrous results. | |
18672 | ||
18673 | A different sort of disaster results from the use of this flag for | |
18674 | a register in which function values may be returned. | |
18675 | ||
18676 | This flag does not have a negative form, because it specifies a | |
18677 | three-way choice. | |
18678 | ||
d77de738 | 18679 | @opindex fpack-struct |
ddf6fe37 | 18680 | @item -fpack-struct[=@var{n}] |
d77de738 ML |
18681 | Without a value specified, pack all structure members together without |
18682 | holes. When a value is specified (which must be a small power of two), pack | |
18683 | structure members according to this value, representing the maximum | |
18684 | alignment (that is, objects with default alignment requirements larger than | |
18685 | this are output potentially unaligned at the next fitting location. | |
18686 | ||
18687 | @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate | |
18688 | code that is not binary compatible with code generated without that switch. | |
18689 | Additionally, it makes the code suboptimal. | |
18690 | Use it to conform to a non-default application binary interface. | |
18691 | ||
d77de738 | 18692 | @opindex fleading-underscore |
ddf6fe37 | 18693 | @item -fleading-underscore |
d77de738 ML |
18694 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
18695 | change the way C symbols are represented in the object file. One use | |
18696 | is to help link with legacy assembly code. | |
18697 | ||
18698 | @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to | |
18699 | generate code that is not binary compatible with code generated without that | |
18700 | switch. Use it to conform to a non-default application binary interface. | |
18701 | Not all targets provide complete support for this switch. | |
18702 | ||
d77de738 | 18703 | @opindex ftls-model |
ddf6fe37 | 18704 | @item -ftls-model=@var{model} |
d77de738 ML |
18705 | Alter the thread-local storage model to be used (@pxref{Thread-Local}). |
18706 | The @var{model} argument should be one of @samp{global-dynamic}, | |
18707 | @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}. | |
18708 | Note that the choice is subject to optimization: the compiler may use | |
18709 | a more efficient model for symbols not visible outside of the translation | |
18710 | unit, or if @option{-fpic} is not given on the command line. | |
18711 | ||
18712 | The default without @option{-fpic} is @samp{initial-exec}; with | |
18713 | @option{-fpic} the default is @samp{global-dynamic}. | |
18714 | ||
d77de738 | 18715 | @opindex ftrampolines |
ddf6fe37 | 18716 | @item -ftrampolines |
d77de738 ML |
18717 | For targets that normally need trampolines for nested functions, always |
18718 | generate them instead of using descriptors. Otherwise, for targets that | |
18719 | do not need them, like for example HP-PA or IA-64, do nothing. | |
18720 | ||
18721 | A trampoline is a small piece of code that is created at run time on the | |
18722 | stack when the address of a nested function is taken, and is used to call | |
18723 | the nested function indirectly. Therefore, it requires the stack to be | |
18724 | made executable in order for the program to work properly. | |
18725 | ||
18726 | @option{-fno-trampolines} is enabled by default on a language by language | |
18727 | basis to let the compiler avoid generating them, if it computes that this | |
18728 | is safe, and replace them with descriptors. Descriptors are made up of data | |
18729 | only, but the generated code must be prepared to deal with them. As of this | |
18730 | writing, @option{-fno-trampolines} is enabled by default only for Ada. | |
18731 | ||
18732 | Moreover, code compiled with @option{-ftrampolines} and code compiled with | |
18733 | @option{-fno-trampolines} are not binary compatible if nested functions are | |
18734 | present. This option must therefore be used on a program-wide basis and be | |
18735 | manipulated with extreme care. | |
18736 | ||
18737 | For languages other than Ada, the @code{-ftrampolines} and | |
18738 | @code{-fno-trampolines} options currently have no effect, and | |
18739 | trampolines are always generated on platforms that need them | |
18740 | for nested functions. | |
18741 | ||
d77de738 | 18742 | @opindex fvisibility |
ddf6fe37 | 18743 | @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
18744 | Set the default ELF image symbol visibility to the specified option---all |
18745 | symbols are marked with this unless overridden within the code. | |
18746 | Using this feature can very substantially improve linking and | |
18747 | load times of shared object libraries, produce more optimized | |
18748 | code, provide near-perfect API export and prevent symbol clashes. | |
18749 | It is @strong{strongly} recommended that you use this in any shared objects | |
18750 | you distribute. | |
18751 | ||
18752 | Despite the nomenclature, @samp{default} always means public; i.e., | |
18753 | available to be linked against from outside the shared object. | |
18754 | @samp{protected} and @samp{internal} are pretty useless in real-world | |
18755 | usage so the only other commonly used option is @samp{hidden}. | |
18756 | The default if @option{-fvisibility} isn't specified is | |
18757 | @samp{default}, i.e., make every symbol public. | |
18758 | ||
18759 | A good explanation of the benefits offered by ensuring ELF | |
18760 | symbols have the correct visibility is given by ``How To Write | |
18761 | Shared Libraries'' by Ulrich Drepper (which can be found at | |
18762 | @w{@uref{https://www.akkadia.org/drepper/}})---however a superior | |
18763 | solution made possible by this option to marking things hidden when | |
18764 | the default is public is to make the default hidden and mark things | |
18765 | public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden} | |
18766 | and @code{__attribute__ ((visibility("default")))} instead of | |
18767 | @code{__declspec(dllexport)} you get almost identical semantics with | |
18768 | identical syntax. This is a great boon to those working with | |
18769 | cross-platform projects. | |
18770 | ||
18771 | For those adding visibility support to existing code, you may find | |
18772 | @code{#pragma GCC visibility} of use. This works by you enclosing | |
18773 | the declarations you wish to set visibility for with (for example) | |
18774 | @code{#pragma GCC visibility push(hidden)} and | |
18775 | @code{#pragma GCC visibility pop}. | |
18776 | Bear in mind that symbol visibility should be viewed @strong{as | |
18777 | part of the API interface contract} and thus all new code should | |
18778 | always specify visibility when it is not the default; i.e., declarations | |
18779 | only for use within the local DSO should @strong{always} be marked explicitly | |
18780 | as hidden as so to avoid PLT indirection overheads---making this | |
18781 | abundantly clear also aids readability and self-documentation of the code. | |
18782 | Note that due to ISO C++ specification requirements, @code{operator new} and | |
18783 | @code{operator delete} must always be of default visibility. | |
18784 | ||
18785 | Be aware that headers from outside your project, in particular system | |
18786 | headers and headers from any other library you use, may not be | |
18787 | expecting to be compiled with visibility other than the default. You | |
18788 | may need to explicitly say @code{#pragma GCC visibility push(default)} | |
18789 | before including any such headers. | |
18790 | ||
18791 | @code{extern} declarations are not affected by @option{-fvisibility}, so | |
18792 | a lot of code can be recompiled with @option{-fvisibility=hidden} with | |
18793 | no modifications. However, this means that calls to @code{extern} | |
18794 | functions with no explicit visibility use the PLT, so it is more | |
18795 | effective to use @code{__attribute ((visibility))} and/or | |
18796 | @code{#pragma GCC visibility} to tell the compiler which @code{extern} | |
18797 | declarations should be treated as hidden. | |
18798 | ||
18799 | Note that @option{-fvisibility} does affect C++ vague linkage | |
18800 | entities. This means that, for instance, an exception class that is | |
18801 | be thrown between DSOs must be explicitly marked with default | |
18802 | visibility so that the @samp{type_info} nodes are unified between | |
18803 | the DSOs. | |
18804 | ||
18805 | An overview of these techniques, their benefits and how to use them | |
18806 | is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}. | |
18807 | ||
d77de738 | 18808 | @opindex fstrict-volatile-bitfields |
ddf6fe37 | 18809 | @item -fstrict-volatile-bitfields |
d77de738 ML |
18810 | This option should be used if accesses to volatile bit-fields (or other |
18811 | structure fields, although the compiler usually honors those types | |
18812 | anyway) should use a single access of the width of the | |
18813 | field's type, aligned to a natural alignment if possible. For | |
18814 | example, targets with memory-mapped peripheral registers might require | |
18815 | all such accesses to be 16 bits wide; with this flag you can | |
18816 | declare all peripheral bit-fields as @code{unsigned short} (assuming short | |
18817 | is 16 bits on these targets) to force GCC to use 16-bit accesses | |
18818 | instead of, perhaps, a more efficient 32-bit access. | |
18819 | ||
18820 | If this option is disabled, the compiler uses the most efficient | |
18821 | instruction. In the previous example, that might be a 32-bit load | |
18822 | instruction, even though that accesses bytes that do not contain | |
18823 | any portion of the bit-field, or memory-mapped registers unrelated to | |
18824 | the one being updated. | |
18825 | ||
18826 | In some cases, such as when the @code{packed} attribute is applied to a | |
18827 | structure field, it may not be possible to access the field with a single | |
18828 | read or write that is correctly aligned for the target machine. In this | |
18829 | case GCC falls back to generating multiple accesses rather than code that | |
18830 | will fault or truncate the result at run time. | |
18831 | ||
18832 | Note: Due to restrictions of the C/C++11 memory model, write accesses are | |
18833 | not allowed to touch non bit-field members. It is therefore recommended | |
18834 | to define all bits of the field's type as bit-field members. | |
18835 | ||
18836 | The default value of this option is determined by the application binary | |
18837 | interface for the target processor. | |
18838 | ||
d77de738 | 18839 | @opindex fsync-libcalls |
ddf6fe37 | 18840 | @item -fsync-libcalls |
d77de738 ML |
18841 | This option controls whether any out-of-line instance of the @code{__sync} |
18842 | family of functions may be used to implement the C++11 @code{__atomic} | |
18843 | family of functions. | |
18844 | ||
18845 | The default value of this option is enabled, thus the only useful form | |
18846 | of the option is @option{-fno-sync-libcalls}. This option is used in | |
18847 | the implementation of the @file{libatomic} runtime library. | |
18848 | ||
18849 | @end table | |
18850 | ||
18851 | @node Developer Options | |
18852 | @section GCC Developer Options | |
18853 | @cindex developer options | |
18854 | @cindex debugging GCC | |
18855 | @cindex debug dump options | |
18856 | @cindex dump options | |
18857 | @cindex compilation statistics | |
18858 | ||
18859 | This section describes command-line options that are primarily of | |
18860 | interest to GCC developers, including options to support compiler | |
18861 | testing and investigation of compiler bugs and compile-time | |
18862 | performance problems. This includes options that produce debug dumps | |
18863 | at various points in the compilation; that print statistics such as | |
18864 | memory use and execution time; and that print information about GCC's | |
18865 | configuration, such as where it searches for libraries. You should | |
18866 | rarely need to use any of these options for ordinary compilation and | |
18867 | linking tasks. | |
18868 | ||
18869 | Many developer options that cause GCC to dump output to a file take an | |
18870 | optional @samp{=@var{filename}} suffix. You can specify @samp{stdout} | |
18871 | or @samp{-} to dump to standard output, and @samp{stderr} for standard | |
18872 | error. | |
18873 | ||
18874 | If @samp{=@var{filename}} is omitted, a default dump file name is | |
18875 | constructed by concatenating the base dump file name, a pass number, | |
18876 | phase letter, and pass name. The base dump file name is the name of | |
18877 | output file produced by the compiler if explicitly specified and not | |
18878 | an executable; otherwise it is the source file name. | |
18879 | The pass number is determined by the order passes are registered with | |
18880 | the compiler's pass manager. | |
18881 | This is generally the same as the order of execution, but passes | |
18882 | registered by plugins, target-specific passes, or passes that are | |
18883 | otherwise registered late are numbered higher than the pass named | |
18884 | @samp{final}, even if they are executed earlier. The phase letter is | |
18885 | one of @samp{i} (inter-procedural analysis), @samp{l} | |
18886 | (language-specific), @samp{r} (RTL), or @samp{t} (tree). | |
18887 | The files are created in the directory of the output file. | |
18888 | ||
18889 | @table @gcctabopt | |
18890 | ||
ddf6fe37 | 18891 | @opindex fcallgraph-info |
d77de738 ML |
18892 | @item -fcallgraph-info |
18893 | @itemx -fcallgraph-info=@var{MARKERS} | |
d77de738 ML |
18894 | Makes the compiler output callgraph information for the program, on a |
18895 | per-object-file basis. The information is generated in the common VCG | |
18896 | format. It can be decorated with additional, per-node and/or per-edge | |
18897 | information, if a list of comma-separated markers is additionally | |
18898 | specified. When the @code{su} marker is specified, the callgraph is | |
18899 | decorated with stack usage information; it is equivalent to | |
18900 | @option{-fstack-usage}. When the @code{da} marker is specified, the | |
18901 | callgraph is decorated with information about dynamically allocated | |
18902 | objects. | |
18903 | ||
18904 | When compiling with @option{-flto}, no callgraph information is output | |
18905 | along with the object file. At LTO link time, @option{-fcallgraph-info} | |
18906 | may generate multiple callgraph information files next to intermediate | |
18907 | LTO output files. | |
18908 | ||
ddf6fe37 AA |
18909 | @opindex d |
18910 | @opindex fdump-rtl-@var{pass} | |
d77de738 ML |
18911 | @item -d@var{letters} |
18912 | @itemx -fdump-rtl-@var{pass} | |
18913 | @itemx -fdump-rtl-@var{pass}=@var{filename} | |
d77de738 ML |
18914 | Says to make debugging dumps during compilation at times specified by |
18915 | @var{letters}. This is used for debugging the RTL-based passes of the | |
18916 | compiler. | |
18917 | ||
18918 | Some @option{-d@var{letters}} switches have different meaning when | |
18919 | @option{-E} is used for preprocessing. @xref{Preprocessor Options}, | |
18920 | for information about preprocessor-specific dump options. | |
18921 | ||
18922 | Debug dumps can be enabled with a @option{-fdump-rtl} switch or some | |
18923 | @option{-d} option @var{letters}. Here are the possible | |
18924 | letters for use in @var{pass} and @var{letters}, and their meanings: | |
18925 | ||
18926 | @table @gcctabopt | |
18927 | ||
d77de738 | 18928 | @opindex fdump-rtl-alignments |
ddf6fe37 | 18929 | @item -fdump-rtl-alignments |
d77de738 ML |
18930 | Dump after branch alignments have been computed. |
18931 | ||
d77de738 | 18932 | @opindex fdump-rtl-asmcons |
ddf6fe37 | 18933 | @item -fdump-rtl-asmcons |
d77de738 ML |
18934 | Dump after fixing rtl statements that have unsatisfied in/out constraints. |
18935 | ||
d77de738 | 18936 | @opindex fdump-rtl-auto_inc_dec |
ddf6fe37 | 18937 | @item -fdump-rtl-auto_inc_dec |
d77de738 ML |
18938 | Dump after auto-inc-dec discovery. This pass is only run on |
18939 | architectures that have auto inc or auto dec instructions. | |
18940 | ||
d77de738 | 18941 | @opindex fdump-rtl-barriers |
ddf6fe37 | 18942 | @item -fdump-rtl-barriers |
d77de738 ML |
18943 | Dump after cleaning up the barrier instructions. |
18944 | ||
d77de738 | 18945 | @opindex fdump-rtl-bbpart |
ddf6fe37 | 18946 | @item -fdump-rtl-bbpart |
d77de738 ML |
18947 | Dump after partitioning hot and cold basic blocks. |
18948 | ||
d77de738 | 18949 | @opindex fdump-rtl-bbro |
ddf6fe37 | 18950 | @item -fdump-rtl-bbro |
d77de738 ML |
18951 | Dump after block reordering. |
18952 | ||
d77de738 ML |
18953 | @opindex fdump-rtl-btl2 |
18954 | @opindex fdump-rtl-btl2 | |
ddf6fe37 AA |
18955 | @item -fdump-rtl-btl1 |
18956 | @itemx -fdump-rtl-btl2 | |
d77de738 ML |
18957 | @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping |
18958 | after the two branch | |
18959 | target load optimization passes. | |
18960 | ||
d77de738 | 18961 | @opindex fdump-rtl-bypass |
ddf6fe37 | 18962 | @item -fdump-rtl-bypass |
d77de738 ML |
18963 | Dump after jump bypassing and control flow optimizations. |
18964 | ||
d77de738 | 18965 | @opindex fdump-rtl-combine |
ddf6fe37 | 18966 | @item -fdump-rtl-combine |
d77de738 ML |
18967 | Dump after the RTL instruction combination pass. |
18968 | ||
d77de738 | 18969 | @opindex fdump-rtl-compgotos |
ddf6fe37 | 18970 | @item -fdump-rtl-compgotos |
d77de738 ML |
18971 | Dump after duplicating the computed gotos. |
18972 | ||
d77de738 ML |
18973 | @opindex fdump-rtl-ce1 |
18974 | @opindex fdump-rtl-ce2 | |
18975 | @opindex fdump-rtl-ce3 | |
ddf6fe37 AA |
18976 | @item -fdump-rtl-ce1 |
18977 | @itemx -fdump-rtl-ce2 | |
18978 | @itemx -fdump-rtl-ce3 | |
d77de738 ML |
18979 | @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and |
18980 | @option{-fdump-rtl-ce3} enable dumping after the three | |
18981 | if conversion passes. | |
18982 | ||
d77de738 | 18983 | @opindex fdump-rtl-cprop_hardreg |
ddf6fe37 | 18984 | @item -fdump-rtl-cprop_hardreg |
d77de738 ML |
18985 | Dump after hard register copy propagation. |
18986 | ||
d77de738 | 18987 | @opindex fdump-rtl-csa |
ddf6fe37 | 18988 | @item -fdump-rtl-csa |
d77de738 ML |
18989 | Dump after combining stack adjustments. |
18990 | ||
d77de738 ML |
18991 | @opindex fdump-rtl-cse1 |
18992 | @opindex fdump-rtl-cse2 | |
ddf6fe37 AA |
18993 | @item -fdump-rtl-cse1 |
18994 | @itemx -fdump-rtl-cse2 | |
d77de738 ML |
18995 | @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after |
18996 | the two common subexpression elimination passes. | |
18997 | ||
d77de738 | 18998 | @opindex fdump-rtl-dce |
ddf6fe37 | 18999 | @item -fdump-rtl-dce |
d77de738 ML |
19000 | Dump after the standalone dead code elimination passes. |
19001 | ||
d77de738 | 19002 | @opindex fdump-rtl-dbr |
ddf6fe37 | 19003 | @item -fdump-rtl-dbr |
d77de738 ML |
19004 | Dump after delayed branch scheduling. |
19005 | ||
d77de738 ML |
19006 | @opindex fdump-rtl-dce1 |
19007 | @opindex fdump-rtl-dce2 | |
ddf6fe37 AA |
19008 | @item -fdump-rtl-dce1 |
19009 | @itemx -fdump-rtl-dce2 | |
d77de738 ML |
19010 | @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after |
19011 | the two dead store elimination passes. | |
19012 | ||
d77de738 | 19013 | @opindex fdump-rtl-eh |
ddf6fe37 | 19014 | @item -fdump-rtl-eh |
d77de738 ML |
19015 | Dump after finalization of EH handling code. |
19016 | ||
d77de738 | 19017 | @opindex fdump-rtl-eh_ranges |
ddf6fe37 | 19018 | @item -fdump-rtl-eh_ranges |
d77de738 ML |
19019 | Dump after conversion of EH handling range regions. |
19020 | ||
d77de738 | 19021 | @opindex fdump-rtl-expand |
ddf6fe37 | 19022 | @item -fdump-rtl-expand |
d77de738 ML |
19023 | Dump after RTL generation. |
19024 | ||
d77de738 ML |
19025 | @opindex fdump-rtl-fwprop1 |
19026 | @opindex fdump-rtl-fwprop2 | |
ddf6fe37 AA |
19027 | @item -fdump-rtl-fwprop1 |
19028 | @itemx -fdump-rtl-fwprop2 | |
d77de738 ML |
19029 | @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable |
19030 | dumping after the two forward propagation passes. | |
19031 | ||
d77de738 ML |
19032 | @opindex fdump-rtl-gcse1 |
19033 | @opindex fdump-rtl-gcse2 | |
ddf6fe37 AA |
19034 | @item -fdump-rtl-gcse1 |
19035 | @itemx -fdump-rtl-gcse2 | |
d77de738 ML |
19036 | @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping |
19037 | after global common subexpression elimination. | |
19038 | ||
d77de738 | 19039 | @opindex fdump-rtl-init-regs |
ddf6fe37 | 19040 | @item -fdump-rtl-init-regs |
d77de738 ML |
19041 | Dump after the initialization of the registers. |
19042 | ||
d77de738 | 19043 | @opindex fdump-rtl-initvals |
ddf6fe37 | 19044 | @item -fdump-rtl-initvals |
d77de738 ML |
19045 | Dump after the computation of the initial value sets. |
19046 | ||
d77de738 | 19047 | @opindex fdump-rtl-into_cfglayout |
ddf6fe37 | 19048 | @item -fdump-rtl-into_cfglayout |
d77de738 ML |
19049 | Dump after converting to cfglayout mode. |
19050 | ||
d77de738 | 19051 | @opindex fdump-rtl-ira |
ddf6fe37 | 19052 | @item -fdump-rtl-ira |
d77de738 ML |
19053 | Dump after iterated register allocation. |
19054 | ||
d77de738 | 19055 | @opindex fdump-rtl-jump |
ddf6fe37 | 19056 | @item -fdump-rtl-jump |
d77de738 ML |
19057 | Dump after the second jump optimization. |
19058 | ||
d77de738 | 19059 | @opindex fdump-rtl-loop2 |
ddf6fe37 | 19060 | @item -fdump-rtl-loop2 |
d77de738 ML |
19061 | @option{-fdump-rtl-loop2} enables dumping after the rtl |
19062 | loop optimization passes. | |
19063 | ||
d77de738 | 19064 | @opindex fdump-rtl-mach |
ddf6fe37 | 19065 | @item -fdump-rtl-mach |
d77de738 ML |
19066 | Dump after performing the machine dependent reorganization pass, if that |
19067 | pass exists. | |
19068 | ||
d77de738 | 19069 | @opindex fdump-rtl-mode_sw |
ddf6fe37 | 19070 | @item -fdump-rtl-mode_sw |
d77de738 ML |
19071 | Dump after removing redundant mode switches. |
19072 | ||
d77de738 | 19073 | @opindex fdump-rtl-rnreg |
ddf6fe37 | 19074 | @item -fdump-rtl-rnreg |
d77de738 ML |
19075 | Dump after register renumbering. |
19076 | ||
d77de738 | 19077 | @opindex fdump-rtl-outof_cfglayout |
ddf6fe37 | 19078 | @item -fdump-rtl-outof_cfglayout |
d77de738 ML |
19079 | Dump after converting from cfglayout mode. |
19080 | ||
d77de738 | 19081 | @opindex fdump-rtl-peephole2 |
ddf6fe37 | 19082 | @item -fdump-rtl-peephole2 |
d77de738 ML |
19083 | Dump after the peephole pass. |
19084 | ||
d77de738 | 19085 | @opindex fdump-rtl-postreload |
ddf6fe37 | 19086 | @item -fdump-rtl-postreload |
d77de738 ML |
19087 | Dump after post-reload optimizations. |
19088 | ||
d77de738 | 19089 | @opindex fdump-rtl-pro_and_epilogue |
ddf6fe37 | 19090 | @item -fdump-rtl-pro_and_epilogue |
d77de738 ML |
19091 | Dump after generating the function prologues and epilogues. |
19092 | ||
d77de738 ML |
19093 | @opindex fdump-rtl-sched1 |
19094 | @opindex fdump-rtl-sched2 | |
ddf6fe37 AA |
19095 | @item -fdump-rtl-sched1 |
19096 | @itemx -fdump-rtl-sched2 | |
d77de738 ML |
19097 | @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping |
19098 | after the basic block scheduling passes. | |
19099 | ||
d77de738 | 19100 | @opindex fdump-rtl-ree |
ddf6fe37 | 19101 | @item -fdump-rtl-ree |
d77de738 ML |
19102 | Dump after sign/zero extension elimination. |
19103 | ||
d77de738 | 19104 | @opindex fdump-rtl-seqabstr |
ddf6fe37 | 19105 | @item -fdump-rtl-seqabstr |
d77de738 ML |
19106 | Dump after common sequence discovery. |
19107 | ||
d77de738 | 19108 | @opindex fdump-rtl-shorten |
ddf6fe37 | 19109 | @item -fdump-rtl-shorten |
d77de738 ML |
19110 | Dump after shortening branches. |
19111 | ||
d77de738 | 19112 | @opindex fdump-rtl-sibling |
ddf6fe37 | 19113 | @item -fdump-rtl-sibling |
d77de738 ML |
19114 | Dump after sibling call optimizations. |
19115 | ||
d77de738 ML |
19116 | @opindex fdump-rtl-split1 |
19117 | @opindex fdump-rtl-split2 | |
19118 | @opindex fdump-rtl-split3 | |
19119 | @opindex fdump-rtl-split4 | |
19120 | @opindex fdump-rtl-split5 | |
ddf6fe37 AA |
19121 | @item -fdump-rtl-split1 |
19122 | @itemx -fdump-rtl-split2 | |
19123 | @itemx -fdump-rtl-split3 | |
19124 | @itemx -fdump-rtl-split4 | |
19125 | @itemx -fdump-rtl-split5 | |
d77de738 ML |
19126 | These options enable dumping after five rounds of |
19127 | instruction splitting. | |
19128 | ||
d77de738 | 19129 | @opindex fdump-rtl-sms |
ddf6fe37 | 19130 | @item -fdump-rtl-sms |
d77de738 ML |
19131 | Dump after modulo scheduling. This pass is only run on some |
19132 | architectures. | |
19133 | ||
d77de738 | 19134 | @opindex fdump-rtl-stack |
ddf6fe37 | 19135 | @item -fdump-rtl-stack |
d77de738 ML |
19136 | Dump after conversion from GCC's ``flat register file'' registers to the |
19137 | x87's stack-like registers. This pass is only run on x86 variants. | |
19138 | ||
d77de738 ML |
19139 | @opindex fdump-rtl-subreg1 |
19140 | @opindex fdump-rtl-subreg2 | |
ddf6fe37 AA |
19141 | @item -fdump-rtl-subreg1 |
19142 | @itemx -fdump-rtl-subreg2 | |
d77de738 ML |
19143 | @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after |
19144 | the two subreg expansion passes. | |
19145 | ||
d77de738 | 19146 | @opindex fdump-rtl-unshare |
ddf6fe37 | 19147 | @item -fdump-rtl-unshare |
d77de738 ML |
19148 | Dump after all rtl has been unshared. |
19149 | ||
d77de738 | 19150 | @opindex fdump-rtl-vartrack |
ddf6fe37 | 19151 | @item -fdump-rtl-vartrack |
d77de738 ML |
19152 | Dump after variable tracking. |
19153 | ||
d77de738 | 19154 | @opindex fdump-rtl-vregs |
ddf6fe37 | 19155 | @item -fdump-rtl-vregs |
d77de738 ML |
19156 | Dump after converting virtual registers to hard registers. |
19157 | ||
d77de738 | 19158 | @opindex fdump-rtl-web |
ddf6fe37 | 19159 | @item -fdump-rtl-web |
d77de738 ML |
19160 | Dump after live range splitting. |
19161 | ||
d77de738 ML |
19162 | @opindex fdump-rtl-regclass |
19163 | @opindex fdump-rtl-subregs_of_mode_init | |
19164 | @opindex fdump-rtl-subregs_of_mode_finish | |
19165 | @opindex fdump-rtl-dfinit | |
19166 | @opindex fdump-rtl-dfinish | |
ddf6fe37 AA |
19167 | @item -fdump-rtl-regclass |
19168 | @itemx -fdump-rtl-subregs_of_mode_init | |
19169 | @itemx -fdump-rtl-subregs_of_mode_finish | |
19170 | @itemx -fdump-rtl-dfinit | |
19171 | @itemx -fdump-rtl-dfinish | |
d77de738 ML |
19172 | These dumps are defined but always produce empty files. |
19173 | ||
d77de738 ML |
19174 | @opindex da |
19175 | @opindex fdump-rtl-all | |
ddf6fe37 AA |
19176 | @item -da |
19177 | @itemx -fdump-rtl-all | |
d77de738 ML |
19178 | Produce all the dumps listed above. |
19179 | ||
d77de738 | 19180 | @opindex dA |
ddf6fe37 | 19181 | @item -dA |
d77de738 ML |
19182 | Annotate the assembler output with miscellaneous debugging information. |
19183 | ||
d77de738 | 19184 | @opindex dD |
ddf6fe37 | 19185 | @item -dD |
d77de738 ML |
19186 | Dump all macro definitions, at the end of preprocessing, in addition to |
19187 | normal output. | |
19188 | ||
d77de738 | 19189 | @opindex dH |
ddf6fe37 | 19190 | @item -dH |
d77de738 ML |
19191 | Produce a core dump whenever an error occurs. |
19192 | ||
d77de738 | 19193 | @opindex dp |
ddf6fe37 | 19194 | @item -dp |
d77de738 ML |
19195 | Annotate the assembler output with a comment indicating which |
19196 | pattern and alternative is used. The length and cost of each instruction are | |
19197 | also printed. | |
19198 | ||
d77de738 | 19199 | @opindex dP |
ddf6fe37 | 19200 | @item -dP |
d77de738 ML |
19201 | Dump the RTL in the assembler output as a comment before each instruction. |
19202 | Also turns on @option{-dp} annotation. | |
19203 | ||
d77de738 | 19204 | @opindex dx |
ddf6fe37 | 19205 | @item -dx |
d77de738 ML |
19206 | Just generate RTL for a function instead of compiling it. Usually used |
19207 | with @option{-fdump-rtl-expand}. | |
19208 | @end table | |
19209 | ||
d77de738 | 19210 | @opindex fdump-debug |
ddf6fe37 | 19211 | @item -fdump-debug |
d77de738 ML |
19212 | Dump debugging information generated during the debug |
19213 | generation phase. | |
19214 | ||
d77de738 | 19215 | @opindex fdump-earlydebug |
ddf6fe37 | 19216 | @item -fdump-earlydebug |
d77de738 ML |
19217 | Dump debugging information generated during the early debug |
19218 | generation phase. | |
19219 | ||
d77de738 | 19220 | @opindex fdump-noaddr |
ddf6fe37 | 19221 | @item -fdump-noaddr |
d77de738 ML |
19222 | When doing debugging dumps, suppress address output. This makes it more |
19223 | feasible to use diff on debugging dumps for compiler invocations with | |
19224 | different compiler binaries and/or different | |
19225 | text / bss / data / heap / stack / dso start locations. | |
19226 | ||
d77de738 | 19227 | @opindex freport-bug |
ddf6fe37 | 19228 | @item -freport-bug |
d77de738 ML |
19229 | Collect and dump debug information into a temporary file if an |
19230 | internal compiler error (ICE) occurs. | |
19231 | ||
d77de738 | 19232 | @opindex fdump-unnumbered |
ddf6fe37 | 19233 | @item -fdump-unnumbered |
d77de738 ML |
19234 | When doing debugging dumps, suppress instruction numbers and address output. |
19235 | This makes it more feasible to use diff on debugging dumps for compiler | |
19236 | invocations with different options, in particular with and without | |
19237 | @option{-g}. | |
19238 | ||
d77de738 | 19239 | @opindex fdump-unnumbered-links |
ddf6fe37 | 19240 | @item -fdump-unnumbered-links |
d77de738 ML |
19241 | When doing debugging dumps (see @option{-d} option above), suppress |
19242 | instruction numbers for the links to the previous and next instructions | |
19243 | in a sequence. | |
19244 | ||
ddf6fe37 | 19245 | @opindex fdump-ipa |
d77de738 ML |
19246 | @item -fdump-ipa-@var{switch} |
19247 | @itemx -fdump-ipa-@var{switch}-@var{options} | |
d77de738 ML |
19248 | Control the dumping at various stages of inter-procedural analysis |
19249 | language tree to a file. The file name is generated by appending a | |
19250 | switch specific suffix to the source file name, and the file is created | |
19251 | in the same directory as the output file. The following dumps are | |
19252 | possible: | |
19253 | ||
19254 | @table @samp | |
19255 | @item all | |
19256 | Enables all inter-procedural analysis dumps. | |
19257 | ||
19258 | @item cgraph | |
19259 | Dumps information about call-graph optimization, unused function removal, | |
19260 | and inlining decisions. | |
19261 | ||
19262 | @item inline | |
19263 | Dump after function inlining. | |
19264 | ||
19265 | @end table | |
19266 | ||
19267 | Additionally, the options @option{-optimized}, @option{-missed}, | |
19268 | @option{-note}, and @option{-all} can be provided, with the same meaning | |
19269 | as for @option{-fopt-info}, defaulting to @option{-optimized}. | |
19270 | ||
19271 | For example, @option{-fdump-ipa-inline-optimized-missed} will emit | |
19272 | information on callsites that were inlined, along with callsites | |
19273 | that were not inlined. | |
19274 | ||
19275 | By default, the dump will contain messages about successful | |
19276 | optimizations (equivalent to @option{-optimized}) together with | |
19277 | low-level details about the analysis. | |
19278 | ||
d77de738 | 19279 | @opindex fdump-lang |
ddf6fe37 | 19280 | @item -fdump-lang |
d77de738 ML |
19281 | Dump language-specific information. The file name is made by appending |
19282 | @file{.lang} to the source file name. | |
19283 | ||
ddf6fe37 AA |
19284 | @opindex fdump-lang-all |
19285 | @opindex fdump-lang | |
d77de738 ML |
19286 | @item -fdump-lang-all |
19287 | @itemx -fdump-lang-@var{switch} | |
19288 | @itemx -fdump-lang-@var{switch}-@var{options} | |
19289 | @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19290 | Control the dumping of language-specific information. The @var{options} |
19291 | and @var{filename} portions behave as described in the | |
19292 | @option{-fdump-tree} option. The following @var{switch} values are | |
19293 | accepted: | |
19294 | ||
19295 | @table @samp | |
19296 | @item all | |
19297 | ||
19298 | Enable all language-specific dumps. | |
19299 | ||
19300 | @item class | |
19301 | Dump class hierarchy information. Virtual table information is emitted | |
19302 | unless '@option{slim}' is specified. This option is applicable to C++ only. | |
19303 | ||
19304 | @item module | |
19305 | Dump module information. Options @option{lineno} (locations), | |
19306 | @option{graph} (reachability), @option{blocks} (clusters), | |
19307 | @option{uid} (serialization), @option{alias} (mergeable), | |
19308 | @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops} | |
19309 | (macros) may provide additional information. This option is | |
19310 | applicable to C++ only. | |
19311 | ||
19312 | @item raw | |
19313 | Dump the raw internal tree data. This option is applicable to C++ only. | |
19314 | ||
19315 | @end table | |
19316 | ||
d77de738 | 19317 | @opindex fdump-passes |
ddf6fe37 | 19318 | @item -fdump-passes |
d77de738 ML |
19319 | Print on @file{stderr} the list of optimization passes that are turned |
19320 | on and off by the current command-line options. | |
19321 | ||
d77de738 | 19322 | @opindex fdump-statistics |
ddf6fe37 | 19323 | @item -fdump-statistics-@var{option} |
d77de738 ML |
19324 | Enable and control dumping of pass statistics in a separate file. The |
19325 | file name is generated by appending a suffix ending in | |
19326 | @samp{.statistics} to the source file name, and the file is created in | |
19327 | the same directory as the output file. If the @samp{-@var{option}} | |
19328 | form is used, @samp{-stats} causes counters to be summed over the | |
19329 | whole compilation unit while @samp{-details} dumps every event as | |
19330 | the passes generate them. The default with no option is to sum | |
19331 | counters for each function compiled. | |
19332 | ||
ddf6fe37 AA |
19333 | @opindex fdump-tree-all |
19334 | @opindex fdump-tree | |
d77de738 ML |
19335 | @item -fdump-tree-all |
19336 | @itemx -fdump-tree-@var{switch} | |
19337 | @itemx -fdump-tree-@var{switch}-@var{options} | |
19338 | @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19339 | Control the dumping at various stages of processing the intermediate |
19340 | language tree to a file. If the @samp{-@var{options}} | |
19341 | form is used, @var{options} is a list of @samp{-} separated options | |
19342 | which control the details of the dump. Not all options are applicable | |
19343 | to all dumps; those that are not meaningful are ignored. The | |
19344 | following options are available | |
19345 | ||
19346 | @table @samp | |
19347 | @item address | |
19348 | Print the address of each node. Usually this is not meaningful as it | |
19349 | changes according to the environment and source file. Its primary use | |
19350 | is for tying up a dump file with a debug environment. | |
19351 | @item asmname | |
19352 | If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that | |
19353 | in the dump instead of @code{DECL_NAME}. Its primary use is ease of | |
19354 | use working backward from mangled names in the assembly file. | |
19355 | @item slim | |
19356 | When dumping front-end intermediate representations, inhibit dumping | |
19357 | of members of a scope or body of a function merely because that scope | |
19358 | has been reached. Only dump such items when they are directly reachable | |
19359 | by some other path. | |
19360 | ||
19361 | When dumping pretty-printed trees, this option inhibits dumping the | |
19362 | bodies of control structures. | |
19363 | ||
19364 | When dumping RTL, print the RTL in slim (condensed) form instead of | |
19365 | the default LISP-like representation. | |
19366 | @item raw | |
19367 | Print a raw representation of the tree. By default, trees are | |
19368 | pretty-printed into a C-like representation. | |
19369 | @item details | |
19370 | Enable more detailed dumps (not honored by every dump option). Also | |
19371 | include information from the optimization passes. | |
19372 | @item stats | |
19373 | Enable dumping various statistics about the pass (not honored by every dump | |
19374 | option). | |
19375 | @item blocks | |
19376 | Enable showing basic block boundaries (disabled in raw dumps). | |
19377 | @item graph | |
19378 | For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}), | |
19379 | dump a representation of the control flow graph suitable for viewing with | |
19380 | GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in | |
19381 | the file is pretty-printed as a subgraph, so that GraphViz can render them | |
19382 | all in a single plot. | |
19383 | ||
19384 | This option currently only works for RTL dumps, and the RTL is always | |
19385 | dumped in slim form. | |
19386 | @item vops | |
19387 | Enable showing virtual operands for every statement. | |
19388 | @item lineno | |
19389 | Enable showing line numbers for statements. | |
19390 | @item uid | |
19391 | Enable showing the unique ID (@code{DECL_UID}) for each variable. | |
19392 | @item verbose | |
19393 | Enable showing the tree dump for each statement. | |
19394 | @item eh | |
19395 | Enable showing the EH region number holding each statement. | |
19396 | @item scev | |
19397 | Enable showing scalar evolution analysis details. | |
19398 | @item optimized | |
19399 | Enable showing optimization information (only available in certain | |
19400 | passes). | |
19401 | @item missed | |
19402 | Enable showing missed optimization information (only available in certain | |
19403 | passes). | |
19404 | @item note | |
19405 | Enable other detailed optimization information (only available in | |
19406 | certain passes). | |
19407 | @item all | |
19408 | Turn on all options, except @option{raw}, @option{slim}, @option{verbose} | |
19409 | and @option{lineno}. | |
19410 | @item optall | |
19411 | Turn on all optimization options, i.e., @option{optimized}, | |
19412 | @option{missed}, and @option{note}. | |
19413 | @end table | |
19414 | ||
19415 | To determine what tree dumps are available or find the dump for a pass | |
19416 | of interest follow the steps below. | |
19417 | ||
19418 | @enumerate | |
19419 | @item | |
19420 | Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output | |
19421 | look for a code that corresponds to the pass you are interested in. | |
19422 | For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and | |
19423 | @code{tree-vrp2} correspond to the three Value Range Propagation passes. | |
19424 | The number at the end distinguishes distinct invocations of the same pass. | |
19425 | @item | |
19426 | To enable the creation of the dump file, append the pass code to | |
19427 | the @option{-fdump-} option prefix and invoke GCC with it. For example, | |
19428 | to enable the dump from the Early Value Range Propagation pass, invoke | |
19429 | GCC with the @option{-fdump-tree-evrp} option. Optionally, you may | |
19430 | specify the name of the dump file. If you don't specify one, GCC | |
19431 | creates as described below. | |
19432 | @item | |
19433 | Find the pass dump in a file whose name is composed of three components | |
19434 | separated by a period: the name of the source file GCC was invoked to | |
19435 | compile, a numeric suffix indicating the pass number followed by the | |
19436 | letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes), | |
19437 | and finally the pass code. For example, the Early VRP pass dump might | |
19438 | be in a file named @file{myfile.c.038t.evrp} in the current working | |
19439 | directory. Note that the numeric codes are not stable and may change | |
19440 | from one version of GCC to another. | |
19441 | @end enumerate | |
19442 | ||
ddf6fe37 | 19443 | @opindex fopt-info |
d77de738 ML |
19444 | @item -fopt-info |
19445 | @itemx -fopt-info-@var{options} | |
19446 | @itemx -fopt-info-@var{options}=@var{filename} | |
d77de738 ML |
19447 | Controls optimization dumps from various optimization passes. If the |
19448 | @samp{-@var{options}} form is used, @var{options} is a list of | |
19449 | @samp{-} separated option keywords to select the dump details and | |
19450 | optimizations. | |
19451 | ||
19452 | The @var{options} can be divided into three groups: | |
19453 | @enumerate | |
19454 | @item | |
19455 | options describing what kinds of messages should be emitted, | |
19456 | @item | |
19457 | options describing the verbosity of the dump, and | |
19458 | @item | |
19459 | options describing which optimizations should be included. | |
19460 | @end enumerate | |
19461 | The options from each group can be freely mixed as they are | |
19462 | non-overlapping. However, in case of any conflicts, | |
19463 | the later options override the earlier options on the command | |
19464 | line. | |
19465 | ||
19466 | The following options control which kinds of messages should be emitted: | |
19467 | ||
19468 | @table @samp | |
19469 | @item optimized | |
19470 | Print information when an optimization is successfully applied. It is | |
19471 | up to a pass to decide which information is relevant. For example, the | |
19472 | vectorizer passes print the source location of loops which are | |
19473 | successfully vectorized. | |
19474 | @item missed | |
19475 | Print information about missed optimizations. Individual passes | |
19476 | control which information to include in the output. | |
19477 | @item note | |
19478 | Print verbose information about optimizations, such as certain | |
19479 | transformations, more detailed messages about decisions etc. | |
19480 | @item all | |
19481 | Print detailed optimization information. This includes | |
19482 | @samp{optimized}, @samp{missed}, and @samp{note}. | |
19483 | @end table | |
19484 | ||
19485 | The following option controls the dump verbosity: | |
19486 | ||
19487 | @table @samp | |
19488 | @item internals | |
19489 | By default, only ``high-level'' messages are emitted. This option enables | |
19490 | additional, more detailed, messages, which are likely to only be of interest | |
19491 | to GCC developers. | |
19492 | @end table | |
19493 | ||
19494 | One or more of the following option keywords can be used to describe a | |
19495 | group of optimizations: | |
19496 | ||
19497 | @table @samp | |
19498 | @item ipa | |
19499 | Enable dumps from all interprocedural optimizations. | |
19500 | @item loop | |
19501 | Enable dumps from all loop optimizations. | |
19502 | @item inline | |
19503 | Enable dumps from all inlining optimizations. | |
19504 | @item omp | |
19505 | Enable dumps from all OMP (Offloading and Multi Processing) optimizations. | |
19506 | @item vec | |
19507 | Enable dumps from all vectorization optimizations. | |
19508 | @item optall | |
19509 | Enable dumps from all optimizations. This is a superset of | |
19510 | the optimization groups listed above. | |
19511 | @end table | |
19512 | ||
19513 | If @var{options} is | |
19514 | omitted, it defaults to @samp{optimized-optall}, which means to dump messages | |
19515 | about successful optimizations from all the passes, omitting messages | |
19516 | that are treated as ``internals''. | |
19517 | ||
19518 | If the @var{filename} is provided, then the dumps from all the | |
19519 | applicable optimizations are concatenated into the @var{filename}. | |
19520 | Otherwise the dump is output onto @file{stderr}. Though multiple | |
19521 | @option{-fopt-info} options are accepted, only one of them can include | |
19522 | a @var{filename}. If other filenames are provided then all but the | |
19523 | first such option are ignored. | |
19524 | ||
19525 | Note that the output @var{filename} is overwritten | |
19526 | in case of multiple translation units. If a combined output from | |
19527 | multiple translation units is desired, @file{stderr} should be used | |
19528 | instead. | |
19529 | ||
19530 | In the following example, the optimization info is output to | |
19531 | @file{stderr}: | |
19532 | ||
19533 | @smallexample | |
19534 | gcc -O3 -fopt-info | |
19535 | @end smallexample | |
19536 | ||
19537 | This example: | |
19538 | @smallexample | |
19539 | gcc -O3 -fopt-info-missed=missed.all | |
19540 | @end smallexample | |
19541 | ||
19542 | @noindent | |
19543 | outputs missed optimization report from all the passes into | |
19544 | @file{missed.all}, and this one: | |
19545 | ||
19546 | @smallexample | |
19547 | gcc -O2 -ftree-vectorize -fopt-info-vec-missed | |
19548 | @end smallexample | |
19549 | ||
19550 | @noindent | |
19551 | prints information about missed optimization opportunities from | |
19552 | vectorization passes on @file{stderr}. | |
19553 | Note that @option{-fopt-info-vec-missed} is equivalent to | |
19554 | @option{-fopt-info-missed-vec}. The order of the optimization group | |
19555 | names and message types listed after @option{-fopt-info} does not matter. | |
19556 | ||
19557 | As another example, | |
19558 | @smallexample | |
19559 | gcc -O3 -fopt-info-inline-optimized-missed=inline.txt | |
19560 | @end smallexample | |
19561 | ||
19562 | @noindent | |
19563 | outputs information about missed optimizations as well as | |
19564 | optimized locations from all the inlining passes into | |
19565 | @file{inline.txt}. | |
19566 | ||
19567 | Finally, consider: | |
19568 | ||
19569 | @smallexample | |
19570 | gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt | |
19571 | @end smallexample | |
19572 | ||
19573 | @noindent | |
19574 | Here the two output filenames @file{vec.miss} and @file{loop.opt} are | |
19575 | in conflict since only one output file is allowed. In this case, only | |
19576 | the first option takes effect and the subsequent options are | |
19577 | ignored. Thus only @file{vec.miss} is produced which contains | |
19578 | dumps from the vectorizer about missed opportunities. | |
19579 | ||
d77de738 | 19580 | @opindex fsave-optimization-record |
ddf6fe37 | 19581 | @item -fsave-optimization-record |
d77de738 ML |
19582 | Write a SRCFILE.opt-record.json.gz file detailing what optimizations |
19583 | were performed, for those optimizations that support @option{-fopt-info}. | |
19584 | ||
19585 | This option is experimental and the format of the data within the | |
19586 | compressed JSON file is subject to change. | |
19587 | ||
19588 | It is roughly equivalent to a machine-readable version of | |
19589 | @option{-fopt-info-all}, as a collection of messages with source file, | |
19590 | line number and column number, with the following additional data for | |
19591 | each message: | |
19592 | ||
19593 | @itemize @bullet | |
19594 | ||
19595 | @item | |
19596 | the execution count of the code being optimized, along with metadata about | |
19597 | whether this was from actual profile data, or just an estimate, allowing | |
19598 | consumers to prioritize messages by code hotness, | |
19599 | ||
19600 | @item | |
19601 | the function name of the code being optimized, where applicable, | |
19602 | ||
19603 | @item | |
19604 | the ``inlining chain'' for the code being optimized, so that when | |
19605 | a function is inlined into several different places (which might | |
19606 | themselves be inlined), the reader can distinguish between the copies, | |
19607 | ||
19608 | @item | |
19609 | objects identifying those parts of the message that refer to expressions, | |
19610 | statements or symbol-table nodes, which of these categories they are, and, | |
19611 | when available, their source code location, | |
19612 | ||
19613 | @item | |
19614 | the GCC pass that emitted the message, and | |
19615 | ||
19616 | @item | |
19617 | the location in GCC's own code from which the message was emitted | |
19618 | ||
19619 | @end itemize | |
19620 | ||
19621 | Additionally, some messages are logically nested within other | |
19622 | messages, reflecting implementation details of the optimization | |
19623 | passes. | |
19624 | ||
d77de738 | 19625 | @opindex fsched-verbose |
ddf6fe37 | 19626 | @item -fsched-verbose=@var{n} |
d77de738 ML |
19627 | On targets that use instruction scheduling, this option controls the |
19628 | amount of debugging output the scheduler prints to the dump files. | |
19629 | ||
19630 | For @var{n} greater than zero, @option{-fsched-verbose} outputs the | |
19631 | same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}. | |
19632 | For @var{n} greater than one, it also output basic block probabilities, | |
19633 | detailed ready list information and unit/insn info. For @var{n} greater | |
19634 | than two, it includes RTL at abort point, control-flow and regions info. | |
19635 | And for @var{n} over four, @option{-fsched-verbose} also includes | |
19636 | dependence info. | |
19637 | ||
19638 | ||
19639 | ||
d77de738 ML |
19640 | @opindex fdisable- |
19641 | @opindex fenable- | |
ddf6fe37 AA |
19642 | @item -fenable-@var{kind}-@var{pass} |
19643 | @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list} | |
d77de738 ML |
19644 | |
19645 | This is a set of options that are used to explicitly disable/enable | |
19646 | optimization passes. These options are intended for use for debugging GCC. | |
19647 | Compiler users should use regular options for enabling/disabling | |
19648 | passes instead. | |
19649 | ||
19650 | @table @gcctabopt | |
19651 | ||
19652 | @item -fdisable-ipa-@var{pass} | |
19653 | Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19654 | statically invoked in the compiler multiple times, the pass name should be | |
19655 | appended with a sequential number starting from 1. | |
19656 | ||
19657 | @item -fdisable-rtl-@var{pass} | |
19658 | @itemx -fdisable-rtl-@var{pass}=@var{range-list} | |
19659 | Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19660 | statically invoked in the compiler multiple times, the pass name should be | |
19661 | appended with a sequential number starting from 1. @var{range-list} is a | |
19662 | comma-separated list of function ranges or assembler names. Each range is a number | |
19663 | pair separated by a colon. The range is inclusive in both ends. If the range | |
19664 | is trivial, the number pair can be simplified as a single number. If the | |
19665 | function's call graph node's @var{uid} falls within one of the specified ranges, | |
19666 | the @var{pass} is disabled for that function. The @var{uid} is shown in the | |
19667 | function header of a dump file, and the pass names can be dumped by using | |
19668 | option @option{-fdump-passes}. | |
19669 | ||
19670 | @item -fdisable-tree-@var{pass} | |
19671 | @itemx -fdisable-tree-@var{pass}=@var{range-list} | |
19672 | Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of | |
19673 | option arguments. | |
19674 | ||
19675 | @item -fenable-ipa-@var{pass} | |
19676 | Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19677 | statically invoked in the compiler multiple times, the pass name should be | |
19678 | appended with a sequential number starting from 1. | |
19679 | ||
19680 | @item -fenable-rtl-@var{pass} | |
19681 | @itemx -fenable-rtl-@var{pass}=@var{range-list} | |
19682 | Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument | |
19683 | description and examples. | |
19684 | ||
19685 | @item -fenable-tree-@var{pass} | |
19686 | @itemx -fenable-tree-@var{pass}=@var{range-list} | |
19687 | Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description | |
19688 | of option arguments. | |
19689 | ||
19690 | @end table | |
19691 | ||
19692 | Here are some examples showing uses of these options. | |
19693 | ||
19694 | @smallexample | |
19695 | ||
19696 | # disable ccp1 for all functions | |
19697 | -fdisable-tree-ccp1 | |
19698 | # disable complete unroll for function whose cgraph node uid is 1 | |
19699 | -fenable-tree-cunroll=1 | |
19700 | # disable gcse2 for functions at the following ranges [1,1], | |
19701 | # [300,400], and [400,1000] | |
19702 | # disable gcse2 for functions foo and foo2 | |
19703 | -fdisable-rtl-gcse2=foo,foo2 | |
19704 | # disable early inlining | |
19705 | -fdisable-tree-einline | |
19706 | # disable ipa inlining | |
19707 | -fdisable-ipa-inline | |
19708 | # enable tree full unroll | |
19709 | -fenable-tree-unroll | |
19710 | ||
19711 | @end smallexample | |
19712 | ||
d77de738 ML |
19713 | @opindex fchecking |
19714 | @opindex fno-checking | |
ddf6fe37 AA |
19715 | @item -fchecking |
19716 | @itemx -fchecking=@var{n} | |
d77de738 ML |
19717 | Enable internal consistency checking. The default depends on |
19718 | the compiler configuration. @option{-fchecking=2} enables further | |
19719 | internal consistency checking that might affect code generation. | |
19720 | ||
d77de738 | 19721 | @opindex frandom-seed |
ddf6fe37 | 19722 | @item -frandom-seed=@var{string} |
d77de738 ML |
19723 | This option provides a seed that GCC uses in place of |
19724 | random numbers in generating certain symbol names | |
19725 | that have to be different in every compiled file. It is also used to | |
19726 | place unique stamps in coverage data files and the object files that | |
19727 | produce them. You can use the @option{-frandom-seed} option to produce | |
19728 | reproducibly identical object files. | |
19729 | ||
19730 | The @var{string} can either be a number (decimal, octal or hex) or an | |
19731 | arbitrary string (in which case it's converted to a number by | |
19732 | computing CRC32). | |
19733 | ||
19734 | The @var{string} should be different for every file you compile. | |
19735 | ||
d77de738 | 19736 | @opindex save-temps |
ddf6fe37 | 19737 | @item -save-temps |
d77de738 ML |
19738 | Store the usual ``temporary'' intermediate files permanently; name them |
19739 | as auxiliary output files, as specified described under | |
19740 | @option{-dumpbase} and @option{-dumpdir}. | |
19741 | ||
19742 | When used in combination with the @option{-x} command-line option, | |
19743 | @option{-save-temps} is sensible enough to avoid overwriting an | |
19744 | input source file with the same extension as an intermediate file. | |
19745 | The corresponding intermediate file may be obtained by renaming the | |
19746 | source file before using @option{-save-temps}. | |
19747 | ||
d77de738 | 19748 | @opindex save-temps=cwd |
ddf6fe37 | 19749 | @item -save-temps=cwd |
d77de738 ML |
19750 | Equivalent to @option{-save-temps -dumpdir ./}. |
19751 | ||
d77de738 | 19752 | @opindex save-temps=obj |
ddf6fe37 | 19753 | @item -save-temps=obj |
d77de738 ML |
19754 | Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where |
19755 | @file{outdir/} is the directory of the output file specified after the | |
19756 | @option{-o} option, including any directory separators. If the | |
19757 | @option{-o} option is not used, the @option{-save-temps=obj} switch | |
19758 | behaves like @option{-save-temps=cwd}. | |
19759 | ||
d77de738 | 19760 | @opindex time |
ddf6fe37 | 19761 | @item -time@r{[}=@var{file}@r{]} |
d77de738 ML |
19762 | Report the CPU time taken by each subprocess in the compilation |
19763 | sequence. For C source files, this is the compiler proper and assembler | |
19764 | (plus the linker if linking is done). | |
19765 | ||
19766 | Without the specification of an output file, the output looks like this: | |
19767 | ||
19768 | @smallexample | |
19769 | # cc1 0.12 0.01 | |
19770 | # as 0.00 0.01 | |
19771 | @end smallexample | |
19772 | ||
19773 | The first number on each line is the ``user time'', that is time spent | |
19774 | executing the program itself. The second number is ``system time'', | |
19775 | time spent executing operating system routines on behalf of the program. | |
19776 | Both numbers are in seconds. | |
19777 | ||
19778 | With the specification of an output file, the output is appended to the | |
19779 | named file, and it looks like this: | |
19780 | ||
19781 | @smallexample | |
19782 | 0.12 0.01 cc1 @var{options} | |
19783 | 0.00 0.01 as @var{options} | |
19784 | @end smallexample | |
19785 | ||
19786 | The ``user time'' and the ``system time'' are moved before the program | |
19787 | name, and the options passed to the program are displayed, so that one | |
19788 | can later tell what file was being compiled, and with which options. | |
19789 | ||
d77de738 | 19790 | @opindex fdump-final-insns |
ddf6fe37 | 19791 | @item -fdump-final-insns@r{[}=@var{file}@r{]} |
d77de738 ML |
19792 | Dump the final internal representation (RTL) to @var{file}. If the |
19793 | optional argument is omitted (or if @var{file} is @code{.}), the name | |
19794 | of the dump file is determined by appending @code{.gkd} to the | |
19795 | dump base name, see @option{-dumpbase}. | |
19796 | ||
d77de738 ML |
19797 | @opindex fcompare-debug |
19798 | @opindex fno-compare-debug | |
ddf6fe37 | 19799 | @item -fcompare-debug@r{[}=@var{opts}@r{]} |
d77de738 ML |
19800 | If no error occurs during compilation, run the compiler a second time, |
19801 | adding @var{opts} and @option{-fcompare-debug-second} to the arguments | |
19802 | passed to the second compilation. Dump the final internal | |
19803 | representation in both compilations, and print an error if they differ. | |
19804 | ||
19805 | If the equal sign is omitted, the default @option{-gtoggle} is used. | |
19806 | ||
19807 | The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty | |
19808 | and nonzero, implicitly enables @option{-fcompare-debug}. If | |
19809 | @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash, | |
19810 | then it is used for @var{opts}, otherwise the default @option{-gtoggle} | |
19811 | is used. | |
19812 | ||
19813 | @option{-fcompare-debug=}, with the equal sign but without @var{opts}, | |
19814 | is equivalent to @option{-fno-compare-debug}, which disables the dumping | |
19815 | of the final representation and the second compilation, preventing even | |
19816 | @env{GCC_COMPARE_DEBUG} from taking effect. | |
19817 | ||
19818 | To verify full coverage during @option{-fcompare-debug} testing, set | |
19819 | @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden}, | |
19820 | which GCC rejects as an invalid option in any actual compilation | |
19821 | (rather than preprocessing, assembly or linking). To get just a | |
19822 | warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug | |
19823 | not overridden} will do. | |
19824 | ||
d77de738 | 19825 | @opindex fcompare-debug-second |
ddf6fe37 | 19826 | @item -fcompare-debug-second |
d77de738 ML |
19827 | This option is implicitly passed to the compiler for the second |
19828 | compilation requested by @option{-fcompare-debug}, along with options to | |
19829 | silence warnings, and omitting other options that would cause the compiler | |
19830 | to produce output to files or to standard output as a side effect. Dump | |
19831 | files and preserved temporary files are renamed so as to contain the | |
19832 | @code{.gk} additional extension during the second compilation, to avoid | |
19833 | overwriting those generated by the first. | |
19834 | ||
19835 | When this option is passed to the compiler driver, it causes the | |
19836 | @emph{first} compilation to be skipped, which makes it useful for little | |
19837 | other than debugging the compiler proper. | |
19838 | ||
d77de738 | 19839 | @opindex gtoggle |
ddf6fe37 | 19840 | @item -gtoggle |
d77de738 ML |
19841 | Turn off generation of debug info, if leaving out this option |
19842 | generates it, or turn it on at level 2 otherwise. The position of this | |
19843 | argument in the command line does not matter; it takes effect after all | |
19844 | other options are processed, and it does so only once, no matter how | |
19845 | many times it is given. This is mainly intended to be used with | |
19846 | @option{-fcompare-debug}. | |
19847 | ||
d77de738 ML |
19848 | @opindex fvar-tracking-assignments-toggle |
19849 | @opindex fno-var-tracking-assignments-toggle | |
ddf6fe37 | 19850 | @item -fvar-tracking-assignments-toggle |
d77de738 ML |
19851 | Toggle @option{-fvar-tracking-assignments}, in the same way that |
19852 | @option{-gtoggle} toggles @option{-g}. | |
19853 | ||
d77de738 | 19854 | @opindex Q |
ddf6fe37 | 19855 | @item -Q |
d77de738 ML |
19856 | Makes the compiler print out each function name as it is compiled, and |
19857 | print some statistics about each pass when it finishes. | |
19858 | ||
d77de738 | 19859 | @opindex ftime-report |
ddf6fe37 | 19860 | @item -ftime-report |
d77de738 ML |
19861 | Makes the compiler print some statistics about the time consumed by each |
19862 | pass when it finishes. | |
19863 | ||
d77de738 | 19864 | @opindex ftime-report-details |
ddf6fe37 | 19865 | @item -ftime-report-details |
d77de738 ML |
19866 | Record the time consumed by infrastructure parts separately for each pass. |
19867 | ||
d77de738 | 19868 | @opindex fira-verbose |
ddf6fe37 | 19869 | @item -fira-verbose=@var{n} |
d77de738 ML |
19870 | Control the verbosity of the dump file for the integrated register allocator. |
19871 | The default value is 5. If the value @var{n} is greater or equal to 10, | |
19872 | the dump output is sent to stderr using the same format as @var{n} minus 10. | |
19873 | ||
d77de738 | 19874 | @opindex flto-report |
ddf6fe37 | 19875 | @item -flto-report |
d77de738 ML |
19876 | Prints a report with internal details on the workings of the link-time |
19877 | optimizer. The contents of this report vary from version to version. | |
19878 | It is meant to be useful to GCC developers when processing object | |
19879 | files in LTO mode (via @option{-flto}). | |
19880 | ||
19881 | Disabled by default. | |
19882 | ||
d77de738 | 19883 | @opindex flto-report-wpa |
ddf6fe37 | 19884 | @item -flto-report-wpa |
d77de738 ML |
19885 | Like @option{-flto-report}, but only print for the WPA phase of link-time |
19886 | optimization. | |
19887 | ||
d77de738 | 19888 | @opindex fmem-report |
ddf6fe37 | 19889 | @item -fmem-report |
d77de738 ML |
19890 | Makes the compiler print some statistics about permanent memory |
19891 | allocation when it finishes. | |
19892 | ||
d77de738 | 19893 | @opindex fmem-report-wpa |
ddf6fe37 | 19894 | @item -fmem-report-wpa |
d77de738 ML |
19895 | Makes the compiler print some statistics about permanent memory |
19896 | allocation for the WPA phase only. | |
19897 | ||
d77de738 | 19898 | @opindex fpre-ipa-mem-report |
d77de738 | 19899 | @opindex fpost-ipa-mem-report |
ddf6fe37 AA |
19900 | @item -fpre-ipa-mem-report |
19901 | @item -fpost-ipa-mem-report | |
d77de738 ML |
19902 | Makes the compiler print some statistics about permanent memory |
19903 | allocation before or after interprocedural optimization. | |
19904 | ||
d77de738 | 19905 | @opindex fmultiflags |
ddf6fe37 | 19906 | @item -fmultiflags |
d77de738 ML |
19907 | This option enables multilib-aware @code{TFLAGS} to be used to build |
19908 | target libraries with options different from those the compiler is | |
19909 | configured to use by default, through the use of specs (@xref{Spec | |
19910 | Files}) set up by compiler internals, by the target, or by builders at | |
19911 | configure time. | |
19912 | ||
19913 | Like @code{TFLAGS}, this allows the target libraries to be built for | |
19914 | portable baseline environments, while the compiler defaults to more | |
19915 | demanding ones. That's useful because users can easily override the | |
19916 | defaults the compiler is configured to use to build their own programs, | |
19917 | if the defaults are not ideal for their target environment, whereas | |
19918 | rebuilding the runtime libraries is usually not as easy or desirable. | |
19919 | ||
19920 | Unlike @code{TFLAGS}, the use of specs enables different flags to be | |
19921 | selected for different multilibs. The way to accomplish that is to | |
19922 | build with @samp{make TFLAGS=-fmultiflags}, after configuring | |
19923 | @samp{--with-specs=%@{fmultiflags:...@}}. | |
19924 | ||
19925 | This option is discarded by the driver once it's done processing driver | |
19926 | self spec. | |
19927 | ||
19928 | It is also useful to check that @code{TFLAGS} are being used to build | |
19929 | all target libraries, by configuring a non-bootstrap compiler | |
19930 | @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building | |
19931 | the compiler and target libraries. | |
19932 | ||
d77de738 | 19933 | @opindex fprofile-report |
ddf6fe37 | 19934 | @item -fprofile-report |
d77de738 ML |
19935 | Makes the compiler print some statistics about consistency of the |
19936 | (estimated) profile and effect of individual passes. | |
19937 | ||
d77de738 | 19938 | @opindex fstack-usage |
ddf6fe37 | 19939 | @item -fstack-usage |
d77de738 ML |
19940 | Makes the compiler output stack usage information for the program, on a |
19941 | per-function basis. The filename for the dump is made by appending | |
19942 | @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of | |
19943 | the output file, if explicitly specified and it is not an executable, | |
19944 | otherwise it is the basename of the source file. An entry is made up | |
19945 | of three fields: | |
19946 | ||
19947 | @itemize | |
19948 | @item | |
19949 | The name of the function. | |
19950 | @item | |
19951 | A number of bytes. | |
19952 | @item | |
19953 | One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}. | |
19954 | @end itemize | |
19955 | ||
19956 | The qualifier @code{static} means that the function manipulates the stack | |
19957 | statically: a fixed number of bytes are allocated for the frame on function | |
19958 | entry and released on function exit; no stack adjustments are otherwise made | |
19959 | in the function. The second field is this fixed number of bytes. | |
19960 | ||
19961 | The qualifier @code{dynamic} means that the function manipulates the stack | |
19962 | dynamically: in addition to the static allocation described above, stack | |
19963 | adjustments are made in the body of the function, for example to push/pop | |
19964 | arguments around function calls. If the qualifier @code{bounded} is also | |
19965 | present, the amount of these adjustments is bounded at compile time and | |
19966 | the second field is an upper bound of the total amount of stack used by | |
19967 | the function. If it is not present, the amount of these adjustments is | |
19968 | not bounded at compile time and the second field only represents the | |
19969 | bounded part. | |
19970 | ||
d77de738 | 19971 | @opindex fstats |
ddf6fe37 | 19972 | @item -fstats |
d77de738 ML |
19973 | Emit statistics about front-end processing at the end of the compilation. |
19974 | This option is supported only by the C++ front end, and | |
19975 | the information is generally only useful to the G++ development team. | |
19976 | ||
d77de738 | 19977 | @opindex fdbg-cnt-list |
ddf6fe37 | 19978 | @item -fdbg-cnt-list |
d77de738 ML |
19979 | Print the name and the counter upper bound for all debug counters. |
19980 | ||
19981 | ||
d77de738 | 19982 | @opindex fdbg-cnt |
ddf6fe37 | 19983 | @item -fdbg-cnt=@var{counter-value-list} |
d77de738 ML |
19984 | Set the internal debug counter lower and upper bound. @var{counter-value-list} |
19985 | is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1} | |
19986 | [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets | |
19987 | the name of the counter and list of closed intervals. | |
19988 | The @var{lower_bound} is optional and is zero | |
19989 | initialized if not set. | |
19990 | For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10}, | |
19991 | @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and | |
19992 | eleventh invocation. | |
19993 | For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations. | |
19994 | ||
d77de738 | 19995 | @opindex print-file-name |
ddf6fe37 | 19996 | @item -print-file-name=@var{library} |
d77de738 ML |
19997 | Print the full absolute name of the library file @var{library} that |
19998 | would be used when linking---and don't do anything else. With this | |
19999 | option, GCC does not compile or link anything; it just prints the | |
20000 | file name. | |
20001 | ||
d77de738 | 20002 | @opindex print-multi-directory |
ddf6fe37 | 20003 | @item -print-multi-directory |
d77de738 ML |
20004 | Print the directory name corresponding to the multilib selected by any |
20005 | other switches present in the command line. This directory is supposed | |
20006 | to exist in @env{GCC_EXEC_PREFIX}. | |
20007 | ||
d77de738 | 20008 | @opindex print-multi-lib |
ddf6fe37 | 20009 | @item -print-multi-lib |
d77de738 ML |
20010 | Print the mapping from multilib directory names to compiler switches |
20011 | that enable them. The directory name is separated from the switches by | |
20012 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
20013 | @samp{-}, without spaces between multiple switches. This is supposed to | |
20014 | ease shell processing. | |
20015 | ||
d77de738 | 20016 | @opindex print-multi-os-directory |
ddf6fe37 | 20017 | @item -print-multi-os-directory |
d77de738 ML |
20018 | Print the path to OS libraries for the selected |
20019 | multilib, relative to some @file{lib} subdirectory. If OS libraries are | |
20020 | present in the @file{lib} subdirectory and no multilibs are used, this is | |
20021 | usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}} | |
20022 | sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or | |
20023 | @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}} | |
20024 | subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}. | |
20025 | ||
d77de738 | 20026 | @opindex print-multiarch |
ddf6fe37 | 20027 | @item -print-multiarch |
d77de738 ML |
20028 | Print the path to OS libraries for the selected multiarch, |
20029 | relative to some @file{lib} subdirectory. | |
20030 | ||
d77de738 | 20031 | @opindex print-prog-name |
ddf6fe37 | 20032 | @item -print-prog-name=@var{program} |
d77de738 ML |
20033 | Like @option{-print-file-name}, but searches for a program such as @command{cpp}. |
20034 | ||
d77de738 | 20035 | @opindex print-libgcc-file-name |
ddf6fe37 | 20036 | @item -print-libgcc-file-name |
d77de738 ML |
20037 | Same as @option{-print-file-name=libgcc.a}. |
20038 | ||
20039 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} | |
20040 | but you do want to link with @file{libgcc.a}. You can do: | |
20041 | ||
20042 | @smallexample | |
20043 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
20044 | @end smallexample | |
20045 | ||
d77de738 | 20046 | @opindex print-search-dirs |
ddf6fe37 | 20047 | @item -print-search-dirs |
d77de738 ML |
20048 | Print the name of the configured installation directory and a list of |
20049 | program and library directories @command{gcc} searches---and don't do anything else. | |
20050 | ||
20051 | This is useful when @command{gcc} prints the error message | |
20052 | @samp{installation problem, cannot exec cpp0: No such file or directory}. | |
20053 | To resolve this you either need to put @file{cpp0} and the other compiler | |
20054 | components where @command{gcc} expects to find them, or you can set the environment | |
20055 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. | |
20056 | Don't forget the trailing @samp{/}. | |
20057 | @xref{Environment Variables}. | |
20058 | ||
d77de738 | 20059 | @opindex print-sysroot |
ddf6fe37 | 20060 | @item -print-sysroot |
d77de738 ML |
20061 | Print the target sysroot directory that is used during |
20062 | compilation. This is the target sysroot specified either at configure | |
20063 | time or using the @option{--sysroot} option, possibly with an extra | |
20064 | suffix that depends on compilation options. If no target sysroot is | |
20065 | specified, the option prints nothing. | |
20066 | ||
d77de738 | 20067 | @opindex print-sysroot-headers-suffix |
ddf6fe37 | 20068 | @item -print-sysroot-headers-suffix |
d77de738 ML |
20069 | Print the suffix added to the target sysroot when searching for |
20070 | headers, or give an error if the compiler is not configured with such | |
20071 | a suffix---and don't do anything else. | |
20072 | ||
d77de738 | 20073 | @opindex dumpmachine |
ddf6fe37 | 20074 | @item -dumpmachine |
d77de738 ML |
20075 | Print the compiler's target machine (for example, |
20076 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
20077 | ||
d77de738 | 20078 | @opindex dumpversion |
ddf6fe37 | 20079 | @item -dumpversion |
d77de738 ML |
20080 | Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do |
20081 | anything else. This is the compiler version used in filesystem paths and | |
20082 | specs. Depending on how the compiler has been configured it can be just | |
20083 | a single number (major version), two numbers separated by a dot (major and | |
20084 | minor version) or three numbers separated by dots (major, minor and patchlevel | |
20085 | version). | |
20086 | ||
d77de738 | 20087 | @opindex dumpfullversion |
ddf6fe37 | 20088 | @item -dumpfullversion |
d77de738 ML |
20089 | Print the full compiler version---and don't do anything else. The output is |
20090 | always three numbers separated by dots, major, minor and patchlevel version. | |
20091 | ||
d77de738 | 20092 | @opindex dumpspecs |
ddf6fe37 | 20093 | @item -dumpspecs |
d77de738 ML |
20094 | Print the compiler's built-in specs---and don't do anything else. (This |
20095 | is used when GCC itself is being built.) @xref{Spec Files}. | |
20096 | @end table | |
20097 | ||
20098 | @node Submodel Options | |
20099 | @section Machine-Dependent Options | |
20100 | @cindex submodel options | |
20101 | @cindex specifying hardware config | |
20102 | @cindex hardware models and configurations, specifying | |
20103 | @cindex target-dependent options | |
20104 | @cindex machine-dependent options | |
20105 | ||
20106 | Each target machine supported by GCC can have its own options---for | |
20107 | example, to allow you to compile for a particular processor variant or | |
20108 | ABI, or to control optimizations specific to that machine. By | |
20109 | convention, the names of machine-specific options start with | |
20110 | @samp{-m}. | |
20111 | ||
20112 | Some configurations of the compiler also support additional target-specific | |
20113 | options, usually for compatibility with other compilers on the same | |
20114 | platform. | |
20115 | ||
20116 | @c This list is ordered alphanumerically by subsection name. | |
20117 | @c It should be the same order and spelling as these options are listed | |
20118 | @c in Machine Dependent Options | |
20119 | ||
20120 | @menu | |
20121 | * AArch64 Options:: | |
20122 | * Adapteva Epiphany Options:: | |
20123 | * AMD GCN Options:: | |
20124 | * ARC Options:: | |
20125 | * ARM Options:: | |
20126 | * AVR Options:: | |
20127 | * Blackfin Options:: | |
20128 | * C6X Options:: | |
20129 | * CRIS Options:: | |
20130 | * C-SKY Options:: | |
20131 | * Darwin Options:: | |
20132 | * DEC Alpha Options:: | |
20133 | * eBPF Options:: | |
20134 | * FR30 Options:: | |
20135 | * FT32 Options:: | |
20136 | * FRV Options:: | |
20137 | * GNU/Linux Options:: | |
20138 | * H8/300 Options:: | |
20139 | * HPPA Options:: | |
20140 | * IA-64 Options:: | |
20141 | * LM32 Options:: | |
20142 | * LoongArch Options:: | |
20143 | * M32C Options:: | |
20144 | * M32R/D Options:: | |
20145 | * M680x0 Options:: | |
20146 | * MCore Options:: | |
d77de738 ML |
20147 | * MicroBlaze Options:: |
20148 | * MIPS Options:: | |
20149 | * MMIX Options:: | |
20150 | * MN10300 Options:: | |
20151 | * Moxie Options:: | |
20152 | * MSP430 Options:: | |
20153 | * NDS32 Options:: | |
20154 | * Nios II Options:: | |
20155 | * Nvidia PTX Options:: | |
20156 | * OpenRISC Options:: | |
20157 | * PDP-11 Options:: | |
d77de738 ML |
20158 | * PowerPC Options:: |
20159 | * PRU Options:: | |
20160 | * RISC-V Options:: | |
20161 | * RL78 Options:: | |
20162 | * RS/6000 and PowerPC Options:: | |
20163 | * RX Options:: | |
20164 | * S/390 and zSeries Options:: | |
d77de738 ML |
20165 | * SH Options:: |
20166 | * Solaris 2 Options:: | |
20167 | * SPARC Options:: | |
20168 | * System V Options:: | |
20169 | * V850 Options:: | |
20170 | * VAX Options:: | |
20171 | * Visium Options:: | |
20172 | * VMS Options:: | |
20173 | * VxWorks Options:: | |
20174 | * x86 Options:: | |
20175 | * x86 Windows Options:: | |
20176 | * Xstormy16 Options:: | |
20177 | * Xtensa Options:: | |
20178 | * zSeries Options:: | |
20179 | @end menu | |
20180 | ||
20181 | @node AArch64 Options | |
20182 | @subsection AArch64 Options | |
20183 | @cindex AArch64 Options | |
20184 | ||
20185 | These options are defined for AArch64 implementations: | |
20186 | ||
20187 | @table @gcctabopt | |
20188 | ||
d77de738 | 20189 | @opindex mabi |
ddf6fe37 | 20190 | @item -mabi=@var{name} |
d77de738 ML |
20191 | Generate code for the specified data model. Permissible values |
20192 | are @samp{ilp32} for SysV-like data model where int, long int and pointers | |
20193 | are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits, | |
20194 | but long int and pointers are 64 bits. | |
20195 | ||
20196 | The default depends on the specific target configuration. Note that | |
20197 | the LP64 and ILP32 ABIs are not link-compatible; you must compile your | |
20198 | entire program with the same ABI, and link with a compatible set of libraries. | |
20199 | ||
d77de738 | 20200 | @opindex mbig-endian |
ddf6fe37 | 20201 | @item -mbig-endian |
d77de738 ML |
20202 | Generate big-endian code. This is the default when GCC is configured for an |
20203 | @samp{aarch64_be-*-*} target. | |
20204 | ||
d77de738 | 20205 | @opindex mgeneral-regs-only |
ddf6fe37 | 20206 | @item -mgeneral-regs-only |
d77de738 ML |
20207 | Generate code which uses only the general-purpose registers. This will prevent |
20208 | the compiler from using floating-point and Advanced SIMD registers but will not | |
20209 | impose any restrictions on the assembler. | |
20210 | ||
d77de738 | 20211 | @opindex mlittle-endian |
ddf6fe37 | 20212 | @item -mlittle-endian |
d77de738 ML |
20213 | Generate little-endian code. This is the default when GCC is configured for an |
20214 | @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target. | |
20215 | ||
d77de738 | 20216 | @opindex mcmodel=tiny |
ddf6fe37 | 20217 | @item -mcmodel=tiny |
d77de738 ML |
20218 | Generate code for the tiny code model. The program and its statically defined |
20219 | symbols must be within 1MB of each other. Programs can be statically or | |
20220 | dynamically linked. | |
20221 | ||
d77de738 | 20222 | @opindex mcmodel=small |
ddf6fe37 | 20223 | @item -mcmodel=small |
d77de738 ML |
20224 | Generate code for the small code model. The program and its statically defined |
20225 | symbols must be within 4GB of each other. Programs can be statically or | |
20226 | dynamically linked. This is the default code model. | |
20227 | ||
d77de738 | 20228 | @opindex mcmodel=large |
ddf6fe37 | 20229 | @item -mcmodel=large |
d77de738 ML |
20230 | Generate code for the large code model. This makes no assumptions about |
20231 | addresses and sizes of sections. Programs can be statically linked only. The | |
20232 | @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32}, | |
20233 | @option{-fpic} and @option{-fPIC}. | |
20234 | ||
573624ec KT |
20235 | @item -mtp=@var{name} |
20236 | @opindex mtp | |
20237 | Specify the system register to use as a thread pointer. The valid values | |
4389a2d2 KT |
20238 | are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2}, |
20239 | @samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0}, | |
20240 | @samp{el1}, @samp{el2}, @samp{el3} are also accepted. | |
20241 | The default setting is @samp{tpidr_el0}. It is recommended to compile all | |
20242 | code intended to interoperate with the same value of this option to avoid | |
20243 | accessing a different thread pointer from the wrong exception level. | |
573624ec | 20244 | |
d77de738 ML |
20245 | @opindex mstrict-align |
20246 | @opindex mno-strict-align | |
ddf6fe37 AA |
20247 | @item -mstrict-align |
20248 | @itemx -mno-strict-align | |
d77de738 ML |
20249 | Avoid or allow generating memory accesses that may not be aligned on a natural |
20250 | object boundary as described in the architecture specification. | |
20251 | ||
d77de738 ML |
20252 | @opindex momit-leaf-frame-pointer |
20253 | @opindex mno-omit-leaf-frame-pointer | |
ddf6fe37 AA |
20254 | @item -momit-leaf-frame-pointer |
20255 | @itemx -mno-omit-leaf-frame-pointer | |
d77de738 ML |
20256 | Omit or keep the frame pointer in leaf functions. The former behavior is the |
20257 | default. | |
20258 | ||
d77de738 ML |
20259 | @opindex mstack-protector-guard |
20260 | @opindex mstack-protector-guard-reg | |
20261 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
20262 | @item -mstack-protector-guard=@var{guard} |
20263 | @itemx -mstack-protector-guard-reg=@var{reg} | |
20264 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
20265 | Generate stack protection code using canary at @var{guard}. Supported |
20266 | locations are @samp{global} for a global canary or @samp{sysreg} for a | |
20267 | canary in an appropriate system register. | |
20268 | ||
20269 | With the latter choice the options | |
20270 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
20271 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
20272 | which system register to use as base register for reading the canary, | |
20273 | and from what offset from that base register. There is no default | |
20274 | register or offset as this is entirely for use within the Linux | |
20275 | kernel. | |
20276 | ||
d77de738 | 20277 | @opindex mtls-dialect=desc |
ddf6fe37 | 20278 | @item -mtls-dialect=desc |
d77de738 ML |
20279 | Use TLS descriptors as the thread-local storage mechanism for dynamic accesses |
20280 | of TLS variables. This is the default. | |
20281 | ||
d77de738 | 20282 | @opindex mtls-dialect=traditional |
ddf6fe37 | 20283 | @item -mtls-dialect=traditional |
d77de738 ML |
20284 | Use traditional TLS as the thread-local storage mechanism for dynamic accesses |
20285 | of TLS variables. | |
20286 | ||
d77de738 | 20287 | @opindex mtls-size |
ddf6fe37 | 20288 | @item -mtls-size=@var{size} |
d77de738 ML |
20289 | Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48. |
20290 | This option requires binutils 2.26 or newer. | |
20291 | ||
d77de738 ML |
20292 | @opindex mfix-cortex-a53-835769 |
20293 | @opindex mno-fix-cortex-a53-835769 | |
ddf6fe37 AA |
20294 | @item -mfix-cortex-a53-835769 |
20295 | @itemx -mno-fix-cortex-a53-835769 | |
d77de738 ML |
20296 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769. |
20297 | This involves inserting a NOP instruction between memory instructions and | |
20298 | 64-bit integer multiply-accumulate instructions. | |
20299 | ||
d77de738 ML |
20300 | @opindex mfix-cortex-a53-843419 |
20301 | @opindex mno-fix-cortex-a53-843419 | |
ddf6fe37 AA |
20302 | @item -mfix-cortex-a53-843419 |
20303 | @itemx -mno-fix-cortex-a53-843419 | |
d77de738 ML |
20304 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419. |
20305 | This erratum workaround is made at link time and this will only pass the | |
20306 | corresponding flag to the linker. | |
20307 | ||
d77de738 ML |
20308 | @opindex mlow-precision-recip-sqrt |
20309 | @opindex mno-low-precision-recip-sqrt | |
ddf6fe37 AA |
20310 | @item -mlow-precision-recip-sqrt |
20311 | @itemx -mno-low-precision-recip-sqrt | |
d77de738 ML |
20312 | Enable or disable the reciprocal square root approximation. |
20313 | This option only has an effect if @option{-ffast-math} or | |
20314 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20315 | precision of reciprocal square root results to about 16 bits for | |
20316 | single precision and to 32 bits for double precision. | |
20317 | ||
d77de738 ML |
20318 | @opindex mlow-precision-sqrt |
20319 | @opindex mno-low-precision-sqrt | |
ddf6fe37 AA |
20320 | @item -mlow-precision-sqrt |
20321 | @itemx -mno-low-precision-sqrt | |
d77de738 ML |
20322 | Enable or disable the square root approximation. |
20323 | This option only has an effect if @option{-ffast-math} or | |
20324 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20325 | precision of square root results to about 16 bits for | |
20326 | single precision and to 32 bits for double precision. | |
20327 | If enabled, it implies @option{-mlow-precision-recip-sqrt}. | |
20328 | ||
d77de738 ML |
20329 | @opindex mlow-precision-div |
20330 | @opindex mno-low-precision-div | |
ddf6fe37 AA |
20331 | @item -mlow-precision-div |
20332 | @itemx -mno-low-precision-div | |
d77de738 ML |
20333 | Enable or disable the division approximation. |
20334 | This option only has an effect if @option{-ffast-math} or | |
20335 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20336 | precision of division results to about 16 bits for | |
20337 | single precision and to 32 bits for double precision. | |
20338 | ||
20339 | @item -mtrack-speculation | |
20340 | @itemx -mno-track-speculation | |
20341 | Enable or disable generation of additional code to track speculative | |
20342 | execution through conditional branches. The tracking state can then | |
20343 | be used by the compiler when expanding calls to | |
20344 | @code{__builtin_speculation_safe_copy} to permit a more efficient code | |
20345 | sequence to be generated. | |
20346 | ||
20347 | @item -moutline-atomics | |
20348 | @itemx -mno-outline-atomics | |
20349 | Enable or disable calls to out-of-line helpers to implement atomic operations. | |
20350 | These helpers will, at runtime, determine if the LSE instructions from | |
20351 | ARMv8.1-A can be used; if not, they will use the load/store-exclusive | |
20352 | instructions that are present in the base ARMv8.0 ISA. | |
20353 | ||
20354 | This option is only applicable when compiling for the base ARMv8.0 | |
20355 | instruction set. If using a later revision, e.g. @option{-march=armv8.1-a} | |
20356 | or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be | |
20357 | used directly. The same applies when using @option{-mcpu=} when the | |
20358 | selected cpu supports the @samp{lse} feature. | |
20359 | This option is on by default. | |
20360 | ||
d77de738 | 20361 | @opindex march |
ddf6fe37 | 20362 | @item -march=@var{name} |
d77de738 ML |
20363 | Specify the name of the target architecture and, optionally, one or |
20364 | more feature modifiers. This option has the form | |
20365 | @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}. | |
20366 | ||
20367 | The table below summarizes the permissible values for @var{arch} | |
20368 | and the features that they enable by default: | |
20369 | ||
20370 | @multitable @columnfractions 0.20 0.20 0.60 | |
20371 | @headitem @var{arch} value @tab Architecture @tab Includes by default | |
20372 | @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd} | |
20373 | @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma} | |
20374 | @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a} | |
20375 | @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth} | |
20376 | @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod} | |
20377 | @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres} | |
20378 | @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm} | |
20379 | @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64} | |
20380 | @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops} | |
20381 | @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2} | |
20382 | @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm} | |
20383 | @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64} | |
20384 | @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops} | |
20385 | @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r} | |
20386 | @end multitable | |
20387 | ||
20388 | The value @samp{native} is available on native AArch64 GNU/Linux and | |
20389 | causes the compiler to pick the architecture of the host system. This | |
20390 | option has no effect if the compiler is unable to recognize the | |
20391 | architecture of the host system, | |
20392 | ||
20393 | The permissible values for @var{feature} are listed in the sub-section | |
20394 | on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20395 | Feature Modifiers}. Where conflicting feature modifiers are | |
20396 | specified, the right-most feature is used. | |
20397 | ||
20398 | GCC uses @var{name} to determine what kind of instructions it can emit | |
20399 | when generating assembly code. If @option{-march} is specified | |
20400 | without either of @option{-mtune} or @option{-mcpu} also being | |
20401 | specified, the code is tuned to perform well across a range of target | |
20402 | processors implementing the target architecture. | |
20403 | ||
d77de738 | 20404 | @opindex mtune |
ddf6fe37 | 20405 | @item -mtune=@var{name} |
d77de738 ML |
20406 | Specify the name of the target processor for which GCC should tune the |
20407 | performance of the code. Permissible values for this option are: | |
20408 | @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
20409 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
20410 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
20411 | @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34}, | |
20412 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, | |
20413 | @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor}, | |
20414 | @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1}, | |
20415 | @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx}, | |
20416 | @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan}, | |
20417 | @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83}, | |
20418 | @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96} | |
20419 | @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n}, | |
20420 | @samp{octeontx2f95mm}, | |
20421 | @samp{a64fx}, | |
20422 | @samp{thunderx}, @samp{thunderxt88}, | |
20423 | @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110}, | |
20424 | @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus}, | |
20425 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20426 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20427 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}, | |
ce51e843 | 20428 | @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2}, |
e07556a8 SP |
20429 | @samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715}, |
20430 | @samp{ampere1}, @samp{ampere1a}, and @samp{native}. | |
d77de738 ML |
20431 | |
20432 | The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20433 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20434 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC | |
20435 | should tune for a big.LITTLE system. | |
20436 | ||
20437 | The value @samp{neoverse-512tvb} specifies that GCC should tune | |
20438 | for Neoverse cores that (a) implement SVE and (b) have a total vector | |
20439 | bandwidth of 512 bits per cycle. In other words, the option tells GCC to | |
20440 | tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic | |
20441 | instructions a cycle and that can execute an equivalent number of SVE | |
20442 | arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE). | |
20443 | This is more general than tuning for a specific core like Neoverse V1 | |
20444 | but is more specific than the default tuning described below. | |
20445 | ||
20446 | Additionally on native AArch64 GNU/Linux systems the value | |
20447 | @samp{native} tunes performance to the host system. This option has no effect | |
20448 | if the compiler is unable to recognize the processor of the host system. | |
20449 | ||
20450 | Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} | |
20451 | are specified, the code is tuned to perform well across a range | |
20452 | of target processors. | |
20453 | ||
20454 | This option cannot be suffixed by feature modifiers. | |
20455 | ||
d77de738 | 20456 | @opindex mcpu |
ddf6fe37 | 20457 | @item -mcpu=@var{name} |
d77de738 ML |
20458 | Specify the name of the target processor, optionally suffixed by one |
20459 | or more feature modifiers. This option has the form | |
20460 | @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where | |
20461 | the permissible values for @var{cpu} are the same as those available | |
20462 | for @option{-mtune}. The permissible values for @var{feature} are | |
20463 | documented in the sub-section on | |
20464 | @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20465 | Feature Modifiers}. Where conflicting feature modifiers are | |
20466 | specified, the right-most feature is used. | |
20467 | ||
20468 | GCC uses @var{name} to determine what kind of instructions it can emit when | |
20469 | generating assembly code (as if by @option{-march}) and to determine | |
20470 | the target processor for which to tune for performance (as if | |
20471 | by @option{-mtune}). Where this option is used in conjunction | |
20472 | with @option{-march} or @option{-mtune}, those options take precedence | |
20473 | over the appropriate part of this option. | |
20474 | ||
20475 | @option{-mcpu=neoverse-512tvb} is special in that it does not refer | |
20476 | to a specific core, but instead refers to all Neoverse cores that | |
20477 | (a) implement SVE and (b) have a total vector bandwidth of 512 bits | |
20478 | a cycle. Unless overridden by @option{-march}, | |
20479 | @option{-mcpu=neoverse-512tvb} generates code that can run on a | |
20480 | Neoverse V1 core, since Neoverse V1 is the first Neoverse core with | |
20481 | these properties. Unless overridden by @option{-mtune}, | |
20482 | @option{-mcpu=neoverse-512tvb} tunes code in the same way as for | |
20483 | @option{-mtune=neoverse-512tvb}. | |
20484 | ||
d77de738 | 20485 | @opindex moverride |
ddf6fe37 | 20486 | @item -moverride=@var{string} |
d77de738 ML |
20487 | Override tuning decisions made by the back-end in response to a |
20488 | @option{-mtune=} switch. The syntax, semantics, and accepted values | |
20489 | for @var{string} in this option are not guaranteed to be consistent | |
20490 | across releases. | |
20491 | ||
20492 | This option is only intended to be useful when developing GCC. | |
20493 | ||
d77de738 | 20494 | @opindex mverbose-cost-dump |
ddf6fe37 | 20495 | @item -mverbose-cost-dump |
d77de738 ML |
20496 | Enable verbose cost model dumping in the debug dump files. This option is |
20497 | provided for use in debugging the compiler. | |
20498 | ||
d77de738 ML |
20499 | @opindex mpc-relative-literal-loads |
20500 | @opindex mno-pc-relative-literal-loads | |
ddf6fe37 AA |
20501 | @item -mpc-relative-literal-loads |
20502 | @itemx -mno-pc-relative-literal-loads | |
d77de738 ML |
20503 | Enable or disable PC-relative literal loads. With this option literal pools are |
20504 | accessed using a single instruction and emitted after each function. This | |
20505 | limits the maximum size of functions to 1MB. This is enabled by default for | |
20506 | @option{-mcmodel=tiny}. | |
20507 | ||
d77de738 | 20508 | @opindex msign-return-address |
ddf6fe37 | 20509 | @item -msign-return-address=@var{scope} |
d77de738 ML |
20510 | Select the function scope on which return address signing will be applied. |
20511 | Permissible values are @samp{none}, which disables return address signing, | |
20512 | @samp{non-leaf}, which enables pointer signing for functions which are not leaf | |
20513 | functions, and @samp{all}, which enables pointer signing for all functions. The | |
20514 | default value is @samp{none}. This option has been deprecated by | |
20515 | -mbranch-protection. | |
20516 | ||
d77de738 | 20517 | @opindex mbranch-protection |
ddf6fe37 | 20518 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti} |
d77de738 ML |
20519 | Select the branch protection features to use. |
20520 | @samp{none} is the default and turns off all types of branch protection. | |
20521 | @samp{standard} turns on all types of branch protection features. If a feature | |
20522 | has additional tuning options, then @samp{standard} sets it to its standard | |
20523 | level. | |
20524 | @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard | |
20525 | level: signing functions that save the return address to memory (non-leaf | |
20526 | functions will practically always do this) using the a-key. The optional | |
20527 | argument @samp{leaf} can be used to extend the signing to include leaf | |
20528 | functions. The optional argument @samp{b-key} can be used to sign the functions | |
20529 | with the B-key instead of the A-key. | |
20530 | @samp{bti} turns on branch target identification mechanism. | |
20531 | ||
d77de738 | 20532 | @opindex mharden-sls |
ddf6fe37 | 20533 | @item -mharden-sls=@var{opts} |
d77de738 ML |
20534 | Enable compiler hardening against straight line speculation (SLS). |
20535 | @var{opts} is a comma-separated list of the following options: | |
20536 | @table @samp | |
20537 | @item retbr | |
20538 | @item blr | |
20539 | @end table | |
20540 | In addition, @samp{-mharden-sls=all} enables all SLS hardening while | |
20541 | @samp{-mharden-sls=none} disables all SLS hardening. | |
20542 | ||
d77de738 | 20543 | @opindex msve-vector-bits |
ddf6fe37 | 20544 | @item -msve-vector-bits=@var{bits} |
d77de738 ML |
20545 | Specify the number of bits in an SVE vector register. This option only has |
20546 | an effect when SVE is enabled. | |
20547 | ||
20548 | GCC supports two forms of SVE code generation: ``vector-length | |
20549 | agnostic'' output that works with any size of vector register and | |
20550 | ``vector-length specific'' output that allows GCC to make assumptions | |
20551 | about the vector length when it is useful for optimization reasons. | |
20552 | The possible values of @samp{bits} are: @samp{scalable}, @samp{128}, | |
20553 | @samp{256}, @samp{512}, @samp{1024} and @samp{2048}. | |
20554 | Specifying @samp{scalable} selects vector-length agnostic | |
20555 | output. At present @samp{-msve-vector-bits=128} also generates vector-length | |
20556 | agnostic output for big-endian targets. All other values generate | |
20557 | vector-length specific code. The behavior of these values may change | |
20558 | in future releases and no value except @samp{scalable} should be | |
20559 | relied on for producing code that is portable across different | |
20560 | hardware SVE vector lengths. | |
20561 | ||
20562 | The default is @samp{-msve-vector-bits=scalable}, which produces | |
20563 | vector-length agnostic code. | |
20564 | @end table | |
20565 | ||
20566 | @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers | |
20567 | @anchor{aarch64-feature-modifiers} | |
20568 | @cindex @option{-march} feature modifiers | |
20569 | @cindex @option{-mcpu} feature modifiers | |
20570 | Feature modifiers used with @option{-march} and @option{-mcpu} can be any of | |
20571 | the following and their inverses @option{no@var{feature}}: | |
20572 | ||
20573 | @table @samp | |
20574 | @item crc | |
20575 | Enable CRC extension. This is on by default for | |
20576 | @option{-march=armv8.1-a}. | |
20577 | @item crypto | |
20578 | Enable Crypto extension. This also enables Advanced SIMD and floating-point | |
20579 | instructions. | |
20580 | @item fp | |
20581 | Enable floating-point instructions. This is on by default for all possible | |
20582 | values for options @option{-march} and @option{-mcpu}. | |
20583 | @item simd | |
20584 | Enable Advanced SIMD instructions. This also enables floating-point | |
20585 | instructions. This is on by default for all possible values for options | |
20586 | @option{-march} and @option{-mcpu}. | |
20587 | @item sve | |
20588 | Enable Scalable Vector Extension instructions. This also enables Advanced | |
20589 | SIMD and floating-point instructions. | |
20590 | @item lse | |
20591 | Enable Large System Extension instructions. This is on by default for | |
20592 | @option{-march=armv8.1-a}. | |
20593 | @item rdma | |
20594 | Enable Round Double Multiply Accumulate instructions. This is on by default | |
20595 | for @option{-march=armv8.1-a}. | |
20596 | @item fp16 | |
20597 | Enable FP16 extension. This also enables floating-point instructions. | |
20598 | @item fp16fml | |
20599 | Enable FP16 fmla extension. This also enables FP16 extensions and | |
20600 | 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. | |
20601 | ||
20602 | @item rcpc | |
0431e8ae AV |
20603 | Enable the RCpc extension. This enables the use of the LDAPR instructions for |
20604 | load-acquire atomic semantics, and passes it on to the assembler, enabling | |
20605 | inline asm statements to use instructions from the RCpc extension. | |
d77de738 ML |
20606 | @item dotprod |
20607 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
20608 | @item aes | |
20609 | Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced | |
20610 | SIMD instructions. | |
20611 | @item sha2 | |
20612 | Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions. | |
20613 | @item sha3 | |
20614 | Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD | |
20615 | instructions. Use of this option with architectures prior to Armv8.2-A is not supported. | |
20616 | @item sm4 | |
20617 | Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions. | |
20618 | Use of this option with architectures prior to Armv8.2-A is not supported. | |
20619 | @item profile | |
20620 | Enable the Statistical Profiling extension. This option is only to enable the | |
20621 | extension at the assembler level and does not affect code generation. | |
20622 | @item rng | |
20623 | Enable the Armv8.5-a Random Number instructions. This option is only to | |
20624 | enable the extension at the assembler level and does not affect code | |
20625 | generation. | |
20626 | @item memtag | |
20627 | Enable the Armv8.5-a Memory Tagging Extensions. | |
20628 | Use of this option with architectures prior to Armv8.5-A is not supported. | |
20629 | @item sb | |
20630 | Enable the Armv8-a Speculation Barrier instruction. This option is only to | |
20631 | enable the extension at the assembler level and does not affect code | |
20632 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20633 | @item ssbs | |
20634 | Enable the Armv8-a Speculative Store Bypass Safe instruction. This option | |
20635 | is only to enable the extension at the assembler level and does not affect code | |
20636 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20637 | @item predres | |
20638 | Enable the Armv8-a Execution and Data Prediction Restriction instructions. | |
20639 | This option is only to enable the extension at the assembler level and does | |
20640 | not affect code generation. This option is enabled by default for | |
20641 | @option{-march=armv8.5-a}. | |
20642 | @item sve2 | |
20643 | Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE | |
20644 | instructions. | |
20645 | @item sve2-bitperm | |
20646 | Enable SVE2 bitperm instructions. This also enables SVE2 instructions. | |
20647 | @item sve2-sm4 | |
20648 | Enable SVE2 sm4 instructions. This also enables SVE2 instructions. | |
20649 | @item sve2-aes | |
20650 | Enable SVE2 aes instructions. This also enables SVE2 instructions. | |
20651 | @item sve2-sha3 | |
20652 | Enable SVE2 sha3 instructions. This also enables SVE2 instructions. | |
20653 | @item tme | |
20654 | Enable the Transactional Memory Extension. | |
20655 | @item i8mm | |
20656 | Enable 8-bit Integer Matrix Multiply instructions. This also enables | |
20657 | Advanced SIMD and floating-point instructions. This option is enabled by | |
20658 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
20659 | prior to Armv8.2-A is not supported. | |
20660 | @item f32mm | |
20661 | Enable 32-bit Floating point Matrix Multiply instructions. This also enables | |
20662 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
20663 | not supported. | |
20664 | @item f64mm | |
20665 | Enable 64-bit Floating point Matrix Multiply instructions. This also enables | |
20666 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
20667 | not supported. | |
20668 | @item bf16 | |
20669 | Enable brain half-precision floating-point instructions. This also enables | |
20670 | Advanced SIMD and floating-point instructions. This option is enabled by | |
20671 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
20672 | prior to Armv8.2-A is not supported. | |
20673 | @item ls64 | |
20674 | Enable the 64-byte atomic load and store instructions for accelerators. | |
20675 | This option is enabled by default for @option{-march=armv8.7-a}. | |
20676 | @item mops | |
20677 | Enable the instructions to accelerate memory operations like @code{memcpy}, | |
20678 | @code{memmove}, @code{memset}. This option is enabled by default for | |
20679 | @option{-march=armv8.8-a} | |
20680 | @item flagm | |
20681 | Enable the Flag Manipulation instructions Extension. | |
20682 | @item pauth | |
20683 | Enable the Pointer Authentication Extension. | |
d758d190 KT |
20684 | @item cssc |
20685 | Enable the Common Short Sequence Compression instructions. | |
d77de738 ML |
20686 | |
20687 | @end table | |
20688 | ||
20689 | Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd}, | |
20690 | which implies @option{fp}. | |
20691 | Conversely, @option{nofp} implies @option{nosimd}, which implies | |
20692 | @option{nocrypto}, @option{noaes} and @option{nosha2}. | |
20693 | ||
20694 | @node Adapteva Epiphany Options | |
20695 | @subsection Adapteva Epiphany Options | |
20696 | ||
20697 | These @samp{-m} options are defined for Adapteva Epiphany: | |
20698 | ||
20699 | @table @gcctabopt | |
d77de738 | 20700 | @opindex mhalf-reg-file |
ddf6fe37 | 20701 | @item -mhalf-reg-file |
d77de738 ML |
20702 | Don't allocate any register in the range @code{r32}@dots{}@code{r63}. |
20703 | That allows code to run on hardware variants that lack these registers. | |
20704 | ||
d77de738 | 20705 | @opindex mprefer-short-insn-regs |
ddf6fe37 | 20706 | @item -mprefer-short-insn-regs |
d77de738 ML |
20707 | Preferentially allocate registers that allow short instruction generation. |
20708 | This can result in increased instruction count, so this may either reduce or | |
20709 | increase overall code size. | |
20710 | ||
d77de738 | 20711 | @opindex mbranch-cost |
ddf6fe37 | 20712 | @item -mbranch-cost=@var{num} |
d77de738 ML |
20713 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
20714 | This cost is only a heuristic and is not guaranteed to produce | |
20715 | consistent results across releases. | |
20716 | ||
d77de738 | 20717 | @opindex mcmove |
ddf6fe37 | 20718 | @item -mcmove |
d77de738 ML |
20719 | Enable the generation of conditional moves. |
20720 | ||
d77de738 | 20721 | @opindex mnops |
ddf6fe37 | 20722 | @item -mnops=@var{num} |
d77de738 ML |
20723 | Emit @var{num} NOPs before every other generated instruction. |
20724 | ||
d77de738 ML |
20725 | @opindex mno-soft-cmpsf |
20726 | @opindex msoft-cmpsf | |
ddf6fe37 | 20727 | @item -mno-soft-cmpsf |
d77de738 ML |
20728 | For single-precision floating-point comparisons, emit an @code{fsub} instruction |
20729 | and test the flags. This is faster than a software comparison, but can | |
20730 | get incorrect results in the presence of NaNs, or when two different small | |
20731 | numbers are compared such that their difference is calculated as zero. | |
20732 | The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant, | |
20733 | software comparisons. | |
20734 | ||
d77de738 | 20735 | @opindex mstack-offset |
ddf6fe37 | 20736 | @item -mstack-offset=@var{num} |
d77de738 ML |
20737 | Set the offset between the top of the stack and the stack pointer. |
20738 | E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7} | |
20739 | can be used by leaf functions without stack allocation. | |
20740 | Values other than @samp{8} or @samp{16} are untested and unlikely to work. | |
20741 | Note also that this option changes the ABI; compiling a program with a | |
20742 | different stack offset than the libraries have been compiled with | |
20743 | generally does not work. | |
20744 | This option can be useful if you want to evaluate if a different stack | |
20745 | offset would give you better code, but to actually use a different stack | |
20746 | offset to build working programs, it is recommended to configure the | |
20747 | toolchain with the appropriate @option{--with-stack-offset=@var{num}} option. | |
20748 | ||
d77de738 ML |
20749 | @opindex mno-round-nearest |
20750 | @opindex mround-nearest | |
ddf6fe37 | 20751 | @item -mno-round-nearest |
d77de738 ML |
20752 | Make the scheduler assume that the rounding mode has been set to |
20753 | truncating. The default is @option{-mround-nearest}. | |
20754 | ||
d77de738 | 20755 | @opindex mlong-calls |
ddf6fe37 | 20756 | @item -mlong-calls |
d77de738 ML |
20757 | If not otherwise specified by an attribute, assume all calls might be beyond |
20758 | the offset range of the @code{b} / @code{bl} instructions, and therefore load the | |
20759 | function address into a register before performing a (otherwise direct) call. | |
20760 | This is the default. | |
20761 | ||
d77de738 | 20762 | @opindex short-calls |
ddf6fe37 | 20763 | @item -mshort-calls |
d77de738 ML |
20764 | If not otherwise specified by an attribute, assume all direct calls are |
20765 | in the range of the @code{b} / @code{bl} instructions, so use these instructions | |
20766 | for direct calls. The default is @option{-mlong-calls}. | |
20767 | ||
d77de738 | 20768 | @opindex msmall16 |
ddf6fe37 | 20769 | @item -msmall16 |
d77de738 ML |
20770 | Assume addresses can be loaded as 16-bit unsigned values. This does not |
20771 | apply to function addresses for which @option{-mlong-calls} semantics | |
20772 | are in effect. | |
20773 | ||
d77de738 | 20774 | @opindex mfp-mode |
ddf6fe37 | 20775 | @item -mfp-mode=@var{mode} |
d77de738 ML |
20776 | Set the prevailing mode of the floating-point unit. |
20777 | This determines the floating-point mode that is provided and expected | |
20778 | at function call and return time. Making this mode match the mode you | |
20779 | predominantly need at function start can make your programs smaller and | |
20780 | faster by avoiding unnecessary mode switches. | |
20781 | ||
20782 | @var{mode} can be set to one the following values: | |
20783 | ||
20784 | @table @samp | |
20785 | @item caller | |
20786 | Any mode at function entry is valid, and retained or restored when | |
20787 | the function returns, and when it calls other functions. | |
20788 | This mode is useful for compiling libraries or other compilation units | |
20789 | you might want to incorporate into different programs with different | |
20790 | prevailing FPU modes, and the convenience of being able to use a single | |
20791 | object file outweighs the size and speed overhead for any extra | |
20792 | mode switching that might be needed, compared with what would be needed | |
20793 | with a more specific choice of prevailing FPU mode. | |
20794 | ||
20795 | @item truncate | |
20796 | This is the mode used for floating-point calculations with | |
20797 | truncating (i.e.@: round towards zero) rounding mode. That includes | |
20798 | conversion from floating point to integer. | |
20799 | ||
20800 | @item round-nearest | |
20801 | This is the mode used for floating-point calculations with | |
20802 | round-to-nearest-or-even rounding mode. | |
20803 | ||
20804 | @item int | |
20805 | This is the mode used to perform integer calculations in the FPU, e.g.@: | |
20806 | integer multiply, or integer multiply-and-accumulate. | |
20807 | @end table | |
20808 | ||
20809 | The default is @option{-mfp-mode=caller} | |
20810 | ||
d77de738 ML |
20811 | @opindex mno-split-lohi |
20812 | @opindex msplit-lohi | |
20813 | @opindex mno-postinc | |
20814 | @opindex mpostinc | |
20815 | @opindex mno-postmodify | |
20816 | @opindex mpostmodify | |
ddf6fe37 AA |
20817 | @item -mno-split-lohi |
20818 | @itemx -mno-postinc | |
20819 | @itemx -mno-postmodify | |
d77de738 ML |
20820 | Code generation tweaks that disable, respectively, splitting of 32-bit |
20821 | loads, generation of post-increment addresses, and generation of | |
20822 | post-modify addresses. The defaults are @option{msplit-lohi}, | |
20823 | @option{-mpost-inc}, and @option{-mpost-modify}. | |
20824 | ||
d77de738 ML |
20825 | @opindex mno-vect-double |
20826 | @opindex mvect-double | |
ddf6fe37 | 20827 | @item -mnovect-double |
d77de738 ML |
20828 | Change the preferred SIMD mode to SImode. The default is |
20829 | @option{-mvect-double}, which uses DImode as preferred SIMD mode. | |
20830 | ||
d77de738 | 20831 | @opindex max-vect-align |
ddf6fe37 | 20832 | @item -max-vect-align=@var{num} |
d77de738 ML |
20833 | The maximum alignment for SIMD vector mode types. |
20834 | @var{num} may be 4 or 8. The default is 8. | |
20835 | Note that this is an ABI change, even though many library function | |
20836 | interfaces are unaffected if they don't use SIMD vector modes | |
20837 | in places that affect size and/or alignment of relevant types. | |
20838 | ||
d77de738 | 20839 | @opindex msplit-vecmove-early |
ddf6fe37 | 20840 | @item -msplit-vecmove-early |
d77de738 ML |
20841 | Split vector moves into single word moves before reload. In theory this |
20842 | can give better register allocation, but so far the reverse seems to be | |
20843 | generally the case. | |
20844 | ||
d77de738 | 20845 | @opindex m1reg- |
ddf6fe37 | 20846 | @item -m1reg-@var{reg} |
d77de738 ML |
20847 | Specify a register to hold the constant @minus{}1, which makes loading small negative |
20848 | constants and certain bitmasks faster. | |
20849 | Allowable values for @var{reg} are @samp{r43} and @samp{r63}, | |
20850 | which specify use of that register as a fixed register, | |
20851 | and @samp{none}, which means that no register is used for this | |
20852 | purpose. The default is @option{-m1reg-none}. | |
20853 | ||
20854 | @end table | |
20855 | ||
20856 | @node AMD GCN Options | |
20857 | @subsection AMD GCN Options | |
20858 | @cindex AMD GCN Options | |
20859 | ||
20860 | These options are defined specifically for the AMD GCN port. | |
20861 | ||
20862 | @table @gcctabopt | |
20863 | ||
d77de738 | 20864 | @opindex march |
d77de738 | 20865 | @opindex mtune |
ddf6fe37 AA |
20866 | @item -march=@var{gpu} |
20867 | @itemx -mtune=@var{gpu} | |
d77de738 ML |
20868 | Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu} |
20869 | are | |
20870 | ||
20871 | @table @samp | |
20872 | @item fiji | |
20873 | Compile for GCN3 Fiji devices (gfx803). | |
20874 | ||
20875 | @item gfx900 | |
20876 | Compile for GCN5 Vega 10 devices (gfx900). | |
20877 | ||
20878 | @item gfx906 | |
20879 | Compile for GCN5 Vega 20 devices (gfx906). | |
20880 | ||
20881 | @item gfx908 | |
20882 | Compile for CDNA1 Instinct MI100 series devices (gfx908). | |
20883 | ||
20884 | @item gfx90a | |
20885 | Compile for CDNA2 Instinct MI200 series devices (gfx90a). | |
20886 | ||
20887 | @end table | |
20888 | ||
ddf6fe37 | 20889 | @opindex msram-ecc |
d77de738 ML |
20890 | @item -msram-ecc=on |
20891 | @itemx -msram-ecc=off | |
20892 | @itemx -msram-ecc=any | |
d77de738 ML |
20893 | Compile binaries suitable for devices with the SRAM-ECC feature enabled, |
20894 | disabled, or either mode. This feature can be enabled per-process on some | |
20895 | devices. The compiled code must match the device mode. The default is | |
20896 | @samp{any}, for devices that support it. | |
20897 | ||
d77de738 | 20898 | @opindex mstack-size |
ddf6fe37 | 20899 | @item -mstack-size=@var{bytes} |
d77de738 ML |
20900 | Specify how many @var{bytes} of stack space will be requested for each GPU |
20901 | thread (wave-front). Beware that there may be many threads and limited memory | |
20902 | available. The size of the stack allocation may also have an impact on | |
20903 | run-time performance. The default is 32KB when using OpenACC or OpenMP, and | |
20904 | 1MB otherwise. | |
20905 | ||
d77de738 | 20906 | @opindex mxnack |
366e3d30 TB |
20907 | @item -mxnack=on |
20908 | @itemx -mxnack=off | |
20909 | @itemx -mxnack=any | |
20910 | Compile binaries suitable for devices with the XNACK feature enabled, disabled, | |
20911 | or either mode. Some devices always require XNACK and some allow the user to | |
20912 | configure XNACK. The compiled code must match the device mode. | |
20913 | @c The default is @samp{-mxnack=any}. | |
20914 | At present this option is a placeholder for support that is not yet implemented. | |
d77de738 ML |
20915 | |
20916 | @end table | |
20917 | ||
20918 | @node ARC Options | |
20919 | @subsection ARC Options | |
20920 | @cindex ARC options | |
20921 | ||
20922 | The following options control the architecture variant for which code | |
20923 | is being compiled: | |
20924 | ||
20925 | @c architecture variants | |
20926 | @table @gcctabopt | |
20927 | ||
d77de738 | 20928 | @opindex mbarrel-shifter |
ddf6fe37 | 20929 | @item -mbarrel-shifter |
d77de738 ML |
20930 | Generate instructions supported by barrel shifter. This is the default |
20931 | unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect. | |
20932 | ||
d77de738 | 20933 | @opindex mjli-always |
ddf6fe37 | 20934 | @item -mjli-always |
d77de738 ML |
20935 | Force to call a function using jli_s instruction. This option is |
20936 | valid only for ARCv2 architecture. | |
20937 | ||
d77de738 | 20938 | @opindex mcpu |
ddf6fe37 | 20939 | @item -mcpu=@var{cpu} |
d77de738 ML |
20940 | Set architecture type, register usage, and instruction scheduling |
20941 | parameters for @var{cpu}. There are also shortcut alias options | |
20942 | available for backward compatibility and convenience. Supported | |
20943 | values for @var{cpu} are | |
20944 | ||
20945 | @table @samp | |
20946 | @opindex mA6 | |
20947 | @opindex mARC600 | |
20948 | @item arc600 | |
20949 | Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}. | |
20950 | ||
d77de738 | 20951 | @opindex mARC601 |
ddf6fe37 | 20952 | @item arc601 |
d77de738 ML |
20953 | Compile for ARC601. Alias: @option{-mARC601}. |
20954 | ||
d77de738 ML |
20955 | @opindex mA7 |
20956 | @opindex mARC700 | |
ddf6fe37 | 20957 | @item arc700 |
d77de738 ML |
20958 | Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}. |
20959 | This is the default when configured with @option{--with-cpu=arc700}@. | |
20960 | ||
20961 | @item arcem | |
20962 | Compile for ARC EM. | |
20963 | ||
20964 | @item archs | |
20965 | Compile for ARC HS. | |
20966 | ||
20967 | @item em | |
20968 | Compile for ARC EM CPU with no hardware extensions. | |
20969 | ||
20970 | @item em4 | |
20971 | Compile for ARC EM4 CPU. | |
20972 | ||
20973 | @item em4_dmips | |
20974 | Compile for ARC EM4 DMIPS CPU. | |
20975 | ||
20976 | @item em4_fpus | |
20977 | Compile for ARC EM4 DMIPS CPU with the single-precision floating-point | |
20978 | extension. | |
20979 | ||
20980 | @item em4_fpuda | |
20981 | Compile for ARC EM4 DMIPS CPU with single-precision floating-point and | |
20982 | double assist instructions. | |
20983 | ||
20984 | @item hs | |
20985 | Compile for ARC HS CPU with no hardware extensions except the atomic | |
20986 | instructions. | |
20987 | ||
20988 | @item hs34 | |
20989 | Compile for ARC HS34 CPU. | |
20990 | ||
20991 | @item hs38 | |
20992 | Compile for ARC HS38 CPU. | |
20993 | ||
20994 | @item hs38_linux | |
20995 | Compile for ARC HS38 CPU with all hardware extensions on. | |
20996 | ||
20997 | @item hs4x | |
20998 | Compile for ARC HS4x CPU. | |
20999 | ||
21000 | @item hs4xd | |
21001 | Compile for ARC HS4xD CPU. | |
21002 | ||
21003 | @item hs4x_rel31 | |
21004 | Compile for ARC HS4x CPU release 3.10a. | |
21005 | ||
21006 | @item arc600_norm | |
21007 | Compile for ARC 600 CPU with @code{norm} instructions enabled. | |
21008 | ||
21009 | @item arc600_mul32x16 | |
21010 | Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply | |
21011 | instructions enabled. | |
21012 | ||
21013 | @item arc600_mul64 | |
21014 | Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family | |
21015 | instructions enabled. | |
21016 | ||
21017 | @item arc601_norm | |
21018 | Compile for ARC 601 CPU with @code{norm} instructions enabled. | |
21019 | ||
21020 | @item arc601_mul32x16 | |
21021 | Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply | |
21022 | instructions enabled. | |
21023 | ||
21024 | @item arc601_mul64 | |
21025 | Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family | |
21026 | instructions enabled. | |
21027 | ||
21028 | @item nps400 | |
21029 | Compile for ARC 700 on NPS400 chip. | |
21030 | ||
21031 | @item em_mini | |
21032 | Compile for ARC EM minimalist configuration featuring reduced register | |
21033 | set. | |
21034 | ||
21035 | @end table | |
21036 | ||
d77de738 | 21037 | @opindex mdpfp |
d77de738 | 21038 | @opindex mdpfp-compact |
ddf6fe37 AA |
21039 | @item -mdpfp |
21040 | @itemx -mdpfp-compact | |
d77de738 ML |
21041 | Generate double-precision FPX instructions, tuned for the compact |
21042 | implementation. | |
21043 | ||
d77de738 | 21044 | @opindex mdpfp-fast |
ddf6fe37 | 21045 | @item -mdpfp-fast |
d77de738 ML |
21046 | Generate double-precision FPX instructions, tuned for the fast |
21047 | implementation. | |
21048 | ||
d77de738 | 21049 | @opindex mno-dpfp-lrsr |
ddf6fe37 | 21050 | @item -mno-dpfp-lrsr |
d77de738 ML |
21051 | Disable @code{lr} and @code{sr} instructions from using FPX extension |
21052 | aux registers. | |
21053 | ||
d77de738 | 21054 | @opindex mea |
ddf6fe37 | 21055 | @item -mea |
d77de738 ML |
21056 | Generate extended arithmetic instructions. Currently only |
21057 | @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are | |
21058 | supported. Only valid for @option{-mcpu=ARC700}. | |
21059 | ||
d77de738 ML |
21060 | @opindex mno-mpy |
21061 | @opindex mmpy | |
ddf6fe37 | 21062 | @item -mno-mpy |
d77de738 ML |
21063 | Do not generate @code{mpy}-family instructions for ARC700. This option is |
21064 | deprecated. | |
21065 | ||
d77de738 | 21066 | @opindex mmul32x16 |
ddf6fe37 | 21067 | @item -mmul32x16 |
d77de738 ML |
21068 | Generate 32x16-bit multiply and multiply-accumulate instructions. |
21069 | ||
d77de738 | 21070 | @opindex mmul64 |
ddf6fe37 | 21071 | @item -mmul64 |
d77de738 ML |
21072 | Generate @code{mul64} and @code{mulu64} instructions. |
21073 | Only valid for @option{-mcpu=ARC600}. | |
21074 | ||
d77de738 | 21075 | @opindex mnorm |
ddf6fe37 | 21076 | @item -mnorm |
d77de738 ML |
21077 | Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700} |
21078 | is in effect. | |
21079 | ||
d77de738 | 21080 | @opindex mspfp |
d77de738 | 21081 | @opindex mspfp-compact |
ddf6fe37 AA |
21082 | @item -mspfp |
21083 | @itemx -mspfp-compact | |
d77de738 ML |
21084 | Generate single-precision FPX instructions, tuned for the compact |
21085 | implementation. | |
21086 | ||
d77de738 | 21087 | @opindex mspfp-fast |
ddf6fe37 | 21088 | @item -mspfp-fast |
d77de738 ML |
21089 | Generate single-precision FPX instructions, tuned for the fast |
21090 | implementation. | |
21091 | ||
d77de738 | 21092 | @opindex msimd |
ddf6fe37 | 21093 | @item -msimd |
d77de738 ML |
21094 | Enable generation of ARC SIMD instructions via target-specific |
21095 | builtins. Only valid for @option{-mcpu=ARC700}. | |
21096 | ||
d77de738 | 21097 | @opindex msoft-float |
ddf6fe37 | 21098 | @item -msoft-float |
d77de738 ML |
21099 | This option ignored; it is provided for compatibility purposes only. |
21100 | Software floating-point code is emitted by default, and this default | |
21101 | can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or | |
21102 | @option{-mspfp-fast} for single precision, and @option{-mdpfp}, | |
21103 | @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision. | |
21104 | ||
d77de738 | 21105 | @opindex mswap |
ddf6fe37 | 21106 | @item -mswap |
d77de738 ML |
21107 | Generate @code{swap} instructions. |
21108 | ||
d77de738 | 21109 | @opindex matomic |
ddf6fe37 | 21110 | @item -matomic |
d77de738 ML |
21111 | This enables use of the locked load/store conditional extension to implement |
21112 | atomic memory built-in functions. Not available for ARC 6xx or ARC | |
21113 | EM cores. | |
21114 | ||
d77de738 | 21115 | @opindex mdiv-rem |
ddf6fe37 | 21116 | @item -mdiv-rem |
d77de738 ML |
21117 | Enable @code{div} and @code{rem} instructions for ARCv2 cores. |
21118 | ||
d77de738 | 21119 | @opindex mcode-density |
ddf6fe37 | 21120 | @item -mcode-density |
d77de738 ML |
21121 | Enable code density instructions for ARC EM. |
21122 | This option is on by default for ARC HS. | |
21123 | ||
d77de738 | 21124 | @opindex mll64 |
ddf6fe37 | 21125 | @item -mll64 |
d77de738 ML |
21126 | Enable double load/store operations for ARC HS cores. |
21127 | ||
d77de738 | 21128 | @opindex mtp-regno |
ddf6fe37 | 21129 | @item -mtp-regno=@var{regno} |
d77de738 ML |
21130 | Specify thread pointer register number. |
21131 | ||
d77de738 | 21132 | @opindex mmpy-option |
ddf6fe37 | 21133 | @item -mmpy-option=@var{multo} |
d77de738 ML |
21134 | Compile ARCv2 code with a multiplier design option. You can specify |
21135 | the option using either a string or numeric value for @var{multo}. | |
21136 | @samp{wlh1} is the default value. The recognized values are: | |
21137 | ||
21138 | @table @samp | |
21139 | @item 0 | |
21140 | @itemx none | |
21141 | No multiplier available. | |
21142 | ||
21143 | @item 1 | |
21144 | @itemx w | |
21145 | 16x16 multiplier, fully pipelined. | |
21146 | The following instructions are enabled: @code{mpyw} and @code{mpyuw}. | |
21147 | ||
21148 | @item 2 | |
21149 | @itemx wlh1 | |
21150 | 32x32 multiplier, fully | |
21151 | pipelined (1 stage). The following instructions are additionally | |
21152 | enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21153 | ||
21154 | @item 3 | |
21155 | @itemx wlh2 | |
21156 | 32x32 multiplier, fully pipelined | |
21157 | (2 stages). The following instructions are additionally enabled: @code{mpy}, | |
21158 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21159 | ||
21160 | @item 4 | |
21161 | @itemx wlh3 | |
21162 | Two 16x16 multipliers, blocking, | |
21163 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21164 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21165 | ||
21166 | @item 5 | |
21167 | @itemx wlh4 | |
21168 | One 16x16 multiplier, blocking, | |
21169 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21170 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21171 | ||
21172 | @item 6 | |
21173 | @itemx wlh5 | |
21174 | One 32x4 multiplier, blocking, | |
21175 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21176 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21177 | ||
21178 | @item 7 | |
21179 | @itemx plus_dmpy | |
21180 | ARC HS SIMD support. | |
21181 | ||
21182 | @item 8 | |
21183 | @itemx plus_macd | |
21184 | ARC HS SIMD support. | |
21185 | ||
21186 | @item 9 | |
21187 | @itemx plus_qmacw | |
21188 | ARC HS SIMD support. | |
21189 | ||
21190 | @end table | |
21191 | ||
21192 | This option is only available for ARCv2 cores@. | |
21193 | ||
d77de738 | 21194 | @opindex mfpu |
ddf6fe37 | 21195 | @item -mfpu=@var{fpu} |
d77de738 ML |
21196 | Enables support for specific floating-point hardware extensions for ARCv2 |
21197 | cores. Supported values for @var{fpu} are: | |
21198 | ||
21199 | @table @samp | |
21200 | ||
21201 | @item fpus | |
21202 | Enables support for single-precision floating-point hardware | |
21203 | extensions@. | |
21204 | ||
21205 | @item fpud | |
21206 | Enables support for double-precision floating-point hardware | |
21207 | extensions. The single-precision floating-point extension is also | |
21208 | enabled. Not available for ARC EM@. | |
21209 | ||
21210 | @item fpuda | |
21211 | Enables support for double-precision floating-point hardware | |
21212 | extensions using double-precision assist instructions. The single-precision | |
21213 | floating-point extension is also enabled. This option is | |
21214 | only available for ARC EM@. | |
21215 | ||
21216 | @item fpuda_div | |
21217 | Enables support for double-precision floating-point hardware | |
21218 | extensions using double-precision assist instructions. | |
21219 | The single-precision floating-point, square-root, and divide | |
21220 | extensions are also enabled. This option is | |
21221 | only available for ARC EM@. | |
21222 | ||
21223 | @item fpuda_fma | |
21224 | Enables support for double-precision floating-point hardware | |
21225 | extensions using double-precision assist instructions. | |
21226 | The single-precision floating-point and fused multiply and add | |
21227 | hardware extensions are also enabled. This option is | |
21228 | only available for ARC EM@. | |
21229 | ||
21230 | @item fpuda_all | |
21231 | Enables support for double-precision floating-point hardware | |
21232 | extensions using double-precision assist instructions. | |
21233 | All single-precision floating-point hardware extensions are also | |
21234 | enabled. This option is only available for ARC EM@. | |
21235 | ||
21236 | @item fpus_div | |
21237 | Enables support for single-precision floating-point, square-root and divide | |
21238 | hardware extensions@. | |
21239 | ||
21240 | @item fpud_div | |
21241 | Enables support for double-precision floating-point, square-root and divide | |
21242 | hardware extensions. This option | |
21243 | includes option @samp{fpus_div}. Not available for ARC EM@. | |
21244 | ||
21245 | @item fpus_fma | |
21246 | Enables support for single-precision floating-point and | |
21247 | fused multiply and add hardware extensions@. | |
21248 | ||
21249 | @item fpud_fma | |
21250 | Enables support for double-precision floating-point and | |
21251 | fused multiply and add hardware extensions. This option | |
21252 | includes option @samp{fpus_fma}. Not available for ARC EM@. | |
21253 | ||
21254 | @item fpus_all | |
21255 | Enables support for all single-precision floating-point hardware | |
21256 | extensions@. | |
21257 | ||
21258 | @item fpud_all | |
21259 | Enables support for all single- and double-precision floating-point | |
21260 | hardware extensions. Not available for ARC EM@. | |
21261 | ||
21262 | @end table | |
21263 | ||
d77de738 | 21264 | @opindex mirq-ctrl-saved |
ddf6fe37 | 21265 | @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count} |
d77de738 ML |
21266 | Specifies general-purposes registers that the processor automatically |
21267 | saves/restores on interrupt entry and exit. @var{register-range} is | |
21268 | specified as two registers separated by a dash. The register range | |
21269 | always starts with @code{r0}, the upper limit is @code{fp} register. | |
21270 | @var{blink} and @var{lp_count} are optional. This option is only | |
21271 | valid for ARC EM and ARC HS cores. | |
21272 | ||
d77de738 | 21273 | @opindex mrgf-banked-regs |
ddf6fe37 | 21274 | @item -mrgf-banked-regs=@var{number} |
d77de738 ML |
21275 | Specifies the number of registers replicated in second register bank |
21276 | on entry to fast interrupt. Fast interrupts are interrupts with the | |
21277 | highest priority level P0. These interrupts save only PC and STATUS32 | |
21278 | registers to avoid memory transactions during interrupt entry and exit | |
21279 | sequences. Use this option when you are using fast interrupts in an | |
21280 | ARC V2 family processor. Permitted values are 4, 8, 16, and 32. | |
21281 | ||
d77de738 | 21282 | @opindex mlpc-width |
ddf6fe37 | 21283 | @item -mlpc-width=@var{width} |
d77de738 ML |
21284 | Specify the width of the @code{lp_count} register. Valid values for |
21285 | @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is | |
21286 | fixed to 32 bits. If the width is less than 32, the compiler does not | |
21287 | attempt to transform loops in your program to use the zero-delay loop | |
21288 | mechanism unless it is known that the @code{lp_count} register can | |
21289 | hold the required loop-counter value. Depending on the width | |
21290 | specified, the compiler and run-time library might continue to use the | |
21291 | loop mechanism for various needs. This option defines macro | |
21292 | @code{__ARC_LPC_WIDTH__} with the value of @var{width}. | |
21293 | ||
d77de738 | 21294 | @opindex mrf16 |
ddf6fe37 | 21295 | @item -mrf16 |
d77de738 ML |
21296 | This option instructs the compiler to generate code for a 16-entry |
21297 | register file. This option defines the @code{__ARC_RF16__} | |
21298 | preprocessor macro. | |
21299 | ||
d77de738 | 21300 | @opindex mbranch-index |
ddf6fe37 | 21301 | @item -mbranch-index |
d77de738 ML |
21302 | Enable use of @code{bi} or @code{bih} instructions to implement jump |
21303 | tables. | |
21304 | ||
21305 | @end table | |
21306 | ||
21307 | The following options are passed through to the assembler, and also | |
21308 | define preprocessor macro symbols. | |
21309 | ||
21310 | @c Flags used by the assembler, but for which we define preprocessor | |
21311 | @c macro symbols as well. | |
21312 | @table @gcctabopt | |
d77de738 | 21313 | @opindex mdsp-packa |
ddf6fe37 | 21314 | @item -mdsp-packa |
d77de738 ML |
21315 | Passed down to the assembler to enable the DSP Pack A extensions. |
21316 | Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is | |
21317 | deprecated. | |
21318 | ||
d77de738 | 21319 | @opindex mdvbf |
ddf6fe37 | 21320 | @item -mdvbf |
d77de738 ML |
21321 | Passed down to the assembler to enable the dual Viterbi butterfly |
21322 | extension. Also sets the preprocessor symbol @code{__Xdvbf}. This | |
21323 | option is deprecated. | |
21324 | ||
21325 | @c ARC700 4.10 extension instruction | |
d77de738 | 21326 | @opindex mlock |
ddf6fe37 | 21327 | @item -mlock |
d77de738 ML |
21328 | Passed down to the assembler to enable the locked load/store |
21329 | conditional extension. Also sets the preprocessor symbol | |
21330 | @code{__Xlock}. | |
21331 | ||
d77de738 | 21332 | @opindex mmac-d16 |
ddf6fe37 | 21333 | @item -mmac-d16 |
d77de738 ML |
21334 | Passed down to the assembler. Also sets the preprocessor symbol |
21335 | @code{__Xxmac_d16}. This option is deprecated. | |
21336 | ||
d77de738 | 21337 | @opindex mmac-24 |
ddf6fe37 | 21338 | @item -mmac-24 |
d77de738 ML |
21339 | Passed down to the assembler. Also sets the preprocessor symbol |
21340 | @code{__Xxmac_24}. This option is deprecated. | |
21341 | ||
21342 | @c ARC700 4.10 extension instruction | |
d77de738 | 21343 | @opindex mrtsc |
ddf6fe37 | 21344 | @item -mrtsc |
d77de738 ML |
21345 | Passed down to the assembler to enable the 64-bit time-stamp counter |
21346 | extension instruction. Also sets the preprocessor symbol | |
21347 | @code{__Xrtsc}. This option is deprecated. | |
21348 | ||
21349 | @c ARC700 4.10 extension instruction | |
d77de738 | 21350 | @opindex mswape |
ddf6fe37 | 21351 | @item -mswape |
d77de738 ML |
21352 | Passed down to the assembler to enable the swap byte ordering |
21353 | extension instruction. Also sets the preprocessor symbol | |
21354 | @code{__Xswape}. | |
21355 | ||
d77de738 | 21356 | @opindex mtelephony |
ddf6fe37 | 21357 | @item -mtelephony |
d77de738 ML |
21358 | Passed down to the assembler to enable dual- and single-operand |
21359 | instructions for telephony. Also sets the preprocessor symbol | |
21360 | @code{__Xtelephony}. This option is deprecated. | |
21361 | ||
d77de738 | 21362 | @opindex mxy |
ddf6fe37 | 21363 | @item -mxy |
d77de738 ML |
21364 | Passed down to the assembler to enable the XY memory extension. Also |
21365 | sets the preprocessor symbol @code{__Xxy}. | |
21366 | ||
21367 | @end table | |
21368 | ||
21369 | The following options control how the assembly code is annotated: | |
21370 | ||
21371 | @c Assembly annotation options | |
21372 | @table @gcctabopt | |
d77de738 | 21373 | @opindex misize |
ddf6fe37 | 21374 | @item -misize |
d77de738 ML |
21375 | Annotate assembler instructions with estimated addresses. |
21376 | ||
d77de738 | 21377 | @opindex mannotate-align |
ddf6fe37 | 21378 | @item -mannotate-align |
d77de738 ML |
21379 | Explain what alignment considerations lead to the decision to make an |
21380 | instruction short or long. | |
21381 | ||
21382 | @end table | |
21383 | ||
21384 | The following options are passed through to the linker: | |
21385 | ||
21386 | @c options passed through to the linker | |
21387 | @table @gcctabopt | |
d77de738 | 21388 | @opindex marclinux |
ddf6fe37 | 21389 | @item -marclinux |
d77de738 ML |
21390 | Passed through to the linker, to specify use of the @code{arclinux} emulation. |
21391 | This option is enabled by default in tool chains built for | |
21392 | @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets | |
21393 | when profiling is not requested. | |
21394 | ||
d77de738 | 21395 | @opindex marclinux_prof |
ddf6fe37 | 21396 | @item -marclinux_prof |
d77de738 ML |
21397 | Passed through to the linker, to specify use of the |
21398 | @code{arclinux_prof} emulation. This option is enabled by default in | |
21399 | tool chains built for @w{@code{arc-linux-uclibc}} and | |
21400 | @w{@code{arceb-linux-uclibc}} targets when profiling is requested. | |
21401 | ||
21402 | @end table | |
21403 | ||
21404 | The following options control the semantics of generated code: | |
21405 | ||
21406 | @c semantically relevant code generation options | |
21407 | @table @gcctabopt | |
d77de738 | 21408 | @opindex mlong-calls |
ddf6fe37 | 21409 | @item -mlong-calls |
d77de738 ML |
21410 | Generate calls as register indirect calls, thus providing access |
21411 | to the full 32-bit address range. | |
21412 | ||
d77de738 | 21413 | @opindex mmedium-calls |
ddf6fe37 | 21414 | @item -mmedium-calls |
d77de738 ML |
21415 | Don't use less than 25-bit addressing range for calls, which is the |
21416 | offset available for an unconditional branch-and-link | |
21417 | instruction. Conditional execution of function calls is suppressed, to | |
21418 | allow use of the 25-bit range, rather than the 21-bit range with | |
21419 | conditional branch-and-link. This is the default for tool chains built | |
21420 | for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets. | |
21421 | ||
d77de738 | 21422 | @opindex G |
ddf6fe37 | 21423 | @item -G @var{num} |
d77de738 ML |
21424 | Put definitions of externally-visible data in a small data section if |
21425 | that data is no bigger than @var{num} bytes. The default value of | |
21426 | @var{num} is 4 for any ARC configuration, or 8 when we have double | |
21427 | load/store operations. | |
21428 | ||
d77de738 ML |
21429 | @opindex mno-sdata |
21430 | @opindex msdata | |
ddf6fe37 | 21431 | @item -mno-sdata |
d77de738 ML |
21432 | Do not generate sdata references. This is the default for tool chains |
21433 | built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} | |
21434 | targets. | |
21435 | ||
d77de738 | 21436 | @opindex mvolatile-cache |
ddf6fe37 | 21437 | @item -mvolatile-cache |
d77de738 ML |
21438 | Use ordinarily cached memory accesses for volatile references. This is the |
21439 | default. | |
21440 | ||
d77de738 ML |
21441 | @opindex mno-volatile-cache |
21442 | @opindex mvolatile-cache | |
ddf6fe37 | 21443 | @item -mno-volatile-cache |
d77de738 ML |
21444 | Enable cache bypass for volatile references. |
21445 | ||
21446 | @end table | |
21447 | ||
21448 | The following options fine tune code generation: | |
21449 | @c code generation tuning options | |
21450 | @table @gcctabopt | |
d77de738 | 21451 | @opindex malign-call |
ddf6fe37 | 21452 | @item -malign-call |
d77de738 ML |
21453 | Does nothing. Preserved for backward compatibility. |
21454 | ||
d77de738 | 21455 | @opindex mauto-modify-reg |
ddf6fe37 | 21456 | @item -mauto-modify-reg |
d77de738 ML |
21457 | Enable the use of pre/post modify with register displacement. |
21458 | ||
d77de738 | 21459 | @opindex mbbit-peephole |
ddf6fe37 | 21460 | @item -mbbit-peephole |
d77de738 ML |
21461 | Enable bbit peephole2. |
21462 | ||
d77de738 | 21463 | @opindex mno-brcc |
ddf6fe37 | 21464 | @item -mno-brcc |
d77de738 ML |
21465 | This option disables a target-specific pass in @file{arc_reorg} to |
21466 | generate compare-and-branch (@code{br@var{cc}}) instructions. | |
21467 | It has no effect on | |
21468 | generation of these instructions driven by the combiner pass. | |
21469 | ||
d77de738 | 21470 | @opindex mcase-vector-pcrel |
ddf6fe37 | 21471 | @item -mcase-vector-pcrel |
d77de738 ML |
21472 | Use PC-relative switch case tables to enable case table shortening. |
21473 | This is the default for @option{-Os}. | |
21474 | ||
d77de738 | 21475 | @opindex mcompact-casesi |
ddf6fe37 | 21476 | @item -mcompact-casesi |
d77de738 ML |
21477 | Enable compact @code{casesi} pattern. This is the default for @option{-Os}, |
21478 | and only available for ARCv1 cores. This option is deprecated. | |
21479 | ||
d77de738 | 21480 | @opindex mno-cond-exec |
ddf6fe37 | 21481 | @item -mno-cond-exec |
d77de738 ML |
21482 | Disable the ARCompact-specific pass to generate conditional |
21483 | execution instructions. | |
21484 | ||
21485 | Due to delay slot scheduling and interactions between operand numbers, | |
21486 | literal sizes, instruction lengths, and the support for conditional execution, | |
21487 | the target-independent pass to generate conditional execution is often lacking, | |
21488 | so the ARC port has kept a special pass around that tries to find more | |
21489 | conditional execution generation opportunities after register allocation, | |
21490 | branch shortening, and delay slot scheduling have been done. This pass | |
21491 | generally, but not always, improves performance and code size, at the cost of | |
21492 | extra compilation time, which is why there is an option to switch it off. | |
21493 | If you have a problem with call instructions exceeding their allowable | |
21494 | offset range because they are conditionalized, you should consider using | |
21495 | @option{-mmedium-calls} instead. | |
21496 | ||
d77de738 | 21497 | @opindex mearly-cbranchsi |
ddf6fe37 | 21498 | @item -mearly-cbranchsi |
d77de738 ML |
21499 | Enable pre-reload use of the @code{cbranchsi} pattern. |
21500 | ||
d77de738 | 21501 | @opindex mexpand-adddi |
ddf6fe37 | 21502 | @item -mexpand-adddi |
d77de738 ML |
21503 | Expand @code{adddi3} and @code{subdi3} at RTL generation time into |
21504 | @code{add.f}, @code{adc} etc. This option is deprecated. | |
21505 | ||
d77de738 | 21506 | @opindex mindexed-loads |
ddf6fe37 | 21507 | @item -mindexed-loads |
d77de738 ML |
21508 | Enable the use of indexed loads. This can be problematic because some |
21509 | optimizers then assume that indexed stores exist, which is not | |
21510 | the case. | |
21511 | ||
d77de738 | 21512 | @opindex mlra |
ddf6fe37 | 21513 | @item -mlra |
d77de738 ML |
21514 | Enable Local Register Allocation. This is still experimental for ARC, |
21515 | so by default the compiler uses standard reload | |
21516 | (i.e.@: @option{-mno-lra}). | |
21517 | ||
d77de738 | 21518 | @opindex mlra-priority-none |
ddf6fe37 | 21519 | @item -mlra-priority-none |
d77de738 ML |
21520 | Don't indicate any priority for target registers. |
21521 | ||
d77de738 | 21522 | @opindex mlra-priority-compact |
ddf6fe37 | 21523 | @item -mlra-priority-compact |
d77de738 ML |
21524 | Indicate target register priority for r0..r3 / r12..r15. |
21525 | ||
d77de738 | 21526 | @opindex mlra-priority-noncompact |
ddf6fe37 | 21527 | @item -mlra-priority-noncompact |
d77de738 ML |
21528 | Reduce target register priority for r0..r3 / r12..r15. |
21529 | ||
d77de738 | 21530 | @opindex mmillicode |
ddf6fe37 | 21531 | @item -mmillicode |
d77de738 ML |
21532 | When optimizing for size (using @option{-Os}), prologues and epilogues |
21533 | that have to save or restore a large number of registers are often | |
21534 | shortened by using call to a special function in libgcc; this is | |
21535 | referred to as a @emph{millicode} call. As these calls can pose | |
21536 | performance issues, and/or cause linking issues when linking in a | |
21537 | nonstandard way, this option is provided to turn on or off millicode | |
21538 | call generation. | |
21539 | ||
d77de738 | 21540 | @opindex mcode-density-frame |
ddf6fe37 | 21541 | @item -mcode-density-frame |
d77de738 ML |
21542 | This option enable the compiler to emit @code{enter} and @code{leave} |
21543 | instructions. These instructions are only valid for CPUs with | |
21544 | code-density feature. | |
21545 | ||
d77de738 | 21546 | @opindex mmixed-code |
ddf6fe37 | 21547 | @item -mmixed-code |
d77de738 ML |
21548 | Does nothing. Preserved for backward compatibility. |
21549 | ||
d77de738 | 21550 | @opindex mq-class |
ddf6fe37 | 21551 | @item -mq-class |
d77de738 ML |
21552 | Ths option is deprecated. Enable @samp{q} instruction alternatives. |
21553 | This is the default for @option{-Os}. | |
21554 | ||
d77de738 | 21555 | @opindex mRcq |
ddf6fe37 | 21556 | @item -mRcq |
d77de738 ML |
21557 | Does nothing. Preserved for backward compatibility. |
21558 | ||
d77de738 | 21559 | @opindex mRcw |
ddf6fe37 | 21560 | @item -mRcw |
d77de738 ML |
21561 | Does nothing. Preserved for backward compatibility. |
21562 | ||
d77de738 | 21563 | @opindex msize-level |
ddf6fe37 | 21564 | @item -msize-level=@var{level} |
d77de738 ML |
21565 | Fine-tune size optimization with regards to instruction lengths and alignment. |
21566 | The recognized values for @var{level} are: | |
21567 | @table @samp | |
21568 | @item 0 | |
21569 | No size optimization. This level is deprecated and treated like @samp{1}. | |
21570 | ||
21571 | @item 1 | |
21572 | Short instructions are used opportunistically. | |
21573 | ||
21574 | @item 2 | |
21575 | In addition, alignment of loops and of code after barriers are dropped. | |
21576 | ||
21577 | @item 3 | |
21578 | In addition, optional data alignment is dropped, and the option @option{Os} is enabled. | |
21579 | ||
21580 | @end table | |
21581 | ||
21582 | This defaults to @samp{3} when @option{-Os} is in effect. Otherwise, | |
21583 | the behavior when this is not set is equivalent to level @samp{1}. | |
21584 | ||
d77de738 | 21585 | @opindex mtune |
ddf6fe37 | 21586 | @item -mtune=@var{cpu} |
d77de738 ML |
21587 | Set instruction scheduling parameters for @var{cpu}, overriding any implied |
21588 | by @option{-mcpu=}. | |
21589 | ||
21590 | Supported values for @var{cpu} are | |
21591 | ||
21592 | @table @samp | |
21593 | @item ARC600 | |
21594 | Tune for ARC600 CPU. | |
21595 | ||
21596 | @item ARC601 | |
21597 | Tune for ARC601 CPU. | |
21598 | ||
21599 | @item ARC700 | |
21600 | Tune for ARC700 CPU with standard multiplier block. | |
21601 | ||
21602 | @item ARC700-xmac | |
21603 | Tune for ARC700 CPU with XMAC block. | |
21604 | ||
21605 | @item ARC725D | |
21606 | Tune for ARC725D CPU. | |
21607 | ||
21608 | @item ARC750D | |
21609 | Tune for ARC750D CPU. | |
21610 | ||
21611 | @item core3 | |
21612 | Tune for ARCv2 core3 type CPU. This option enable usage of | |
21613 | @code{dbnz} instruction. | |
21614 | ||
21615 | @item release31a | |
21616 | Tune for ARC4x release 3.10a. | |
21617 | ||
21618 | @end table | |
21619 | ||
d77de738 | 21620 | @opindex mmultcost |
ddf6fe37 | 21621 | @item -mmultcost=@var{num} |
d77de738 ML |
21622 | Cost to assume for a multiply instruction, with @samp{4} being equal to a |
21623 | normal instruction. | |
21624 | ||
d77de738 | 21625 | @opindex munalign-prob-threshold |
ddf6fe37 | 21626 | @item -munalign-prob-threshold=@var{probability} |
d77de738 ML |
21627 | Does nothing. Preserved for backward compatibility. |
21628 | ||
21629 | @end table | |
21630 | ||
21631 | The following options are maintained for backward compatibility, but | |
21632 | are now deprecated and will be removed in a future release: | |
21633 | ||
21634 | @c Deprecated options | |
21635 | @table @gcctabopt | |
21636 | ||
d77de738 | 21637 | @opindex margonaut |
ddf6fe37 | 21638 | @item -margonaut |
d77de738 ML |
21639 | Obsolete FPX. |
21640 | ||
d77de738 | 21641 | @opindex mbig-endian |
d77de738 | 21642 | @opindex EB |
ddf6fe37 AA |
21643 | @item -mbig-endian |
21644 | @itemx -EB | |
d77de738 ML |
21645 | Compile code for big-endian targets. Use of these options is now |
21646 | deprecated. Big-endian code is supported by configuring GCC to build | |
21647 | @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets, | |
21648 | for which big endian is the default. | |
21649 | ||
d77de738 | 21650 | @opindex mlittle-endian |
d77de738 | 21651 | @opindex EL |
ddf6fe37 AA |
21652 | @item -mlittle-endian |
21653 | @itemx -EL | |
d77de738 ML |
21654 | Compile code for little-endian targets. Use of these options is now |
21655 | deprecated. Little-endian code is supported by configuring GCC to build | |
21656 | @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets, | |
21657 | for which little endian is the default. | |
21658 | ||
d77de738 | 21659 | @opindex mbarrel_shifter |
ddf6fe37 | 21660 | @item -mbarrel_shifter |
d77de738 ML |
21661 | Replaced by @option{-mbarrel-shifter}. |
21662 | ||
d77de738 | 21663 | @opindex mdpfp_compact |
ddf6fe37 | 21664 | @item -mdpfp_compact |
d77de738 ML |
21665 | Replaced by @option{-mdpfp-compact}. |
21666 | ||
d77de738 | 21667 | @opindex mdpfp_fast |
ddf6fe37 | 21668 | @item -mdpfp_fast |
d77de738 ML |
21669 | Replaced by @option{-mdpfp-fast}. |
21670 | ||
d77de738 | 21671 | @opindex mdsp_packa |
ddf6fe37 | 21672 | @item -mdsp_packa |
d77de738 ML |
21673 | Replaced by @option{-mdsp-packa}. |
21674 | ||
d77de738 | 21675 | @opindex mEA |
ddf6fe37 | 21676 | @item -mEA |
d77de738 ML |
21677 | Replaced by @option{-mea}. |
21678 | ||
d77de738 | 21679 | @opindex mmac_24 |
ddf6fe37 | 21680 | @item -mmac_24 |
d77de738 ML |
21681 | Replaced by @option{-mmac-24}. |
21682 | ||
d77de738 | 21683 | @opindex mmac_d16 |
ddf6fe37 | 21684 | @item -mmac_d16 |
d77de738 ML |
21685 | Replaced by @option{-mmac-d16}. |
21686 | ||
d77de738 | 21687 | @opindex mspfp_compact |
ddf6fe37 | 21688 | @item -mspfp_compact |
d77de738 ML |
21689 | Replaced by @option{-mspfp-compact}. |
21690 | ||
d77de738 | 21691 | @opindex mspfp_fast |
ddf6fe37 | 21692 | @item -mspfp_fast |
d77de738 ML |
21693 | Replaced by @option{-mspfp-fast}. |
21694 | ||
d77de738 | 21695 | @opindex mtune |
ddf6fe37 | 21696 | @item -mtune=@var{cpu} |
d77de738 ML |
21697 | Values @samp{arc600}, @samp{arc601}, @samp{arc700} and |
21698 | @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600}, | |
21699 | @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively. | |
21700 | ||
d77de738 | 21701 | @opindex multcost |
ddf6fe37 | 21702 | @item -multcost=@var{num} |
d77de738 ML |
21703 | Replaced by @option{-mmultcost}. |
21704 | ||
21705 | @end table | |
21706 | ||
21707 | @node ARM Options | |
21708 | @subsection ARM Options | |
21709 | @cindex ARM options | |
21710 | ||
21711 | These @samp{-m} options are defined for the ARM port: | |
21712 | ||
21713 | @table @gcctabopt | |
d77de738 | 21714 | @opindex mabi |
ddf6fe37 | 21715 | @item -mabi=@var{name} |
d77de738 ML |
21716 | Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu}, |
21717 | @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}. | |
21718 | ||
d77de738 | 21719 | @opindex mapcs-frame |
ddf6fe37 | 21720 | @item -mapcs-frame |
d77de738 ML |
21721 | Generate a stack frame that is compliant with the ARM Procedure Call |
21722 | Standard for all functions, even if this is not strictly necessary for | |
21723 | correct execution of the code. Specifying @option{-fomit-frame-pointer} | |
21724 | with this option causes the stack frames not to be generated for | |
21725 | leaf functions. The default is @option{-mno-apcs-frame}. | |
21726 | This option is deprecated. | |
21727 | ||
d77de738 | 21728 | @opindex mapcs |
ddf6fe37 | 21729 | @item -mapcs |
d77de738 ML |
21730 | This is a synonym for @option{-mapcs-frame} and is deprecated. |
21731 | ||
21732 | @ignore | |
21733 | @c not currently implemented | |
d77de738 | 21734 | @opindex mapcs-stack-check |
ddf6fe37 | 21735 | @item -mapcs-stack-check |
d77de738 ML |
21736 | Generate code to check the amount of stack space available upon entry to |
21737 | every function (that actually uses some stack space). If there is | |
21738 | insufficient space available then either the function | |
21739 | @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is | |
21740 | called, depending upon the amount of stack space required. The runtime | |
21741 | system is required to provide these functions. The default is | |
21742 | @option{-mno-apcs-stack-check}, since this produces smaller code. | |
21743 | ||
21744 | @c not currently implemented | |
d77de738 | 21745 | @opindex mapcs-reentrant |
ddf6fe37 | 21746 | @item -mapcs-reentrant |
d77de738 ML |
21747 | Generate reentrant, position-independent code. The default is |
21748 | @option{-mno-apcs-reentrant}. | |
21749 | @end ignore | |
21750 | ||
d77de738 | 21751 | @opindex mthumb-interwork |
ddf6fe37 | 21752 | @item -mthumb-interwork |
d77de738 ML |
21753 | Generate code that supports calling between the ARM and Thumb |
21754 | instruction sets. Without this option, on pre-v5 architectures, the | |
21755 | two instruction sets cannot be reliably used inside one program. The | |
21756 | default is @option{-mno-thumb-interwork}, since slightly larger code | |
21757 | is generated when @option{-mthumb-interwork} is specified. In AAPCS | |
21758 | configurations this option is meaningless. | |
21759 | ||
d77de738 ML |
21760 | @opindex mno-sched-prolog |
21761 | @opindex msched-prolog | |
ddf6fe37 | 21762 | @item -mno-sched-prolog |
d77de738 ML |
21763 | Prevent the reordering of instructions in the function prologue, or the |
21764 | merging of those instruction with the instructions in the function's | |
21765 | body. This means that all functions start with a recognizable set | |
21766 | of instructions (or in fact one of a choice from a small set of | |
21767 | different function prologues), and this information can be used to | |
21768 | locate the start of functions inside an executable piece of code. The | |
21769 | default is @option{-msched-prolog}. | |
21770 | ||
d77de738 | 21771 | @opindex mfloat-abi |
ddf6fe37 | 21772 | @item -mfloat-abi=@var{name} |
d77de738 ML |
21773 | Specifies which floating-point ABI to use. Permissible values |
21774 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
21775 | ||
21776 | Specifying @samp{soft} causes GCC to generate output containing | |
21777 | library calls for floating-point operations. | |
21778 | @samp{softfp} allows the generation of code using hardware floating-point | |
21779 | instructions, but still uses the soft-float calling conventions. | |
21780 | @samp{hard} allows generation of floating-point instructions | |
21781 | and uses FPU-specific calling conventions. | |
21782 | ||
21783 | The default depends on the specific target configuration. Note that | |
21784 | the hard-float and soft-float ABIs are not link-compatible; you must | |
21785 | compile your entire program with the same ABI, and link with a | |
21786 | compatible set of libraries. | |
21787 | ||
d77de738 | 21788 | @opindex mgeneral-regs-only |
ddf6fe37 | 21789 | @item -mgeneral-regs-only |
d77de738 ML |
21790 | Generate code which uses only the general-purpose registers. This will prevent |
21791 | the compiler from using floating-point and Advanced SIMD registers but will not | |
21792 | impose any restrictions on the assembler. | |
21793 | ||
d77de738 | 21794 | @opindex mlittle-endian |
ddf6fe37 | 21795 | @item -mlittle-endian |
d77de738 ML |
21796 | Generate code for a processor running in little-endian mode. This is |
21797 | the default for all standard configurations. | |
21798 | ||
d77de738 | 21799 | @opindex mbig-endian |
ddf6fe37 | 21800 | @item -mbig-endian |
d77de738 ML |
21801 | Generate code for a processor running in big-endian mode; the default is |
21802 | to compile code for a little-endian processor. | |
21803 | ||
ddf6fe37 | 21804 | @opindex mbe8 |
d77de738 ML |
21805 | @item -mbe8 |
21806 | @itemx -mbe32 | |
d77de738 ML |
21807 | When linking a big-endian image select between BE8 and BE32 formats. |
21808 | The option has no effect for little-endian images and is ignored. The | |
21809 | default is dependent on the selected target architecture. For ARMv6 | |
21810 | and later architectures the default is BE8, for older architectures | |
21811 | the default is BE32. BE32 format has been deprecated by ARM. | |
21812 | ||
d77de738 | 21813 | @opindex march |
ddf6fe37 | 21814 | @item -march=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
21815 | This specifies the name of the target ARM architecture. GCC uses this |
21816 | name to determine what kind of instructions it can emit when generating | |
21817 | assembly code. This option can be used in conjunction with or instead | |
21818 | of the @option{-mcpu=} option. | |
21819 | ||
21820 | Permissible names are: | |
21821 | @samp{armv4t}, | |
21822 | @samp{armv5t}, @samp{armv5te}, | |
21823 | @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2}, | |
21824 | @samp{armv6z}, @samp{armv6zk}, | |
21825 | @samp{armv7}, @samp{armv7-a}, @samp{armv7ve}, | |
21826 | @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a}, | |
21827 | @samp{armv8.4-a}, | |
21828 | @samp{armv8.5-a}, | |
21829 | @samp{armv8.6-a}, | |
21830 | @samp{armv9-a}, | |
21831 | @samp{armv7-r}, | |
21832 | @samp{armv8-r}, | |
21833 | @samp{armv6-m}, @samp{armv6s-m}, | |
21834 | @samp{armv7-m}, @samp{armv7e-m}, | |
21835 | @samp{armv8-m.base}, @samp{armv8-m.main}, | |
21836 | @samp{armv8.1-m.main}, | |
21837 | @samp{armv9-a}, | |
21838 | @samp{iwmmxt} and @samp{iwmmxt2}. | |
21839 | ||
21840 | Additionally, the following architectures, which lack support for the | |
21841 | Thumb execution state, are recognized but support is deprecated: @samp{armv4}. | |
21842 | ||
21843 | Many of the architectures support extensions. These can be added by | |
21844 | appending @samp{+@var{extension}} to the architecture name. Extension | |
21845 | options are processed in order and capabilities accumulate. An extension | |
21846 | will also enable any necessary base extensions | |
21847 | upon which it depends. For example, the @samp{+crypto} extension | |
21848 | will always enable the @samp{+simd} extension. The exception to the | |
21849 | additive construction is for extensions that are prefixed with | |
21850 | @samp{+no@dots{}}: these extensions disable the specified option and | |
21851 | any other extensions that may depend on the presence of that | |
21852 | extension. | |
21853 | ||
21854 | For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to | |
21855 | writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is | |
21856 | entirely disabled by the @samp{+nofp} option that follows it. | |
21857 | ||
21858 | Most extension names are generically named, but have an effect that is | |
21859 | dependent upon the architecture to which it is applied. For example, | |
21860 | the @samp{+simd} option can be applied to both @samp{armv7-a} and | |
21861 | @samp{armv8-a} architectures, but will enable the original ARMv7-A | |
21862 | Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A | |
21863 | variant for @samp{armv8-a}. | |
21864 | ||
21865 | The table below lists the supported extensions for each architecture. | |
21866 | Architectures not mentioned do not support any extensions. | |
21867 | ||
21868 | @table @samp | |
21869 | @item armv5te | |
21870 | @itemx armv6 | |
21871 | @itemx armv6j | |
21872 | @itemx armv6k | |
21873 | @itemx armv6kz | |
21874 | @itemx armv6t2 | |
21875 | @itemx armv6z | |
21876 | @itemx armv6zk | |
21877 | @table @samp | |
21878 | @item +fp | |
21879 | The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be | |
21880 | used as an alias for this extension. | |
21881 | ||
21882 | @item +nofp | |
21883 | Disable the floating-point instructions. | |
21884 | @end table | |
21885 | ||
21886 | @item armv7 | |
21887 | The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures. | |
21888 | @table @samp | |
21889 | @item +fp | |
21890 | The VFPv3 floating-point instructions, with 16 double-precision | |
21891 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
21892 | for this extension. Note that floating-point is not supported by the | |
21893 | base ARMv7-M architecture, but is compatible with both the ARMv7-A and | |
21894 | ARMv7-R architectures. | |
21895 | ||
21896 | @item +nofp | |
21897 | Disable the floating-point instructions. | |
21898 | @end table | |
21899 | ||
21900 | @item armv7-a | |
21901 | @table @samp | |
21902 | @item +mp | |
21903 | The multiprocessing extension. | |
21904 | ||
21905 | @item +sec | |
21906 | The security extension. | |
21907 | ||
21908 | @item +fp | |
21909 | The VFPv3 floating-point instructions, with 16 double-precision | |
21910 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
21911 | for this extension. | |
21912 | ||
21913 | @item +simd | |
21914 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
21915 | The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases | |
21916 | for this extension. | |
21917 | ||
21918 | @item +vfpv3 | |
21919 | The VFPv3 floating-point instructions, with 32 double-precision | |
21920 | registers. | |
21921 | ||
21922 | @item +vfpv3-d16-fp16 | |
21923 | The VFPv3 floating-point instructions, with 16 double-precision | |
21924 | registers and the half-precision floating-point conversion operations. | |
21925 | ||
21926 | @item +vfpv3-fp16 | |
21927 | The VFPv3 floating-point instructions, with 32 double-precision | |
21928 | registers and the half-precision floating-point conversion operations. | |
21929 | ||
21930 | @item +vfpv4-d16 | |
21931 | The VFPv4 floating-point instructions, with 16 double-precision | |
21932 | registers. | |
21933 | ||
21934 | @item +vfpv4 | |
21935 | The VFPv4 floating-point instructions, with 32 double-precision | |
21936 | registers. | |
21937 | ||
21938 | @item +neon-fp16 | |
21939 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
21940 | the half-precision floating-point conversion operations. | |
21941 | ||
21942 | @item +neon-vfpv4 | |
21943 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. | |
21944 | ||
21945 | @item +nosimd | |
21946 | Disable the Advanced SIMD instructions (does not disable floating point). | |
21947 | ||
21948 | @item +nofp | |
21949 | Disable the floating-point and Advanced SIMD instructions. | |
21950 | @end table | |
21951 | ||
21952 | @item armv7ve | |
21953 | The extended version of the ARMv7-A architecture with support for | |
21954 | virtualization. | |
21955 | @table @samp | |
21956 | @item +fp | |
21957 | The VFPv4 floating-point instructions, with 16 double-precision registers. | |
21958 | The extension @samp{+vfpv4-d16} can be used as an alias for this extension. | |
21959 | ||
21960 | @item +simd | |
21961 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The | |
21962 | extension @samp{+neon-vfpv4} can be used as an alias for this extension. | |
21963 | ||
21964 | @item +vfpv3-d16 | |
21965 | The VFPv3 floating-point instructions, with 16 double-precision | |
21966 | registers. | |
21967 | ||
21968 | @item +vfpv3 | |
21969 | The VFPv3 floating-point instructions, with 32 double-precision | |
21970 | registers. | |
21971 | ||
21972 | @item +vfpv3-d16-fp16 | |
21973 | The VFPv3 floating-point instructions, with 16 double-precision | |
21974 | registers and the half-precision floating-point conversion operations. | |
21975 | ||
21976 | @item +vfpv3-fp16 | |
21977 | The VFPv3 floating-point instructions, with 32 double-precision | |
21978 | registers and the half-precision floating-point conversion operations. | |
21979 | ||
21980 | @item +vfpv4-d16 | |
21981 | The VFPv4 floating-point instructions, with 16 double-precision | |
21982 | registers. | |
21983 | ||
21984 | @item +vfpv4 | |
21985 | The VFPv4 floating-point instructions, with 32 double-precision | |
21986 | registers. | |
21987 | ||
21988 | @item +neon | |
21989 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
21990 | The extension @samp{+neon-vfpv3} can be used as an alias for this extension. | |
21991 | ||
21992 | @item +neon-fp16 | |
21993 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
21994 | the half-precision floating-point conversion operations. | |
21995 | ||
21996 | @item +nosimd | |
21997 | Disable the Advanced SIMD instructions (does not disable floating point). | |
21998 | ||
21999 | @item +nofp | |
22000 | Disable the floating-point and Advanced SIMD instructions. | |
22001 | @end table | |
22002 | ||
22003 | @item armv8-a | |
22004 | @table @samp | |
22005 | @item +crc | |
22006 | The Cyclic Redundancy Check (CRC) instructions. | |
22007 | @item +simd | |
22008 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22009 | @item +crypto | |
22010 | The cryptographic instructions. | |
22011 | @item +nocrypto | |
22012 | Disable the cryptographic instructions. | |
22013 | @item +nofp | |
22014 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22015 | @item +sb | |
22016 | Speculation Barrier Instruction. | |
22017 | @item +predres | |
22018 | Execution and Data Prediction Restriction Instructions. | |
22019 | @end table | |
22020 | ||
22021 | @item armv8.1-a | |
22022 | @table @samp | |
22023 | @item +simd | |
22024 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22025 | ||
22026 | @item +crypto | |
22027 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22028 | floating-point instructions. | |
22029 | ||
22030 | @item +nocrypto | |
22031 | Disable the cryptographic instructions. | |
22032 | ||
22033 | @item +nofp | |
22034 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22035 | ||
22036 | @item +sb | |
22037 | Speculation Barrier Instruction. | |
22038 | ||
22039 | @item +predres | |
22040 | Execution and Data Prediction Restriction Instructions. | |
22041 | @end table | |
22042 | ||
22043 | @item armv8.2-a | |
22044 | @itemx armv8.3-a | |
22045 | @table @samp | |
22046 | @item +fp16 | |
22047 | The half-precision floating-point data processing instructions. | |
22048 | This also enables the Advanced SIMD and floating-point instructions. | |
22049 | ||
22050 | @item +fp16fml | |
22051 | The half-precision floating-point fmla extension. This also enables | |
22052 | the half-precision floating-point extension and Advanced SIMD and | |
22053 | floating-point instructions. | |
22054 | ||
22055 | @item +simd | |
22056 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22057 | ||
22058 | @item +crypto | |
22059 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22060 | floating-point instructions. | |
22061 | ||
22062 | @item +dotprod | |
22063 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
22064 | ||
22065 | @item +nocrypto | |
22066 | Disable the cryptographic extension. | |
22067 | ||
22068 | @item +nofp | |
22069 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22070 | ||
22071 | @item +sb | |
22072 | Speculation Barrier Instruction. | |
22073 | ||
22074 | @item +predres | |
22075 | Execution and Data Prediction Restriction Instructions. | |
22076 | ||
22077 | @item +i8mm | |
22078 | 8-bit Integer Matrix Multiply instructions. | |
22079 | This also enables Advanced SIMD and floating-point instructions. | |
22080 | ||
22081 | @item +bf16 | |
22082 | Brain half-precision floating-point instructions. | |
22083 | This also enables Advanced SIMD and floating-point instructions. | |
22084 | @end table | |
22085 | ||
22086 | @item armv8.4-a | |
22087 | @table @samp | |
22088 | @item +fp16 | |
22089 | The half-precision floating-point data processing instructions. | |
22090 | This also enables the Advanced SIMD and floating-point instructions as well | |
22091 | as the Dot Product extension and the half-precision floating-point fmla | |
22092 | extension. | |
22093 | ||
22094 | @item +simd | |
22095 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22096 | Dot Product extension. | |
22097 | ||
22098 | @item +crypto | |
22099 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22100 | floating-point instructions as well as the Dot Product extension. | |
22101 | ||
22102 | @item +nocrypto | |
22103 | Disable the cryptographic extension. | |
22104 | ||
22105 | @item +nofp | |
22106 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22107 | ||
22108 | @item +sb | |
22109 | Speculation Barrier Instruction. | |
22110 | ||
22111 | @item +predres | |
22112 | Execution and Data Prediction Restriction Instructions. | |
22113 | ||
22114 | @item +i8mm | |
22115 | 8-bit Integer Matrix Multiply instructions. | |
22116 | This also enables Advanced SIMD and floating-point instructions. | |
22117 | ||
22118 | @item +bf16 | |
22119 | Brain half-precision floating-point instructions. | |
22120 | This also enables Advanced SIMD and floating-point instructions. | |
22121 | @end table | |
22122 | ||
22123 | @item armv8.5-a | |
22124 | @table @samp | |
22125 | @item +fp16 | |
22126 | The half-precision floating-point data processing instructions. | |
22127 | This also enables the Advanced SIMD and floating-point instructions as well | |
22128 | as the Dot Product extension and the half-precision floating-point fmla | |
22129 | extension. | |
22130 | ||
22131 | @item +simd | |
22132 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22133 | Dot Product extension. | |
22134 | ||
22135 | @item +crypto | |
22136 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22137 | floating-point instructions as well as the Dot Product extension. | |
22138 | ||
22139 | @item +nocrypto | |
22140 | Disable the cryptographic extension. | |
22141 | ||
22142 | @item +nofp | |
22143 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22144 | ||
22145 | @item +i8mm | |
22146 | 8-bit Integer Matrix Multiply instructions. | |
22147 | This also enables Advanced SIMD and floating-point instructions. | |
22148 | ||
22149 | @item +bf16 | |
22150 | Brain half-precision floating-point instructions. | |
22151 | This also enables Advanced SIMD and floating-point instructions. | |
22152 | @end table | |
22153 | ||
22154 | @item armv8.6-a | |
22155 | @table @samp | |
22156 | @item +fp16 | |
22157 | The half-precision floating-point data processing instructions. | |
22158 | This also enables the Advanced SIMD and floating-point instructions as well | |
22159 | as the Dot Product extension and the half-precision floating-point fmla | |
22160 | extension. | |
22161 | ||
22162 | @item +simd | |
22163 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22164 | Dot Product extension. | |
22165 | ||
22166 | @item +crypto | |
22167 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22168 | floating-point instructions as well as the Dot Product extension. | |
22169 | ||
22170 | @item +nocrypto | |
22171 | Disable the cryptographic extension. | |
22172 | ||
22173 | @item +nofp | |
22174 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22175 | ||
22176 | @item +i8mm | |
22177 | 8-bit Integer Matrix Multiply instructions. | |
22178 | This also enables Advanced SIMD and floating-point instructions. | |
22179 | ||
22180 | @item +bf16 | |
22181 | Brain half-precision floating-point instructions. | |
22182 | This also enables Advanced SIMD and floating-point instructions. | |
22183 | @end table | |
22184 | ||
22185 | @item armv7-r | |
22186 | @table @samp | |
22187 | @item +fp.sp | |
22188 | The single-precision VFPv3 floating-point instructions. The extension | |
22189 | @samp{+vfpv3xd} can be used as an alias for this extension. | |
22190 | ||
22191 | @item +fp | |
22192 | The VFPv3 floating-point instructions with 16 double-precision registers. | |
22193 | The extension +vfpv3-d16 can be used as an alias for this extension. | |
22194 | ||
22195 | @item +vfpv3xd-d16-fp16 | |
22196 | The single-precision VFPv3 floating-point instructions with 16 double-precision | |
22197 | registers and the half-precision floating-point conversion operations. | |
22198 | ||
22199 | @item +vfpv3-d16-fp16 | |
22200 | The VFPv3 floating-point instructions with 16 double-precision | |
22201 | registers and the half-precision floating-point conversion operations. | |
22202 | ||
22203 | @item +nofp | |
22204 | Disable the floating-point extension. | |
22205 | ||
22206 | @item +idiv | |
22207 | The ARM-state integer division instructions. | |
22208 | ||
22209 | @item +noidiv | |
22210 | Disable the ARM-state integer division extension. | |
22211 | @end table | |
22212 | ||
22213 | @item armv7e-m | |
22214 | @table @samp | |
22215 | @item +fp | |
22216 | The single-precision VFPv4 floating-point instructions. | |
22217 | ||
22218 | @item +fpv5 | |
22219 | The single-precision FPv5 floating-point instructions. | |
22220 | ||
22221 | @item +fp.dp | |
22222 | The single- and double-precision FPv5 floating-point instructions. | |
22223 | ||
22224 | @item +nofp | |
22225 | Disable the floating-point extensions. | |
22226 | @end table | |
22227 | ||
22228 | @item armv8.1-m.main | |
22229 | @table @samp | |
22230 | ||
22231 | @item +dsp | |
22232 | The DSP instructions. | |
22233 | ||
22234 | @item +mve | |
22235 | The M-Profile Vector Extension (MVE) integer instructions. | |
22236 | ||
22237 | @item +mve.fp | |
22238 | The M-Profile Vector Extension (MVE) integer and single precision | |
22239 | floating-point instructions. | |
22240 | ||
22241 | @item +fp | |
22242 | The single-precision floating-point instructions. | |
22243 | ||
22244 | @item +fp.dp | |
22245 | The single- and double-precision floating-point instructions. | |
22246 | ||
22247 | @item +nofp | |
22248 | Disable the floating-point extension. | |
22249 | ||
22250 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22251 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22252 | to the numbers given in the options in the range 0 to 7. | |
c91bb7b9 AC |
22253 | |
22254 | @item +pacbti | |
22255 | Enable the Pointer Authentication and Branch Target Identification Extension. | |
d77de738 ML |
22256 | @end table |
22257 | ||
22258 | @item armv8-m.main | |
22259 | @table @samp | |
22260 | @item +dsp | |
22261 | The DSP instructions. | |
22262 | ||
22263 | @item +nodsp | |
22264 | Disable the DSP extension. | |
22265 | ||
22266 | @item +fp | |
22267 | The single-precision floating-point instructions. | |
22268 | ||
22269 | @item +fp.dp | |
22270 | The single- and double-precision floating-point instructions. | |
22271 | ||
22272 | @item +nofp | |
22273 | Disable the floating-point extension. | |
22274 | ||
22275 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22276 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22277 | to the numbers given in the options in the range 0 to 7. | |
22278 | @end table | |
22279 | ||
22280 | @item armv8-r | |
22281 | @table @samp | |
22282 | @item +crc | |
22283 | The Cyclic Redundancy Check (CRC) instructions. | |
22284 | @item +fp.sp | |
22285 | The single-precision FPv5 floating-point instructions. | |
22286 | @item +simd | |
22287 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22288 | @item +crypto | |
22289 | The cryptographic instructions. | |
22290 | @item +nocrypto | |
22291 | Disable the cryptographic instructions. | |
22292 | @item +nofp | |
22293 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22294 | @end table | |
22295 | ||
22296 | @end table | |
22297 | ||
22298 | @option{-march=native} causes the compiler to auto-detect the architecture | |
22299 | of the build computer. At present, this feature is only supported on | |
22300 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22301 | is unsuccessful the option has no effect. | |
22302 | ||
d77de738 | 22303 | @opindex mtune |
ddf6fe37 | 22304 | @item -mtune=@var{name} |
d77de738 ML |
22305 | This option specifies the name of the target ARM processor for |
22306 | which GCC should tune the performance of the code. | |
22307 | For some ARM implementations better performance can be obtained by using | |
22308 | this option. | |
22309 | Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t}, | |
22310 | @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110}, | |
22311 | @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810}, | |
22312 | @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t}, | |
22313 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s}, | |
22314 | @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t}, | |
22315 | @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e}, | |
22316 | @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp}, | |
22317 | @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s}, | |
22318 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8}, | |
22319 | @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17}, | |
22320 | @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
22321 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
22322 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
22323 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710}, | |
22324 | @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5}, | |
22325 | @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus}, | |
22326 | @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3}, | |
22327 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33}, | |
ccfd1e7f SP |
22328 | @samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1}, |
22329 | @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply}, | |
d77de738 ML |
22330 | @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4}, |
22331 | @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale}, | |
22332 | @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626}, | |
22333 | @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1}, | |
22334 | @samp{xgene1}. | |
22335 | ||
22336 | Additionally, this option can specify that GCC should tune the performance | |
22337 | of the code for a big.LITTLE system. Permissible names are: | |
22338 | @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7}, | |
22339 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22340 | @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
22341 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}. | |
22342 | ||
22343 | @option{-mtune=generic-@var{arch}} specifies that GCC should tune the | |
22344 | performance for a blend of processors within architecture @var{arch}. | |
22345 | The aim is to generate code that run well on the current most popular | |
22346 | processors, balancing between optimizations that benefit some CPUs in the | |
22347 | range, and avoiding performance pitfalls of other CPUs. The effects of | |
22348 | this option may change in future GCC versions as CPU models come and go. | |
22349 | ||
22350 | @option{-mtune} permits the same extension options as @option{-mcpu}, but | |
22351 | the extension options do not affect the tuning of the generated code. | |
22352 | ||
22353 | @option{-mtune=native} causes the compiler to auto-detect the CPU | |
22354 | of the build computer. At present, this feature is only supported on | |
22355 | GNU/Linux, and not all architectures are recognized. If the auto-detect is | |
22356 | unsuccessful the option has no effect. | |
22357 | ||
d77de738 | 22358 | @opindex mcpu |
ddf6fe37 | 22359 | @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22360 | This specifies the name of the target ARM processor. GCC uses this name |
22361 | to derive the name of the target ARM architecture (as if specified | |
22362 | by @option{-march}) and the ARM processor type for which to tune for | |
22363 | performance (as if specified by @option{-mtune}). Where this option | |
22364 | is used in conjunction with @option{-march} or @option{-mtune}, | |
22365 | those options take precedence over the appropriate part of this option. | |
22366 | ||
22367 | Many of the supported CPUs implement optional architectural | |
22368 | extensions. Where this is so the architectural extensions are | |
22369 | normally enabled by default. If implementations that lack the | |
22370 | extension exist, then the extension syntax can be used to disable | |
22371 | those extensions that have been omitted. For floating-point and | |
22372 | Advanced SIMD (Neon) instructions, the settings of the options | |
22373 | @option{-mfloat-abi} and @option{-mfpu} must also be considered: | |
22374 | floating-point and Advanced SIMD instructions will only be used if | |
22375 | @option{-mfloat-abi} is not set to @samp{soft}; and any setting of | |
22376 | @option{-mfpu} other than @samp{auto} will override the available | |
22377 | floating-point and SIMD extension instructions. | |
22378 | ||
22379 | For example, @samp{cortex-a9} can be found in three major | |
22380 | configurations: integer only, with just a floating-point unit or with | |
22381 | floating-point and Advanced SIMD. The default is to enable all the | |
22382 | instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can | |
22383 | be used to disable just the SIMD or both the SIMD and floating-point | |
22384 | instructions respectively. | |
22385 | ||
22386 | Permissible names for this option are the same as those for | |
22387 | @option{-mtune}. | |
22388 | ||
22389 | The following extension options are common to the listed CPUs: | |
22390 | ||
22391 | @table @samp | |
22392 | @item +nodsp | |
ccfd1e7f SP |
22393 | Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}, |
22394 | @samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector | |
22395 | Extension (MVE) integer and single precision floating-point instructions on | |
22396 | @samp{cortex-m55} and @samp{cortex-m85}. | |
22397 | ||
22398 | @item +nopacbti | |
22399 | Disable the Pointer Authentication and Branch Target Identification Extension | |
22400 | on @samp{cortex-m85}. | |
d77de738 ML |
22401 | |
22402 | @item +nomve | |
22403 | Disable the M-Profile Vector Extension (MVE) integer and single precision | |
ccfd1e7f | 22404 | floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 ML |
22405 | |
22406 | @item +nomve.fp | |
22407 | Disable the M-Profile Vector Extension (MVE) single precision floating-point | |
ccfd1e7f | 22408 | instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 | 22409 | |
798a0d05 SP |
22410 | @item +cdecp0, +cdecp1, ... , +cdecp7 |
22411 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22412 | to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}. | |
22413 | ||
d77de738 ML |
22414 | @item +nofp |
22415 | Disables the floating-point instructions on @samp{arm9e}, | |
22416 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e}, | |
22417 | @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s}, | |
22418 | @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, | |
22419 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p} | |
ccfd1e7f SP |
22420 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}, |
22421 | @samp{cortex-m55} and @samp{cortex-m85}. | |
d77de738 ML |
22422 | Disables the floating-point and SIMD instructions on |
22423 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, | |
22424 | @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12}, | |
22425 | @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7}, | |
22426 | @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35}, | |
22427 | @samp{cortex-a53} and @samp{cortex-a55}. | |
22428 | ||
22429 | @item +nofp.dp | |
22430 | Disables the double-precision component of the floating-point instructions | |
22431 | on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, | |
22432 | @samp{cortex-r52plus} and @samp{cortex-m7}. | |
22433 | ||
22434 | @item +nosimd | |
22435 | Disables the SIMD (but not floating-point) instructions on | |
22436 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7} | |
22437 | and @samp{cortex-a9}. | |
22438 | ||
22439 | @item +crypto | |
22440 | Enables the cryptographic instructions on @samp{cortex-a32}, | |
22441 | @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57}, | |
22442 | @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1}, | |
22443 | @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22444 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and | |
22445 | @samp{cortex-a75.cortex-a55}. | |
22446 | @end table | |
22447 | ||
22448 | Additionally the @samp{generic-armv7-a} pseudo target defaults to | |
22449 | VFPv3 with 16 double-precision registers. It supports the following | |
22450 | extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16}, | |
22451 | @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16}, | |
22452 | @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3}, | |
22453 | @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for | |
22454 | the extensions to @option{-march=armv7-a}. | |
22455 | ||
22456 | @option{-mcpu=generic-@var{arch}} is also permissible, and is | |
22457 | equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}. | |
22458 | See @option{-mtune} for more information. | |
22459 | ||
22460 | @option{-mcpu=native} causes the compiler to auto-detect the CPU | |
22461 | of the build computer. At present, this feature is only supported on | |
22462 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22463 | is unsuccessful the option has no effect. | |
22464 | ||
d77de738 | 22465 | @opindex mfpu |
ddf6fe37 | 22466 | @item -mfpu=@var{name} |
d77de738 ML |
22467 | This specifies what floating-point hardware (or hardware emulation) is |
22468 | available on the target. Permissible names are: @samp{auto}, @samp{vfpv2}, | |
22469 | @samp{vfpv3}, | |
22470 | @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd}, | |
22471 | @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4}, | |
22472 | @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4}, | |
22473 | @samp{fpv5-d16}, @samp{fpv5-sp-d16}, | |
22474 | @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}. | |
22475 | Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp} | |
22476 | is an alias for @samp{vfpv2}. | |
22477 | ||
22478 | The setting @samp{auto} is the default and is special. It causes the | |
22479 | compiler to select the floating-point and Advanced SIMD instructions | |
22480 | based on the settings of @option{-mcpu} and @option{-march}. | |
22481 | ||
22482 | If the selected floating-point hardware includes the NEON extension | |
22483 | (e.g.@: @option{-mfpu=neon}), note that floating-point | |
22484 | operations are not generated by GCC's auto-vectorization pass unless | |
22485 | @option{-funsafe-math-optimizations} is also specified. This is | |
22486 | because NEON hardware does not fully implement the IEEE 754 standard for | |
22487 | floating-point arithmetic (in particular denormal values are treated as | |
22488 | zero), so the use of NEON instructions may lead to a loss of precision. | |
22489 | ||
22490 | 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}). | |
22491 | ||
d77de738 | 22492 | @opindex mfp16-format |
ddf6fe37 | 22493 | @item -mfp16-format=@var{name} |
d77de738 ML |
22494 | Specify the format of the @code{__fp16} half-precision floating-point type. |
22495 | Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative}; | |
22496 | the default is @samp{none}, in which case the @code{__fp16} type is not | |
22497 | defined. @xref{Half-Precision}, for more information. | |
22498 | ||
d77de738 | 22499 | @opindex mstructure-size-boundary |
ddf6fe37 | 22500 | @item -mstructure-size-boundary=@var{n} |
d77de738 ML |
22501 | The sizes of all structures and unions are rounded up to a multiple |
22502 | of the number of bits set by this option. Permissible values are 8, 32 | |
22503 | and 64. The default value varies for different toolchains. For the COFF | |
22504 | targeted toolchain the default value is 8. A value of 64 is only allowed | |
22505 | if the underlying ABI supports it. | |
22506 | ||
22507 | Specifying a larger number can produce faster, more efficient code, but | |
22508 | can also increase the size of the program. Different values are potentially | |
22509 | incompatible. Code compiled with one value cannot necessarily expect to | |
22510 | work with code or libraries compiled with another value, if they exchange | |
22511 | information using structures or unions. | |
22512 | ||
22513 | This option is deprecated. | |
22514 | ||
d77de738 | 22515 | @opindex mabort-on-noreturn |
ddf6fe37 | 22516 | @item -mabort-on-noreturn |
d77de738 ML |
22517 | Generate a call to the function @code{abort} at the end of a |
22518 | @code{noreturn} function. It is executed if the function tries to | |
22519 | return. | |
22520 | ||
d77de738 ML |
22521 | @opindex mlong-calls |
22522 | @opindex mno-long-calls | |
ddf6fe37 AA |
22523 | @item -mlong-calls |
22524 | @itemx -mno-long-calls | |
d77de738 ML |
22525 | Tells the compiler to perform function calls by first loading the |
22526 | address of the function into a register and then performing a subroutine | |
22527 | call on this register. This switch is needed if the target function | |
22528 | lies outside of the 64-megabyte addressing range of the offset-based | |
22529 | version of subroutine call instruction. | |
22530 | ||
22531 | Even if this switch is enabled, not all function calls are turned | |
22532 | into long calls. The heuristic is that static functions, functions | |
22533 | that have the @code{short_call} attribute, functions that are inside | |
22534 | the scope of a @code{#pragma no_long_calls} directive, and functions whose | |
22535 | definitions have already been compiled within the current compilation | |
22536 | unit are not turned into long calls. The exceptions to this rule are | |
22537 | that weak function definitions, functions with the @code{long_call} | |
22538 | attribute or the @code{section} attribute, and functions that are within | |
22539 | the scope of a @code{#pragma long_calls} directive are always | |
22540 | turned into long calls. | |
22541 | ||
22542 | This feature is not enabled by default. Specifying | |
22543 | @option{-mno-long-calls} restores the default behavior, as does | |
22544 | placing the function calls within the scope of a @code{#pragma | |
22545 | long_calls_off} directive. Note these switches have no effect on how | |
22546 | the compiler generates code to handle function calls via function | |
22547 | pointers. | |
22548 | ||
d77de738 | 22549 | @opindex msingle-pic-base |
ddf6fe37 | 22550 | @item -msingle-pic-base |
d77de738 ML |
22551 | Treat the register used for PIC addressing as read-only, rather than |
22552 | loading it in the prologue for each function. The runtime system is | |
22553 | responsible for initializing this register with an appropriate value | |
22554 | before execution begins. | |
22555 | ||
d77de738 | 22556 | @opindex mpic-register |
ddf6fe37 | 22557 | @item -mpic-register=@var{reg} |
d77de738 ML |
22558 | Specify the register to be used for PIC addressing. |
22559 | For standard PIC base case, the default is any suitable register | |
22560 | determined by compiler. For single PIC base case, the default is | |
22561 | @samp{R9} if target is EABI based or stack-checking is enabled, | |
22562 | otherwise the default is @samp{R10}. | |
22563 | ||
d77de738 | 22564 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 22565 | @item -mpic-data-is-text-relative |
d77de738 ML |
22566 | Assume that the displacement between the text and data segments is fixed |
22567 | at static link time. This permits using PC-relative addressing | |
22568 | operations to access data known to be in the data segment. For | |
22569 | non-VxWorks RTP targets, this option is enabled by default. When | |
22570 | disabled on such targets, it will enable @option{-msingle-pic-base} by | |
22571 | default. | |
22572 | ||
d77de738 | 22573 | @opindex mpoke-function-name |
ddf6fe37 | 22574 | @item -mpoke-function-name |
d77de738 ML |
22575 | Write the name of each function into the text section, directly |
22576 | preceding the function prologue. The generated code is similar to this: | |
22577 | ||
22578 | @smallexample | |
22579 | t0 | |
22580 | .ascii "arm_poke_function_name", 0 | |
22581 | .align | |
22582 | t1 | |
22583 | .word 0xff000000 + (t1 - t0) | |
22584 | arm_poke_function_name | |
22585 | mov ip, sp | |
22586 | stmfd sp!, @{fp, ip, lr, pc@} | |
22587 | sub fp, ip, #4 | |
22588 | @end smallexample | |
22589 | ||
22590 | When performing a stack backtrace, code can inspect the value of | |
22591 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
22592 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
22593 | there is a function name embedded immediately preceding this location | |
22594 | and has length @code{((pc[-3]) & 0xff000000)}. | |
22595 | ||
d77de738 ML |
22596 | @opindex marm |
22597 | @opindex mthumb | |
ddf6fe37 AA |
22598 | @item -mthumb |
22599 | @itemx -marm | |
d77de738 ML |
22600 | |
22601 | Select between generating code that executes in ARM and Thumb | |
22602 | states. The default for most configurations is to generate code | |
22603 | that executes in ARM state, but the default can be changed by | |
22604 | configuring GCC with the @option{--with-mode=}@var{state} | |
22605 | configure option. | |
22606 | ||
22607 | You can also override the ARM and Thumb mode for each function | |
22608 | by using the @code{target("thumb")} and @code{target("arm")} function attributes | |
22609 | (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}). | |
22610 | ||
d77de738 | 22611 | @opindex mflip-thumb |
ddf6fe37 | 22612 | @item -mflip-thumb |
d77de738 ML |
22613 | Switch ARM/Thumb modes on alternating functions. |
22614 | This option is provided for regression testing of mixed Thumb/ARM code | |
22615 | generation, and is not intended for ordinary use in compiling code. | |
22616 | ||
d77de738 | 22617 | @opindex mtpcs-frame |
ddf6fe37 | 22618 | @item -mtpcs-frame |
d77de738 ML |
22619 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22620 | Standard for all non-leaf functions. (A leaf function is one that does | |
22621 | not call any other functions.) The default is @option{-mno-tpcs-frame}. | |
22622 | ||
d77de738 | 22623 | @opindex mtpcs-leaf-frame |
ddf6fe37 | 22624 | @item -mtpcs-leaf-frame |
d77de738 ML |
22625 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22626 | Standard for all leaf functions. (A leaf function is one that does | |
22627 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. | |
22628 | ||
d77de738 | 22629 | @opindex mcallee-super-interworking |
ddf6fe37 | 22630 | @item -mcallee-super-interworking |
d77de738 ML |
22631 | Gives all externally visible functions in the file being compiled an ARM |
22632 | instruction set header which switches to Thumb mode before executing the | |
22633 | rest of the function. This allows these functions to be called from | |
22634 | non-interworking code. This option is not valid in AAPCS configurations | |
22635 | because interworking is enabled by default. | |
22636 | ||
d77de738 | 22637 | @opindex mcaller-super-interworking |
ddf6fe37 | 22638 | @item -mcaller-super-interworking |
d77de738 ML |
22639 | Allows calls via function pointers (including virtual functions) to |
22640 | execute correctly regardless of whether the target code has been | |
22641 | compiled for interworking or not. There is a small overhead in the cost | |
22642 | of executing a function pointer if this option is enabled. This option | |
22643 | is not valid in AAPCS configurations because interworking is enabled | |
22644 | by default. | |
22645 | ||
d77de738 | 22646 | @opindex mtp |
ddf6fe37 | 22647 | @item -mtp=@var{name} |
d77de738 ML |
22648 | Specify the access model for the thread local storage pointer. The valid |
22649 | models are @samp{soft}, which generates calls to @code{__aeabi_read_tp}, | |
22650 | @samp{cp15}, which fetches the thread pointer from @code{cp15} directly | |
22651 | (supported in the arm6k architecture), and @samp{auto}, which uses the | |
22652 | best available method for the selected processor. The default setting is | |
22653 | @samp{auto}. | |
22654 | ||
d77de738 | 22655 | @opindex mtls-dialect |
ddf6fe37 | 22656 | @item -mtls-dialect=@var{dialect} |
d77de738 ML |
22657 | Specify the dialect to use for accessing thread local storage. Two |
22658 | @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The | |
22659 | @samp{gnu} dialect selects the original GNU scheme for supporting | |
22660 | local and global dynamic TLS models. The @samp{gnu2} dialect | |
22661 | selects the GNU descriptor scheme, which provides better performance | |
22662 | for shared libraries. The GNU descriptor scheme is compatible with | |
22663 | the original scheme, but does require new assembler, linker and | |
22664 | library support. Initial and local exec TLS models are unaffected by | |
22665 | this option and always use the original scheme. | |
22666 | ||
d77de738 | 22667 | @opindex mword-relocations |
ddf6fe37 | 22668 | @item -mword-relocations |
d77de738 ML |
22669 | Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32). |
22670 | This is enabled by default on targets (uClinux, SymbianOS) where the runtime | |
22671 | loader imposes this restriction, and when @option{-fpic} or @option{-fPIC} | |
22672 | is specified. This option conflicts with @option{-mslow-flash-data}. | |
22673 | ||
d77de738 | 22674 | @opindex mfix-cortex-m3-ldrd |
ddf6fe37 | 22675 | @item -mfix-cortex-m3-ldrd |
d77de738 ML |
22676 | Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions |
22677 | with overlapping destination and base registers are used. This option avoids | |
22678 | generating these instructions. This option is enabled by default when | |
22679 | @option{-mcpu=cortex-m3} is specified. | |
22680 | ||
22681 | @item -mfix-cortex-a57-aes-1742098 | |
22682 | @itemx -mno-fix-cortex-a57-aes-1742098 | |
22683 | @itemx -mfix-cortex-a72-aes-1655431 | |
22684 | @itemx -mno-fix-cortex-a72-aes-1655431 | |
22685 | Enable (disable) mitigation for an erratum on Cortex-A57 and | |
22686 | Cortex-A72 that affects the AES cryptographic instructions. This | |
22687 | option is enabled by default when either @option{-mcpu=cortex-a57} or | |
22688 | @option{-mcpu=cortex-a72} is specified. | |
22689 | ||
d77de738 ML |
22690 | @opindex munaligned-access |
22691 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
22692 | @item -munaligned-access |
22693 | @itemx -mno-unaligned-access | |
d77de738 ML |
22694 | Enables (or disables) reading and writing of 16- and 32- bit values |
22695 | from addresses that are not 16- or 32- bit aligned. By default | |
22696 | unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for | |
22697 | ARMv8-M Baseline architectures, and enabled for all other | |
22698 | architectures. If unaligned access is not enabled then words in packed | |
22699 | data structures are accessed a byte at a time. | |
22700 | ||
22701 | The ARM attribute @code{Tag_CPU_unaligned_access} is set in the | |
22702 | generated object file to either true or false, depending upon the | |
22703 | setting of this option. If unaligned access is enabled then the | |
22704 | preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also | |
22705 | defined. | |
22706 | ||
d77de738 | 22707 | @opindex mneon-for-64bits |
ddf6fe37 | 22708 | @item -mneon-for-64bits |
d77de738 ML |
22709 | This option is deprecated and has no effect. |
22710 | ||
d77de738 | 22711 | @opindex mslow-flash-data |
ddf6fe37 | 22712 | @item -mslow-flash-data |
d77de738 ML |
22713 | Assume loading data from flash is slower than fetching instruction. |
22714 | Therefore literal load is minimized for better performance. | |
22715 | This option is only supported when compiling for ARMv7 M-profile and | |
22716 | off by default. It conflicts with @option{-mword-relocations}. | |
22717 | ||
d77de738 | 22718 | @opindex masm-syntax-unified |
ddf6fe37 | 22719 | @item -masm-syntax-unified |
d77de738 ML |
22720 | Assume inline assembler is using unified asm syntax. The default is |
22721 | currently off which implies divided syntax. This option has no impact | |
22722 | on Thumb2. However, this may change in future releases of GCC. | |
22723 | Divided syntax should be considered deprecated. | |
22724 | ||
d77de738 | 22725 | @opindex mrestrict-it |
ddf6fe37 | 22726 | @item -mrestrict-it |
d77de738 ML |
22727 | Restricts generation of IT blocks to conform to the rules of ARMv8-A. |
22728 | IT blocks can only contain a single 16-bit instruction from a select | |
22729 | set of instructions. This option is on by default for ARMv8-A Thumb mode. | |
22730 | ||
d77de738 | 22731 | @opindex mprint-tune-info |
ddf6fe37 | 22732 | @item -mprint-tune-info |
d77de738 ML |
22733 | Print CPU tuning information as comment in assembler file. This is |
22734 | an option used only for regression testing of the compiler and not | |
22735 | intended for ordinary use in compiling code. This option is disabled | |
22736 | by default. | |
22737 | ||
d77de738 | 22738 | @opindex mverbose-cost-dump |
ddf6fe37 | 22739 | @item -mverbose-cost-dump |
d77de738 ML |
22740 | Enable verbose cost model dumping in the debug dump files. This option is |
22741 | provided for use in debugging the compiler. | |
22742 | ||
d77de738 | 22743 | @opindex mpure-code |
ddf6fe37 | 22744 | @item -mpure-code |
d77de738 ML |
22745 | Do not allow constant data to be placed in code sections. |
22746 | Additionally, when compiling for ELF object format give all text sections the | |
22747 | ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option | |
22748 | is only available when generating non-pic code for M-profile targets. | |
22749 | ||
d77de738 | 22750 | @opindex mcmse |
ddf6fe37 | 22751 | @item -mcmse |
d77de738 ML |
22752 | Generate secure code as per the "ARMv8-M Security Extensions: Requirements on |
22753 | Development Tools Engineering Specification", which can be found on | |
22754 | @url{https://developer.arm.com/documentation/ecm0359818/latest/}. | |
22755 | ||
d77de738 | 22756 | @opindex mfix-cmse-cve-2021-35465 |
ddf6fe37 | 22757 | @item -mfix-cmse-cve-2021-35465 |
d77de738 ML |
22758 | Mitigate against a potential security issue with the @code{VLLDM} instruction |
22759 | in some M-profile devices when using CMSE (CVE-2021-365465). This option is | |
22760 | enabled by default when the option @option{-mcpu=} is used with | |
ccfd1e7f SP |
22761 | @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85} |
22762 | or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used | |
22763 | to disable the mitigation. | |
d77de738 | 22764 | |
d77de738 ML |
22765 | @opindex mstack-protector-guard |
22766 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
22767 | @item -mstack-protector-guard=@var{guard} |
22768 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
22769 | Generate stack protection code using canary at @var{guard}. Supported |
22770 | locations are @samp{global} for a global canary or @samp{tls} for a | |
22771 | canary accessible via the TLS register. The option | |
22772 | @option{-mstack-protector-guard-offset=} is for use with | |
22773 | @option{-fstack-protector-guard=tls} and not for use in user-land code. | |
22774 | ||
d77de738 ML |
22775 | @opindex mfdpic |
22776 | @opindex mno-fdpic | |
ddf6fe37 AA |
22777 | @item -mfdpic |
22778 | @itemx -mno-fdpic | |
d77de738 ML |
22779 | Select the FDPIC ABI, which uses 64-bit function descriptors to |
22780 | represent pointers to functions. When the compiler is configured for | |
22781 | @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default | |
22782 | and implies @option{-fPIE} if none of the PIC/PIE-related options is | |
22783 | provided. On other targets, it only enables the FDPIC-specific code | |
22784 | generation features, and the user should explicitly provide the | |
22785 | PIC/PIE-related options as needed. | |
22786 | ||
22787 | Note that static linking is not supported because it would still | |
22788 | involve the dynamic linker when the program self-relocates. If such | |
22789 | behavior is acceptable, use -static and -Wl,-dynamic-linker options. | |
22790 | ||
22791 | The opposite @option{-mno-fdpic} option is useful (and required) to | |
22792 | build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) | |
22793 | toolchain as the one used to build the userland programs. | |
22794 | ||
14fab5fb | 22795 | @opindex mbranch-protection |
ddf6fe37 | 22796 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] |
14fab5fb AC |
22797 | Enable branch protection features (armv8.1-m.main only). |
22798 | @samp{none} generate code without branch protection or return address | |
22799 | signing. | |
22800 | @samp{standard[+@var{leaf}]} generate code with all branch protection | |
22801 | features enabled at their standard level. | |
22802 | @samp{pac-ret[+@var{leaf}]} generate code with return address signing | |
22803 | set to its standard level, which is to sign all functions that save | |
22804 | the return address to memory. | |
22805 | @samp{leaf} When return address signing is enabled, also sign leaf | |
22806 | functions even if they do not write the return address to memory. | |
22807 | +@samp{bti} Add landing-pad instructions at the permitted targets of | |
22808 | indirect branch instructions. | |
22809 | ||
22810 | If the @samp{+pacbti} architecture extension is not enabled, then all | |
22811 | branch protection and return address signing operations are | |
22812 | constrained to use only the instructions defined in the | |
22813 | architectural-NOP space. The generated code will remain | |
22814 | backwards-compatible with earlier versions of the architecture, but | |
22815 | the additional security can be enabled at run time on processors that | |
22816 | support the @samp{PACBTI} extension. | |
22817 | ||
22818 | Branch target enforcement using BTI can only be enabled at runtime if | |
22819 | all code in the application has been compiled with at least | |
22820 | @samp{-mbranch-protection=bti}. | |
22821 | ||
22822 | Any setting other than @samp{none} is supported only on armv8-m.main | |
22823 | or later. | |
22824 | ||
22825 | The default is to generate code without branch protection or return | |
22826 | address signing. | |
22827 | ||
d77de738 ML |
22828 | @end table |
22829 | ||
22830 | @node AVR Options | |
22831 | @subsection AVR Options | |
22832 | @cindex AVR Options | |
22833 | ||
22834 | These options are defined for AVR implementations: | |
22835 | ||
22836 | @table @gcctabopt | |
d77de738 | 22837 | @opindex mmcu |
ddf6fe37 | 22838 | @item -mmcu=@var{mcu} |
d77de738 ML |
22839 | Specify Atmel AVR instruction set architectures (ISA) or MCU type. |
22840 | ||
22841 | The default for this option is@tie{}@samp{avr2}. | |
22842 | ||
22843 | GCC supports the following AVR devices and ISAs: | |
22844 | ||
22845 | @include avr-mmcu.texi | |
22846 | ||
d77de738 | 22847 | @opindex mabsdata |
ddf6fe37 | 22848 | @item -mabsdata |
d77de738 ML |
22849 | |
22850 | Assume that all data in static storage can be accessed by LDS / STS | |
22851 | instructions. This option has only an effect on reduced Tiny devices like | |
22852 | ATtiny40. See also the @code{absdata} | |
22853 | @ref{AVR Variable Attributes,variable attribute}. | |
22854 | ||
d77de738 | 22855 | @opindex maccumulate-args |
ddf6fe37 | 22856 | @item -maccumulate-args |
d77de738 ML |
22857 | Accumulate outgoing function arguments and acquire/release the needed |
22858 | stack space for outgoing function arguments once in function | |
22859 | prologue/epilogue. Without this option, outgoing arguments are pushed | |
22860 | before calling a function and popped afterwards. | |
22861 | ||
22862 | Popping the arguments after the function call can be expensive on | |
22863 | AVR so that accumulating the stack space might lead to smaller | |
22864 | executables because arguments need not be removed from the | |
22865 | stack after such a function call. | |
22866 | ||
22867 | This option can lead to reduced code size for functions that perform | |
22868 | several calls to functions that get their arguments on the stack like | |
22869 | calls to printf-like functions. | |
22870 | ||
d77de738 | 22871 | @opindex mbranch-cost |
ddf6fe37 | 22872 | @item -mbranch-cost=@var{cost} |
d77de738 ML |
22873 | Set the branch costs for conditional branch instructions to |
22874 | @var{cost}. Reasonable values for @var{cost} are small, non-negative | |
22875 | integers. The default branch cost is 0. | |
22876 | ||
d77de738 | 22877 | @opindex mcall-prologues |
ddf6fe37 | 22878 | @item -mcall-prologues |
d77de738 ML |
22879 | Functions prologues/epilogues are expanded as calls to appropriate |
22880 | subroutines. Code size is smaller. | |
22881 | ||
d77de738 ML |
22882 | @opindex mdouble |
22883 | @opindex mlong-double | |
ddf6fe37 AA |
22884 | @item -mdouble=@var{bits} |
22885 | @itemx -mlong-double=@var{bits} | |
d77de738 ML |
22886 | Set the size (in bits) of the @code{double} or @code{long double} type, |
22887 | respectively. Possible values for @var{bits} are 32 and 64. | |
22888 | Whether or not a specific value for @var{bits} is allowed depends on | |
22889 | the @code{--with-double=} and @code{--with-long-double=} | |
22890 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}}, | |
22891 | and the same applies for the default values of the options. | |
22892 | ||
d77de738 | 22893 | @opindex mgas-isr-prologues |
ddf6fe37 | 22894 | @item -mgas-isr-prologues |
d77de738 ML |
22895 | Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo |
22896 | instruction supported by GNU Binutils. | |
22897 | If this option is on, the feature can still be disabled for individual | |
22898 | ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}} | |
22899 | function attribute. This feature is activated per default | |
22900 | if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}), | |
22901 | and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}. | |
22902 | ||
d77de738 | 22903 | @opindex mint8 |
ddf6fe37 | 22904 | @item -mint8 |
d77de738 ML |
22905 | Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a |
22906 | @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes, | |
22907 | and @code{long long} is 4 bytes. Please note that this option does not | |
22908 | conform to the C standards, but it results in smaller code | |
22909 | size. | |
22910 | ||
d77de738 | 22911 | @opindex mmain-is-OS_task |
ddf6fe37 | 22912 | @item -mmain-is-OS_task |
d77de738 ML |
22913 | Do not save registers in @code{main}. The effect is the same like |
22914 | attaching attribute @ref{AVR Function Attributes,,@code{OS_task}} | |
22915 | to @code{main}. It is activated per default if optimization is on. | |
22916 | ||
d77de738 | 22917 | @opindex mn-flash |
ddf6fe37 | 22918 | @item -mn-flash=@var{num} |
d77de738 ML |
22919 | Assume that the flash memory has a size of |
22920 | @var{num} times 64@tie{}KiB. | |
22921 | ||
d77de738 | 22922 | @opindex mno-interrupts |
ddf6fe37 | 22923 | @item -mno-interrupts |
d77de738 ML |
22924 | Generated code is not compatible with hardware interrupts. |
22925 | Code size is smaller. | |
22926 | ||
d77de738 | 22927 | @opindex mrelax |
ddf6fe37 | 22928 | @item -mrelax |
d77de738 ML |
22929 | Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter |
22930 | @code{RCALL} resp.@: @code{RJMP} instruction if applicable. | |
22931 | Setting @option{-mrelax} just adds the @option{--mlink-relax} option to | |
22932 | the assembler's command line and the @option{--relax} option to the | |
22933 | linker's command line. | |
22934 | ||
22935 | Jump relaxing is performed by the linker because jump offsets are not | |
22936 | known before code is located. Therefore, the assembler code generated by the | |
22937 | compiler is the same, but the instructions in the executable may | |
22938 | differ from instructions in the assembler code. | |
22939 | ||
22940 | Relaxing must be turned on if linker stubs are needed, see the | |
22941 | section on @code{EIND} and linker stubs below. | |
22942 | ||
d77de738 | 22943 | @opindex mrmw |
ddf6fe37 | 22944 | @item -mrmw |
d77de738 ML |
22945 | Assume that the device supports the Read-Modify-Write |
22946 | instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}. | |
22947 | ||
d77de738 | 22948 | @opindex mshort-calls |
ddf6fe37 | 22949 | @item -mshort-calls |
d77de738 ML |
22950 | |
22951 | Assume that @code{RJMP} and @code{RCALL} can target the whole | |
22952 | program memory. | |
22953 | ||
22954 | This option is used internally for multilib selection. It is | |
22955 | not an optimization option, and you don't need to set it by hand. | |
22956 | ||
d77de738 | 22957 | @opindex msp8 |
ddf6fe37 | 22958 | @item -msp8 |
d77de738 ML |
22959 | Treat the stack pointer register as an 8-bit register, |
22960 | i.e.@: assume the high byte of the stack pointer is zero. | |
22961 | In general, you don't need to set this option by hand. | |
22962 | ||
22963 | This option is used internally by the compiler to select and | |
22964 | build multilibs for architectures @code{avr2} and @code{avr25}. | |
22965 | These architectures mix devices with and without @code{SPH}. | |
22966 | For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25} | |
22967 | the compiler driver adds or removes this option from the compiler | |
22968 | proper's command line, because the compiler then knows if the device | |
22969 | or architecture has an 8-bit stack pointer and thus no @code{SPH} | |
22970 | register or not. | |
22971 | ||
d77de738 | 22972 | @opindex mstrict-X |
ddf6fe37 | 22973 | @item -mstrict-X |
d77de738 ML |
22974 | Use address register @code{X} in a way proposed by the hardware. This means |
22975 | that @code{X} is only used in indirect, post-increment or | |
22976 | pre-decrement addressing. | |
22977 | ||
22978 | Without this option, the @code{X} register may be used in the same way | |
22979 | as @code{Y} or @code{Z} which then is emulated by additional | |
22980 | instructions. | |
22981 | For example, loading a value with @code{X+const} addressing with a | |
22982 | small non-negative @code{const < 64} to a register @var{Rn} is | |
22983 | performed as | |
22984 | ||
22985 | @example | |
22986 | adiw r26, const ; X += const | |
22987 | ld @var{Rn}, X ; @var{Rn} = *X | |
22988 | sbiw r26, const ; X -= const | |
22989 | @end example | |
22990 | ||
d77de738 | 22991 | @opindex mtiny-stack |
ddf6fe37 | 22992 | @item -mtiny-stack |
d77de738 ML |
22993 | Only change the lower 8@tie{}bits of the stack pointer. |
22994 | ||
d77de738 | 22995 | @opindex mfract-convert-truncate |
ddf6fe37 | 22996 | @item -mfract-convert-truncate |
d77de738 ML |
22997 | Allow to use truncation instead of rounding towards zero for fractional fixed-point types. |
22998 | ||
d77de738 | 22999 | @opindex nodevicelib |
ddf6fe37 | 23000 | @item -nodevicelib |
d77de738 ML |
23001 | Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}. |
23002 | ||
d77de738 | 23003 | @opindex nodevicespecs |
ddf6fe37 | 23004 | @item -nodevicespecs |
d77de738 ML |
23005 | Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's |
23006 | command line. The user takes responsibility for supplying the sub-processes | |
23007 | like compiler proper, assembler and linker with appropriate command line | |
23008 | options. This means that the user has to supply her private device specs | |
23009 | file by means of @option{-specs=@var{path-to-specs-file}}. There is no | |
23010 | more need for option @option{-mmcu=@var{mcu}}. | |
23011 | ||
23012 | This option can also serve as a replacement for the older way of | |
23013 | specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory | |
23014 | which contains a folder named @code{device-specs} which contains a specs file named | |
23015 | @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}. | |
23016 | ||
d77de738 ML |
23017 | @opindex Waddr-space-convert |
23018 | @opindex Wno-addr-space-convert | |
ddf6fe37 | 23019 | @item -Waddr-space-convert |
d77de738 ML |
23020 | Warn about conversions between address spaces in the case where the |
23021 | resulting address space is not contained in the incoming address space. | |
23022 | ||
d77de738 ML |
23023 | @opindex Wmisspelled-isr |
23024 | @opindex Wno-misspelled-isr | |
ddf6fe37 | 23025 | @item -Wmisspelled-isr |
d77de738 ML |
23026 | Warn if the ISR is misspelled, i.e.@: without __vector prefix. |
23027 | Enabled by default. | |
23028 | @end table | |
23029 | ||
23030 | @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash | |
23031 | @cindex @code{EIND} | |
23032 | Pointers in the implementation are 16@tie{}bits wide. | |
23033 | The address of a function or label is represented as word address so | |
23034 | that indirect jumps and calls can target any code address in the | |
23035 | range of 64@tie{}Ki words. | |
23036 | ||
23037 | In order to facilitate indirect jump on devices with more than 128@tie{}Ki | |
23038 | bytes of program memory space, there is a special function register called | |
23039 | @code{EIND} that serves as most significant part of the target address | |
23040 | when @code{EICALL} or @code{EIJMP} instructions are used. | |
23041 | ||
23042 | Indirect jumps and calls on these devices are handled as follows by | |
23043 | the compiler and are subject to some limitations: | |
23044 | ||
23045 | @itemize @bullet | |
23046 | ||
23047 | @item | |
23048 | The compiler never sets @code{EIND}. | |
23049 | ||
23050 | @item | |
23051 | The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP} | |
23052 | instructions or might read @code{EIND} directly in order to emulate an | |
23053 | indirect call/jump by means of a @code{RET} instruction. | |
23054 | ||
23055 | @item | |
23056 | The compiler assumes that @code{EIND} never changes during the startup | |
23057 | code or during the application. In particular, @code{EIND} is not | |
23058 | saved/restored in function or interrupt service routine | |
23059 | prologue/epilogue. | |
23060 | ||
23061 | @item | |
23062 | For indirect calls to functions and computed goto, the linker | |
23063 | generates @emph{stubs}. Stubs are jump pads sometimes also called | |
23064 | @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub. | |
23065 | The stub contains a direct jump to the desired address. | |
23066 | ||
23067 | @item | |
23068 | Linker relaxation must be turned on so that the linker generates | |
23069 | the stubs correctly in all situations. See the compiler option | |
23070 | @option{-mrelax} and the linker option @option{--relax}. | |
23071 | There are corner cases where the linker is supposed to generate stubs | |
23072 | but aborts without relaxation and without a helpful error message. | |
23073 | ||
23074 | @item | |
23075 | The default linker script is arranged for code with @code{EIND = 0}. | |
23076 | If code is supposed to work for a setup with @code{EIND != 0}, a custom | |
23077 | linker script has to be used in order to place the sections whose | |
23078 | name start with @code{.trampolines} into the segment where @code{EIND} | |
23079 | points to. | |
23080 | ||
23081 | @item | |
23082 | The startup code from libgcc never sets @code{EIND}. | |
23083 | Notice that startup code is a blend of code from libgcc and AVR-LibC. | |
23084 | For the impact of AVR-LibC on @code{EIND}, see the | |
a65da9be | 23085 | @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}. |
d77de738 ML |
23086 | |
23087 | @item | |
23088 | It is legitimate for user-specific startup code to set up @code{EIND} | |
23089 | early, for example by means of initialization code located in | |
23090 | section @code{.init3}. Such code runs prior to general startup code | |
23091 | that initializes RAM and calls constructors, but after the bit | |
23092 | of startup code from AVR-LibC that sets @code{EIND} to the segment | |
23093 | where the vector table is located. | |
23094 | @example | |
23095 | #include <avr/io.h> | |
23096 | ||
23097 | static void | |
23098 | __attribute__((section(".init3"),naked,used,no_instrument_function)) | |
23099 | init3_set_eind (void) | |
23100 | @{ | |
23101 | __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t" | |
23102 | "out %i0,r24" :: "n" (&EIND) : "r24","memory"); | |
23103 | @} | |
23104 | @end example | |
23105 | ||
23106 | @noindent | |
23107 | The @code{__trampolines_start} symbol is defined in the linker script. | |
23108 | ||
23109 | @item | |
23110 | Stubs are generated automatically by the linker if | |
23111 | the following two conditions are met: | |
23112 | @itemize @minus | |
23113 | ||
23114 | @item The address of a label is taken by means of the @code{gs} modifier | |
23115 | (short for @emph{generate stubs}) like so: | |
23116 | @example | |
23117 | LDI r24, lo8(gs(@var{func})) | |
23118 | LDI r25, hi8(gs(@var{func})) | |
23119 | @end example | |
23120 | @item The final location of that label is in a code segment | |
23121 | @emph{outside} the segment where the stubs are located. | |
23122 | @end itemize | |
23123 | ||
23124 | @item | |
23125 | The compiler emits such @code{gs} modifiers for code labels in the | |
23126 | following situations: | |
23127 | @itemize @minus | |
23128 | @item Taking address of a function or code label. | |
23129 | @item Computed goto. | |
23130 | @item If prologue-save function is used, see @option{-mcall-prologues} | |
23131 | command-line option. | |
23132 | @item Switch/case dispatch tables. If you do not want such dispatch | |
23133 | tables you can specify the @option{-fno-jump-tables} command-line option. | |
23134 | @item C and C++ constructors/destructors called during startup/shutdown. | |
23135 | @item If the tools hit a @code{gs()} modifier explained above. | |
23136 | @end itemize | |
23137 | ||
23138 | @item | |
23139 | Jumping to non-symbolic addresses like so is @emph{not} supported: | |
23140 | ||
23141 | @example | |
23142 | int main (void) | |
23143 | @{ | |
23144 | /* Call function at word address 0x2 */ | |
23145 | return ((int(*)(void)) 0x2)(); | |
23146 | @} | |
23147 | @end example | |
23148 | ||
23149 | Instead, a stub has to be set up, i.e.@: the function has to be called | |
23150 | through a symbol (@code{func_4} in the example): | |
23151 | ||
23152 | @example | |
23153 | int main (void) | |
23154 | @{ | |
23155 | extern int func_4 (void); | |
23156 | ||
23157 | /* Call function at byte address 0x4 */ | |
23158 | return func_4(); | |
23159 | @} | |
23160 | @end example | |
23161 | ||
23162 | and the application be linked with @option{-Wl,--defsym,func_4=0x4}. | |
23163 | Alternatively, @code{func_4} can be defined in the linker script. | |
23164 | @end itemize | |
23165 | ||
23166 | @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers | |
23167 | @cindex @code{RAMPD} | |
23168 | @cindex @code{RAMPX} | |
23169 | @cindex @code{RAMPY} | |
23170 | @cindex @code{RAMPZ} | |
23171 | Some AVR devices support memories larger than the 64@tie{}KiB range | |
23172 | that can be accessed with 16-bit pointers. To access memory locations | |
23173 | outside this 64@tie{}KiB range, the content of a @code{RAMP} | |
23174 | register is used as high part of the address: | |
23175 | The @code{X}, @code{Y}, @code{Z} address register is concatenated | |
23176 | with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function | |
23177 | register, respectively, to get a wide address. Similarly, | |
23178 | @code{RAMPD} is used together with direct addressing. | |
23179 | ||
23180 | @itemize | |
23181 | @item | |
23182 | The startup code initializes the @code{RAMP} special function | |
23183 | registers with zero. | |
23184 | ||
23185 | @item | |
23186 | If a @ref{AVR Named Address Spaces,named address space} other than | |
23187 | generic or @code{__flash} is used, then @code{RAMPZ} is set | |
23188 | as needed before the operation. | |
23189 | ||
23190 | @item | |
23191 | If the device supports RAM larger than 64@tie{}KiB and the compiler | |
23192 | needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ} | |
23193 | is reset to zero after the operation. | |
23194 | ||
23195 | @item | |
23196 | If the device comes with a specific @code{RAMP} register, the ISR | |
23197 | prologue/epilogue saves/restores that SFR and initializes it with | |
23198 | zero in case the ISR code might (implicitly) use it. | |
23199 | ||
23200 | @item | |
23201 | RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets. | |
23202 | If you use inline assembler to read from locations outside the | |
23203 | 16-bit address range and change one of the @code{RAMP} registers, | |
23204 | you must reset it to zero after the access. | |
23205 | ||
23206 | @end itemize | |
23207 | ||
23208 | @subsubsection AVR Built-in Macros | |
23209 | ||
23210 | GCC defines several built-in macros so that the user code can test | |
23211 | for the presence or absence of features. Almost any of the following | |
23212 | built-in macros are deduced from device capabilities and thus | |
23213 | triggered by the @option{-mmcu=} command-line option. | |
23214 | ||
23215 | For even more AVR-specific built-in macros see | |
23216 | @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}. | |
23217 | ||
23218 | @table @code | |
23219 | ||
23220 | @item __AVR_ARCH__ | |
23221 | Build-in macro that resolves to a decimal number that identifies the | |
23222 | architecture and depends on the @option{-mmcu=@var{mcu}} option. | |
23223 | Possible values are: | |
23224 | ||
23225 | @code{2}, @code{25}, @code{3}, @code{31}, @code{35}, | |
23226 | @code{4}, @code{5}, @code{51}, @code{6} | |
23227 | ||
23228 | for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31}, | |
23229 | @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6}, | |
23230 | ||
23231 | respectively and | |
23232 | ||
23233 | @code{100}, | |
23234 | @code{102}, @code{103}, @code{104}, | |
23235 | @code{105}, @code{106}, @code{107} | |
23236 | ||
23237 | for @var{mcu}=@code{avrtiny}, | |
23238 | @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4}, | |
23239 | @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively. | |
23240 | If @var{mcu} specifies a device, this built-in macro is set | |
23241 | accordingly. For example, with @option{-mmcu=atmega8} the macro is | |
23242 | defined to @code{4}. | |
23243 | ||
23244 | @item __AVR_@var{Device}__ | |
23245 | Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects | |
23246 | the device's name. For example, @option{-mmcu=atmega8} defines the | |
23247 | built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines | |
23248 | @code{__AVR_ATtiny261A__}, etc. | |
23249 | ||
23250 | The built-in macros' names follow | |
23251 | the scheme @code{__AVR_@var{Device}__} where @var{Device} is | |
23252 | the device name as from the AVR user manual. The difference between | |
23253 | @var{Device} in the built-in macro and @var{device} in | |
23254 | @option{-mmcu=@var{device}} is that the latter is always lowercase. | |
23255 | ||
23256 | If @var{device} is not a device but only a core architecture like | |
23257 | @samp{avr51}, this macro is not defined. | |
23258 | ||
23259 | @item __AVR_DEVICE_NAME__ | |
23260 | Setting @option{-mmcu=@var{device}} defines this built-in macro to | |
23261 | the device's name. For example, with @option{-mmcu=atmega8} the macro | |
23262 | is defined to @code{atmega8}. | |
23263 | ||
23264 | If @var{device} is not a device but only a core architecture like | |
23265 | @samp{avr51}, this macro is not defined. | |
23266 | ||
23267 | @item __AVR_XMEGA__ | |
23268 | The device / architecture belongs to the XMEGA family of devices. | |
23269 | ||
23270 | @item __AVR_HAVE_ELPM__ | |
23271 | The device has the @code{ELPM} instruction. | |
23272 | ||
23273 | @item __AVR_HAVE_ELPMX__ | |
23274 | The device has the @code{ELPM R@var{n},Z} and @code{ELPM | |
23275 | R@var{n},Z+} instructions. | |
23276 | ||
23277 | @item __AVR_HAVE_MOVW__ | |
23278 | The device has the @code{MOVW} instruction to perform 16-bit | |
23279 | register-register moves. | |
23280 | ||
23281 | @item __AVR_HAVE_LPMX__ | |
23282 | The device has the @code{LPM R@var{n},Z} and | |
23283 | @code{LPM R@var{n},Z+} instructions. | |
23284 | ||
23285 | @item __AVR_HAVE_MUL__ | |
23286 | The device has a hardware multiplier. | |
23287 | ||
23288 | @item __AVR_HAVE_JMP_CALL__ | |
23289 | The device has the @code{JMP} and @code{CALL} instructions. | |
23290 | This is the case for devices with more than 8@tie{}KiB of program | |
23291 | memory. | |
23292 | ||
23293 | @item __AVR_HAVE_EIJMP_EICALL__ | |
23294 | @itemx __AVR_3_BYTE_PC__ | |
23295 | The device has the @code{EIJMP} and @code{EICALL} instructions. | |
23296 | This is the case for devices with more than 128@tie{}KiB of program memory. | |
23297 | This also means that the program counter | |
23298 | (PC) is 3@tie{}bytes wide. | |
23299 | ||
23300 | @item __AVR_2_BYTE_PC__ | |
23301 | The program counter (PC) is 2@tie{}bytes wide. This is the case for devices | |
23302 | with up to 128@tie{}KiB of program memory. | |
23303 | ||
23304 | @item __AVR_HAVE_8BIT_SP__ | |
23305 | @itemx __AVR_HAVE_16BIT_SP__ | |
23306 | The stack pointer (SP) register is treated as 8-bit respectively | |
23307 | 16-bit register by the compiler. | |
23308 | The definition of these macros is affected by @option{-mtiny-stack}. | |
23309 | ||
23310 | @item __AVR_HAVE_SPH__ | |
23311 | @itemx __AVR_SP8__ | |
23312 | The device has the SPH (high part of stack pointer) special function | |
23313 | register or has an 8-bit stack pointer, respectively. | |
23314 | The definition of these macros is affected by @option{-mmcu=} and | |
23315 | in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also | |
23316 | by @option{-msp8}. | |
23317 | ||
23318 | @item __AVR_HAVE_RAMPD__ | |
23319 | @itemx __AVR_HAVE_RAMPX__ | |
23320 | @itemx __AVR_HAVE_RAMPY__ | |
23321 | @itemx __AVR_HAVE_RAMPZ__ | |
23322 | The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY}, | |
23323 | @code{RAMPZ} special function register, respectively. | |
23324 | ||
23325 | @item __NO_INTERRUPTS__ | |
23326 | This macro reflects the @option{-mno-interrupts} command-line option. | |
23327 | ||
23328 | @item __AVR_ERRATA_SKIP__ | |
23329 | @itemx __AVR_ERRATA_SKIP_JMP_CALL__ | |
23330 | Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit | |
23331 | instructions because of a hardware erratum. Skip instructions are | |
23332 | @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}. | |
23333 | The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also | |
23334 | set. | |
23335 | ||
23336 | @item __AVR_ISA_RMW__ | |
23337 | The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT). | |
23338 | ||
23339 | @item __AVR_SFR_OFFSET__=@var{offset} | |
23340 | Instructions that can address I/O special function registers directly | |
23341 | like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different | |
23342 | address as if addressed by an instruction to access RAM like @code{LD} | |
23343 | or @code{STS}. This offset depends on the device architecture and has | |
23344 | to be subtracted from the RAM address in order to get the | |
23345 | respective I/O@tie{}address. | |
23346 | ||
23347 | @item __AVR_SHORT_CALLS__ | |
23348 | The @option{-mshort-calls} command line option is set. | |
23349 | ||
23350 | @item __AVR_PM_BASE_ADDRESS__=@var{addr} | |
23351 | Some devices support reading from flash memory by means of @code{LD*} | |
23352 | instructions. The flash memory is seen in the data address space | |
23353 | at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro | |
23354 | is not defined, this feature is not available. If defined, | |
23355 | the address space is linear and there is no need to put | |
23356 | @code{.rodata} into RAM. This is handled by the default linker | |
23357 | description file, and is currently available for | |
23358 | @code{avrtiny} and @code{avrxmega3}. Even more convenient, | |
23359 | there is no need to use address spaces like @code{__flash} or | |
23360 | features like attribute @code{progmem} and @code{pgm_read_*}. | |
23361 | ||
23362 | @item __WITH_AVRLIBC__ | |
23363 | The compiler is configured to be used together with AVR-Libc. | |
23364 | See the @option{--with-avrlibc} configure option. | |
23365 | ||
23366 | @item __HAVE_DOUBLE_MULTILIB__ | |
23367 | Defined if @option{-mdouble=} acts as a multilib option. | |
23368 | ||
23369 | @item __HAVE_DOUBLE32__ | |
23370 | @itemx __HAVE_DOUBLE64__ | |
23371 | Defined if the compiler supports 32-bit double resp. 64-bit double. | |
23372 | The actual layout is specified by option @option{-mdouble=}. | |
23373 | ||
23374 | @item __DEFAULT_DOUBLE__ | |
23375 | The size in bits of @code{double} if @option{-mdouble=} is not set. | |
23376 | To test the layout of @code{double} in a program, use the built-in | |
23377 | macro @code{__SIZEOF_DOUBLE__}. | |
23378 | ||
23379 | @item __HAVE_LONG_DOUBLE32__ | |
23380 | @itemx __HAVE_LONG_DOUBLE64__ | |
23381 | @itemx __HAVE_LONG_DOUBLE_MULTILIB__ | |
23382 | @itemx __DEFAULT_LONG_DOUBLE__ | |
23383 | Same as above, but for @code{long double} instead of @code{double}. | |
23384 | ||
23385 | @item __WITH_DOUBLE_COMPARISON__ | |
23386 | Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}} | |
23387 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}} | |
23388 | and is defined to @code{2} or @code{3}. | |
23389 | ||
23390 | @item __WITH_LIBF7_LIBGCC__ | |
23391 | @itemx __WITH_LIBF7_MATH__ | |
23392 | @itemx __WITH_LIBF7_MATH_SYMBOLS__ | |
23393 | Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}} | |
23394 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}. | |
23395 | ||
23396 | @end table | |
23397 | ||
23398 | @node Blackfin Options | |
23399 | @subsection Blackfin Options | |
23400 | @cindex Blackfin Options | |
23401 | ||
23402 | @table @gcctabopt | |
d77de738 | 23403 | @opindex mcpu= |
ddf6fe37 | 23404 | @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
d77de738 ML |
23405 | Specifies the name of the target Blackfin processor. Currently, @var{cpu} |
23406 | can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518}, | |
23407 | @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526}, | |
23408 | @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533}, | |
23409 | @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539}, | |
23410 | @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549}, | |
23411 | @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m}, | |
23412 | @samp{bf561}, @samp{bf592}. | |
23413 | ||
23414 | The optional @var{sirevision} specifies the silicon revision of the target | |
23415 | Blackfin processor. Any workarounds available for the targeted silicon revision | |
23416 | are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled. | |
23417 | If @var{sirevision} is @samp{any}, all workarounds for the targeted processor | |
23418 | are enabled. The @code{__SILICON_REVISION__} macro is defined to two | |
23419 | hexadecimal digits representing the major and minor numbers in the silicon | |
23420 | revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__} | |
23421 | is not defined. If @var{sirevision} is @samp{any}, the | |
23422 | @code{__SILICON_REVISION__} is defined to be @code{0xffff}. | |
23423 | If this optional @var{sirevision} is not used, GCC assumes the latest known | |
23424 | silicon revision of the targeted Blackfin processor. | |
23425 | ||
23426 | GCC defines a preprocessor macro for the specified @var{cpu}. | |
23427 | For the @samp{bfin-elf} toolchain, this option causes the hardware BSP | |
23428 | provided by libgloss to be linked in if @option{-msim} is not given. | |
23429 | ||
23430 | Without this option, @samp{bf532} is used as the processor by default. | |
23431 | ||
23432 | Note that support for @samp{bf561} is incomplete. For @samp{bf561}, | |
23433 | only the preprocessor macro is defined. | |
23434 | ||
d77de738 | 23435 | @opindex msim |
ddf6fe37 | 23436 | @item -msim |
d77de738 ML |
23437 | Specifies that the program will be run on the simulator. This causes |
23438 | the simulator BSP provided by libgloss to be linked in. This option | |
23439 | has effect only for @samp{bfin-elf} toolchain. | |
23440 | Certain other options, such as @option{-mid-shared-library} and | |
23441 | @option{-mfdpic}, imply @option{-msim}. | |
23442 | ||
d77de738 | 23443 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 23444 | @item -momit-leaf-frame-pointer |
d77de738 ML |
23445 | Don't keep the frame pointer in a register for leaf functions. This |
23446 | avoids the instructions to save, set up and restore frame pointers and | |
23447 | makes an extra register available in leaf functions. | |
23448 | ||
d77de738 | 23449 | @opindex mspecld-anomaly |
ddf6fe37 | 23450 | @item -mspecld-anomaly |
d77de738 ML |
23451 | When enabled, the compiler ensures that the generated code does not |
23452 | contain speculative loads after jump instructions. If this option is used, | |
23453 | @code{__WORKAROUND_SPECULATIVE_LOADS} is defined. | |
23454 | ||
d77de738 ML |
23455 | @opindex mno-specld-anomaly |
23456 | @opindex mspecld-anomaly | |
ddf6fe37 | 23457 | @item -mno-specld-anomaly |
d77de738 ML |
23458 | Don't generate extra code to prevent speculative loads from occurring. |
23459 | ||
d77de738 | 23460 | @opindex mcsync-anomaly |
ddf6fe37 | 23461 | @item -mcsync-anomaly |
d77de738 ML |
23462 | When enabled, the compiler ensures that the generated code does not |
23463 | contain CSYNC or SSYNC instructions too soon after conditional branches. | |
23464 | If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined. | |
23465 | ||
d77de738 ML |
23466 | @opindex mno-csync-anomaly |
23467 | @opindex mcsync-anomaly | |
ddf6fe37 | 23468 | @item -mno-csync-anomaly |
d77de738 ML |
23469 | Don't generate extra code to prevent CSYNC or SSYNC instructions from |
23470 | occurring too soon after a conditional branch. | |
23471 | ||
d77de738 | 23472 | @opindex mlow64k |
ddf6fe37 | 23473 | @item -mlow64k |
d77de738 ML |
23474 | When enabled, the compiler is free to take advantage of the knowledge that |
23475 | the entire program fits into the low 64k of memory. | |
23476 | ||
d77de738 | 23477 | @opindex mno-low64k |
ddf6fe37 | 23478 | @item -mno-low64k |
d77de738 ML |
23479 | Assume that the program is arbitrarily large. This is the default. |
23480 | ||
d77de738 | 23481 | @opindex mstack-check-l1 |
ddf6fe37 | 23482 | @item -mstack-check-l1 |
d77de738 ML |
23483 | Do stack checking using information placed into L1 scratchpad memory by the |
23484 | uClinux kernel. | |
23485 | ||
d77de738 | 23486 | @opindex mid-shared-library |
ddf6fe37 | 23487 | @item -mid-shared-library |
d77de738 ML |
23488 | Generate code that supports shared libraries via the library ID method. |
23489 | This allows for execute in place and shared libraries in an environment | |
23490 | without virtual memory management. This option implies @option{-fPIC}. | |
23491 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
23492 | ||
d77de738 ML |
23493 | @opindex mno-id-shared-library |
23494 | @opindex mid-shared-library | |
ddf6fe37 | 23495 | @item -mno-id-shared-library |
d77de738 ML |
23496 | Generate code that doesn't assume ID-based shared libraries are being used. |
23497 | This is the default. | |
23498 | ||
d77de738 | 23499 | @opindex mleaf-id-shared-library |
ddf6fe37 | 23500 | @item -mleaf-id-shared-library |
d77de738 ML |
23501 | Generate code that supports shared libraries via the library ID method, |
23502 | but assumes that this library or executable won't link against any other | |
23503 | ID shared libraries. That allows the compiler to use faster code for jumps | |
23504 | and calls. | |
23505 | ||
d77de738 ML |
23506 | @opindex mno-leaf-id-shared-library |
23507 | @opindex mleaf-id-shared-library | |
ddf6fe37 | 23508 | @item -mno-leaf-id-shared-library |
d77de738 ML |
23509 | Do not assume that the code being compiled won't link against any ID shared |
23510 | libraries. Slower code is generated for jump and call insns. | |
23511 | ||
d77de738 | 23512 | @opindex mshared-library-id |
ddf6fe37 | 23513 | @item -mshared-library-id=n |
d77de738 ML |
23514 | Specifies the identification number of the ID-based shared library being |
23515 | compiled. Specifying a value of 0 generates more compact code; specifying | |
23516 | other values forces the allocation of that number to the current | |
23517 | library but is no more space- or time-efficient than omitting this option. | |
23518 | ||
d77de738 | 23519 | @opindex msep-data |
ddf6fe37 | 23520 | @item -msep-data |
d77de738 ML |
23521 | Generate code that allows the data segment to be located in a different |
23522 | area of memory from the text segment. This allows for execute in place in | |
23523 | an environment without virtual memory management by eliminating relocations | |
23524 | against the text section. | |
23525 | ||
d77de738 ML |
23526 | @opindex mno-sep-data |
23527 | @opindex msep-data | |
ddf6fe37 | 23528 | @item -mno-sep-data |
d77de738 ML |
23529 | Generate code that assumes that the data segment follows the text segment. |
23530 | This is the default. | |
23531 | ||
d77de738 ML |
23532 | @opindex mlong-calls |
23533 | @opindex mno-long-calls | |
ddf6fe37 AA |
23534 | @item -mlong-calls |
23535 | @itemx -mno-long-calls | |
d77de738 ML |
23536 | Tells the compiler to perform function calls by first loading the |
23537 | address of the function into a register and then performing a subroutine | |
23538 | call on this register. This switch is needed if the target function | |
23539 | lies outside of the 24-bit addressing range of the offset-based | |
23540 | version of subroutine call instruction. | |
23541 | ||
23542 | This feature is not enabled by default. Specifying | |
23543 | @option{-mno-long-calls} restores the default behavior. Note these | |
23544 | switches have no effect on how the compiler generates code to handle | |
23545 | function calls via function pointers. | |
23546 | ||
d77de738 | 23547 | @opindex mfast-fp |
ddf6fe37 | 23548 | @item -mfast-fp |
d77de738 ML |
23549 | Link with the fast floating-point library. This library relaxes some of |
23550 | the IEEE floating-point standard's rules for checking inputs against | |
23551 | Not-a-Number (NAN), in the interest of performance. | |
23552 | ||
d77de738 | 23553 | @opindex minline-plt |
ddf6fe37 | 23554 | @item -minline-plt |
d77de738 ML |
23555 | Enable inlining of PLT entries in function calls to functions that are |
23556 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
23557 | ||
d77de738 | 23558 | @opindex mmulticore |
ddf6fe37 | 23559 | @item -mmulticore |
d77de738 ML |
23560 | Build a standalone application for multicore Blackfin processors. |
23561 | This option causes proper start files and link scripts supporting | |
23562 | multicore to be used, and defines the macro @code{__BFIN_MULTICORE}. | |
23563 | It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}. | |
23564 | ||
23565 | This option can be used with @option{-mcorea} or @option{-mcoreb}, which | |
23566 | selects the one-application-per-core programming model. Without | |
23567 | @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core | |
23568 | programming model is used. In this model, the main function of Core B | |
23569 | should be named as @code{coreb_main}. | |
23570 | ||
23571 | If this option is not used, the single-core application programming | |
23572 | model is used. | |
23573 | ||
d77de738 | 23574 | @opindex mcorea |
ddf6fe37 | 23575 | @item -mcorea |
d77de738 ML |
23576 | Build a standalone application for Core A of BF561 when using |
23577 | the one-application-per-core programming model. Proper start files | |
23578 | and link scripts are used to support Core A, and the macro | |
23579 | @code{__BFIN_COREA} is defined. | |
23580 | This option can only be used in conjunction with @option{-mmulticore}. | |
23581 | ||
d77de738 | 23582 | @opindex mcoreb |
ddf6fe37 | 23583 | @item -mcoreb |
d77de738 ML |
23584 | Build a standalone application for Core B of BF561 when using |
23585 | the one-application-per-core programming model. Proper start files | |
23586 | and link scripts are used to support Core B, and the macro | |
23587 | @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main} | |
23588 | should be used instead of @code{main}. | |
23589 | This option can only be used in conjunction with @option{-mmulticore}. | |
23590 | ||
d77de738 | 23591 | @opindex msdram |
ddf6fe37 | 23592 | @item -msdram |
d77de738 ML |
23593 | Build a standalone application for SDRAM. Proper start files and |
23594 | link scripts are used to put the application into SDRAM, and the macro | |
23595 | @code{__BFIN_SDRAM} is defined. | |
23596 | The loader should initialize SDRAM before loading the application. | |
23597 | ||
d77de738 | 23598 | @opindex micplb |
ddf6fe37 | 23599 | @item -micplb |
d77de738 ML |
23600 | Assume that ICPLBs are enabled at run time. This has an effect on certain |
23601 | anomaly workarounds. For Linux targets, the default is to assume ICPLBs | |
23602 | are enabled; for standalone applications the default is off. | |
23603 | @end table | |
23604 | ||
23605 | @node C6X Options | |
23606 | @subsection C6X Options | |
23607 | @cindex C6X Options | |
23608 | ||
23609 | @table @gcctabopt | |
d77de738 | 23610 | @opindex march |
ddf6fe37 | 23611 | @item -march=@var{name} |
d77de738 ML |
23612 | This specifies the name of the target architecture. GCC uses this |
23613 | name to determine what kind of instructions it can emit when generating | |
23614 | assembly code. Permissible names are: @samp{c62x}, | |
23615 | @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}. | |
23616 | ||
d77de738 | 23617 | @opindex mbig-endian |
ddf6fe37 | 23618 | @item -mbig-endian |
d77de738 ML |
23619 | Generate code for a big-endian target. |
23620 | ||
d77de738 | 23621 | @opindex mlittle-endian |
ddf6fe37 | 23622 | @item -mlittle-endian |
d77de738 ML |
23623 | Generate code for a little-endian target. This is the default. |
23624 | ||
d77de738 | 23625 | @opindex msim |
ddf6fe37 | 23626 | @item -msim |
d77de738 ML |
23627 | Choose startup files and linker script suitable for the simulator. |
23628 | ||
d77de738 | 23629 | @opindex msdata=default |
ddf6fe37 | 23630 | @item -msdata=default |
d77de738 ML |
23631 | Put small global and static data in the @code{.neardata} section, |
23632 | which is pointed to by register @code{B14}. Put small uninitialized | |
23633 | global and static data in the @code{.bss} section, which is adjacent | |
23634 | to the @code{.neardata} section. Put small read-only data into the | |
23635 | @code{.rodata} section. The corresponding sections used for large | |
23636 | pieces of data are @code{.fardata}, @code{.far} and @code{.const}. | |
23637 | ||
d77de738 | 23638 | @opindex msdata=all |
ddf6fe37 | 23639 | @item -msdata=all |
d77de738 ML |
23640 | Put all data, not just small objects, into the sections reserved for |
23641 | small data, and use addressing relative to the @code{B14} register to | |
23642 | access them. | |
23643 | ||
d77de738 | 23644 | @opindex msdata=none |
ddf6fe37 | 23645 | @item -msdata=none |
d77de738 ML |
23646 | Make no use of the sections reserved for small data, and use absolute |
23647 | addresses to access all data. Put all initialized global and static | |
23648 | data in the @code{.fardata} section, and all uninitialized data in the | |
23649 | @code{.far} section. Put all constant data into the @code{.const} | |
23650 | section. | |
23651 | @end table | |
23652 | ||
23653 | @node CRIS Options | |
23654 | @subsection CRIS Options | |
23655 | @cindex CRIS Options | |
23656 | ||
23657 | These options are defined specifically for the CRIS ports. | |
23658 | ||
23659 | @table @gcctabopt | |
d77de738 ML |
23660 | @opindex march |
23661 | @opindex mcpu | |
ddf6fe37 AA |
23662 | @item -march=@var{architecture-type} |
23663 | @itemx -mcpu=@var{architecture-type} | |
d77de738 ML |
23664 | Generate code for the specified architecture. The choices for |
23665 | @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for | |
23666 | respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@. | |
23667 | Default is @samp{v0}. | |
23668 | ||
d77de738 | 23669 | @opindex mtune |
ddf6fe37 | 23670 | @item -mtune=@var{architecture-type} |
d77de738 ML |
23671 | Tune to @var{architecture-type} everything applicable about the generated |
23672 | code, except for the ABI and the set of available instructions. The | |
23673 | choices for @var{architecture-type} are the same as for | |
23674 | @option{-march=@var{architecture-type}}. | |
23675 | ||
d77de738 | 23676 | @opindex mmax-stack-frame |
ddf6fe37 | 23677 | @item -mmax-stack-frame=@var{n} |
d77de738 ML |
23678 | Warn when the stack frame of a function exceeds @var{n} bytes. |
23679 | ||
d77de738 ML |
23680 | @opindex metrax4 |
23681 | @opindex metrax100 | |
ddf6fe37 AA |
23682 | @item -metrax4 |
23683 | @itemx -metrax100 | |
d77de738 ML |
23684 | The options @option{-metrax4} and @option{-metrax100} are synonyms for |
23685 | @option{-march=v3} and @option{-march=v8} respectively. | |
23686 | ||
d77de738 ML |
23687 | @opindex mmul-bug-workaround |
23688 | @opindex mno-mul-bug-workaround | |
ddf6fe37 AA |
23689 | @item -mmul-bug-workaround |
23690 | @itemx -mno-mul-bug-workaround | |
d77de738 ML |
23691 | Work around a bug in the @code{muls} and @code{mulu} instructions for CPU |
23692 | models where it applies. This option is disabled by default. | |
23693 | ||
d77de738 | 23694 | @opindex mpdebug |
ddf6fe37 | 23695 | @item -mpdebug |
d77de738 ML |
23696 | Enable CRIS-specific verbose debug-related information in the assembly |
23697 | code. This option also has the effect of turning off the @samp{#NO_APP} | |
23698 | formatted-code indicator to the assembler at the beginning of the | |
23699 | assembly file. | |
23700 | ||
d77de738 | 23701 | @opindex mcc-init |
ddf6fe37 | 23702 | @item -mcc-init |
d77de738 ML |
23703 | Do not use condition-code results from previous instruction; always emit |
23704 | compare and test instructions before use of condition codes. | |
23705 | ||
d77de738 ML |
23706 | @opindex mno-side-effects |
23707 | @opindex mside-effects | |
ddf6fe37 | 23708 | @item -mno-side-effects |
d77de738 ML |
23709 | Do not emit instructions with side effects in addressing modes other than |
23710 | post-increment. | |
23711 | ||
d77de738 ML |
23712 | @opindex mstack-align |
23713 | @opindex mno-stack-align | |
23714 | @opindex mdata-align | |
23715 | @opindex mno-data-align | |
23716 | @opindex mconst-align | |
23717 | @opindex mno-const-align | |
ddf6fe37 AA |
23718 | @item -mstack-align |
23719 | @itemx -mno-stack-align | |
23720 | @itemx -mdata-align | |
23721 | @itemx -mno-data-align | |
23722 | @itemx -mconst-align | |
23723 | @itemx -mno-const-align | |
d77de738 ML |
23724 | These options (@samp{no-} options) arrange (eliminate arrangements) for the |
23725 | stack frame, individual data and constants to be aligned for the maximum | |
23726 | single data access size for the chosen CPU model. The default is to | |
23727 | arrange for 32-bit alignment. ABI details such as structure layout are | |
23728 | not affected by these options. | |
23729 | ||
d77de738 ML |
23730 | @opindex m32-bit |
23731 | @opindex m16-bit | |
23732 | @opindex m8-bit | |
ddf6fe37 AA |
23733 | @item -m32-bit |
23734 | @itemx -m16-bit | |
23735 | @itemx -m8-bit | |
d77de738 ML |
23736 | Similar to the stack- data- and const-align options above, these options |
23737 | arrange for stack frame, writable data and constants to all be 32-bit, | |
23738 | 16-bit or 8-bit aligned. The default is 32-bit alignment. | |
23739 | ||
d77de738 ML |
23740 | @opindex mno-prologue-epilogue |
23741 | @opindex mprologue-epilogue | |
ddf6fe37 AA |
23742 | @item -mno-prologue-epilogue |
23743 | @itemx -mprologue-epilogue | |
d77de738 ML |
23744 | With @option{-mno-prologue-epilogue}, the normal function prologue and |
23745 | epilogue which set up the stack frame are omitted and no return | |
23746 | instructions or return sequences are generated in the code. Use this | |
23747 | option only together with visual inspection of the compiled code: no | |
23748 | warnings or errors are generated when call-saved registers must be saved, | |
23749 | or storage for local variables needs to be allocated. | |
23750 | ||
d77de738 | 23751 | @opindex melf |
ddf6fe37 | 23752 | @item -melf |
d77de738 ML |
23753 | Legacy no-op option. |
23754 | ||
d77de738 | 23755 | @opindex sim |
ddf6fe37 | 23756 | @item -sim |
d77de738 ML |
23757 | This option arranges |
23758 | to link with input-output functions from a simulator library. Code, | |
23759 | initialized data and zero-initialized data are allocated consecutively. | |
23760 | ||
d77de738 | 23761 | @opindex sim2 |
ddf6fe37 | 23762 | @item -sim2 |
d77de738 ML |
23763 | Like @option{-sim}, but pass linker options to locate initialized data at |
23764 | 0x40000000 and zero-initialized data at 0x80000000. | |
23765 | @end table | |
23766 | ||
23767 | @node C-SKY Options | |
23768 | @subsection C-SKY Options | |
23769 | @cindex C-SKY Options | |
23770 | ||
23771 | GCC supports these options when compiling for C-SKY V2 processors. | |
23772 | ||
23773 | @table @gcctabopt | |
23774 | ||
d77de738 | 23775 | @opindex march= |
ddf6fe37 | 23776 | @item -march=@var{arch} |
d77de738 ML |
23777 | Specify the C-SKY target architecture. Valid values for @var{arch} are: |
23778 | @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}. | |
23779 | The default is @samp{ck810}. | |
23780 | ||
d77de738 | 23781 | @opindex mcpu= |
ddf6fe37 | 23782 | @item -mcpu=@var{cpu} |
d77de738 ML |
23783 | Specify the C-SKY target processor. Valid values for @var{cpu} are: |
23784 | @samp{ck801}, @samp{ck801t}, | |
23785 | @samp{ck802}, @samp{ck802t}, @samp{ck802j}, | |
23786 | @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht}, | |
23787 | @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh}, | |
23788 | @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh}, | |
23789 | @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1}, | |
23790 | @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1}, | |
23791 | @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1}, | |
23792 | @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1}, | |
23793 | @samp{ck803eftr1}, @samp{ck803efhtr1}, | |
23794 | @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf}, | |
23795 | @samp{ck803sef}, @samp{ck803seft}, | |
23796 | @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f}, | |
23797 | @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft}, | |
23798 | @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv}, | |
23799 | @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}. | |
23800 | ||
d77de738 | 23801 | @opindex mbig-endian |
d77de738 | 23802 | @opindex EB |
d77de738 | 23803 | @opindex mlittle-endian |
d77de738 | 23804 | @opindex EL |
ddf6fe37 AA |
23805 | @item -mbig-endian |
23806 | @itemx -EB | |
23807 | @itemx -mlittle-endian | |
23808 | @itemx -EL | |
d77de738 ML |
23809 | |
23810 | Select big- or little-endian code. The default is little-endian. | |
23811 | ||
d77de738 | 23812 | @opindex mfloat-abi |
ddf6fe37 | 23813 | @item -mfloat-abi=@var{name} |
d77de738 ML |
23814 | Specifies which floating-point ABI to use. Permissible values |
23815 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
23816 | ||
23817 | Specifying @samp{soft} causes GCC to generate output containing | |
23818 | library calls for floating-point operations. | |
23819 | @samp{softfp} allows the generation of code using hardware floating-point | |
23820 | instructions, but still uses the soft-float calling conventions. | |
23821 | @samp{hard} allows generation of floating-point instructions | |
23822 | and uses FPU-specific calling conventions. | |
23823 | ||
23824 | The default depends on the specific target configuration. Note that | |
23825 | the hard-float and soft-float ABIs are not link-compatible; you must | |
23826 | compile your entire program with the same ABI, and link with a | |
23827 | compatible set of libraries. | |
23828 | ||
d77de738 | 23829 | @opindex mhard-float |
d77de738 | 23830 | @opindex msoft-float |
ddf6fe37 AA |
23831 | @item -mhard-float |
23832 | @itemx -msoft-float | |
d77de738 ML |
23833 | |
23834 | Select hardware or software floating-point implementations. | |
23835 | The default is soft float. | |
23836 | ||
ddf6fe37 | 23837 | @opindex mdouble-float |
d77de738 ML |
23838 | @item -mdouble-float |
23839 | @itemx -mno-double-float | |
d77de738 ML |
23840 | When @option{-mhard-float} is in effect, enable generation of |
23841 | double-precision float instructions. This is the default except | |
23842 | when compiling for CK803. | |
23843 | ||
ddf6fe37 | 23844 | @opindex mfdivdu |
d77de738 ML |
23845 | @item -mfdivdu |
23846 | @itemx -mno-fdivdu | |
d77de738 ML |
23847 | When @option{-mhard-float} is in effect, enable generation of |
23848 | @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions. | |
23849 | This is the default except when compiling for CK803. | |
23850 | ||
d77de738 | 23851 | @opindex mfpu= |
ddf6fe37 | 23852 | @item -mfpu=@var{fpu} |
d77de738 ML |
23853 | Select the floating-point processor. This option can only be used with |
23854 | @option{-mhard-float}. | |
23855 | Values for @var{fpu} are | |
23856 | @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}), | |
23857 | @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and | |
23858 | @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}). | |
23859 | ||
ddf6fe37 | 23860 | @opindex melrw |
d77de738 ML |
23861 | @item -melrw |
23862 | @itemx -mno-elrw | |
d77de738 ML |
23863 | Enable the extended @code{lrw} instruction. This option defaults to on |
23864 | for CK801 and off otherwise. | |
23865 | ||
ddf6fe37 | 23866 | @opindex mistack |
d77de738 ML |
23867 | @item -mistack |
23868 | @itemx -mno-istack | |
d77de738 ML |
23869 | Enable interrupt stack instructions; the default is off. |
23870 | ||
23871 | The @option{-mistack} option is required to handle the | |
23872 | @code{interrupt} and @code{isr} function attributes | |
23873 | (@pxref{C-SKY Function Attributes}). | |
23874 | ||
d77de738 | 23875 | @opindex mmp |
ddf6fe37 | 23876 | @item -mmp |
d77de738 ML |
23877 | Enable multiprocessor instructions; the default is off. |
23878 | ||
d77de738 | 23879 | @opindex mcp |
ddf6fe37 | 23880 | @item -mcp |
d77de738 ML |
23881 | Enable coprocessor instructions; the default is off. |
23882 | ||
d77de738 | 23883 | @opindex mcache |
ddf6fe37 | 23884 | @item -mcache |
d77de738 ML |
23885 | Enable coprocessor instructions; the default is off. |
23886 | ||
d77de738 | 23887 | @opindex msecurity |
ddf6fe37 | 23888 | @item -msecurity |
d77de738 ML |
23889 | Enable C-SKY security instructions; the default is off. |
23890 | ||
d77de738 | 23891 | @opindex mtrust |
ddf6fe37 | 23892 | @item -mtrust |
d77de738 ML |
23893 | Enable C-SKY trust instructions; the default is off. |
23894 | ||
d77de738 | 23895 | @opindex mdsp |
d77de738 | 23896 | @opindex medsp |
d77de738 | 23897 | @opindex mvdsp |
ddf6fe37 AA |
23898 | @item -mdsp |
23899 | @itemx -medsp | |
23900 | @itemx -mvdsp | |
d77de738 ML |
23901 | Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively. |
23902 | All of these options default to off. | |
23903 | ||
ddf6fe37 | 23904 | @opindex mdiv |
d77de738 ML |
23905 | @item -mdiv |
23906 | @itemx -mno-div | |
d77de738 ML |
23907 | Generate divide instructions. Default is off. |
23908 | ||
ddf6fe37 | 23909 | @opindex msmart |
d77de738 ML |
23910 | @item -msmart |
23911 | @itemx -mno-smart | |
d77de738 ML |
23912 | Generate code for Smart Mode, using only registers numbered 0-7 to allow |
23913 | use of 16-bit instructions. This option is ignored for CK801 where this | |
23914 | is the required behavior, and it defaults to on for CK802. | |
23915 | For other targets, the default is off. | |
23916 | ||
ddf6fe37 | 23917 | @opindex mhigh-registers |
d77de738 ML |
23918 | @item -mhigh-registers |
23919 | @itemx -mno-high-registers | |
d77de738 ML |
23920 | Generate code using the high registers numbered 16-31. This option |
23921 | is not supported on CK801, CK802, or CK803, and is enabled by default | |
23922 | for other processors. | |
23923 | ||
ddf6fe37 | 23924 | @opindex manchor |
d77de738 ML |
23925 | @item -manchor |
23926 | @itemx -mno-anchor | |
d77de738 ML |
23927 | Generate code using global anchor symbol addresses. |
23928 | ||
ddf6fe37 | 23929 | @opindex mpushpop |
d77de738 ML |
23930 | @item -mpushpop |
23931 | @itemx -mno-pushpop | |
d77de738 ML |
23932 | Generate code using @code{push} and @code{pop} instructions. This option |
23933 | defaults to on. | |
23934 | ||
ddf6fe37 | 23935 | @opindex mmultiple-stld |
d77de738 ML |
23936 | @item -mmultiple-stld |
23937 | @itemx -mstm | |
23938 | @itemx -mno-multiple-stld | |
23939 | @itemx -mno-stm | |
d77de738 ML |
23940 | Generate code using @code{stm} and @code{ldm} instructions. This option |
23941 | isn't supported on CK801 but is enabled by default on other processors. | |
23942 | ||
ddf6fe37 | 23943 | @opindex mconstpool |
d77de738 ML |
23944 | @item -mconstpool |
23945 | @itemx -mno-constpool | |
d77de738 ML |
23946 | Create constant pools in the compiler instead of deferring it to the |
23947 | assembler. This option is the default and required for correct code | |
23948 | generation on CK801 and CK802, and is optional on other processors. | |
23949 | ||
ddf6fe37 | 23950 | @opindex mstack-size |
d77de738 ML |
23951 | @item -mstack-size |
23952 | @item -mno-stack-size | |
d77de738 ML |
23953 | Emit @code{.stack_size} directives for each function in the assembly |
23954 | output. This option defaults to off. | |
23955 | ||
ddf6fe37 | 23956 | @opindex mccrt |
d77de738 ML |
23957 | @item -mccrt |
23958 | @itemx -mno-ccrt | |
d77de738 ML |
23959 | Generate code for the C-SKY compiler runtime instead of libgcc. This |
23960 | option defaults to off. | |
23961 | ||
d77de738 | 23962 | @opindex mbranch-cost= |
ddf6fe37 | 23963 | @item -mbranch-cost=@var{n} |
d77de738 ML |
23964 | Set the branch costs to roughly @code{n} instructions. The default is 1. |
23965 | ||
ddf6fe37 | 23966 | @opindex msched-prolog |
d77de738 ML |
23967 | @item -msched-prolog |
23968 | @itemx -mno-sched-prolog | |
d77de738 ML |
23969 | Permit scheduling of function prologue and epilogue sequences. Using |
23970 | this option can result in code that is not compliant with the C-SKY V2 ABI | |
23971 | prologue requirements and that cannot be debugged or backtraced. | |
23972 | It is disabled by default. | |
23973 | ||
d77de738 | 23974 | @opindex msim |
ddf6fe37 | 23975 | @item -msim |
d77de738 ML |
23976 | Links the library libsemi.a which is in compatible with simulator. Applicable |
23977 | to ELF compiler only. | |
23978 | ||
23979 | @end table | |
23980 | ||
23981 | @node Darwin Options | |
23982 | @subsection Darwin Options | |
23983 | @cindex Darwin options | |
23984 | ||
23985 | These options are defined for all architectures running the Darwin operating | |
23986 | system. | |
23987 | ||
23988 | FSF GCC on Darwin does not create ``fat'' object files; it creates | |
23989 | an object file for the single architecture that GCC was built to | |
23990 | target. Apple's GCC on Darwin does create ``fat'' files if multiple | |
23991 | @option{-arch} options are used; it does so by running the compiler or | |
23992 | linker multiple times and joining the results together with | |
23993 | @file{lipo}. | |
23994 | ||
23995 | The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or | |
23996 | @samp{i686}) is determined by the flags that specify the ISA | |
23997 | that GCC is targeting, like @option{-mcpu} or @option{-march}. The | |
23998 | @option{-force_cpusubtype_ALL} option can be used to override this. | |
23999 | ||
24000 | The Darwin tools vary in their behavior when presented with an ISA | |
24001 | mismatch. The assembler, @file{as}, only permits instructions to | |
24002 | be used that are valid for the subtype of the file it is generating, | |
24003 | so you cannot put 64-bit instructions in a @samp{ppc750} object file. | |
24004 | The linker for shared libraries, @file{/usr/bin/libtool}, fails | |
24005 | and prints an error if asked to create a shared library with a less | |
24006 | restrictive subtype than its input files (for instance, trying to put | |
24007 | a @samp{ppc970} object file in a @samp{ppc7400} library). The linker | |
24008 | for executables, @command{ld}, quietly gives the executable the most | |
24009 | restrictive subtype of any of its input files. | |
24010 | ||
24011 | @table @gcctabopt | |
d77de738 | 24012 | @opindex F |
ddf6fe37 | 24013 | @item -F@var{dir} |
d77de738 ML |
24014 | Add the framework directory @var{dir} to the head of the list of |
24015 | directories to be searched for header files. These directories are | |
24016 | interleaved with those specified by @option{-I} options and are | |
24017 | scanned in a left-to-right order. | |
24018 | ||
24019 | A framework directory is a directory with frameworks in it. A | |
24020 | framework is a directory with a @file{Headers} and/or | |
24021 | @file{PrivateHeaders} directory contained directly in it that ends | |
24022 | in @file{.framework}. The name of a framework is the name of this | |
24023 | directory excluding the @file{.framework}. Headers associated with | |
24024 | the framework are found in one of those two directories, with | |
24025 | @file{Headers} being searched first. A subframework is a framework | |
24026 | directory that is in a framework's @file{Frameworks} directory. | |
24027 | Includes of subframework headers can only appear in a header of a | |
24028 | framework that contains the subframework, or in a sibling subframework | |
24029 | header. Two subframeworks are siblings if they occur in the same | |
24030 | framework. A subframework should not have the same name as a | |
24031 | framework; a warning is issued if this is violated. Currently a | |
24032 | subframework cannot have subframeworks; in the future, the mechanism | |
24033 | may be extended to support this. The standard frameworks can be found | |
24034 | in @file{/System/Library/Frameworks} and | |
24035 | @file{/Library/Frameworks}. An example include looks like | |
24036 | @code{#include <Framework/header.h>}, where @file{Framework} denotes | |
24037 | the name of the framework and @file{header.h} is found in the | |
24038 | @file{PrivateHeaders} or @file{Headers} directory. | |
24039 | ||
d77de738 | 24040 | @opindex iframework |
ddf6fe37 | 24041 | @item -iframework@var{dir} |
d77de738 ML |
24042 | Like @option{-F} except the directory is a treated as a system |
24043 | directory. The main difference between this @option{-iframework} and | |
24044 | @option{-F} is that with @option{-iframework} the compiler does not | |
24045 | warn about constructs contained within header files found via | |
24046 | @var{dir}. This option is valid only for the C family of languages. | |
24047 | ||
d77de738 | 24048 | @opindex gused |
ddf6fe37 | 24049 | @item -gused |
d77de738 ML |
24050 | Emit debugging information for symbols that are used. For stabs |
24051 | debugging format, this enables @option{-feliminate-unused-debug-symbols}. | |
24052 | This is by default ON@. | |
24053 | ||
d77de738 | 24054 | @opindex gfull |
ddf6fe37 | 24055 | @item -gfull |
d77de738 ML |
24056 | Emit debugging information for all symbols and types. |
24057 | ||
24058 | @item -mmacosx-version-min=@var{version} | |
24059 | The earliest version of MacOS X that this executable will run on | |
24060 | is @var{version}. Typical values of @var{version} include @code{10.1}, | |
24061 | @code{10.2}, and @code{10.3.9}. | |
24062 | ||
24063 | If the compiler was built to use the system's headers by default, | |
24064 | then the default for this option is the system version on which the | |
24065 | compiler is running, otherwise the default is to make choices that | |
24066 | are compatible with as many systems and code bases as possible. | |
24067 | ||
d77de738 | 24068 | @opindex mkernel |
ddf6fe37 | 24069 | @item -mkernel |
d77de738 ML |
24070 | Enable kernel development mode. The @option{-mkernel} option sets |
24071 | @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit}, | |
24072 | @option{-fno-exceptions}, @option{-fno-non-call-exceptions}, | |
24073 | @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where | |
24074 | applicable. This mode also sets @option{-mno-altivec}, | |
24075 | @option{-msoft-float}, @option{-fno-builtin} and | |
24076 | @option{-mlong-branch} for PowerPC targets. | |
24077 | ||
d77de738 | 24078 | @opindex mone-byte-bool |
ddf6fe37 | 24079 | @item -mone-byte-bool |
d77de738 ML |
24080 | Override the defaults for @code{bool} so that @code{sizeof(bool)==1}. |
24081 | By default @code{sizeof(bool)} is @code{4} when compiling for | |
24082 | Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this | |
24083 | option has no effect on x86. | |
24084 | ||
24085 | @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC | |
24086 | to generate code that is not binary compatible with code generated | |
24087 | without that switch. Using this switch may require recompiling all | |
24088 | other modules in a program, including system libraries. Use this | |
24089 | switch to conform to a non-default data model. | |
24090 | ||
d77de738 ML |
24091 | @opindex mfix-and-continue |
24092 | @opindex ffix-and-continue | |
24093 | @opindex findirect-data | |
ddf6fe37 AA |
24094 | @item -mfix-and-continue |
24095 | @itemx -ffix-and-continue | |
24096 | @itemx -findirect-data | |
d77de738 ML |
24097 | Generate code suitable for fast turnaround development, such as to |
24098 | allow GDB to dynamically load @file{.o} files into already-running | |
24099 | programs. @option{-findirect-data} and @option{-ffix-and-continue} | |
24100 | are provided for backwards compatibility. | |
24101 | ||
d77de738 | 24102 | @opindex all_load |
ddf6fe37 | 24103 | @item -all_load |
d77de738 ML |
24104 | Loads all members of static archive libraries. |
24105 | See man ld(1) for more information. | |
24106 | ||
d77de738 | 24107 | @opindex arch_errors_fatal |
ddf6fe37 | 24108 | @item -arch_errors_fatal |
d77de738 ML |
24109 | Cause the errors having to do with files that have the wrong architecture |
24110 | to be fatal. | |
24111 | ||
d77de738 | 24112 | @opindex bind_at_load |
ddf6fe37 | 24113 | @item -bind_at_load |
d77de738 ML |
24114 | Causes the output file to be marked such that the dynamic linker will |
24115 | bind all undefined references when the file is loaded or launched. | |
24116 | ||
d77de738 | 24117 | @opindex bundle |
ddf6fe37 | 24118 | @item -bundle |
d77de738 ML |
24119 | Produce a Mach-o bundle format file. |
24120 | See man ld(1) for more information. | |
24121 | ||
d77de738 | 24122 | @opindex bundle_loader |
ddf6fe37 | 24123 | @item -bundle_loader @var{executable} |
d77de738 ML |
24124 | This option specifies the @var{executable} that will load the build |
24125 | output file being linked. See man ld(1) for more information. | |
24126 | ||
d77de738 | 24127 | @opindex dynamiclib |
ddf6fe37 | 24128 | @item -dynamiclib |
d77de738 ML |
24129 | When passed this option, GCC produces a dynamic library instead of |
24130 | an executable when linking, using the Darwin @file{libtool} command. | |
24131 | ||
d77de738 | 24132 | @opindex force_cpusubtype_ALL |
ddf6fe37 | 24133 | @item -force_cpusubtype_ALL |
d77de738 ML |
24134 | This causes GCC's output file to have the @samp{ALL} subtype, instead of |
24135 | one controlled by the @option{-mcpu} or @option{-march} option. | |
24136 | ||
24137 | @item -allowable_client @var{client_name} | |
24138 | @itemx -client_name | |
24139 | @itemx -compatibility_version | |
24140 | @itemx -current_version | |
24141 | @itemx -dead_strip | |
24142 | @itemx -dependency-file | |
24143 | @itemx -dylib_file | |
24144 | @itemx -dylinker_install_name | |
24145 | @itemx -dynamic | |
24146 | @itemx -exported_symbols_list | |
24147 | @itemx -filelist | |
24148 | @need 800 | |
24149 | @itemx -flat_namespace | |
24150 | @itemx -force_flat_namespace | |
24151 | @itemx -headerpad_max_install_names | |
24152 | @itemx -image_base | |
24153 | @itemx -init | |
24154 | @itemx -install_name | |
24155 | @itemx -keep_private_externs | |
24156 | @itemx -multi_module | |
24157 | @itemx -multiply_defined | |
24158 | @itemx -multiply_defined_unused | |
24159 | @need 800 | |
24160 | @itemx -noall_load | |
24161 | @itemx -no_dead_strip_inits_and_terms | |
24162 | @itemx -nofixprebinding | |
24163 | @itemx -nomultidefs | |
24164 | @itemx -noprebind | |
24165 | @itemx -noseglinkedit | |
24166 | @itemx -pagezero_size | |
24167 | @itemx -prebind | |
24168 | @itemx -prebind_all_twolevel_modules | |
24169 | @itemx -private_bundle | |
24170 | @need 800 | |
24171 | @itemx -read_only_relocs | |
24172 | @itemx -sectalign | |
24173 | @itemx -sectobjectsymbols | |
24174 | @itemx -whyload | |
24175 | @itemx -seg1addr | |
24176 | @itemx -sectcreate | |
24177 | @itemx -sectobjectsymbols | |
24178 | @itemx -sectorder | |
24179 | @itemx -segaddr | |
24180 | @itemx -segs_read_only_addr | |
24181 | @need 800 | |
24182 | @itemx -segs_read_write_addr | |
24183 | @itemx -seg_addr_table | |
24184 | @itemx -seg_addr_table_filename | |
24185 | @itemx -seglinkedit | |
24186 | @itemx -segprot | |
24187 | @itemx -segs_read_only_addr | |
24188 | @itemx -segs_read_write_addr | |
24189 | @itemx -single_module | |
24190 | @itemx -static | |
24191 | @itemx -sub_library | |
24192 | @need 800 | |
d77de738 ML |
24193 | @opindex allowable_client |
24194 | @opindex client_name | |
24195 | @opindex compatibility_version | |
24196 | @opindex current_version | |
24197 | @opindex dead_strip | |
24198 | @opindex dependency-file | |
24199 | @opindex dylib_file | |
24200 | @opindex dylinker_install_name | |
24201 | @opindex dynamic | |
24202 | @opindex exported_symbols_list | |
24203 | @opindex filelist | |
24204 | @opindex flat_namespace | |
24205 | @opindex force_flat_namespace | |
24206 | @opindex headerpad_max_install_names | |
24207 | @opindex image_base | |
24208 | @opindex init | |
24209 | @opindex install_name | |
24210 | @opindex keep_private_externs | |
24211 | @opindex multi_module | |
24212 | @opindex multiply_defined | |
24213 | @opindex multiply_defined_unused | |
24214 | @opindex noall_load | |
24215 | @opindex no_dead_strip_inits_and_terms | |
24216 | @opindex nofixprebinding | |
24217 | @opindex nomultidefs | |
24218 | @opindex noprebind | |
24219 | @opindex noseglinkedit | |
24220 | @opindex pagezero_size | |
24221 | @opindex prebind | |
24222 | @opindex prebind_all_twolevel_modules | |
24223 | @opindex private_bundle | |
24224 | @opindex read_only_relocs | |
24225 | @opindex sectalign | |
24226 | @opindex sectobjectsymbols | |
24227 | @opindex whyload | |
24228 | @opindex seg1addr | |
24229 | @opindex sectcreate | |
24230 | @opindex sectobjectsymbols | |
24231 | @opindex sectorder | |
24232 | @opindex segaddr | |
24233 | @opindex segs_read_only_addr | |
24234 | @opindex segs_read_write_addr | |
24235 | @opindex seg_addr_table | |
24236 | @opindex seg_addr_table_filename | |
24237 | @opindex seglinkedit | |
24238 | @opindex segprot | |
24239 | @opindex segs_read_only_addr | |
24240 | @opindex segs_read_write_addr | |
24241 | @opindex single_module | |
24242 | @opindex static | |
24243 | @opindex sub_library | |
24244 | @opindex sub_umbrella | |
24245 | @opindex twolevel_namespace | |
24246 | @opindex umbrella | |
24247 | @opindex undefined | |
24248 | @opindex unexported_symbols_list | |
24249 | @opindex weak_reference_mismatches | |
24250 | @opindex whatsloaded | |
ddf6fe37 AA |
24251 | @itemx -sub_umbrella |
24252 | @itemx -twolevel_namespace | |
24253 | @itemx -umbrella | |
24254 | @itemx -undefined | |
24255 | @itemx -unexported_symbols_list | |
24256 | @itemx -weak_reference_mismatches | |
24257 | @itemx -whatsloaded | |
d77de738 ML |
24258 | These options are passed to the Darwin linker. The Darwin linker man page |
24259 | describes them in detail. | |
24260 | @end table | |
24261 | ||
24262 | @node DEC Alpha Options | |
24263 | @subsection DEC Alpha Options | |
24264 | ||
24265 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
24266 | ||
24267 | @table @gcctabopt | |
d77de738 ML |
24268 | @opindex mno-soft-float |
24269 | @opindex msoft-float | |
ddf6fe37 AA |
24270 | @item -mno-soft-float |
24271 | @itemx -msoft-float | |
d77de738 ML |
24272 | Use (do not use) the hardware floating-point instructions for |
24273 | floating-point operations. When @option{-msoft-float} is specified, | |
24274 | functions in @file{libgcc.a} are used to perform floating-point | |
24275 | operations. Unless they are replaced by routines that emulate the | |
24276 | floating-point operations, or compiled in such a way as to call such | |
24277 | emulations routines, these routines issue floating-point | |
24278 | operations. If you are compiling for an Alpha without floating-point | |
24279 | operations, you must ensure that the library is built so as not to call | |
24280 | them. | |
24281 | ||
24282 | Note that Alpha implementations without floating-point operations are | |
24283 | required to have floating-point registers. | |
24284 | ||
d77de738 ML |
24285 | @opindex mfp-reg |
24286 | @opindex mno-fp-regs | |
ddf6fe37 AA |
24287 | @item -mfp-reg |
24288 | @itemx -mno-fp-regs | |
d77de738 ML |
24289 | Generate code that uses (does not use) the floating-point register set. |
24290 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point | |
24291 | register set is not used, floating-point operands are passed in integer | |
24292 | registers as if they were integers and floating-point results are passed | |
24293 | in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence, | |
24294 | so any function with a floating-point argument or return value called by code | |
24295 | compiled with @option{-mno-fp-regs} must also be compiled with that | |
24296 | option. | |
24297 | ||
24298 | A typical use of this option is building a kernel that does not use, | |
24299 | and hence need not save and restore, any floating-point registers. | |
24300 | ||
d77de738 | 24301 | @opindex mieee |
ddf6fe37 | 24302 | @item -mieee |
d77de738 ML |
24303 | The Alpha architecture implements floating-point hardware optimized for |
24304 | maximum performance. It is mostly compliant with the IEEE floating-point | |
24305 | standard. However, for full compliance, software assistance is | |
24306 | required. This option generates code fully IEEE-compliant code | |
24307 | @emph{except} that the @var{inexact-flag} is not maintained (see below). | |
24308 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is | |
24309 | defined during compilation. The resulting code is less efficient but is | |
24310 | able to correctly support denormalized numbers and exceptional IEEE | |
24311 | values such as not-a-number and plus/minus infinity. Other Alpha | |
24312 | compilers call this option @option{-ieee_with_no_inexact}. | |
24313 | ||
d77de738 | 24314 | @opindex mieee-with-inexact |
ddf6fe37 | 24315 | @item -mieee-with-inexact |
d77de738 ML |
24316 | This is like @option{-mieee} except the generated code also maintains |
24317 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
24318 | generated code to implement fully-compliant IEEE math. In addition to | |
24319 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
24320 | macro. On some Alpha implementations the resulting code may execute | |
24321 | significantly slower than the code generated by default. Since there is | |
24322 | very little code that depends on the @var{inexact-flag}, you should | |
24323 | normally not specify this option. Other Alpha compilers call this | |
24324 | option @option{-ieee_with_inexact}. | |
24325 | ||
d77de738 | 24326 | @opindex mfp-trap-mode |
ddf6fe37 | 24327 | @item -mfp-trap-mode=@var{trap-mode} |
d77de738 ML |
24328 | This option controls what floating-point related traps are enabled. |
24329 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. | |
24330 | The trap mode can be set to one of four values: | |
24331 | ||
24332 | @table @samp | |
24333 | @item n | |
24334 | This is the default (normal) setting. The only traps that are enabled | |
24335 | are the ones that cannot be disabled in software (e.g., division by zero | |
24336 | trap). | |
24337 | ||
24338 | @item u | |
24339 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
24340 | as well. | |
24341 | ||
24342 | @item su | |
24343 | Like @samp{u}, but the instructions are marked to be safe for software | |
24344 | completion (see Alpha architecture manual for details). | |
24345 | ||
24346 | @item sui | |
24347 | Like @samp{su}, but inexact traps are enabled as well. | |
24348 | @end table | |
24349 | ||
d77de738 | 24350 | @opindex mfp-rounding-mode |
ddf6fe37 | 24351 | @item -mfp-rounding-mode=@var{rounding-mode} |
d77de738 ML |
24352 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
24353 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one | |
24354 | of: | |
24355 | ||
24356 | @table @samp | |
24357 | @item n | |
24358 | Normal IEEE rounding mode. Floating-point numbers are rounded towards | |
24359 | the nearest machine number or towards the even machine number in case | |
24360 | of a tie. | |
24361 | ||
24362 | @item m | |
24363 | Round towards minus infinity. | |
24364 | ||
24365 | @item c | |
24366 | Chopped rounding mode. Floating-point numbers are rounded towards zero. | |
24367 | ||
24368 | @item d | |
24369 | Dynamic rounding mode. A field in the floating-point control register | |
24370 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
24371 | rounding mode in effect. The C library initializes this register for | |
24372 | rounding towards plus infinity. Thus, unless your program modifies the | |
24373 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. | |
24374 | @end table | |
24375 | ||
d77de738 | 24376 | @opindex mtrap-precision |
ddf6fe37 | 24377 | @item -mtrap-precision=@var{trap-precision} |
d77de738 ML |
24378 | In the Alpha architecture, floating-point traps are imprecise. This |
24379 | means without software assistance it is impossible to recover from a | |
24380 | floating trap and program execution normally needs to be terminated. | |
24381 | GCC can generate code that can assist operating system trap handlers | |
24382 | in determining the exact location that caused a floating-point trap. | |
24383 | Depending on the requirements of an application, different levels of | |
24384 | precisions can be selected: | |
24385 | ||
24386 | @table @samp | |
24387 | @item p | |
24388 | Program precision. This option is the default and means a trap handler | |
24389 | can only identify which program caused a floating-point exception. | |
24390 | ||
24391 | @item f | |
24392 | Function precision. The trap handler can determine the function that | |
24393 | caused a floating-point exception. | |
24394 | ||
24395 | @item i | |
24396 | Instruction precision. The trap handler can determine the exact | |
24397 | instruction that caused a floating-point exception. | |
24398 | @end table | |
24399 | ||
24400 | Other Alpha compilers provide the equivalent options called | |
24401 | @option{-scope_safe} and @option{-resumption_safe}. | |
24402 | ||
d77de738 | 24403 | @opindex mieee-conformant |
ddf6fe37 | 24404 | @item -mieee-conformant |
d77de738 ML |
24405 | This option marks the generated code as IEEE conformant. You must not |
24406 | use this option unless you also specify @option{-mtrap-precision=i} and either | |
24407 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
24408 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
24409 | generated assembly file. | |
24410 | ||
d77de738 | 24411 | @opindex mbuild-constants |
ddf6fe37 | 24412 | @item -mbuild-constants |
d77de738 ML |
24413 | Normally GCC examines a 32- or 64-bit integer constant to |
24414 | see if it can construct it from smaller constants in two or three | |
24415 | instructions. If it cannot, it outputs the constant as a literal and | |
24416 | generates code to load it from the data segment at run time. | |
24417 | ||
24418 | Use this option to require GCC to construct @emph{all} integer constants | |
24419 | using code, even if it takes more instructions (the maximum is six). | |
24420 | ||
24421 | You typically use this option to build a shared library dynamic | |
24422 | loader. Itself a shared library, it must relocate itself in memory | |
24423 | before it can find the variables and constants in its own data segment. | |
24424 | ||
d77de738 ML |
24425 | @opindex mbwx |
24426 | @opindex mno-bwx | |
24427 | @opindex mcix | |
24428 | @opindex mno-cix | |
24429 | @opindex mfix | |
24430 | @opindex mno-fix | |
24431 | @opindex mmax | |
24432 | @opindex mno-max | |
ddf6fe37 AA |
24433 | @item -mbwx |
24434 | @itemx -mno-bwx | |
24435 | @itemx -mcix | |
24436 | @itemx -mno-cix | |
24437 | @itemx -mfix | |
24438 | @itemx -mno-fix | |
24439 | @itemx -mmax | |
24440 | @itemx -mno-max | |
d77de738 ML |
24441 | Indicate whether GCC should generate code to use the optional BWX, |
24442 | CIX, FIX and MAX instruction sets. The default is to use the instruction | |
24443 | sets supported by the CPU type specified via @option{-mcpu=} option or that | |
24444 | of the CPU on which GCC was built if none is specified. | |
24445 | ||
d77de738 ML |
24446 | @opindex mfloat-vax |
24447 | @opindex mfloat-ieee | |
ddf6fe37 AA |
24448 | @item -mfloat-vax |
24449 | @itemx -mfloat-ieee | |
d77de738 ML |
24450 | Generate code that uses (does not use) VAX F and G floating-point |
24451 | arithmetic instead of IEEE single and double precision. | |
24452 | ||
d77de738 ML |
24453 | @opindex mexplicit-relocs |
24454 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
24455 | @item -mexplicit-relocs |
24456 | @itemx -mno-explicit-relocs | |
d77de738 ML |
24457 | Older Alpha assemblers provided no way to generate symbol relocations |
24458 | except via assembler macros. Use of these macros does not allow | |
24459 | optimal instruction scheduling. GNU binutils as of version 2.12 | |
24460 | supports a new syntax that allows the compiler to explicitly mark | |
24461 | which relocations should apply to which instructions. This option | |
24462 | is mostly useful for debugging, as GCC detects the capabilities of | |
24463 | the assembler when it is built and sets the default accordingly. | |
24464 | ||
d77de738 ML |
24465 | @opindex msmall-data |
24466 | @opindex mlarge-data | |
ddf6fe37 AA |
24467 | @item -msmall-data |
24468 | @itemx -mlarge-data | |
d77de738 ML |
24469 | When @option{-mexplicit-relocs} is in effect, static data is |
24470 | accessed via @dfn{gp-relative} relocations. When @option{-msmall-data} | |
24471 | is used, objects 8 bytes long or smaller are placed in a @dfn{small data area} | |
24472 | (the @code{.sdata} and @code{.sbss} sections) and are accessed via | |
24473 | 16-bit relocations off of the @code{$gp} register. This limits the | |
24474 | size of the small data area to 64KB, but allows the variables to be | |
24475 | directly accessed via a single instruction. | |
24476 | ||
24477 | The default is @option{-mlarge-data}. With this option the data area | |
24478 | is limited to just below 2GB@. Programs that require more than 2GB of | |
24479 | data must use @code{malloc} or @code{mmap} to allocate the data in the | |
24480 | heap instead of in the program's data segment. | |
24481 | ||
24482 | When generating code for shared libraries, @option{-fpic} implies | |
24483 | @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}. | |
24484 | ||
d77de738 ML |
24485 | @opindex msmall-text |
24486 | @opindex mlarge-text | |
ddf6fe37 AA |
24487 | @item -msmall-text |
24488 | @itemx -mlarge-text | |
d77de738 ML |
24489 | When @option{-msmall-text} is used, the compiler assumes that the |
24490 | code of the entire program (or shared library) fits in 4MB, and is | |
24491 | thus reachable with a branch instruction. When @option{-msmall-data} | |
24492 | is used, the compiler can assume that all local symbols share the | |
24493 | same @code{$gp} value, and thus reduce the number of instructions | |
24494 | required for a function call from 4 to 1. | |
24495 | ||
24496 | The default is @option{-mlarge-text}. | |
24497 | ||
d77de738 | 24498 | @opindex mcpu |
ddf6fe37 | 24499 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
24500 | Set the instruction set and instruction scheduling parameters for |
24501 | machine type @var{cpu_type}. You can specify either the @samp{EV} | |
24502 | style name or the corresponding chip number. GCC supports scheduling | |
24503 | parameters for the EV4, EV5 and EV6 family of processors and | |
24504 | chooses the default values for the instruction set from the processor | |
24505 | you specify. If you do not specify a processor type, GCC defaults | |
24506 | to the processor on which the compiler was built. | |
24507 | ||
24508 | Supported values for @var{cpu_type} are | |
24509 | ||
24510 | @table @samp | |
24511 | @item ev4 | |
24512 | @itemx ev45 | |
24513 | @itemx 21064 | |
24514 | Schedules as an EV4 and has no instruction set extensions. | |
24515 | ||
24516 | @item ev5 | |
24517 | @itemx 21164 | |
24518 | Schedules as an EV5 and has no instruction set extensions. | |
24519 | ||
24520 | @item ev56 | |
24521 | @itemx 21164a | |
24522 | Schedules as an EV5 and supports the BWX extension. | |
24523 | ||
24524 | @item pca56 | |
24525 | @itemx 21164pc | |
24526 | @itemx 21164PC | |
24527 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
24528 | ||
24529 | @item ev6 | |
24530 | @itemx 21264 | |
24531 | Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. | |
24532 | ||
24533 | @item ev67 | |
24534 | @itemx 21264a | |
24535 | Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. | |
24536 | @end table | |
24537 | ||
24538 | Native toolchains also support the value @samp{native}, | |
24539 | which selects the best architecture option for the host processor. | |
24540 | @option{-mcpu=native} has no effect if GCC does not recognize | |
24541 | the processor. | |
24542 | ||
d77de738 | 24543 | @opindex mtune |
ddf6fe37 | 24544 | @item -mtune=@var{cpu_type} |
d77de738 ML |
24545 | Set only the instruction scheduling parameters for machine type |
24546 | @var{cpu_type}. The instruction set is not changed. | |
24547 | ||
24548 | Native toolchains also support the value @samp{native}, | |
24549 | which selects the best architecture option for the host processor. | |
24550 | @option{-mtune=native} has no effect if GCC does not recognize | |
24551 | the processor. | |
24552 | ||
d77de738 | 24553 | @opindex mmemory-latency |
ddf6fe37 | 24554 | @item -mmemory-latency=@var{time} |
d77de738 ML |
24555 | Sets the latency the scheduler should assume for typical memory |
24556 | references as seen by the application. This number is highly | |
24557 | dependent on the memory access patterns used by the application | |
24558 | and the size of the external cache on the machine. | |
24559 | ||
24560 | Valid options for @var{time} are | |
24561 | ||
24562 | @table @samp | |
24563 | @item @var{number} | |
24564 | A decimal number representing clock cycles. | |
24565 | ||
24566 | @item L1 | |
24567 | @itemx L2 | |
24568 | @itemx L3 | |
24569 | @itemx main | |
24570 | The compiler contains estimates of the number of clock cycles for | |
24571 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
24572 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
24573 | Note that L3 is only valid for EV5. | |
24574 | ||
24575 | @end table | |
24576 | @end table | |
24577 | ||
24578 | @node eBPF Options | |
24579 | @subsection eBPF Options | |
24580 | @cindex eBPF Options | |
24581 | ||
24582 | @table @gcctabopt | |
24583 | @item -mframe-limit=@var{bytes} | |
24584 | This specifies the hard limit for frame sizes, in bytes. Currently, | |
24585 | the value that can be specified should be less than or equal to | |
24586 | @samp{32767}. Defaults to whatever limit is imposed by the version of | |
24587 | the Linux kernel targeted. | |
24588 | ||
d77de738 | 24589 | @opindex mkernel |
ddf6fe37 | 24590 | @item -mkernel=@var{version} |
d77de738 ML |
24591 | This specifies the minimum version of the kernel that will run the |
24592 | compiled program. GCC uses this version to determine which | |
24593 | instructions to use, what kernel helpers to allow, etc. Currently, | |
24594 | @var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2}, | |
24595 | @samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7}, | |
24596 | @samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12}, | |
24597 | @samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17}, | |
24598 | @samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1}, | |
24599 | @samp{5.2}, @samp{latest} and @samp{native}. | |
24600 | ||
d77de738 | 24601 | @opindex mbig-endian |
ddf6fe37 | 24602 | @item -mbig-endian |
d77de738 ML |
24603 | Generate code for a big-endian target. |
24604 | ||
d77de738 | 24605 | @opindex mlittle-endian |
ddf6fe37 | 24606 | @item -mlittle-endian |
d77de738 ML |
24607 | Generate code for a little-endian target. This is the default. |
24608 | ||
d77de738 | 24609 | @opindex mjmpext |
ddf6fe37 | 24610 | @item -mjmpext |
d77de738 ML |
24611 | Enable generation of extra conditional-branch instructions. |
24612 | Enabled for CPU v2 and above. | |
24613 | ||
d77de738 | 24614 | @opindex mjmp32 |
ddf6fe37 | 24615 | @item -mjmp32 |
d77de738 ML |
24616 | Enable 32-bit jump instructions. Enabled for CPU v3 and above. |
24617 | ||
d77de738 | 24618 | @opindex malu32 |
ddf6fe37 | 24619 | @item -malu32 |
d77de738 ML |
24620 | Enable 32-bit ALU instructions. Enabled for CPU v3 and above. |
24621 | ||
d77de738 | 24622 | @opindex mcpu |
ddf6fe37 | 24623 | @item -mcpu=@var{version} |
d77de738 ML |
24624 | This specifies which version of the eBPF ISA to target. Newer versions |
24625 | may not be supported by all kernels. The default is @samp{v3}. | |
24626 | ||
24627 | Supported values for @var{version} are: | |
24628 | ||
24629 | @table @samp | |
24630 | @item v1 | |
24631 | The first stable eBPF ISA with no special features or extensions. | |
24632 | ||
24633 | @item v2 | |
24634 | Supports the jump extensions, as in @option{-mjmpext}. | |
24635 | ||
24636 | @item v3 | |
24637 | All features of v2, plus: | |
24638 | @itemize @minus | |
24639 | @item 32-bit jump operations, as in @option{-mjmp32} | |
24640 | @item 32-bit ALU operations, as in @option{-malu32} | |
24641 | @end itemize | |
24642 | ||
24643 | @end table | |
24644 | ||
d77de738 | 24645 | @opindex mco-re |
ddf6fe37 | 24646 | @item -mco-re |
d77de738 ML |
24647 | Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and |
24648 | is implied by @option{-gbtf}. | |
24649 | ||
d77de738 | 24650 | @opindex mno-co-re |
ddf6fe37 | 24651 | @item -mno-co-re |
d77de738 ML |
24652 | Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE |
24653 | support is enabled by default when generating BTF debug information for | |
24654 | the BPF target. | |
24655 | ||
24656 | @item -mxbpf | |
24657 | Generate code for an expanded version of BPF, which relaxes some of | |
24658 | the restrictions imposed by the BPF architecture: | |
24659 | @itemize @minus | |
24660 | @item Save and restore callee-saved registers at function entry and | |
24661 | exit, respectively. | |
24662 | @end itemize | |
24663 | @end table | |
24664 | ||
24665 | @node FR30 Options | |
24666 | @subsection FR30 Options | |
24667 | @cindex FR30 Options | |
24668 | ||
24669 | These options are defined specifically for the FR30 port. | |
24670 | ||
24671 | @table @gcctabopt | |
24672 | ||
d77de738 | 24673 | @opindex msmall-model |
ddf6fe37 | 24674 | @item -msmall-model |
d77de738 ML |
24675 | Use the small address space model. This can produce smaller code, but |
24676 | it does assume that all symbolic values and addresses fit into a | |
24677 | 20-bit range. | |
24678 | ||
d77de738 | 24679 | @opindex mno-lsim |
ddf6fe37 | 24680 | @item -mno-lsim |
d77de738 ML |
24681 | Assume that runtime support has been provided and so there is no need |
24682 | to include the simulator library (@file{libsim.a}) on the linker | |
24683 | command line. | |
24684 | ||
24685 | @end table | |
24686 | ||
24687 | @node FT32 Options | |
24688 | @subsection FT32 Options | |
24689 | @cindex FT32 Options | |
24690 | ||
24691 | These options are defined specifically for the FT32 port. | |
24692 | ||
24693 | @table @gcctabopt | |
24694 | ||
d77de738 | 24695 | @opindex msim |
ddf6fe37 | 24696 | @item -msim |
d77de738 ML |
24697 | Specifies that the program will be run on the simulator. This causes |
24698 | an alternate runtime startup and library to be linked. | |
24699 | You must not use this option when generating programs that will run on | |
24700 | real hardware; you must provide your own runtime library for whatever | |
24701 | I/O functions are needed. | |
24702 | ||
d77de738 | 24703 | @opindex mlra |
ddf6fe37 | 24704 | @item -mlra |
d77de738 ML |
24705 | Enable Local Register Allocation. This is still experimental for FT32, |
24706 | so by default the compiler uses standard reload. | |
24707 | ||
d77de738 | 24708 | @opindex mnodiv |
ddf6fe37 | 24709 | @item -mnodiv |
d77de738 ML |
24710 | Do not use div and mod instructions. |
24711 | ||
d77de738 | 24712 | @opindex mft32b |
ddf6fe37 | 24713 | @item -mft32b |
d77de738 ML |
24714 | Enable use of the extended instructions of the FT32B processor. |
24715 | ||
d77de738 | 24716 | @opindex mcompress |
ddf6fe37 | 24717 | @item -mcompress |
d77de738 ML |
24718 | Compress all code using the Ft32B code compression scheme. |
24719 | ||
d77de738 | 24720 | @opindex mnopm |
ddf6fe37 | 24721 | @item -mnopm |
d77de738 ML |
24722 | Do not generate code that reads program memory. |
24723 | ||
24724 | @end table | |
24725 | ||
24726 | @node FRV Options | |
24727 | @subsection FRV Options | |
24728 | @cindex FRV Options | |
24729 | ||
24730 | @table @gcctabopt | |
d77de738 | 24731 | @opindex mgpr-32 |
ddf6fe37 | 24732 | @item -mgpr-32 |
d77de738 ML |
24733 | |
24734 | Only use the first 32 general-purpose registers. | |
24735 | ||
d77de738 | 24736 | @opindex mgpr-64 |
ddf6fe37 | 24737 | @item -mgpr-64 |
d77de738 ML |
24738 | |
24739 | Use all 64 general-purpose registers. | |
24740 | ||
d77de738 | 24741 | @opindex mfpr-32 |
ddf6fe37 | 24742 | @item -mfpr-32 |
d77de738 ML |
24743 | |
24744 | Use only the first 32 floating-point registers. | |
24745 | ||
d77de738 | 24746 | @opindex mfpr-64 |
ddf6fe37 | 24747 | @item -mfpr-64 |
d77de738 ML |
24748 | |
24749 | Use all 64 floating-point registers. | |
24750 | ||
d77de738 | 24751 | @opindex mhard-float |
ddf6fe37 | 24752 | @item -mhard-float |
d77de738 ML |
24753 | |
24754 | Use hardware instructions for floating-point operations. | |
24755 | ||
d77de738 | 24756 | @opindex msoft-float |
ddf6fe37 | 24757 | @item -msoft-float |
d77de738 ML |
24758 | |
24759 | Use library routines for floating-point operations. | |
24760 | ||
d77de738 | 24761 | @opindex malloc-cc |
ddf6fe37 | 24762 | @item -malloc-cc |
d77de738 ML |
24763 | |
24764 | Dynamically allocate condition code registers. | |
24765 | ||
d77de738 | 24766 | @opindex mfixed-cc |
ddf6fe37 | 24767 | @item -mfixed-cc |
d77de738 ML |
24768 | |
24769 | Do not try to dynamically allocate condition code registers, only | |
24770 | use @code{icc0} and @code{fcc0}. | |
24771 | ||
d77de738 | 24772 | @opindex mdword |
ddf6fe37 | 24773 | @item -mdword |
d77de738 ML |
24774 | |
24775 | Change ABI to use double word insns. | |
24776 | ||
d77de738 ML |
24777 | @opindex mno-dword |
24778 | @opindex mdword | |
ddf6fe37 | 24779 | @item -mno-dword |
d77de738 ML |
24780 | |
24781 | Do not use double word instructions. | |
24782 | ||
d77de738 | 24783 | @opindex mdouble |
ddf6fe37 | 24784 | @item -mdouble |
d77de738 ML |
24785 | |
24786 | Use floating-point double instructions. | |
24787 | ||
d77de738 | 24788 | @opindex mno-double |
ddf6fe37 | 24789 | @item -mno-double |
d77de738 ML |
24790 | |
24791 | Do not use floating-point double instructions. | |
24792 | ||
d77de738 | 24793 | @opindex mmedia |
ddf6fe37 | 24794 | @item -mmedia |
d77de738 ML |
24795 | |
24796 | Use media instructions. | |
24797 | ||
d77de738 | 24798 | @opindex mno-media |
ddf6fe37 | 24799 | @item -mno-media |
d77de738 ML |
24800 | |
24801 | Do not use media instructions. | |
24802 | ||
d77de738 | 24803 | @opindex mmuladd |
ddf6fe37 | 24804 | @item -mmuladd |
d77de738 ML |
24805 | |
24806 | Use multiply and add/subtract instructions. | |
24807 | ||
d77de738 | 24808 | @opindex mno-muladd |
ddf6fe37 | 24809 | @item -mno-muladd |
d77de738 ML |
24810 | |
24811 | Do not use multiply and add/subtract instructions. | |
24812 | ||
d77de738 | 24813 | @opindex mfdpic |
ddf6fe37 | 24814 | @item -mfdpic |
d77de738 ML |
24815 | |
24816 | Select the FDPIC ABI, which uses function descriptors to represent | |
24817 | pointers to functions. Without any PIC/PIE-related options, it | |
24818 | implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it | |
24819 | assumes GOT entries and small data are within a 12-bit range from the | |
24820 | GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets | |
24821 | are computed with 32 bits. | |
24822 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
24823 | ||
d77de738 | 24824 | @opindex minline-plt |
ddf6fe37 | 24825 | @item -minline-plt |
d77de738 ML |
24826 | |
24827 | Enable inlining of PLT entries in function calls to functions that are | |
24828 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
24829 | It's enabled by default if optimizing for speed and compiling for | |
24830 | shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an | |
24831 | optimization option such as @option{-O3} or above is present in the | |
24832 | command line. | |
24833 | ||
d77de738 | 24834 | @opindex mTLS |
ddf6fe37 | 24835 | @item -mTLS |
d77de738 ML |
24836 | |
24837 | Assume a large TLS segment when generating thread-local code. | |
24838 | ||
d77de738 | 24839 | @opindex mtls |
ddf6fe37 | 24840 | @item -mtls |
d77de738 ML |
24841 | |
24842 | Do not assume a large TLS segment when generating thread-local code. | |
24843 | ||
d77de738 | 24844 | @opindex mgprel-ro |
ddf6fe37 | 24845 | @item -mgprel-ro |
d77de738 ML |
24846 | |
24847 | Enable the use of @code{GPREL} relocations in the FDPIC ABI for data | |
24848 | that is known to be in read-only sections. It's enabled by default, | |
24849 | except for @option{-fpic} or @option{-fpie}: even though it may help | |
24850 | make the global offset table smaller, it trades 1 instruction for 4. | |
24851 | With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4, | |
24852 | one of which may be shared by multiple symbols, and it avoids the need | |
24853 | for a GOT entry for the referenced symbol, so it's more likely to be a | |
24854 | win. If it is not, @option{-mno-gprel-ro} can be used to disable it. | |
24855 | ||
d77de738 | 24856 | @opindex multilib-library-pic |
ddf6fe37 | 24857 | @item -multilib-library-pic |
d77de738 ML |
24858 | |
24859 | Link with the (library, not FD) pic libraries. It's implied by | |
24860 | @option{-mlibrary-pic}, as well as by @option{-fPIC} and | |
24861 | @option{-fpic} without @option{-mfdpic}. You should never have to use | |
24862 | it explicitly. | |
24863 | ||
d77de738 | 24864 | @opindex mlinked-fp |
ddf6fe37 | 24865 | @item -mlinked-fp |
d77de738 ML |
24866 | |
24867 | Follow the EABI requirement of always creating a frame pointer whenever | |
24868 | a stack frame is allocated. This option is enabled by default and can | |
24869 | be disabled with @option{-mno-linked-fp}. | |
24870 | ||
d77de738 | 24871 | @opindex mlong-calls |
ddf6fe37 | 24872 | @item -mlong-calls |
d77de738 ML |
24873 | |
24874 | Use indirect addressing to call functions outside the current | |
24875 | compilation unit. This allows the functions to be placed anywhere | |
24876 | within the 32-bit address space. | |
24877 | ||
d77de738 | 24878 | @opindex malign-labels |
ddf6fe37 | 24879 | @item -malign-labels |
d77de738 ML |
24880 | |
24881 | Try to align labels to an 8-byte boundary by inserting NOPs into the | |
24882 | previous packet. This option only has an effect when VLIW packing | |
24883 | is enabled. It doesn't create new packets; it merely adds NOPs to | |
24884 | existing ones. | |
24885 | ||
d77de738 | 24886 | @opindex mlibrary-pic |
ddf6fe37 | 24887 | @item -mlibrary-pic |
d77de738 ML |
24888 | |
24889 | Generate position-independent EABI code. | |
24890 | ||
d77de738 | 24891 | @opindex macc-4 |
ddf6fe37 | 24892 | @item -macc-4 |
d77de738 ML |
24893 | |
24894 | Use only the first four media accumulator registers. | |
24895 | ||
d77de738 | 24896 | @opindex macc-8 |
ddf6fe37 | 24897 | @item -macc-8 |
d77de738 ML |
24898 | |
24899 | Use all eight media accumulator registers. | |
24900 | ||
d77de738 | 24901 | @opindex mpack |
ddf6fe37 | 24902 | @item -mpack |
d77de738 ML |
24903 | |
24904 | Pack VLIW instructions. | |
24905 | ||
d77de738 | 24906 | @opindex mno-pack |
ddf6fe37 | 24907 | @item -mno-pack |
d77de738 ML |
24908 | |
24909 | Do not pack VLIW instructions. | |
24910 | ||
d77de738 | 24911 | @opindex mno-eflags |
ddf6fe37 | 24912 | @item -mno-eflags |
d77de738 ML |
24913 | |
24914 | Do not mark ABI switches in e_flags. | |
24915 | ||
d77de738 | 24916 | @opindex mcond-move |
ddf6fe37 | 24917 | @item -mcond-move |
d77de738 ML |
24918 | |
24919 | Enable the use of conditional-move instructions (default). | |
24920 | ||
24921 | This switch is mainly for debugging the compiler and will likely be removed | |
24922 | in a future version. | |
24923 | ||
d77de738 | 24924 | @opindex mno-cond-move |
ddf6fe37 | 24925 | @item -mno-cond-move |
d77de738 ML |
24926 | |
24927 | Disable the use of conditional-move instructions. | |
24928 | ||
24929 | This switch is mainly for debugging the compiler and will likely be removed | |
24930 | in a future version. | |
24931 | ||
d77de738 | 24932 | @opindex mscc |
ddf6fe37 | 24933 | @item -mscc |
d77de738 ML |
24934 | |
24935 | Enable the use of conditional set instructions (default). | |
24936 | ||
24937 | This switch is mainly for debugging the compiler and will likely be removed | |
24938 | in a future version. | |
24939 | ||
d77de738 | 24940 | @opindex mno-scc |
ddf6fe37 | 24941 | @item -mno-scc |
d77de738 ML |
24942 | |
24943 | Disable the use of conditional set instructions. | |
24944 | ||
24945 | This switch is mainly for debugging the compiler and will likely be removed | |
24946 | in a future version. | |
24947 | ||
d77de738 | 24948 | @opindex mcond-exec |
ddf6fe37 | 24949 | @item -mcond-exec |
d77de738 ML |
24950 | |
24951 | Enable the use of conditional execution (default). | |
24952 | ||
24953 | This switch is mainly for debugging the compiler and will likely be removed | |
24954 | in a future version. | |
24955 | ||
d77de738 | 24956 | @opindex mno-cond-exec |
ddf6fe37 | 24957 | @item -mno-cond-exec |
d77de738 ML |
24958 | |
24959 | Disable the use of conditional execution. | |
24960 | ||
24961 | This switch is mainly for debugging the compiler and will likely be removed | |
24962 | in a future version. | |
24963 | ||
d77de738 | 24964 | @opindex mvliw-branch |
ddf6fe37 | 24965 | @item -mvliw-branch |
d77de738 ML |
24966 | |
24967 | Run a pass to pack branches into VLIW instructions (default). | |
24968 | ||
24969 | This switch is mainly for debugging the compiler and will likely be removed | |
24970 | in a future version. | |
24971 | ||
d77de738 | 24972 | @opindex mno-vliw-branch |
ddf6fe37 | 24973 | @item -mno-vliw-branch |
d77de738 ML |
24974 | |
24975 | Do not run a pass to pack branches into VLIW instructions. | |
24976 | ||
24977 | This switch is mainly for debugging the compiler and will likely be removed | |
24978 | in a future version. | |
24979 | ||
d77de738 | 24980 | @opindex mmulti-cond-exec |
ddf6fe37 | 24981 | @item -mmulti-cond-exec |
d77de738 ML |
24982 | |
24983 | Enable optimization of @code{&&} and @code{||} in conditional execution | |
24984 | (default). | |
24985 | ||
24986 | This switch is mainly for debugging the compiler and will likely be removed | |
24987 | in a future version. | |
24988 | ||
d77de738 | 24989 | @opindex mno-multi-cond-exec |
ddf6fe37 | 24990 | @item -mno-multi-cond-exec |
d77de738 ML |
24991 | |
24992 | Disable optimization of @code{&&} and @code{||} in conditional execution. | |
24993 | ||
24994 | This switch is mainly for debugging the compiler and will likely be removed | |
24995 | in a future version. | |
24996 | ||
d77de738 | 24997 | @opindex mnested-cond-exec |
ddf6fe37 | 24998 | @item -mnested-cond-exec |
d77de738 ML |
24999 | |
25000 | Enable nested conditional execution optimizations (default). | |
25001 | ||
25002 | This switch is mainly for debugging the compiler and will likely be removed | |
25003 | in a future version. | |
25004 | ||
d77de738 | 25005 | @opindex mno-nested-cond-exec |
ddf6fe37 | 25006 | @item -mno-nested-cond-exec |
d77de738 ML |
25007 | |
25008 | Disable nested conditional execution optimizations. | |
25009 | ||
25010 | This switch is mainly for debugging the compiler and will likely be removed | |
25011 | in a future version. | |
25012 | ||
d77de738 | 25013 | @opindex moptimize-membar |
ddf6fe37 | 25014 | @item -moptimize-membar |
d77de738 ML |
25015 | |
25016 | This switch removes redundant @code{membar} instructions from the | |
25017 | compiler-generated code. It is enabled by default. | |
25018 | ||
d77de738 ML |
25019 | @opindex mno-optimize-membar |
25020 | @opindex moptimize-membar | |
ddf6fe37 | 25021 | @item -mno-optimize-membar |
d77de738 ML |
25022 | |
25023 | This switch disables the automatic removal of redundant @code{membar} | |
25024 | instructions from the generated code. | |
25025 | ||
d77de738 | 25026 | @opindex mtomcat-stats |
ddf6fe37 | 25027 | @item -mtomcat-stats |
d77de738 ML |
25028 | |
25029 | Cause gas to print out tomcat statistics. | |
25030 | ||
d77de738 | 25031 | @opindex mcpu |
ddf6fe37 | 25032 | @item -mcpu=@var{cpu} |
d77de738 ML |
25033 | |
25034 | Select the processor type for which to generate code. Possible values are | |
25035 | @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450}, | |
25036 | @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}. | |
25037 | ||
25038 | @end table | |
25039 | ||
25040 | @node GNU/Linux Options | |
25041 | @subsection GNU/Linux Options | |
25042 | ||
25043 | These @samp{-m} options are defined for GNU/Linux targets: | |
25044 | ||
25045 | @table @gcctabopt | |
d77de738 | 25046 | @opindex mglibc |
ddf6fe37 | 25047 | @item -mglibc |
d77de738 ML |
25048 | Use the GNU C library. This is the default except |
25049 | on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and | |
25050 | @samp{*-*-linux-*android*} targets. | |
25051 | ||
d77de738 | 25052 | @opindex muclibc |
ddf6fe37 | 25053 | @item -muclibc |
d77de738 ML |
25054 | Use uClibc C library. This is the default on |
25055 | @samp{*-*-linux-*uclibc*} targets. | |
25056 | ||
d77de738 | 25057 | @opindex mmusl |
ddf6fe37 | 25058 | @item -mmusl |
d77de738 ML |
25059 | Use the musl C library. This is the default on |
25060 | @samp{*-*-linux-*musl*} targets. | |
25061 | ||
d77de738 | 25062 | @opindex mbionic |
ddf6fe37 | 25063 | @item -mbionic |
d77de738 ML |
25064 | Use Bionic C library. This is the default on |
25065 | @samp{*-*-linux-*android*} targets. | |
25066 | ||
d77de738 | 25067 | @opindex mandroid |
ddf6fe37 | 25068 | @item -mandroid |
d77de738 ML |
25069 | Compile code compatible with Android platform. This is the default on |
25070 | @samp{*-*-linux-*android*} targets. | |
25071 | ||
25072 | When compiling, this option enables @option{-mbionic}, @option{-fPIC}, | |
25073 | @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking, | |
25074 | this option makes the GCC driver pass Android-specific options to the linker. | |
25075 | Finally, this option causes the preprocessor macro @code{__ANDROID__} | |
25076 | to be defined. | |
25077 | ||
d77de738 | 25078 | @opindex tno-android-cc |
ddf6fe37 | 25079 | @item -tno-android-cc |
d77de738 ML |
25080 | Disable compilation effects of @option{-mandroid}, i.e., do not enable |
25081 | @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and | |
25082 | @option{-fno-rtti} by default. | |
25083 | ||
d77de738 | 25084 | @opindex tno-android-ld |
ddf6fe37 | 25085 | @item -tno-android-ld |
d77de738 ML |
25086 | Disable linking effects of @option{-mandroid}, i.e., pass standard Linux |
25087 | linking options to the linker. | |
25088 | ||
25089 | @end table | |
25090 | ||
25091 | @node H8/300 Options | |
25092 | @subsection H8/300 Options | |
25093 | ||
25094 | These @samp{-m} options are defined for the H8/300 implementations: | |
25095 | ||
25096 | @table @gcctabopt | |
d77de738 | 25097 | @opindex mrelax |
ddf6fe37 | 25098 | @item -mrelax |
d77de738 ML |
25099 | Shorten some address references at link time, when possible; uses the |
25100 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
25101 | ld, Using ld}, for a fuller description. | |
25102 | ||
d77de738 | 25103 | @opindex mh |
ddf6fe37 | 25104 | @item -mh |
d77de738 ML |
25105 | Generate code for the H8/300H@. |
25106 | ||
d77de738 | 25107 | @opindex ms |
ddf6fe37 | 25108 | @item -ms |
d77de738 ML |
25109 | Generate code for the H8S@. |
25110 | ||
d77de738 | 25111 | @opindex mn |
ddf6fe37 | 25112 | @item -mn |
d77de738 ML |
25113 | Generate code for the H8S and H8/300H in the normal mode. This switch |
25114 | must be used either with @option{-mh} or @option{-ms}. | |
25115 | ||
d77de738 | 25116 | @opindex ms2600 |
ddf6fe37 | 25117 | @item -ms2600 |
d77de738 ML |
25118 | Generate code for the H8S/2600. This switch must be used with @option{-ms}. |
25119 | ||
d77de738 | 25120 | @opindex mexr |
ddf6fe37 | 25121 | @item -mexr |
d77de738 ML |
25122 | Extended registers are stored on stack before execution of function |
25123 | with monitor attribute. Default option is @option{-mexr}. | |
25124 | This option is valid only for H8S targets. | |
25125 | ||
d77de738 ML |
25126 | @opindex mno-exr |
25127 | @opindex mexr | |
ddf6fe37 | 25128 | @item -mno-exr |
d77de738 ML |
25129 | Extended registers are not stored on stack before execution of function |
25130 | with monitor attribute. Default option is @option{-mno-exr}. | |
25131 | This option is valid only for H8S targets. | |
25132 | ||
d77de738 | 25133 | @opindex mint32 |
ddf6fe37 | 25134 | @item -mint32 |
d77de738 ML |
25135 | Make @code{int} data 32 bits by default. |
25136 | ||
d77de738 | 25137 | @opindex malign-300 |
ddf6fe37 | 25138 | @item -malign-300 |
d77de738 ML |
25139 | On the H8/300H and H8S, use the same alignment rules as for the H8/300. |
25140 | The default for the H8/300H and H8S is to align longs and floats on | |
25141 | 4-byte boundaries. | |
25142 | @option{-malign-300} causes them to be aligned on 2-byte boundaries. | |
25143 | This option has no effect on the H8/300. | |
25144 | @end table | |
25145 | ||
25146 | @node HPPA Options | |
25147 | @subsection HPPA Options | |
25148 | @cindex HPPA Options | |
25149 | ||
25150 | These @samp{-m} options are defined for the HPPA family of computers: | |
25151 | ||
25152 | @table @gcctabopt | |
d77de738 | 25153 | @opindex march |
ddf6fe37 | 25154 | @item -march=@var{architecture-type} |
d77de738 ML |
25155 | Generate code for the specified architecture. The choices for |
25156 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA | |
25157 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to | |
25158 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
25159 | architecture option for your machine. Code compiled for lower numbered | |
25160 | architectures runs on higher numbered architectures, but not the | |
25161 | other way around. | |
25162 | ||
d77de738 ML |
25163 | @opindex mpa-risc-1-0 |
25164 | @opindex mpa-risc-1-1 | |
25165 | @opindex mpa-risc-2-0 | |
ddf6fe37 AA |
25166 | @item -mpa-risc-1-0 |
25167 | @itemx -mpa-risc-1-1 | |
25168 | @itemx -mpa-risc-2-0 | |
d77de738 ML |
25169 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
25170 | ||
cf467fb9 JDA |
25171 | @opindex matomic-libcalls |
25172 | @opindex mno-atomic-libcalls | |
ddf6fe37 | 25173 | @item -matomic-libcalls |
cf467fb9 JDA |
25174 | Generate libcalls for atomic loads and stores when sync libcalls are disabled. |
25175 | This option is enabled by default. It only affects the generation of | |
25176 | atomic libcalls by the HPPA backend. | |
25177 | ||
25178 | Both the sync and @file{libatomic} libcall implementations use locking. | |
25179 | As a result, processor stores are not atomic with respect to other | |
25180 | atomic operations. Processor loads up to DImode are atomic with | |
25181 | respect to other atomic operations provided they are implemented as | |
25182 | a single access. | |
25183 | ||
25184 | The PA-RISC architecture does not support any atomic operations in | |
25185 | hardware except for the @code{ldcw} instruction. Thus, all atomic | |
25186 | support is implemented using sync and atomic libcalls. Sync libcall | |
25187 | support is in @file{libgcc.a}. Atomic libcall support is in | |
25188 | @file{libatomic}. | |
25189 | ||
25190 | This option generates @code{__atomic_exchange} calls for atomic stores. | |
25191 | It also provides special handling for atomic DImode accesses on 32-bit | |
25192 | targets. | |
25193 | ||
cf467fb9 | 25194 | @opindex mbig-switch |
ddf6fe37 | 25195 | @item -mbig-switch |
cf467fb9 JDA |
25196 | Does nothing. Preserved for backward compatibility. |
25197 | ||
d77de738 | 25198 | @opindex mcaller-copies |
ddf6fe37 | 25199 | @item -mcaller-copies |
d77de738 ML |
25200 | The caller copies function arguments passed by hidden reference. This |
25201 | option should be used with care as it is not compatible with the default | |
25202 | 32-bit runtime. However, only aggregates larger than eight bytes are | |
25203 | passed by hidden reference and the option provides better compatibility | |
25204 | with OpenMP. | |
25205 | ||
cf467fb9 | 25206 | @opindex mcoherent-ldcw |
ddf6fe37 | 25207 | @item -mcoherent-ldcw |
cf467fb9 | 25208 | Use ldcw/ldcd coherent cache-control hint. |
d77de738 | 25209 | |
d77de738 | 25210 | @opindex mdisable-fpregs |
ddf6fe37 | 25211 | @item -mdisable-fpregs |
cf467fb9 | 25212 | Disable floating-point registers. Equivalent to @code{-msoft-float}. |
d77de738 | 25213 | |
d77de738 | 25214 | @opindex mdisable-indexing |
ddf6fe37 | 25215 | @item -mdisable-indexing |
d77de738 ML |
25216 | Prevent the compiler from using indexing address modes. This avoids some |
25217 | rather obscure problems when compiling MIG generated code under MACH@. | |
25218 | ||
d77de738 | 25219 | @opindex mfast-indirect-calls |
ddf6fe37 | 25220 | @item -mfast-indirect-calls |
d77de738 ML |
25221 | Generate code that assumes calls never cross space boundaries. This |
25222 | allows GCC to emit code that performs faster indirect calls. | |
25223 | ||
25224 | This option does not work in the presence of shared libraries or nested | |
25225 | functions. | |
25226 | ||
d77de738 | 25227 | @opindex mfixed-range |
ddf6fe37 | 25228 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25229 | Generate code treating the given register range as fixed registers. |
25230 | A fixed register is one that the register allocator cannot use. This is | |
25231 | useful when compiling kernel code. A register range is specified as | |
25232 | two registers separated by a dash. Multiple register ranges can be | |
25233 | specified separated by a comma. | |
25234 | ||
d77de738 | 25235 | @opindex mgas |
ddf6fe37 | 25236 | @item -mgas |
d77de738 ML |
25237 | Enable the use of assembler directives only GAS understands. |
25238 | ||
d77de738 | 25239 | @opindex mgnu-ld |
ddf6fe37 | 25240 | @item -mgnu-ld |
d77de738 ML |
25241 | Use options specific to GNU @command{ld}. |
25242 | This passes @option{-shared} to @command{ld} when | |
25243 | building a shared library. It is the default when GCC is configured, | |
25244 | explicitly or implicitly, with the GNU linker. This option does not | |
25245 | affect which @command{ld} is called; it only changes what parameters | |
25246 | are passed to that @command{ld}. | |
25247 | The @command{ld} that is called is determined by the | |
25248 | @option{--with-ld} configure option, GCC's program search path, and | |
25249 | finally by the user's @env{PATH}. The linker used by GCC can be printed | |
25250 | using @samp{which `gcc -print-prog-name=ld`}. This option is only available | |
25251 | on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25252 | ||
d77de738 | 25253 | @opindex mhp-ld |
ddf6fe37 | 25254 | @item -mhp-ld |
d77de738 ML |
25255 | Use options specific to HP @command{ld}. |
25256 | This passes @option{-b} to @command{ld} when building | |
25257 | a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all | |
25258 | links. It is the default when GCC is configured, explicitly or | |
25259 | implicitly, with the HP linker. This option does not affect | |
25260 | which @command{ld} is called; it only changes what parameters are passed to that | |
25261 | @command{ld}. | |
25262 | The @command{ld} that is called is determined by the @option{--with-ld} | |
25263 | configure option, GCC's program search path, and finally by the user's | |
25264 | @env{PATH}. The linker used by GCC can be printed using @samp{which | |
25265 | `gcc -print-prog-name=ld`}. This option is only available on the 64-bit | |
25266 | HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25267 | ||
cf467fb9 | 25268 | @opindex mlinker-opt |
ddf6fe37 | 25269 | @item -mlinker-opt |
cf467fb9 JDA |
25270 | Enable the optimization pass in the HP-UX linker. Note this makes symbolic |
25271 | debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 | |
25272 | linkers in which they give bogus error messages when linking some programs. | |
25273 | ||
d77de738 ML |
25274 | @opindex mno-long-calls |
25275 | @opindex mlong-calls | |
ddf6fe37 | 25276 | @item -mlong-calls |
d77de738 ML |
25277 | Generate code that uses long call sequences. This ensures that a call |
25278 | is always able to reach linker generated stubs. The default is to generate | |
25279 | long calls only when the distance from the call site to the beginning | |
25280 | of the function or translation unit, as the case may be, exceeds a | |
25281 | predefined limit set by the branch type being used. The limits for | |
25282 | normal calls are 7,600,000 and 240,000 bytes, respectively for the | |
25283 | PA 2.0 and PA 1.X architectures. Sibcalls are always limited at | |
25284 | 240,000 bytes. | |
25285 | ||
25286 | Distances are measured from the beginning of functions when using the | |
25287 | @option{-ffunction-sections} option, or when using the @option{-mgas} | |
25288 | and @option{-mno-portable-runtime} options together under HP-UX with | |
25289 | the SOM linker. | |
25290 | ||
25291 | It is normally not desirable to use this option as it degrades | |
25292 | performance. However, it may be useful in large applications, | |
25293 | particularly when partial linking is used to build the application. | |
25294 | ||
25295 | The types of long calls used depends on the capabilities of the | |
25296 | assembler and linker, and the type of code being generated. The | |
25297 | impact on systems that support long absolute calls, and long pic | |
25298 | symbol-difference or pc-relative calls should be relatively small. | |
25299 | However, an indirect call is used on 32-bit ELF systems in pic code | |
25300 | and it is quite long. | |
25301 | ||
cf467fb9 | 25302 | @opindex mlong-load-store |
ddf6fe37 | 25303 | @item -mlong-load-store |
cf467fb9 JDA |
25304 | Generate 3-instruction load and store sequences as sometimes required by |
25305 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
25306 | the HP compilers. | |
25307 | ||
cf467fb9 | 25308 | @opindex mjump-in-delay |
ddf6fe37 | 25309 | @item -mjump-in-delay |
cf467fb9 JDA |
25310 | This option is ignored and provided for compatibility purposes only. |
25311 | ||
cf467fb9 JDA |
25312 | @opindex mno-space-regs |
25313 | @opindex mspace-regs | |
ddf6fe37 | 25314 | @item -mno-space-regs |
cf467fb9 JDA |
25315 | Generate code that assumes the target has no space registers. This allows |
25316 | GCC to generate faster indirect calls and use unscaled index address modes. | |
25317 | ||
25318 | Such code is suitable for level 0 PA systems and kernels. | |
25319 | ||
cf467fb9 | 25320 | @opindex mordered |
ddf6fe37 | 25321 | @item -mordered |
cf467fb9 JDA |
25322 | Assume memory references are ordered and barriers are not needed. |
25323 | ||
cf467fb9 | 25324 | @opindex mportable-runtime |
ddf6fe37 | 25325 | @item -mportable-runtime |
cf467fb9 JDA |
25326 | Use the portable calling conventions proposed by HP for ELF systems. |
25327 | ||
cf467fb9 | 25328 | @opindex mschedule |
ddf6fe37 | 25329 | @item -mschedule=@var{cpu-type} |
cf467fb9 JDA |
25330 | Schedule code according to the constraints for the machine type |
25331 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} | |
25332 | @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer | |
25333 | to @file{/usr/lib/sched.models} on an HP-UX system to determine the | |
25334 | proper scheduling option for your machine. The default scheduling is | |
25335 | @samp{8000}. | |
25336 | ||
cf467fb9 | 25337 | @opindex msio |
ddf6fe37 | 25338 | @item -msio |
cf467fb9 JDA |
25339 | Generate the predefine, @code{_SIO}, for server IO@. The default is |
25340 | @option{-mwsio}. This generates the predefines, @code{__hp9000s700}, | |
25341 | @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These | |
25342 | options are available under HP-UX and HI-UX@. | |
25343 | ||
cf467fb9 | 25344 | @opindex msoft-float |
ddf6fe37 | 25345 | @item -msoft-float |
cf467fb9 JDA |
25346 | Generate output containing library calls for floating point. |
25347 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
25348 | targets. Normally the facilities of the machine's usual C compiler are | |
25349 | used, but this cannot be done directly in cross-compilation. You must make | |
25350 | your own arrangements to provide suitable library functions for | |
25351 | cross-compilation. | |
25352 | ||
25353 | @option{-msoft-float} changes the calling convention in the output file; | |
25354 | therefore, it is only useful if you compile @emph{all} of a program with | |
25355 | this option. In particular, you need to compile @file{libgcc.a}, the | |
25356 | library that comes with GCC, with @option{-msoft-float} in order for | |
25357 | this to work. | |
25358 | ||
cf467fb9 | 25359 | @opindex msoft-mult |
ddf6fe37 | 25360 | @item -msoft-mult |
cf467fb9 JDA |
25361 | Use software integer multiplication. |
25362 | ||
25363 | This disables the use of the @code{xmpyu} instruction. | |
25364 | ||
d77de738 | 25365 | @opindex march |
ddf6fe37 | 25366 | @item -munix=@var{unix-std} |
d77de738 ML |
25367 | Generate compiler predefines and select a startfile for the specified |
25368 | UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95} | |
25369 | and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95} | |
25370 | is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX | |
25371 | 11.11 and later. The default values are @samp{93} for HP-UX 10.00, | |
25372 | @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11 | |
25373 | and later. | |
25374 | ||
25375 | @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4. | |
25376 | @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX} | |
25377 | and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}. | |
25378 | @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX}, | |
25379 | @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and | |
25380 | @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}. | |
25381 | ||
25382 | It is @emph{important} to note that this option changes the interfaces | |
25383 | for various library routines. It also affects the operational behavior | |
25384 | of the C library. Thus, @emph{extreme} care is needed in using this | |
25385 | option. | |
25386 | ||
25387 | Library code that is intended to operate with more than one UNIX | |
25388 | standard must test, set and restore the variable @code{__xpg4_extended_mask} | |
25389 | as appropriate. Most GNU software doesn't provide this capability. | |
25390 | ||
d77de738 | 25391 | @opindex nolibdld |
ddf6fe37 | 25392 | @item -nolibdld |
d77de738 ML |
25393 | Suppress the generation of link options to search libdld.sl when the |
25394 | @option{-static} option is specified on HP-UX 10 and later. | |
25395 | ||
d77de738 | 25396 | @opindex static |
ddf6fe37 | 25397 | @item -static |
d77de738 ML |
25398 | The HP-UX implementation of setlocale in libc has a dependency on |
25399 | libdld.sl. There isn't an archive version of libdld.sl. Thus, | |
25400 | when the @option{-static} option is specified, special link options | |
25401 | are needed to resolve this dependency. | |
25402 | ||
25403 | On HP-UX 10 and later, the GCC driver adds the necessary options to | |
25404 | link with libdld.sl when the @option{-static} option is specified. | |
25405 | This causes the resulting binary to be dynamic. On the 64-bit port, | |
25406 | the linkers generate dynamic binaries by default in any case. The | |
25407 | @option{-nolibdld} option can be used to prevent the GCC driver from | |
25408 | adding these link options. | |
25409 | ||
d77de738 | 25410 | @opindex threads |
ddf6fe37 | 25411 | @item -threads |
d77de738 ML |
25412 | Add support for multithreading with the @dfn{dce thread} library |
25413 | under HP-UX@. This option sets flags for both the preprocessor and | |
25414 | linker. | |
25415 | @end table | |
25416 | ||
25417 | @node IA-64 Options | |
25418 | @subsection IA-64 Options | |
25419 | @cindex IA-64 Options | |
25420 | ||
25421 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
25422 | ||
25423 | @table @gcctabopt | |
d77de738 | 25424 | @opindex mbig-endian |
ddf6fe37 | 25425 | @item -mbig-endian |
d77de738 ML |
25426 | Generate code for a big-endian target. This is the default for HP-UX@. |
25427 | ||
d77de738 | 25428 | @opindex mlittle-endian |
ddf6fe37 | 25429 | @item -mlittle-endian |
d77de738 ML |
25430 | Generate code for a little-endian target. This is the default for AIX5 |
25431 | and GNU/Linux. | |
25432 | ||
d77de738 ML |
25433 | @opindex mgnu-as |
25434 | @opindex mno-gnu-as | |
ddf6fe37 AA |
25435 | @item -mgnu-as |
25436 | @itemx -mno-gnu-as | |
d77de738 ML |
25437 | Generate (or don't) code for the GNU assembler. This is the default. |
25438 | @c Also, this is the default if the configure option @option{--with-gnu-as} | |
25439 | @c is used. | |
25440 | ||
d77de738 ML |
25441 | @opindex mgnu-ld |
25442 | @opindex mno-gnu-ld | |
ddf6fe37 AA |
25443 | @item -mgnu-ld |
25444 | @itemx -mno-gnu-ld | |
d77de738 ML |
25445 | Generate (or don't) code for the GNU linker. This is the default. |
25446 | @c Also, this is the default if the configure option @option{--with-gnu-ld} | |
25447 | @c is used. | |
25448 | ||
d77de738 | 25449 | @opindex mno-pic |
ddf6fe37 | 25450 | @item -mno-pic |
d77de738 ML |
25451 | Generate code that does not use a global pointer register. The result |
25452 | is not position independent code, and violates the IA-64 ABI@. | |
25453 | ||
d77de738 ML |
25454 | @opindex mvolatile-asm-stop |
25455 | @opindex mno-volatile-asm-stop | |
ddf6fe37 AA |
25456 | @item -mvolatile-asm-stop |
25457 | @itemx -mno-volatile-asm-stop | |
d77de738 ML |
25458 | Generate (or don't) a stop bit immediately before and after volatile asm |
25459 | statements. | |
25460 | ||
d77de738 ML |
25461 | @opindex mregister-names |
25462 | @opindex mno-register-names | |
ddf6fe37 AA |
25463 | @item -mregister-names |
25464 | @itemx -mno-register-names | |
d77de738 ML |
25465 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
25466 | the stacked registers. This may make assembler output more readable. | |
25467 | ||
d77de738 ML |
25468 | @opindex mno-sdata |
25469 | @opindex msdata | |
ddf6fe37 AA |
25470 | @item -mno-sdata |
25471 | @itemx -msdata | |
d77de738 ML |
25472 | Disable (or enable) optimizations that use the small data section. This may |
25473 | be useful for working around optimizer bugs. | |
25474 | ||
d77de738 | 25475 | @opindex mconstant-gp |
ddf6fe37 | 25476 | @item -mconstant-gp |
d77de738 ML |
25477 | Generate code that uses a single constant global pointer value. This is |
25478 | useful when compiling kernel code. | |
25479 | ||
d77de738 | 25480 | @opindex mauto-pic |
ddf6fe37 | 25481 | @item -mauto-pic |
d77de738 ML |
25482 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
25483 | This is useful when compiling firmware code. | |
25484 | ||
d77de738 | 25485 | @opindex minline-float-divide-min-latency |
ddf6fe37 | 25486 | @item -minline-float-divide-min-latency |
d77de738 ML |
25487 | Generate code for inline divides of floating-point values |
25488 | using the minimum latency algorithm. | |
25489 | ||
d77de738 | 25490 | @opindex minline-float-divide-max-throughput |
ddf6fe37 | 25491 | @item -minline-float-divide-max-throughput |
d77de738 ML |
25492 | Generate code for inline divides of floating-point values |
25493 | using the maximum throughput algorithm. | |
25494 | ||
d77de738 | 25495 | @opindex mno-inline-float-divide |
ddf6fe37 | 25496 | @item -mno-inline-float-divide |
d77de738 ML |
25497 | Do not generate inline code for divides of floating-point values. |
25498 | ||
d77de738 | 25499 | @opindex minline-int-divide-min-latency |
ddf6fe37 | 25500 | @item -minline-int-divide-min-latency |
d77de738 ML |
25501 | Generate code for inline divides of integer values |
25502 | using the minimum latency algorithm. | |
25503 | ||
d77de738 | 25504 | @opindex minline-int-divide-max-throughput |
ddf6fe37 | 25505 | @item -minline-int-divide-max-throughput |
d77de738 ML |
25506 | Generate code for inline divides of integer values |
25507 | using the maximum throughput algorithm. | |
25508 | ||
d77de738 ML |
25509 | @opindex mno-inline-int-divide |
25510 | @opindex minline-int-divide | |
ddf6fe37 | 25511 | @item -mno-inline-int-divide |
d77de738 ML |
25512 | Do not generate inline code for divides of integer values. |
25513 | ||
d77de738 | 25514 | @opindex minline-sqrt-min-latency |
ddf6fe37 | 25515 | @item -minline-sqrt-min-latency |
d77de738 ML |
25516 | Generate code for inline square roots |
25517 | using the minimum latency algorithm. | |
25518 | ||
d77de738 | 25519 | @opindex minline-sqrt-max-throughput |
ddf6fe37 | 25520 | @item -minline-sqrt-max-throughput |
d77de738 ML |
25521 | Generate code for inline square roots |
25522 | using the maximum throughput algorithm. | |
25523 | ||
d77de738 | 25524 | @opindex mno-inline-sqrt |
ddf6fe37 | 25525 | @item -mno-inline-sqrt |
d77de738 ML |
25526 | Do not generate inline code for @code{sqrt}. |
25527 | ||
d77de738 ML |
25528 | @opindex mfused-madd |
25529 | @opindex mno-fused-madd | |
ddf6fe37 AA |
25530 | @item -mfused-madd |
25531 | @itemx -mno-fused-madd | |
d77de738 ML |
25532 | Do (don't) generate code that uses the fused multiply/add or multiply/subtract |
25533 | instructions. The default is to use these instructions. | |
25534 | ||
d77de738 ML |
25535 | @opindex mno-dwarf2-asm |
25536 | @opindex mdwarf2-asm | |
ddf6fe37 AA |
25537 | @item -mno-dwarf2-asm |
25538 | @itemx -mdwarf2-asm | |
d77de738 ML |
25539 | Don't (or do) generate assembler code for the DWARF line number debugging |
25540 | info. This may be useful when not using the GNU assembler. | |
25541 | ||
d77de738 ML |
25542 | @opindex mearly-stop-bits |
25543 | @opindex mno-early-stop-bits | |
ddf6fe37 AA |
25544 | @item -mearly-stop-bits |
25545 | @itemx -mno-early-stop-bits | |
d77de738 ML |
25546 | Allow stop bits to be placed earlier than immediately preceding the |
25547 | instruction that triggered the stop bit. This can improve instruction | |
25548 | scheduling, but does not always do so. | |
25549 | ||
d77de738 | 25550 | @opindex mfixed-range |
ddf6fe37 | 25551 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25552 | Generate code treating the given register range as fixed registers. |
25553 | A fixed register is one that the register allocator cannot use. This is | |
25554 | useful when compiling kernel code. A register range is specified as | |
25555 | two registers separated by a dash. Multiple register ranges can be | |
25556 | specified separated by a comma. | |
25557 | ||
d77de738 | 25558 | @opindex mtls-size |
ddf6fe37 | 25559 | @item -mtls-size=@var{tls-size} |
d77de738 ML |
25560 | Specify bit size of immediate TLS offsets. Valid values are 14, 22, and |
25561 | 64. | |
25562 | ||
d77de738 | 25563 | @opindex mtune |
ddf6fe37 | 25564 | @item -mtune=@var{cpu-type} |
d77de738 ML |
25565 | Tune the instruction scheduling for a particular CPU, Valid values are |
25566 | @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2}, | |
25567 | and @samp{mckinley}. | |
25568 | ||
d77de738 ML |
25569 | @opindex milp32 |
25570 | @opindex mlp64 | |
ddf6fe37 AA |
25571 | @item -milp32 |
25572 | @itemx -mlp64 | |
d77de738 ML |
25573 | Generate code for a 32-bit or 64-bit environment. |
25574 | The 32-bit environment sets int, long and pointer to 32 bits. | |
25575 | The 64-bit environment sets int to 32 bits and long and pointer | |
25576 | to 64 bits. These are HP-UX specific flags. | |
25577 | ||
d77de738 ML |
25578 | @opindex mno-sched-br-data-spec |
25579 | @opindex msched-br-data-spec | |
ddf6fe37 AA |
25580 | @item -mno-sched-br-data-spec |
25581 | @itemx -msched-br-data-spec | |
d77de738 ML |
25582 | (Dis/En)able data speculative scheduling before reload. |
25583 | This results in generation of @code{ld.a} instructions and | |
25584 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
25585 | The default setting is disabled. | |
25586 | ||
d77de738 ML |
25587 | @opindex msched-ar-data-spec |
25588 | @opindex mno-sched-ar-data-spec | |
ddf6fe37 AA |
25589 | @item -msched-ar-data-spec |
25590 | @itemx -mno-sched-ar-data-spec | |
d77de738 ML |
25591 | (En/Dis)able data speculative scheduling after reload. |
25592 | This results in generation of @code{ld.a} instructions and | |
25593 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
25594 | The default setting is enabled. | |
25595 | ||
d77de738 ML |
25596 | @opindex mno-sched-control-spec |
25597 | @opindex msched-control-spec | |
ddf6fe37 AA |
25598 | @item -mno-sched-control-spec |
25599 | @itemx -msched-control-spec | |
d77de738 ML |
25600 | (Dis/En)able control speculative scheduling. This feature is |
25601 | available only during region scheduling (i.e.@: before reload). | |
25602 | This results in generation of the @code{ld.s} instructions and | |
25603 | the corresponding check instructions @code{chk.s}. | |
25604 | The default setting is disabled. | |
25605 | ||
d77de738 ML |
25606 | @opindex msched-br-in-data-spec |
25607 | @opindex mno-sched-br-in-data-spec | |
ddf6fe37 AA |
25608 | @item -msched-br-in-data-spec |
25609 | @itemx -mno-sched-br-in-data-spec | |
d77de738 ML |
25610 | (En/Dis)able speculative scheduling of the instructions that |
25611 | are dependent on the data speculative loads before reload. | |
25612 | This is effective only with @option{-msched-br-data-spec} enabled. | |
25613 | The default setting is enabled. | |
25614 | ||
d77de738 ML |
25615 | @opindex msched-ar-in-data-spec |
25616 | @opindex mno-sched-ar-in-data-spec | |
ddf6fe37 AA |
25617 | @item -msched-ar-in-data-spec |
25618 | @itemx -mno-sched-ar-in-data-spec | |
d77de738 ML |
25619 | (En/Dis)able speculative scheduling of the instructions that |
25620 | are dependent on the data speculative loads after reload. | |
25621 | This is effective only with @option{-msched-ar-data-spec} enabled. | |
25622 | The default setting is enabled. | |
25623 | ||
d77de738 ML |
25624 | @opindex msched-in-control-spec |
25625 | @opindex mno-sched-in-control-spec | |
ddf6fe37 AA |
25626 | @item -msched-in-control-spec |
25627 | @itemx -mno-sched-in-control-spec | |
d77de738 ML |
25628 | (En/Dis)able speculative scheduling of the instructions that |
25629 | are dependent on the control speculative loads. | |
25630 | This is effective only with @option{-msched-control-spec} enabled. | |
25631 | The default setting is enabled. | |
25632 | ||
d77de738 ML |
25633 | @opindex mno-sched-prefer-non-data-spec-insns |
25634 | @opindex msched-prefer-non-data-spec-insns | |
ddf6fe37 AA |
25635 | @item -mno-sched-prefer-non-data-spec-insns |
25636 | @itemx -msched-prefer-non-data-spec-insns | |
d77de738 ML |
25637 | If enabled, data-speculative instructions are chosen for schedule |
25638 | only if there are no other choices at the moment. This makes | |
25639 | the use of the data speculation much more conservative. | |
25640 | The default setting is disabled. | |
25641 | ||
d77de738 ML |
25642 | @opindex mno-sched-prefer-non-control-spec-insns |
25643 | @opindex msched-prefer-non-control-spec-insns | |
ddf6fe37 AA |
25644 | @item -mno-sched-prefer-non-control-spec-insns |
25645 | @itemx -msched-prefer-non-control-spec-insns | |
d77de738 ML |
25646 | If enabled, control-speculative instructions are chosen for schedule |
25647 | only if there are no other choices at the moment. This makes | |
25648 | the use of the control speculation much more conservative. | |
25649 | The default setting is disabled. | |
25650 | ||
d77de738 ML |
25651 | @opindex mno-sched-count-spec-in-critical-path |
25652 | @opindex msched-count-spec-in-critical-path | |
ddf6fe37 AA |
25653 | @item -mno-sched-count-spec-in-critical-path |
25654 | @itemx -msched-count-spec-in-critical-path | |
d77de738 ML |
25655 | If enabled, speculative dependencies are considered during |
25656 | computation of the instructions priorities. This makes the use of the | |
25657 | speculation a bit more conservative. | |
25658 | The default setting is disabled. | |
25659 | ||
d77de738 | 25660 | @opindex msched-spec-ldc |
ddf6fe37 | 25661 | @item -msched-spec-ldc |
d77de738 ML |
25662 | Use a simple data speculation check. This option is on by default. |
25663 | ||
d77de738 | 25664 | @opindex msched-spec-ldc |
ddf6fe37 | 25665 | @item -msched-control-spec-ldc |
d77de738 ML |
25666 | Use a simple check for control speculation. This option is on by default. |
25667 | ||
d77de738 | 25668 | @opindex msched-stop-bits-after-every-cycle |
ddf6fe37 | 25669 | @item -msched-stop-bits-after-every-cycle |
d77de738 ML |
25670 | Place a stop bit after every cycle when scheduling. This option is on |
25671 | by default. | |
25672 | ||
d77de738 | 25673 | @opindex msched-fp-mem-deps-zero-cost |
ddf6fe37 | 25674 | @item -msched-fp-mem-deps-zero-cost |
d77de738 ML |
25675 | Assume that floating-point stores and loads are not likely to cause a conflict |
25676 | when placed into the same instruction group. This option is disabled by | |
25677 | default. | |
25678 | ||
d77de738 | 25679 | @opindex msel-sched-dont-check-control-spec |
ddf6fe37 | 25680 | @item -msel-sched-dont-check-control-spec |
d77de738 ML |
25681 | Generate checks for control speculation in selective scheduling. |
25682 | This flag is disabled by default. | |
25683 | ||
d77de738 | 25684 | @opindex msched-max-memory-insns |
ddf6fe37 | 25685 | @item -msched-max-memory-insns=@var{max-insns} |
d77de738 ML |
25686 | Limit on the number of memory insns per instruction group, giving lower |
25687 | priority to subsequent memory insns attempting to schedule in the same | |
25688 | instruction group. Frequently useful to prevent cache bank conflicts. | |
25689 | The default value is 1. | |
25690 | ||
d77de738 | 25691 | @opindex msched-max-memory-insns-hard-limit |
ddf6fe37 | 25692 | @item -msched-max-memory-insns-hard-limit |
d77de738 ML |
25693 | Makes the limit specified by @option{msched-max-memory-insns} a hard limit, |
25694 | disallowing more than that number in an instruction group. | |
25695 | Otherwise, the limit is ``soft'', meaning that non-memory operations | |
25696 | are preferred when the limit is reached, but memory operations may still | |
25697 | be scheduled. | |
25698 | ||
25699 | @end table | |
25700 | ||
25701 | @node LM32 Options | |
25702 | @subsection LM32 Options | |
25703 | @cindex LM32 options | |
25704 | ||
25705 | These @option{-m} options are defined for the LatticeMico32 architecture: | |
25706 | ||
25707 | @table @gcctabopt | |
d77de738 | 25708 | @opindex mbarrel-shift-enabled |
ddf6fe37 | 25709 | @item -mbarrel-shift-enabled |
d77de738 ML |
25710 | Enable barrel-shift instructions. |
25711 | ||
d77de738 | 25712 | @opindex mdivide-enabled |
ddf6fe37 | 25713 | @item -mdivide-enabled |
d77de738 ML |
25714 | Enable divide and modulus instructions. |
25715 | ||
d77de738 | 25716 | @opindex multiply-enabled |
ddf6fe37 | 25717 | @item -mmultiply-enabled |
d77de738 ML |
25718 | Enable multiply instructions. |
25719 | ||
d77de738 | 25720 | @opindex msign-extend-enabled |
ddf6fe37 | 25721 | @item -msign-extend-enabled |
d77de738 ML |
25722 | Enable sign extend instructions. |
25723 | ||
d77de738 | 25724 | @opindex muser-enabled |
ddf6fe37 | 25725 | @item -muser-enabled |
d77de738 ML |
25726 | Enable user-defined instructions. |
25727 | ||
25728 | @end table | |
25729 | ||
25730 | @node LoongArch Options | |
25731 | @subsection LoongArch Options | |
25732 | @cindex LoongArch Options | |
25733 | ||
25734 | These command-line options are defined for LoongArch targets: | |
25735 | ||
25736 | @table @gcctabopt | |
9c19597c | 25737 | @opindex march |
ddf6fe37 | 25738 | @item -march=@var{cpu-type} |
d77de738 ML |
25739 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
25740 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
25741 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
25742 | to generate code that may not run at all on processors other than the one | |
25743 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
25744 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
25745 | ||
25746 | The choices for @var{cpu-type} are: | |
25747 | ||
25748 | @table @samp | |
25749 | @item native | |
25750 | This selects the CPU to generate code for at compilation time by determining | |
25751 | the processor type of the compiling machine. Using @option{-march=native} | |
25752 | enables all instruction subsets supported by the local machine (hence | |
25753 | the result might not run on different machines). Using @option{-mtune=native} | |
25754 | produces code optimized for the local machine under the constraints | |
25755 | of the selected instruction set. | |
25756 | @item loongarch64 | |
25757 | A generic CPU with 64-bit extensions. | |
25758 | @item la464 | |
25759 | LoongArch LA464 CPU with LBT, LSX, LASX, LVZ. | |
25760 | @end table | |
25761 | ||
d77de738 | 25762 | @opindex mtune |
ddf6fe37 | 25763 | @item -mtune=@var{cpu-type} |
d77de738 ML |
25764 | Optimize the output for the given processor, specified by microarchitecture |
25765 | name. | |
25766 | ||
d77de738 | 25767 | @opindex mabi |
ddf6fe37 | 25768 | @item -mabi=@var{base-abi-type} |
d77de738 ML |
25769 | Generate code for the specified calling convention. |
25770 | @var{base-abi-type} can be one of: | |
25771 | @table @samp | |
25772 | @item lp64d | |
25773 | Uses 64-bit general purpose registers and 32/64-bit floating-point | |
25774 | registers for parameter passing. Data model is LP64, where @samp{int} | |
25775 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
25776 | @item lp64f | |
25777 | Uses 64-bit general purpose registers and 32-bit floating-point | |
25778 | registers for parameter passing. Data model is LP64, where @samp{int} | |
25779 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
25780 | @item lp64s | |
25781 | Uses 64-bit general purpose registers and no floating-point | |
25782 | registers for parameter passing. Data model is LP64, where @samp{int} | |
25783 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
25784 | @end table | |
25785 | ||
d77de738 | 25786 | @opindex mfpu |
ddf6fe37 | 25787 | @item -mfpu=@var{fpu-type} |
d77de738 ML |
25788 | Generate code for the specified FPU type, which can be one of: |
25789 | @table @samp | |
25790 | @item 64 | |
25791 | Allow the use of hardware floating-point instructions for 32-bit | |
25792 | and 64-bit operations. | |
25793 | @item 32 | |
25794 | Allow the use of hardware floating-point instructions for 32-bit | |
25795 | operations. | |
25796 | @item none | |
25797 | @item 0 | |
25798 | Prevent the use of hardware floating-point instructions. | |
25799 | @end table | |
25800 | ||
d77de738 | 25801 | @opindex msoft-float |
ddf6fe37 | 25802 | @item -msoft-float |
d77de738 ML |
25803 | Force @option{-mfpu=none} and prevents the use of floating-point |
25804 | registers for parameter passing. This option may change the target | |
25805 | ABI. | |
25806 | ||
9c19597c | 25807 | @opindex msingle-float |
ddf6fe37 | 25808 | @item -msingle-float |
d77de738 ML |
25809 | Force @option{-mfpu=32} and allow the use of 32-bit floating-point |
25810 | registers for parameter passing. This option may change the target | |
25811 | ABI. | |
25812 | ||
9c19597c | 25813 | @opindex mdouble-float |
ddf6fe37 | 25814 | @item -mdouble-float |
d77de738 ML |
25815 | Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point |
25816 | registers for parameter passing. This option may change the target | |
25817 | ABI. | |
25818 | ||
9c19597c | 25819 | @opindex mbranch-cost |
ddf6fe37 | 25820 | @item -mbranch-cost=@var{n} |
d77de738 ML |
25821 | Set the cost of branches to roughly @var{n} instructions. |
25822 | ||
ddf6fe37 | 25823 | @opindex mcheck-zero-division |
d77de738 ML |
25824 | @item -mcheck-zero-division |
25825 | @itemx -mno-check-zero-divison | |
d77de738 ML |
25826 | Trap (do not trap) on integer division by zero. The default is |
25827 | @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and | |
25828 | @option{-mno-check-zero-division} for other optimization levels. | |
25829 | ||
ddf6fe37 | 25830 | @opindex mcond-move-int |
d77de738 ML |
25831 | @item -mcond-move-int |
25832 | @itemx -mno-cond-move-int | |
d77de738 ML |
25833 | Conditional moves for integral data in general-purpose registers |
25834 | are enabled (disabled). The default is @option{-mcond-move-int}. | |
25835 | ||
ddf6fe37 | 25836 | @opindex mcond-move-float |
d77de738 ML |
25837 | @item -mcond-move-float |
25838 | @itemx -mno-cond-move-float | |
d77de738 ML |
25839 | Conditional moves for floating-point registers are enabled (disabled). |
25840 | The default is @option{-mcond-move-float}. | |
25841 | ||
ddf6fe37 | 25842 | @opindex mmemcpy |
d77de738 ML |
25843 | @item -mmemcpy |
25844 | @itemx -mno-memcpy | |
d77de738 ML |
25845 | Force (do not force) the use of @code{memcpy} for non-trivial block moves. |
25846 | The default is @option{-mno-memcpy}, which allows GCC to inline most | |
25847 | constant-sized copies. Setting optimization level to @option{-Os} also | |
25848 | forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this | |
25849 | behavior if explicitly specified, regardless of the order these options on | |
25850 | the command line. | |
25851 | ||
ddf6fe37 | 25852 | @opindex mstrict-align |
d77de738 ML |
25853 | @item -mstrict-align |
25854 | @itemx -mno-strict-align | |
d77de738 ML |
25855 | Avoid or allow generating memory accesses that may not be aligned on a natural |
25856 | object boundary as described in the architecture specification. The default is | |
25857 | @option{-mno-strict-align}. | |
25858 | ||
9c19597c | 25859 | @opindex msmall-data-limit |
ddf6fe37 | 25860 | @item -msmall-data-limit=@var{number} |
d77de738 ML |
25861 | Put global and static data smaller than @var{number} bytes into a special |
25862 | section (on some targets). The default value is 0. | |
25863 | ||
9c19597c | 25864 | @opindex mmax-inline-memcpy-size |
ddf6fe37 | 25865 | @item -mmax-inline-memcpy-size=@var{n} |
d77de738 ML |
25866 | Inline all block moves (such as calls to @code{memcpy} or structure copies) |
25867 | less than or equal to @var{n} bytes. The default value of @var{n} is 1024. | |
25868 | ||
25869 | @item -mcmodel=@var{code-model} | |
25870 | Set the code model to one of: | |
25871 | @table @samp | |
25872 | @item tiny-static (Not implemented yet) | |
25873 | @item tiny (Not implemented yet) | |
25874 | ||
25875 | @item normal | |
25876 | The text segment must be within 128MB addressing space. The data segment must | |
25877 | be within 2GB addressing space. | |
25878 | ||
25879 | @item medium | |
25880 | The text segment and data segment must be within 2GB addressing space. | |
25881 | ||
25882 | @item large (Not implemented yet) | |
25883 | ||
25884 | @item extreme | |
25885 | This mode does not limit the size of the code segment and data segment. | |
25886 | The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and | |
25887 | @option{-mno-explicit-relocs}. | |
25888 | @end table | |
25889 | The default code model is @code{normal}. | |
25890 | ||
d77de738 ML |
25891 | @opindex mexplicit-relocs |
25892 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
25893 | @item -mexplicit-relocs |
25894 | @itemx -mno-explicit-relocs | |
d77de738 ML |
25895 | Use or do not use assembler relocation operators when dealing with symbolic |
25896 | addresses. The alternative is to use assembler macros instead, which may | |
25897 | limit optimization. The default value for the option is determined during | |
25898 | GCC build-time by detecting corresponding assembler support: | |
25899 | @code{-mexplicit-relocs} if said support is present, | |
25900 | @code{-mno-explicit-relocs} otherwise. This option is mostly useful for | |
25901 | debugging, or interoperation with assemblers different from the build-time | |
25902 | one. | |
25903 | ||
ddf6fe37 | 25904 | @opindex mdirect-extern-access |
d77de738 ML |
25905 | @item -mdirect-extern-access |
25906 | @itemx -mno-direct-extern-access | |
d77de738 ML |
25907 | Do not use or use GOT to access external symbols. The default is |
25908 | @option{-mno-direct-extern-access}: GOT is used for external symbols with | |
25909 | default visibility, but not used for other external symbols. | |
25910 | ||
25911 | With @option{-mdirect-extern-access}, GOT is not used and all external | |
25912 | symbols are PC-relatively addressed. It is @strong{only} suitable for | |
25913 | environments where no dynamic link is performed, like firmwares, OS | |
25914 | kernels, executables linked with @option{-static} or @option{-static-pie}. | |
25915 | @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or | |
25916 | @option{-fpic}. | |
25917 | @end table | |
25918 | ||
25919 | @node M32C Options | |
25920 | @subsection M32C Options | |
25921 | @cindex M32C options | |
25922 | ||
25923 | @table @gcctabopt | |
d77de738 | 25924 | @opindex mcpu= |
ddf6fe37 | 25925 | @item -mcpu=@var{name} |
d77de738 ML |
25926 | Select the CPU for which code is generated. @var{name} may be one of |
25927 | @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to | |
25928 | /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for | |
25929 | the M32C/80 series. | |
25930 | ||
d77de738 | 25931 | @opindex msim |
ddf6fe37 | 25932 | @item -msim |
d77de738 ML |
25933 | Specifies that the program will be run on the simulator. This causes |
25934 | an alternate runtime library to be linked in which supports, for | |
25935 | example, file I/O@. You must not use this option when generating | |
25936 | programs that will run on real hardware; you must provide your own | |
25937 | runtime library for whatever I/O functions are needed. | |
25938 | ||
d77de738 | 25939 | @opindex memregs= |
ddf6fe37 | 25940 | @item -memregs=@var{number} |
d77de738 ML |
25941 | Specifies the number of memory-based pseudo-registers GCC uses |
25942 | during code generation. These pseudo-registers are used like real | |
25943 | registers, so there is a tradeoff between GCC's ability to fit the | |
25944 | code into available registers, and the performance penalty of using | |
25945 | memory instead of registers. Note that all modules in a program must | |
25946 | be compiled with the same value for this option. Because of that, you | |
25947 | must not use this option with GCC's default runtime libraries. | |
25948 | ||
25949 | @end table | |
25950 | ||
25951 | @node M32R/D Options | |
25952 | @subsection M32R/D Options | |
25953 | @cindex M32R/D options | |
25954 | ||
25955 | These @option{-m} options are defined for Renesas M32R/D architectures: | |
25956 | ||
25957 | @table @gcctabopt | |
d77de738 | 25958 | @opindex m32r2 |
ddf6fe37 | 25959 | @item -m32r2 |
d77de738 ML |
25960 | Generate code for the M32R/2@. |
25961 | ||
d77de738 | 25962 | @opindex m32rx |
ddf6fe37 | 25963 | @item -m32rx |
d77de738 ML |
25964 | Generate code for the M32R/X@. |
25965 | ||
d77de738 | 25966 | @opindex m32r |
ddf6fe37 | 25967 | @item -m32r |
d77de738 ML |
25968 | Generate code for the M32R@. This is the default. |
25969 | ||
d77de738 | 25970 | @opindex mmodel=small |
ddf6fe37 | 25971 | @item -mmodel=small |
d77de738 ML |
25972 | Assume all objects live in the lower 16MB of memory (so that their addresses |
25973 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
25974 | are reachable with the @code{bl} instruction. | |
25975 | This is the default. | |
25976 | ||
25977 | The addressability of a particular object can be set with the | |
25978 | @code{model} attribute. | |
25979 | ||
d77de738 | 25980 | @opindex mmodel=medium |
ddf6fe37 | 25981 | @item -mmodel=medium |
d77de738 ML |
25982 | Assume objects may be anywhere in the 32-bit address space (the compiler |
25983 | generates @code{seth/add3} instructions to load their addresses), and | |
25984 | assume all subroutines are reachable with the @code{bl} instruction. | |
25985 | ||
d77de738 | 25986 | @opindex mmodel=large |
ddf6fe37 | 25987 | @item -mmodel=large |
d77de738 ML |
25988 | Assume objects may be anywhere in the 32-bit address space (the compiler |
25989 | generates @code{seth/add3} instructions to load their addresses), and | |
25990 | assume subroutines may not be reachable with the @code{bl} instruction | |
25991 | (the compiler generates the much slower @code{seth/add3/jl} | |
25992 | instruction sequence). | |
25993 | ||
d77de738 | 25994 | @opindex msdata=none |
ddf6fe37 | 25995 | @item -msdata=none |
d77de738 ML |
25996 | Disable use of the small data area. Variables are put into |
25997 | one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the | |
25998 | @code{section} attribute has been specified). | |
25999 | This is the default. | |
26000 | ||
26001 | The small data area consists of sections @code{.sdata} and @code{.sbss}. | |
26002 | Objects may be explicitly put in the small data area with the | |
26003 | @code{section} attribute using one of these sections. | |
26004 | ||
d77de738 | 26005 | @opindex msdata=sdata |
ddf6fe37 | 26006 | @item -msdata=sdata |
d77de738 ML |
26007 | Put small global and static data in the small data area, but do not |
26008 | generate special code to reference them. | |
26009 | ||
d77de738 | 26010 | @opindex msdata=use |
ddf6fe37 | 26011 | @item -msdata=use |
d77de738 ML |
26012 | Put small global and static data in the small data area, and generate |
26013 | special instructions to reference them. | |
26014 | ||
d77de738 ML |
26015 | @opindex G |
26016 | @cindex smaller data references | |
f33d7a88 | 26017 | @item -G @var{num} |
d77de738 ML |
26018 | Put global and static objects less than or equal to @var{num} bytes |
26019 | into the small data or BSS sections instead of the normal data or BSS | |
26020 | sections. The default value of @var{num} is 8. | |
26021 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
26022 | for this option to have any effect. | |
26023 | ||
26024 | All modules should be compiled with the same @option{-G @var{num}} value. | |
26025 | Compiling with different values of @var{num} may or may not work; if it | |
26026 | doesn't the linker gives an error message---incorrect code is not | |
26027 | generated. | |
26028 | ||
d77de738 | 26029 | @opindex mdebug |
ddf6fe37 | 26030 | @item -mdebug |
d77de738 ML |
26031 | Makes the M32R-specific code in the compiler display some statistics |
26032 | that might help in debugging programs. | |
26033 | ||
d77de738 | 26034 | @opindex malign-loops |
ddf6fe37 | 26035 | @item -malign-loops |
d77de738 ML |
26036 | Align all loops to a 32-byte boundary. |
26037 | ||
d77de738 | 26038 | @opindex mno-align-loops |
ddf6fe37 | 26039 | @item -mno-align-loops |
d77de738 ML |
26040 | Do not enforce a 32-byte alignment for loops. This is the default. |
26041 | ||
d77de738 | 26042 | @opindex missue-rate=@var{number} |
ddf6fe37 | 26043 | @item -missue-rate=@var{number} |
d77de738 ML |
26044 | Issue @var{number} instructions per cycle. @var{number} can only be 1 |
26045 | or 2. | |
26046 | ||
d77de738 | 26047 | @opindex mbranch-cost=@var{number} |
ddf6fe37 | 26048 | @item -mbranch-cost=@var{number} |
d77de738 ML |
26049 | @var{number} can only be 1 or 2. If it is 1 then branches are |
26050 | preferred over conditional code, if it is 2, then the opposite applies. | |
26051 | ||
d77de738 | 26052 | @opindex mflush-trap=@var{number} |
ddf6fe37 | 26053 | @item -mflush-trap=@var{number} |
d77de738 ML |
26054 | Specifies the trap number to use to flush the cache. The default is |
26055 | 12. Valid numbers are between 0 and 15 inclusive. | |
26056 | ||
d77de738 | 26057 | @opindex mno-flush-trap |
ddf6fe37 | 26058 | @item -mno-flush-trap |
d77de738 ML |
26059 | Specifies that the cache cannot be flushed by using a trap. |
26060 | ||
d77de738 | 26061 | @opindex mflush-func=@var{name} |
ddf6fe37 | 26062 | @item -mflush-func=@var{name} |
d77de738 ML |
26063 | Specifies the name of the operating system function to call to flush |
26064 | the cache. The default is @samp{_flush_cache}, but a function call | |
26065 | is only used if a trap is not available. | |
26066 | ||
d77de738 | 26067 | @opindex mno-flush-func |
ddf6fe37 | 26068 | @item -mno-flush-func |
d77de738 ML |
26069 | Indicates that there is no OS function for flushing the cache. |
26070 | ||
26071 | @end table | |
26072 | ||
26073 | @node M680x0 Options | |
26074 | @subsection M680x0 Options | |
26075 | @cindex M680x0 options | |
26076 | ||
26077 | These are the @samp{-m} options defined for M680x0 and ColdFire processors. | |
26078 | The default settings depend on which architecture was selected when | |
26079 | the compiler was configured; the defaults for the most common choices | |
26080 | are given below. | |
26081 | ||
26082 | @table @gcctabopt | |
d77de738 | 26083 | @opindex march |
ddf6fe37 | 26084 | @item -march=@var{arch} |
d77de738 ML |
26085 | Generate code for a specific M680x0 or ColdFire instruction set |
26086 | architecture. Permissible values of @var{arch} for M680x0 | |
26087 | architectures are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26088 | @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire | |
26089 | architectures are selected according to Freescale's ISA classification | |
26090 | and the permissible values are: @samp{isaa}, @samp{isaaplus}, | |
26091 | @samp{isab} and @samp{isac}. | |
26092 | ||
26093 | GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating | |
26094 | code for a ColdFire target. The @var{arch} in this macro is one of the | |
26095 | @option{-march} arguments given above. | |
26096 | ||
26097 | When used together, @option{-march} and @option{-mtune} select code | |
26098 | that runs on a family of similar processors but that is optimized | |
26099 | for a particular microarchitecture. | |
26100 | ||
d77de738 | 26101 | @opindex mcpu |
ddf6fe37 | 26102 | @item -mcpu=@var{cpu} |
d77de738 ML |
26103 | Generate code for a specific M680x0 or ColdFire processor. |
26104 | The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26105 | @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332} | |
26106 | and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table | |
26107 | below, which also classifies the CPUs into families: | |
26108 | ||
26109 | @multitable @columnfractions 0.20 0.80 | |
26110 | @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments} | |
26111 | @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} | |
26112 | @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206} | |
26113 | @item @samp{5206e} @tab @samp{5206e} | |
26114 | @item @samp{5208} @tab @samp{5207} @samp{5208} | |
26115 | @item @samp{5211a} @tab @samp{5210a} @samp{5211a} | |
26116 | @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213} | |
26117 | @item @samp{5216} @tab @samp{5214} @samp{5216} | |
26118 | @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235} | |
26119 | @item @samp{5225} @tab @samp{5224} @samp{5225} | |
26120 | @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259} | |
26121 | @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x} | |
26122 | @item @samp{5249} @tab @samp{5249} | |
26123 | @item @samp{5250} @tab @samp{5250} | |
26124 | @item @samp{5271} @tab @samp{5270} @samp{5271} | |
26125 | @item @samp{5272} @tab @samp{5272} | |
26126 | @item @samp{5275} @tab @samp{5274} @samp{5275} | |
26127 | @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x} | |
26128 | @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017} | |
26129 | @item @samp{5307} @tab @samp{5307} | |
26130 | @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x} | |
26131 | @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x} | |
26132 | @item @samp{5407} @tab @samp{5407} | |
26133 | @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} | |
26134 | @end multitable | |
26135 | ||
26136 | @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if | |
26137 | @var{arch} is compatible with @var{cpu}. Other combinations of | |
26138 | @option{-mcpu} and @option{-march} are rejected. | |
26139 | ||
26140 | GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target | |
26141 | @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}}, | |
26142 | where the value of @var{family} is given by the table above. | |
26143 | ||
d77de738 | 26144 | @opindex mtune |
ddf6fe37 | 26145 | @item -mtune=@var{tune} |
d77de738 ML |
26146 | Tune the code for a particular microarchitecture within the |
26147 | constraints set by @option{-march} and @option{-mcpu}. | |
26148 | The M680x0 microarchitectures are: @samp{68000}, @samp{68010}, | |
26149 | @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060} | |
26150 | and @samp{cpu32}. The ColdFire microarchitectures | |
26151 | are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}. | |
26152 | ||
26153 | You can also use @option{-mtune=68020-40} for code that needs | |
26154 | to run relatively well on 68020, 68030 and 68040 targets. | |
26155 | @option{-mtune=68020-60} is similar but includes 68060 targets | |
26156 | as well. These two options select the same tuning decisions as | |
26157 | @option{-m68020-40} and @option{-m68020-60} respectively. | |
26158 | ||
26159 | GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__} | |
26160 | when tuning for 680x0 architecture @var{arch}. It also defines | |
26161 | @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std} | |
26162 | option is used. If GCC is tuning for a range of architectures, | |
26163 | as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60}, | |
26164 | it defines the macros for every architecture in the range. | |
26165 | ||
26166 | GCC also defines the macro @code{__m@var{uarch}__} when tuning for | |
26167 | ColdFire microarchitecture @var{uarch}, where @var{uarch} is one | |
26168 | of the arguments given above. | |
26169 | ||
d77de738 ML |
26170 | @opindex m68000 |
26171 | @opindex mc68000 | |
ddf6fe37 AA |
26172 | @item -m68000 |
26173 | @itemx -mc68000 | |
d77de738 ML |
26174 | Generate output for a 68000. This is the default |
26175 | when the compiler is configured for 68000-based systems. | |
26176 | It is equivalent to @option{-march=68000}. | |
26177 | ||
26178 | Use this option for microcontrollers with a 68000 or EC000 core, | |
26179 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
26180 | ||
d77de738 | 26181 | @opindex m68010 |
ddf6fe37 | 26182 | @item -m68010 |
d77de738 ML |
26183 | Generate output for a 68010. This is the default |
26184 | when the compiler is configured for 68010-based systems. | |
26185 | It is equivalent to @option{-march=68010}. | |
26186 | ||
d77de738 ML |
26187 | @opindex m68020 |
26188 | @opindex mc68020 | |
ddf6fe37 AA |
26189 | @item -m68020 |
26190 | @itemx -mc68020 | |
d77de738 ML |
26191 | Generate output for a 68020. This is the default |
26192 | when the compiler is configured for 68020-based systems. | |
26193 | It is equivalent to @option{-march=68020}. | |
26194 | ||
d77de738 | 26195 | @opindex m68030 |
ddf6fe37 | 26196 | @item -m68030 |
d77de738 ML |
26197 | Generate output for a 68030. This is the default when the compiler is |
26198 | configured for 68030-based systems. It is equivalent to | |
26199 | @option{-march=68030}. | |
26200 | ||
d77de738 | 26201 | @opindex m68040 |
ddf6fe37 | 26202 | @item -m68040 |
d77de738 ML |
26203 | Generate output for a 68040. This is the default when the compiler is |
26204 | configured for 68040-based systems. It is equivalent to | |
26205 | @option{-march=68040}. | |
26206 | ||
26207 | This option inhibits the use of 68881/68882 instructions that have to be | |
26208 | emulated by software on the 68040. Use this option if your 68040 does not | |
26209 | have code to emulate those instructions. | |
26210 | ||
d77de738 | 26211 | @opindex m68060 |
ddf6fe37 | 26212 | @item -m68060 |
d77de738 ML |
26213 | Generate output for a 68060. This is the default when the compiler is |
26214 | configured for 68060-based systems. It is equivalent to | |
26215 | @option{-march=68060}. | |
26216 | ||
26217 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
26218 | have to be emulated by software on the 68060. Use this option if your 68060 | |
26219 | does not have code to emulate those instructions. | |
26220 | ||
d77de738 | 26221 | @opindex mcpu32 |
ddf6fe37 | 26222 | @item -mcpu32 |
d77de738 ML |
26223 | Generate output for a CPU32. This is the default |
26224 | when the compiler is configured for CPU32-based systems. | |
26225 | It is equivalent to @option{-march=cpu32}. | |
26226 | ||
26227 | Use this option for microcontrollers with a | |
26228 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
26229 | 68336, 68340, 68341, 68349 and 68360. | |
26230 | ||
d77de738 | 26231 | @opindex m5200 |
ddf6fe37 | 26232 | @item -m5200 |
d77de738 ML |
26233 | Generate output for a 520X ColdFire CPU@. This is the default |
26234 | when the compiler is configured for 520X-based systems. | |
26235 | It is equivalent to @option{-mcpu=5206}, and is now deprecated | |
26236 | in favor of that option. | |
26237 | ||
26238 | Use this option for microcontroller with a 5200 core, including | |
26239 | the MCF5202, MCF5203, MCF5204 and MCF5206. | |
26240 | ||
d77de738 | 26241 | @opindex m5206e |
ddf6fe37 | 26242 | @item -m5206e |
d77de738 ML |
26243 | Generate output for a 5206e ColdFire CPU@. The option is now |
26244 | deprecated in favor of the equivalent @option{-mcpu=5206e}. | |
26245 | ||
d77de738 | 26246 | @opindex m528x |
ddf6fe37 | 26247 | @item -m528x |
d77de738 ML |
26248 | Generate output for a member of the ColdFire 528X family. |
26249 | The option is now deprecated in favor of the equivalent | |
26250 | @option{-mcpu=528x}. | |
26251 | ||
d77de738 | 26252 | @opindex m5307 |
ddf6fe37 | 26253 | @item -m5307 |
d77de738 ML |
26254 | Generate output for a ColdFire 5307 CPU@. The option is now deprecated |
26255 | in favor of the equivalent @option{-mcpu=5307}. | |
26256 | ||
d77de738 | 26257 | @opindex m5407 |
ddf6fe37 | 26258 | @item -m5407 |
d77de738 ML |
26259 | Generate output for a ColdFire 5407 CPU@. The option is now deprecated |
26260 | in favor of the equivalent @option{-mcpu=5407}. | |
26261 | ||
d77de738 | 26262 | @opindex mcfv4e |
ddf6fe37 | 26263 | @item -mcfv4e |
d77de738 ML |
26264 | Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x). |
26265 | This includes use of hardware floating-point instructions. | |
26266 | The option is equivalent to @option{-mcpu=547x}, and is now | |
26267 | deprecated in favor of that option. | |
26268 | ||
d77de738 | 26269 | @opindex m68020-40 |
ddf6fe37 | 26270 | @item -m68020-40 |
d77de738 ML |
26271 | Generate output for a 68040, without using any of the new instructions. |
26272 | This results in code that can run relatively efficiently on either a | |
26273 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26274 | 68881 instructions that are emulated on the 68040. | |
26275 | ||
26276 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}. | |
26277 | ||
d77de738 | 26278 | @opindex m68020-60 |
ddf6fe37 | 26279 | @item -m68020-60 |
d77de738 ML |
26280 | Generate output for a 68060, without using any of the new instructions. |
26281 | This results in code that can run relatively efficiently on either a | |
26282 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26283 | 68881 instructions that are emulated on the 68060. | |
26284 | ||
26285 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}. | |
26286 | ||
d77de738 ML |
26287 | @opindex mhard-float |
26288 | @opindex m68881 | |
ddf6fe37 AA |
26289 | @item -mhard-float |
26290 | @itemx -m68881 | |
d77de738 ML |
26291 | Generate floating-point instructions. This is the default for 68020 |
26292 | and above, and for ColdFire devices that have an FPU@. It defines the | |
26293 | macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__} | |
26294 | on ColdFire targets. | |
26295 | ||
d77de738 | 26296 | @opindex msoft-float |
ddf6fe37 | 26297 | @item -msoft-float |
d77de738 ML |
26298 | Do not generate floating-point instructions; use library calls instead. |
26299 | This is the default for 68000, 68010, and 68832 targets. It is also | |
26300 | the default for ColdFire devices that have no FPU. | |
26301 | ||
d77de738 ML |
26302 | @opindex mdiv |
26303 | @opindex mno-div | |
ddf6fe37 AA |
26304 | @item -mdiv |
26305 | @itemx -mno-div | |
d77de738 ML |
26306 | Generate (do not generate) ColdFire hardware divide and remainder |
26307 | instructions. If @option{-march} is used without @option{-mcpu}, | |
26308 | the default is ``on'' for ColdFire architectures and ``off'' for M680x0 | |
26309 | architectures. Otherwise, the default is taken from the target CPU | |
26310 | (either the default CPU, or the one specified by @option{-mcpu}). For | |
26311 | example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for | |
26312 | @option{-mcpu=5206e}. | |
26313 | ||
26314 | GCC defines the macro @code{__mcfhwdiv__} when this option is enabled. | |
26315 | ||
d77de738 | 26316 | @opindex mshort |
ddf6fe37 | 26317 | @item -mshort |
d77de738 ML |
26318 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
26319 | Additionally, parameters passed on the stack are also aligned to a | |
26320 | 16-bit boundary even on targets whose API mandates promotion to 32-bit. | |
26321 | ||
d77de738 | 26322 | @opindex mno-short |
ddf6fe37 | 26323 | @item -mno-short |
d77de738 ML |
26324 | Do not consider type @code{int} to be 16 bits wide. This is the default. |
26325 | ||
d77de738 ML |
26326 | @opindex mnobitfield |
26327 | @opindex mno-bitfield | |
ddf6fe37 AA |
26328 | @item -mnobitfield |
26329 | @itemx -mno-bitfield | |
d77de738 ML |
26330 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
26331 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
26332 | ||
d77de738 | 26333 | @opindex mbitfield |
ddf6fe37 | 26334 | @item -mbitfield |
d77de738 ML |
26335 | Do use the bit-field instructions. The @option{-m68020} option implies |
26336 | @option{-mbitfield}. This is the default if you use a configuration | |
26337 | designed for a 68020. | |
26338 | ||
d77de738 | 26339 | @opindex mrtd |
ddf6fe37 | 26340 | @item -mrtd |
d77de738 ML |
26341 | Use a different function-calling convention, in which functions |
26342 | that take a fixed number of arguments return with the @code{rtd} | |
26343 | instruction, which pops their arguments while returning. This | |
26344 | saves one instruction in the caller since there is no need to pop | |
26345 | the arguments there. | |
26346 | ||
26347 | This calling convention is incompatible with the one normally | |
26348 | used on Unix, so you cannot use it if you need to call libraries | |
26349 | compiled with the Unix compiler. | |
26350 | ||
26351 | Also, you must provide function prototypes for all functions that | |
26352 | take variable numbers of arguments (including @code{printf}); | |
26353 | otherwise incorrect code is generated for calls to those | |
26354 | functions. | |
26355 | ||
26356 | In addition, seriously incorrect code results if you call a | |
26357 | function with too many arguments. (Normally, extra arguments are | |
26358 | harmlessly ignored.) | |
26359 | ||
26360 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
26361 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. | |
26362 | ||
26363 | The default is @option{-mno-rtd}. | |
26364 | ||
d77de738 ML |
26365 | @opindex malign-int |
26366 | @opindex mno-align-int | |
ddf6fe37 AA |
26367 | @item -malign-int |
26368 | @itemx -mno-align-int | |
d77de738 ML |
26369 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
26370 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
26371 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). | |
26372 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
26373 | faster on processors with 32-bit busses at the expense of more memory. | |
26374 | ||
26375 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC | |
26376 | aligns structures containing the above types differently than | |
26377 | most published application binary interface specifications for the m68k. | |
26378 | ||
26379 | @opindex mpcrel | |
26380 | Use the pc-relative addressing mode of the 68000 directly, instead of | |
26381 | using a global offset table. At present, this option implies @option{-fpic}, | |
26382 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
26383 | not presently supported with @option{-mpcrel}, though this could be supported for | |
26384 | 68020 and higher processors. | |
26385 | ||
d77de738 ML |
26386 | @opindex mno-strict-align |
26387 | @opindex mstrict-align | |
ddf6fe37 AA |
26388 | @item -mno-strict-align |
26389 | @itemx -mstrict-align | |
d77de738 ML |
26390 | Do not (do) assume that unaligned memory references are handled by |
26391 | the system. | |
26392 | ||
26393 | @item -msep-data | |
26394 | Generate code that allows the data segment to be located in a different | |
26395 | area of memory from the text segment. This allows for execute-in-place in | |
26396 | an environment without virtual memory management. This option implies | |
26397 | @option{-fPIC}. | |
26398 | ||
26399 | @item -mno-sep-data | |
26400 | Generate code that assumes that the data segment follows the text segment. | |
26401 | This is the default. | |
26402 | ||
26403 | @item -mid-shared-library | |
26404 | Generate code that supports shared libraries via the library ID method. | |
26405 | This allows for execute-in-place and shared libraries in an environment | |
26406 | without virtual memory management. This option implies @option{-fPIC}. | |
26407 | ||
26408 | @item -mno-id-shared-library | |
26409 | Generate code that doesn't assume ID-based shared libraries are being used. | |
26410 | This is the default. | |
26411 | ||
26412 | @item -mshared-library-id=n | |
26413 | Specifies the identification number of the ID-based shared library being | |
26414 | compiled. Specifying a value of 0 generates more compact code; specifying | |
26415 | other values forces the allocation of that number to the current | |
26416 | library, but is no more space- or time-efficient than omitting this option. | |
26417 | ||
d77de738 ML |
26418 | @opindex mxgot |
26419 | @opindex mno-xgot | |
ddf6fe37 AA |
26420 | @item -mxgot |
26421 | @itemx -mno-xgot | |
d77de738 ML |
26422 | When generating position-independent code for ColdFire, generate code |
26423 | that works if the GOT has more than 8192 entries. This code is | |
26424 | larger and slower than code generated without this option. On M680x0 | |
26425 | processors, this option is not needed; @option{-fPIC} suffices. | |
26426 | ||
26427 | GCC normally uses a single instruction to load values from the GOT@. | |
26428 | While this is relatively efficient, it only works if the GOT | |
26429 | is smaller than about 64k. Anything larger causes the linker | |
26430 | to report an error such as: | |
26431 | ||
26432 | @cindex relocation truncated to fit (ColdFire) | |
26433 | @smallexample | |
26434 | relocation truncated to fit: R_68K_GOT16O foobar | |
26435 | @end smallexample | |
26436 | ||
26437 | If this happens, you should recompile your code with @option{-mxgot}. | |
26438 | It should then work with very large GOTs. However, code generated with | |
26439 | @option{-mxgot} is less efficient, since it takes 4 instructions to fetch | |
26440 | the value of a global symbol. | |
26441 | ||
26442 | Note that some linkers, including newer versions of the GNU linker, | |
26443 | can create multiple GOTs and sort GOT entries. If you have such a linker, | |
26444 | you should only need to use @option{-mxgot} when compiling a single | |
26445 | object file that accesses more than 8192 GOT entries. Very few do. | |
26446 | ||
26447 | These options have no effect unless GCC is generating | |
26448 | position-independent code. | |
26449 | ||
d77de738 | 26450 | @opindex mlong-jump-table-offsets |
ddf6fe37 | 26451 | @item -mlong-jump-table-offsets |
d77de738 ML |
26452 | Use 32-bit offsets in @code{switch} tables. The default is to use |
26453 | 16-bit offsets. | |
26454 | ||
26455 | @end table | |
26456 | ||
26457 | @node MCore Options | |
26458 | @subsection MCore Options | |
26459 | @cindex MCore options | |
26460 | ||
26461 | These are the @samp{-m} options defined for the Motorola M*Core | |
26462 | processors. | |
26463 | ||
26464 | @table @gcctabopt | |
26465 | ||
d77de738 ML |
26466 | @opindex mhardlit |
26467 | @opindex mno-hardlit | |
ddf6fe37 AA |
26468 | @item -mhardlit |
26469 | @itemx -mno-hardlit | |
d77de738 ML |
26470 | Inline constants into the code stream if it can be done in two |
26471 | instructions or less. | |
26472 | ||
d77de738 ML |
26473 | @opindex mdiv |
26474 | @opindex mno-div | |
ddf6fe37 AA |
26475 | @item -mdiv |
26476 | @itemx -mno-div | |
d77de738 ML |
26477 | Use the divide instruction. (Enabled by default). |
26478 | ||
d77de738 ML |
26479 | @opindex mrelax-immediate |
26480 | @opindex mno-relax-immediate | |
ddf6fe37 AA |
26481 | @item -mrelax-immediate |
26482 | @itemx -mno-relax-immediate | |
d77de738 ML |
26483 | Allow arbitrary-sized immediates in bit operations. |
26484 | ||
d77de738 ML |
26485 | @opindex mwide-bitfields |
26486 | @opindex mno-wide-bitfields | |
ddf6fe37 AA |
26487 | @item -mwide-bitfields |
26488 | @itemx -mno-wide-bitfields | |
d77de738 ML |
26489 | Always treat bit-fields as @code{int}-sized. |
26490 | ||
d77de738 ML |
26491 | @opindex m4byte-functions |
26492 | @opindex mno-4byte-functions | |
ddf6fe37 AA |
26493 | @item -m4byte-functions |
26494 | @itemx -mno-4byte-functions | |
d77de738 ML |
26495 | Force all functions to be aligned to a 4-byte boundary. |
26496 | ||
d77de738 ML |
26497 | @opindex mcallgraph-data |
26498 | @opindex mno-callgraph-data | |
ddf6fe37 AA |
26499 | @item -mcallgraph-data |
26500 | @itemx -mno-callgraph-data | |
d77de738 ML |
26501 | Emit callgraph information. |
26502 | ||
d77de738 ML |
26503 | @opindex mslow-bytes |
26504 | @opindex mno-slow-bytes | |
ddf6fe37 AA |
26505 | @item -mslow-bytes |
26506 | @itemx -mno-slow-bytes | |
d77de738 ML |
26507 | Prefer word access when reading byte quantities. |
26508 | ||
d77de738 ML |
26509 | @opindex mlittle-endian |
26510 | @opindex mbig-endian | |
ddf6fe37 AA |
26511 | @item -mlittle-endian |
26512 | @itemx -mbig-endian | |
d77de738 ML |
26513 | Generate code for a little-endian target. |
26514 | ||
d77de738 ML |
26515 | @opindex m210 |
26516 | @opindex m340 | |
ddf6fe37 AA |
26517 | @item -m210 |
26518 | @itemx -m340 | |
d77de738 ML |
26519 | Generate code for the 210 processor. |
26520 | ||
d77de738 | 26521 | @opindex mno-lsim |
ddf6fe37 | 26522 | @item -mno-lsim |
d77de738 ML |
26523 | Assume that runtime support has been provided and so omit the |
26524 | simulator library (@file{libsim.a)} from the linker command line. | |
26525 | ||
d77de738 | 26526 | @opindex mstack-increment |
ddf6fe37 | 26527 | @item -mstack-increment=@var{size} |
d77de738 ML |
26528 | Set the maximum amount for a single stack increment operation. Large |
26529 | values can increase the speed of programs that contain functions | |
26530 | that need a large amount of stack space, but they can also trigger a | |
26531 | segmentation fault if the stack is extended too much. The default | |
26532 | value is 0x1000. | |
26533 | ||
26534 | @end table | |
26535 | ||
d77de738 ML |
26536 | @node MicroBlaze Options |
26537 | @subsection MicroBlaze Options | |
26538 | @cindex MicroBlaze Options | |
26539 | ||
26540 | @table @gcctabopt | |
26541 | ||
d77de738 | 26542 | @opindex msoft-float |
ddf6fe37 | 26543 | @item -msoft-float |
d77de738 ML |
26544 | Use software emulation for floating point (default). |
26545 | ||
d77de738 | 26546 | @opindex mhard-float |
ddf6fe37 | 26547 | @item -mhard-float |
d77de738 ML |
26548 | Use hardware floating-point instructions. |
26549 | ||
d77de738 | 26550 | @opindex mmemcpy |
ddf6fe37 | 26551 | @item -mmemcpy |
d77de738 ML |
26552 | Do not optimize block moves, use @code{memcpy}. |
26553 | ||
d77de738 | 26554 | @opindex mno-clearbss |
ddf6fe37 | 26555 | @item -mno-clearbss |
d77de738 ML |
26556 | This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead. |
26557 | ||
d77de738 | 26558 | @opindex mcpu= |
ddf6fe37 | 26559 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
26560 | Use features of, and schedule code for, the given CPU. |
26561 | Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}}, | |
26562 | where @var{X} is a major version, @var{YY} is the minor version, and | |
26563 | @var{Z} is compatibility code. Example values are @samp{v3.00.a}, | |
26564 | @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}. | |
26565 | ||
d77de738 | 26566 | @opindex mxl-soft-mul |
ddf6fe37 | 26567 | @item -mxl-soft-mul |
d77de738 ML |
26568 | Use software multiply emulation (default). |
26569 | ||
d77de738 | 26570 | @opindex mxl-soft-div |
ddf6fe37 | 26571 | @item -mxl-soft-div |
d77de738 ML |
26572 | Use software emulation for divides (default). |
26573 | ||
d77de738 | 26574 | @opindex mxl-barrel-shift |
ddf6fe37 | 26575 | @item -mxl-barrel-shift |
d77de738 ML |
26576 | Use the hardware barrel shifter. |
26577 | ||
d77de738 | 26578 | @opindex mxl-pattern-compare |
ddf6fe37 | 26579 | @item -mxl-pattern-compare |
d77de738 ML |
26580 | Use pattern compare instructions. |
26581 | ||
d77de738 | 26582 | @opindex msmall-divides |
ddf6fe37 | 26583 | @item -msmall-divides |
d77de738 ML |
26584 | Use table lookup optimization for small signed integer divisions. |
26585 | ||
d77de738 | 26586 | @opindex mxl-stack-check |
ddf6fe37 | 26587 | @item -mxl-stack-check |
d77de738 ML |
26588 | This option is deprecated. Use @option{-fstack-check} instead. |
26589 | ||
d77de738 | 26590 | @opindex mxl-gp-opt |
ddf6fe37 | 26591 | @item -mxl-gp-opt |
d77de738 ML |
26592 | Use GP-relative @code{.sdata}/@code{.sbss} sections. |
26593 | ||
d77de738 | 26594 | @opindex mxl-multiply-high |
ddf6fe37 | 26595 | @item -mxl-multiply-high |
d77de738 ML |
26596 | Use multiply high instructions for high part of 32x32 multiply. |
26597 | ||
d77de738 | 26598 | @opindex mxl-float-convert |
ddf6fe37 | 26599 | @item -mxl-float-convert |
d77de738 ML |
26600 | Use hardware floating-point conversion instructions. |
26601 | ||
d77de738 | 26602 | @opindex mxl-float-sqrt |
ddf6fe37 | 26603 | @item -mxl-float-sqrt |
d77de738 ML |
26604 | Use hardware floating-point square root instruction. |
26605 | ||
d77de738 | 26606 | @opindex mbig-endian |
ddf6fe37 | 26607 | @item -mbig-endian |
d77de738 ML |
26608 | Generate code for a big-endian target. |
26609 | ||
d77de738 | 26610 | @opindex mlittle-endian |
ddf6fe37 | 26611 | @item -mlittle-endian |
d77de738 ML |
26612 | Generate code for a little-endian target. |
26613 | ||
d77de738 | 26614 | @opindex mxl-reorder |
ddf6fe37 | 26615 | @item -mxl-reorder |
d77de738 ML |
26616 | Use reorder instructions (swap and byte reversed load/store). |
26617 | ||
26618 | @item -mxl-mode-@var{app-model} | |
26619 | Select application model @var{app-model}. Valid models are | |
26620 | @table @samp | |
26621 | @item executable | |
26622 | normal executable (default), uses startup code @file{crt0.o}. | |
26623 | ||
26624 | @item xmdstub | |
26625 | for use with Xilinx Microprocessor Debugger (XMD) based | |
26626 | software intrusive debug agent called xmdstub. This uses startup file | |
26627 | @file{crt1.o} and sets the start address of the program to 0x800. | |
26628 | ||
26629 | @item bootstrap | |
26630 | for applications that are loaded using a bootloader. | |
26631 | This model uses startup file @file{crt2.o} which does not contain a processor | |
26632 | reset vector handler. This is suitable for transferring control on a | |
26633 | processor reset to the bootloader rather than the application. | |
26634 | ||
26635 | @item novectors | |
26636 | for applications that do not require any of the | |
26637 | MicroBlaze vectors. This option may be useful for applications running | |
26638 | within a monitoring application. This model uses @file{crt3.o} as a startup file. | |
26639 | @end table | |
26640 | ||
26641 | Option @option{-xl-mode-@var{app-model}} is a deprecated alias for | |
26642 | @option{-mxl-mode-@var{app-model}}. | |
26643 | ||
d77de738 | 26644 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 26645 | @item -mpic-data-is-text-relative |
d77de738 ML |
26646 | Assume that the displacement between the text and data segments is fixed |
26647 | at static link time. This allows data to be referenced by offset from start of | |
26648 | text address instead of GOT since PC-relative addressing is not supported. | |
26649 | ||
26650 | @end table | |
26651 | ||
26652 | @node MIPS Options | |
26653 | @subsection MIPS Options | |
26654 | @cindex MIPS options | |
26655 | ||
26656 | @table @gcctabopt | |
26657 | ||
d77de738 | 26658 | @opindex EB |
ddf6fe37 | 26659 | @item -EB |
d77de738 ML |
26660 | Generate big-endian code. |
26661 | ||
d77de738 | 26662 | @opindex EL |
ddf6fe37 | 26663 | @item -EL |
d77de738 ML |
26664 | Generate little-endian code. This is the default for @samp{mips*el-*-*} |
26665 | configurations. | |
26666 | ||
d77de738 | 26667 | @opindex march |
ddf6fe37 | 26668 | @item -march=@var{arch} |
d77de738 ML |
26669 | Generate code that runs on @var{arch}, which can be the name of a |
26670 | generic MIPS ISA, or the name of a particular processor. | |
26671 | The ISA names are: | |
26672 | @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4}, | |
26673 | @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5}, | |
26674 | @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3}, | |
26675 | @samp{mips64r5} and @samp{mips64r6}. | |
26676 | The processor names are: | |
26677 | @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc}, | |
26678 | @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd}, | |
26679 | @samp{5kc}, @samp{5kf}, | |
26680 | @samp{20kc}, | |
26681 | @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1}, | |
26682 | @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1}, | |
26683 | @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn}, | |
26684 | @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2}, | |
26685 | @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1}, | |
26686 | @samp{i6400}, @samp{i6500}, | |
26687 | @samp{interaptiv}, | |
26688 | @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464}, | |
26689 | @samp{gs464e}, @samp{gs264e}, | |
26690 | @samp{m4k}, | |
26691 | @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec}, | |
26692 | @samp{m5100}, @samp{m5101}, | |
26693 | @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3}, | |
26694 | @samp{orion}, | |
26695 | @samp{p5600}, @samp{p6600}, | |
26696 | @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400}, | |
26697 | @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900}, | |
26698 | @samp{r6000}, @samp{r8000}, | |
26699 | @samp{rm7000}, @samp{rm9000}, | |
26700 | @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000}, | |
26701 | @samp{sb1}, | |
26702 | @samp{sr71000}, | |
26703 | @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300}, | |
26704 | @samp{vr5000}, @samp{vr5400}, @samp{vr5500}, | |
26705 | @samp{xlr} and @samp{xlp}. | |
26706 | The special value @samp{from-abi} selects the | |
26707 | most compatible architecture for the selected ABI (that is, | |
26708 | @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. | |
26709 | ||
26710 | The native Linux/GNU toolchain also supports the value @samp{native}, | |
26711 | which selects the best architecture option for the host processor. | |
26712 | @option{-march=native} has no effect if GCC does not recognize | |
26713 | the processor. | |
26714 | ||
26715 | In processor names, a final @samp{000} can be abbreviated as @samp{k} | |
26716 | (for example, @option{-march=r2k}). Prefixes are optional, and | |
26717 | @samp{vr} may be written @samp{r}. | |
26718 | ||
26719 | Names of the form @samp{@var{n}f2_1} refer to processors with | |
26720 | FPUs clocked at half the rate of the core, names of the form | |
26721 | @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same | |
26722 | rate as the core, and names of the form @samp{@var{n}f3_2} refer to | |
26723 | processors with FPUs clocked a ratio of 3:2 with respect to the core. | |
26724 | For compatibility reasons, @samp{@var{n}f} is accepted as a synonym | |
26725 | for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are | |
26726 | accepted as synonyms for @samp{@var{n}f1_1}. | |
26727 | ||
26728 | GCC defines two macros based on the value of this option. The first | |
26729 | is @code{_MIPS_ARCH}, which gives the name of target architecture, as | |
26730 | a string. The second has the form @code{_MIPS_ARCH_@var{foo}}, | |
26731 | where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@. | |
26732 | For example, @option{-march=r2000} sets @code{_MIPS_ARCH} | |
26733 | to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}. | |
26734 | ||
26735 | Note that the @code{_MIPS_ARCH} macro uses the processor names given | |
26736 | above. In other words, it has the full prefix and does not | |
26737 | abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi}, | |
26738 | the macro names the resolved architecture (either @code{"mips1"} or | |
26739 | @code{"mips3"}). It names the default architecture when no | |
26740 | @option{-march} option is given. | |
26741 | ||
d77de738 | 26742 | @opindex mtune |
ddf6fe37 | 26743 | @item -mtune=@var{arch} |
d77de738 ML |
26744 | Optimize for @var{arch}. Among other things, this option controls |
26745 | the way instructions are scheduled, and the perceived cost of arithmetic | |
26746 | operations. The list of @var{arch} values is the same as for | |
26747 | @option{-march}. | |
26748 | ||
26749 | When this option is not used, GCC optimizes for the processor | |
26750 | specified by @option{-march}. By using @option{-march} and | |
26751 | @option{-mtune} together, it is possible to generate code that | |
26752 | runs on a family of processors, but optimize the code for one | |
26753 | particular member of that family. | |
26754 | ||
26755 | @option{-mtune} defines the macros @code{_MIPS_TUNE} and | |
26756 | @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the | |
26757 | @option{-march} ones described above. | |
26758 | ||
d77de738 | 26759 | @opindex mips1 |
ddf6fe37 | 26760 | @item -mips1 |
d77de738 ML |
26761 | Equivalent to @option{-march=mips1}. |
26762 | ||
d77de738 | 26763 | @opindex mips2 |
ddf6fe37 | 26764 | @item -mips2 |
d77de738 ML |
26765 | Equivalent to @option{-march=mips2}. |
26766 | ||
d77de738 | 26767 | @opindex mips3 |
ddf6fe37 | 26768 | @item -mips3 |
d77de738 ML |
26769 | Equivalent to @option{-march=mips3}. |
26770 | ||
d77de738 | 26771 | @opindex mips4 |
ddf6fe37 | 26772 | @item -mips4 |
d77de738 ML |
26773 | Equivalent to @option{-march=mips4}. |
26774 | ||
d77de738 | 26775 | @opindex mips32 |
ddf6fe37 | 26776 | @item -mips32 |
d77de738 ML |
26777 | Equivalent to @option{-march=mips32}. |
26778 | ||
d77de738 | 26779 | @opindex mips32r3 |
ddf6fe37 | 26780 | @item -mips32r3 |
d77de738 ML |
26781 | Equivalent to @option{-march=mips32r3}. |
26782 | ||
d77de738 | 26783 | @opindex mips32r5 |
ddf6fe37 | 26784 | @item -mips32r5 |
d77de738 ML |
26785 | Equivalent to @option{-march=mips32r5}. |
26786 | ||
d77de738 | 26787 | @opindex mips32r6 |
ddf6fe37 | 26788 | @item -mips32r6 |
d77de738 ML |
26789 | Equivalent to @option{-march=mips32r6}. |
26790 | ||
d77de738 | 26791 | @opindex mips64 |
ddf6fe37 | 26792 | @item -mips64 |
d77de738 ML |
26793 | Equivalent to @option{-march=mips64}. |
26794 | ||
d77de738 | 26795 | @opindex mips64r2 |
ddf6fe37 | 26796 | @item -mips64r2 |
d77de738 ML |
26797 | Equivalent to @option{-march=mips64r2}. |
26798 | ||
d77de738 | 26799 | @opindex mips64r3 |
ddf6fe37 | 26800 | @item -mips64r3 |
d77de738 ML |
26801 | Equivalent to @option{-march=mips64r3}. |
26802 | ||
d77de738 | 26803 | @opindex mips64r5 |
ddf6fe37 | 26804 | @item -mips64r5 |
d77de738 ML |
26805 | Equivalent to @option{-march=mips64r5}. |
26806 | ||
d77de738 | 26807 | @opindex mips64r6 |
ddf6fe37 | 26808 | @item -mips64r6 |
d77de738 ML |
26809 | Equivalent to @option{-march=mips64r6}. |
26810 | ||
d77de738 ML |
26811 | @opindex mips16 |
26812 | @opindex mno-mips16 | |
ddf6fe37 AA |
26813 | @item -mips16 |
26814 | @itemx -mno-mips16 | |
d77de738 ML |
26815 | Generate (do not generate) MIPS16 code. If GCC is targeting a |
26816 | MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@. | |
26817 | ||
26818 | MIPS16 code generation can also be controlled on a per-function basis | |
26819 | by means of @code{mips16} and @code{nomips16} attributes. | |
26820 | @xref{Function Attributes}, for more information. | |
26821 | ||
d77de738 | 26822 | @opindex mflip-mips16 |
ddf6fe37 | 26823 | @item -mflip-mips16 |
d77de738 ML |
26824 | Generate MIPS16 code on alternating functions. This option is provided |
26825 | for regression testing of mixed MIPS16/non-MIPS16 code generation, and is | |
26826 | not intended for ordinary use in compiling user code. | |
26827 | ||
d77de738 ML |
26828 | @opindex minterlink-compressed |
26829 | @opindex mno-interlink-compressed | |
ddf6fe37 AA |
26830 | @item -minterlink-compressed |
26831 | @itemx -mno-interlink-compressed | |
d77de738 ML |
26832 | Require (do not require) that code using the standard (uncompressed) MIPS ISA |
26833 | be link-compatible with MIPS16 and microMIPS code, and vice versa. | |
26834 | ||
26835 | For example, code using the standard ISA encoding cannot jump directly | |
26836 | to MIPS16 or microMIPS code; it must either use a call or an indirect jump. | |
26837 | @option{-minterlink-compressed} therefore disables direct jumps unless GCC | |
26838 | knows that the target of the jump is not compressed. | |
26839 | ||
d77de738 ML |
26840 | @opindex minterlink-mips16 |
26841 | @opindex mno-interlink-mips16 | |
ddf6fe37 AA |
26842 | @item -minterlink-mips16 |
26843 | @itemx -mno-interlink-mips16 | |
d77de738 ML |
26844 | Aliases of @option{-minterlink-compressed} and |
26845 | @option{-mno-interlink-compressed}. These options predate the microMIPS ASE | |
26846 | and are retained for backwards compatibility. | |
26847 | ||
d77de738 ML |
26848 | @opindex mabi=32 |
26849 | @opindex mabi=o64 | |
26850 | @opindex mabi=n32 | |
26851 | @opindex mabi=64 | |
26852 | @opindex mabi=eabi | |
ddf6fe37 AA |
26853 | @item -mabi=32 |
26854 | @itemx -mabi=o64 | |
26855 | @itemx -mabi=n32 | |
26856 | @itemx -mabi=64 | |
26857 | @itemx -mabi=eabi | |
d77de738 ML |
26858 | Generate code for the given ABI@. |
26859 | ||
26860 | Note that the EABI has a 32-bit and a 64-bit variant. GCC normally | |
26861 | generates 64-bit code when you select a 64-bit architecture, but you | |
26862 | can use @option{-mgp32} to get 32-bit code instead. | |
26863 | ||
26864 | For information about the O64 ABI, see | |
26865 | @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}. | |
26866 | ||
26867 | GCC supports a variant of the o32 ABI in which floating-point registers | |
26868 | are 64 rather than 32 bits wide. You can select this combination with | |
26869 | @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1} | |
26870 | and @code{mfhc1} instructions and is therefore only supported for | |
26871 | MIPS32R2, MIPS32R3 and MIPS32R5 processors. | |
26872 | ||
26873 | The register assignments for arguments and return values remain the | |
26874 | same, but each scalar value is passed in a single 64-bit register | |
26875 | rather than a pair of 32-bit registers. For example, scalar | |
26876 | floating-point values are returned in @samp{$f0} only, not a | |
26877 | @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also | |
26878 | remains the same in that the even-numbered double-precision registers | |
26879 | are saved. | |
26880 | ||
26881 | Two additional variants of the o32 ABI are supported to enable | |
26882 | a transition from 32-bit to 64-bit registers. These are FPXX | |
26883 | (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}). | |
26884 | The FPXX extension mandates that all code must execute correctly | |
26885 | when run using 32-bit or 64-bit registers. The code can be interlinked | |
26886 | with either FP32 or FP64, but not both. | |
26887 | The FP64A extension is similar to the FP64 extension but forbids the | |
26888 | use of odd-numbered single-precision registers. This can be used | |
26889 | in conjunction with the @code{FRE} mode of FPUs in MIPS32R5 | |
26890 | processors and allows both FP32 and FP64A code to interlink and | |
26891 | run in the same process without changing FPU modes. | |
26892 | ||
d77de738 ML |
26893 | @opindex mabicalls |
26894 | @opindex mno-abicalls | |
ddf6fe37 AA |
26895 | @item -mabicalls |
26896 | @itemx -mno-abicalls | |
d77de738 ML |
26897 | Generate (do not generate) code that is suitable for SVR4-style |
26898 | dynamic objects. @option{-mabicalls} is the default for SVR4-based | |
26899 | systems. | |
26900 | ||
26901 | @item -mshared | |
26902 | @itemx -mno-shared | |
26903 | Generate (do not generate) code that is fully position-independent, | |
26904 | and that can therefore be linked into shared libraries. This option | |
26905 | only affects @option{-mabicalls}. | |
26906 | ||
26907 | All @option{-mabicalls} code has traditionally been position-independent, | |
26908 | regardless of options like @option{-fPIC} and @option{-fpic}. However, | |
26909 | as an extension, the GNU toolchain allows executables to use absolute | |
26910 | accesses for locally-binding symbols. It can also use shorter GP | |
26911 | initialization sequences and generate direct calls to locally-defined | |
26912 | functions. This mode is selected by @option{-mno-shared}. | |
26913 | ||
26914 | @option{-mno-shared} depends on binutils 2.16 or higher and generates | |
26915 | objects that can only be linked by the GNU linker. However, the option | |
26916 | does not affect the ABI of the final executable; it only affects the ABI | |
26917 | of relocatable objects. Using @option{-mno-shared} generally makes | |
26918 | executables both smaller and quicker. | |
26919 | ||
26920 | @option{-mshared} is the default. | |
26921 | ||
d77de738 ML |
26922 | @opindex mplt |
26923 | @opindex mno-plt | |
ddf6fe37 AA |
26924 | @item -mplt |
26925 | @itemx -mno-plt | |
d77de738 ML |
26926 | Assume (do not assume) that the static and dynamic linkers |
26927 | support PLTs and copy relocations. This option only affects | |
26928 | @option{-mno-shared -mabicalls}. For the n64 ABI, this option | |
26929 | has no effect without @option{-msym32}. | |
26930 | ||
26931 | You can make @option{-mplt} the default by configuring | |
26932 | GCC with @option{--with-mips-plt}. The default is | |
26933 | @option{-mno-plt} otherwise. | |
26934 | ||
d77de738 ML |
26935 | @opindex mxgot |
26936 | @opindex mno-xgot | |
ddf6fe37 AA |
26937 | @item -mxgot |
26938 | @itemx -mno-xgot | |
d77de738 ML |
26939 | Lift (do not lift) the usual restrictions on the size of the global |
26940 | offset table. | |
26941 | ||
26942 | GCC normally uses a single instruction to load values from the GOT@. | |
26943 | While this is relatively efficient, it only works if the GOT | |
26944 | is smaller than about 64k. Anything larger causes the linker | |
26945 | to report an error such as: | |
26946 | ||
26947 | @cindex relocation truncated to fit (MIPS) | |
26948 | @smallexample | |
26949 | relocation truncated to fit: R_MIPS_GOT16 foobar | |
26950 | @end smallexample | |
26951 | ||
26952 | If this happens, you should recompile your code with @option{-mxgot}. | |
26953 | This works with very large GOTs, although the code is also | |
26954 | less efficient, since it takes three instructions to fetch the | |
26955 | value of a global symbol. | |
26956 | ||
26957 | Note that some linkers can create multiple GOTs. If you have such a | |
26958 | linker, you should only need to use @option{-mxgot} when a single object | |
26959 | file accesses more than 64k's worth of GOT entries. Very few do. | |
26960 | ||
26961 | These options have no effect unless GCC is generating position | |
26962 | independent code. | |
26963 | ||
d77de738 | 26964 | @opindex mgp32 |
ddf6fe37 | 26965 | @item -mgp32 |
d77de738 ML |
26966 | Assume that general-purpose registers are 32 bits wide. |
26967 | ||
d77de738 | 26968 | @opindex mgp64 |
ddf6fe37 | 26969 | @item -mgp64 |
d77de738 ML |
26970 | Assume that general-purpose registers are 64 bits wide. |
26971 | ||
d77de738 | 26972 | @opindex mfp32 |
ddf6fe37 | 26973 | @item -mfp32 |
d77de738 ML |
26974 | Assume that floating-point registers are 32 bits wide. |
26975 | ||
d77de738 | 26976 | @opindex mfp64 |
ddf6fe37 | 26977 | @item -mfp64 |
d77de738 ML |
26978 | Assume that floating-point registers are 64 bits wide. |
26979 | ||
d77de738 | 26980 | @opindex mfpxx |
ddf6fe37 | 26981 | @item -mfpxx |
d77de738 ML |
26982 | Do not assume the width of floating-point registers. |
26983 | ||
d77de738 | 26984 | @opindex mhard-float |
ddf6fe37 | 26985 | @item -mhard-float |
d77de738 ML |
26986 | Use floating-point coprocessor instructions. |
26987 | ||
d77de738 | 26988 | @opindex msoft-float |
ddf6fe37 | 26989 | @item -msoft-float |
d77de738 ML |
26990 | Do not use floating-point coprocessor instructions. Implement |
26991 | floating-point calculations using library calls instead. | |
26992 | ||
d77de738 | 26993 | @opindex mno-float |
ddf6fe37 | 26994 | @item -mno-float |
d77de738 ML |
26995 | Equivalent to @option{-msoft-float}, but additionally asserts that the |
26996 | program being compiled does not perform any floating-point operations. | |
26997 | This option is presently supported only by some bare-metal MIPS | |
26998 | configurations, where it may select a special set of libraries | |
26999 | that lack all floating-point support (including, for example, the | |
27000 | floating-point @code{printf} formats). | |
27001 | If code compiled with @option{-mno-float} accidentally contains | |
27002 | floating-point operations, it is likely to suffer a link-time | |
27003 | or run-time failure. | |
27004 | ||
d77de738 | 27005 | @opindex msingle-float |
ddf6fe37 | 27006 | @item -msingle-float |
d77de738 ML |
27007 | Assume that the floating-point coprocessor only supports single-precision |
27008 | operations. | |
27009 | ||
d77de738 | 27010 | @opindex mdouble-float |
ddf6fe37 | 27011 | @item -mdouble-float |
d77de738 ML |
27012 | Assume that the floating-point coprocessor supports double-precision |
27013 | operations. This is the default. | |
27014 | ||
d77de738 ML |
27015 | @opindex modd-spreg |
27016 | @opindex mno-odd-spreg | |
ddf6fe37 AA |
27017 | @item -modd-spreg |
27018 | @itemx -mno-odd-spreg | |
d77de738 ML |
27019 | Enable the use of odd-numbered single-precision floating-point registers |
27020 | for the o32 ABI. This is the default for processors that are known to | |
27021 | support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg} | |
27022 | is set by default. | |
27023 | ||
d77de738 ML |
27024 | @opindex mabs=2008 |
27025 | @opindex mabs=legacy | |
ddf6fe37 AA |
27026 | @item -mabs=2008 |
27027 | @itemx -mabs=legacy | |
d77de738 ML |
27028 | These options control the treatment of the special not-a-number (NaN) |
27029 | IEEE 754 floating-point data with the @code{abs.@i{fmt}} and | |
27030 | @code{neg.@i{fmt}} machine instructions. | |
27031 | ||
27032 | By default or when @option{-mabs=legacy} is used the legacy | |
27033 | treatment is selected. In this case these instructions are considered | |
27034 | arithmetic and avoided where correct operation is required and the | |
27035 | input operand might be a NaN. A longer sequence of instructions that | |
27036 | manipulate the sign bit of floating-point datum manually is used | |
27037 | instead unless the @option{-ffinite-math-only} option has also been | |
27038 | specified. | |
27039 | ||
27040 | The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In | |
27041 | this case these instructions are considered non-arithmetic and therefore | |
27042 | operating correctly in all cases, including in particular where the | |
27043 | input operand is a NaN. These instructions are therefore always used | |
27044 | for the respective operations. | |
27045 | ||
d77de738 ML |
27046 | @opindex mnan=2008 |
27047 | @opindex mnan=legacy | |
ddf6fe37 AA |
27048 | @item -mnan=2008 |
27049 | @itemx -mnan=legacy | |
d77de738 ML |
27050 | These options control the encoding of the special not-a-number (NaN) |
27051 | IEEE 754 floating-point data. | |
27052 | ||
27053 | The @option{-mnan=legacy} option selects the legacy encoding. In this | |
27054 | case quiet NaNs (qNaNs) are denoted by the first bit of their trailing | |
27055 | significand field being 0, whereas signaling NaNs (sNaNs) are denoted | |
27056 | by the first bit of their trailing significand field being 1. | |
27057 | ||
27058 | The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In | |
27059 | this case qNaNs are denoted by the first bit of their trailing | |
27060 | significand field being 1, whereas sNaNs are denoted by the first bit of | |
27061 | their trailing significand field being 0. | |
27062 | ||
27063 | The default is @option{-mnan=legacy} unless GCC has been configured with | |
27064 | @option{--with-nan=2008}. | |
27065 | ||
d77de738 ML |
27066 | @opindex mllsc |
27067 | @opindex mno-llsc | |
ddf6fe37 AA |
27068 | @item -mllsc |
27069 | @itemx -mno-llsc | |
d77de738 ML |
27070 | Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to |
27071 | implement atomic memory built-in functions. When neither option is | |
27072 | specified, GCC uses the instructions if the target architecture | |
27073 | supports them. | |
27074 | ||
27075 | @option{-mllsc} is useful if the runtime environment can emulate the | |
27076 | instructions and @option{-mno-llsc} can be useful when compiling for | |
27077 | nonstandard ISAs. You can make either option the default by | |
27078 | configuring GCC with @option{--with-llsc} and @option{--without-llsc} | |
27079 | respectively. @option{--with-llsc} is the default for some | |
27080 | configurations; see the installation documentation for details. | |
27081 | ||
d77de738 ML |
27082 | @opindex mdsp |
27083 | @opindex mno-dsp | |
ddf6fe37 AA |
27084 | @item -mdsp |
27085 | @itemx -mno-dsp | |
d77de738 ML |
27086 | Use (do not use) revision 1 of the MIPS DSP ASE@. |
27087 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27088 | preprocessor macro @code{__mips_dsp}. It also defines | |
27089 | @code{__mips_dsp_rev} to 1. | |
27090 | ||
d77de738 ML |
27091 | @opindex mdspr2 |
27092 | @opindex mno-dspr2 | |
ddf6fe37 AA |
27093 | @item -mdspr2 |
27094 | @itemx -mno-dspr2 | |
d77de738 ML |
27095 | Use (do not use) revision 2 of the MIPS DSP ASE@. |
27096 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27097 | preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}. | |
27098 | It also defines @code{__mips_dsp_rev} to 2. | |
27099 | ||
d77de738 ML |
27100 | @opindex msmartmips |
27101 | @opindex mno-smartmips | |
ddf6fe37 AA |
27102 | @item -msmartmips |
27103 | @itemx -mno-smartmips | |
d77de738 ML |
27104 | Use (do not use) the MIPS SmartMIPS ASE. |
27105 | ||
d77de738 ML |
27106 | @opindex mpaired-single |
27107 | @opindex mno-paired-single | |
ddf6fe37 AA |
27108 | @item -mpaired-single |
27109 | @itemx -mno-paired-single | |
d77de738 ML |
27110 | Use (do not use) paired-single floating-point instructions. |
27111 | @xref{MIPS Paired-Single Support}. This option requires | |
27112 | hardware floating-point support to be enabled. | |
27113 | ||
d77de738 ML |
27114 | @opindex mdmx |
27115 | @opindex mno-mdmx | |
ddf6fe37 AA |
27116 | @item -mdmx |
27117 | @itemx -mno-mdmx | |
d77de738 ML |
27118 | Use (do not use) MIPS Digital Media Extension instructions. |
27119 | This option can only be used when generating 64-bit code and requires | |
27120 | hardware floating-point support to be enabled. | |
27121 | ||
d77de738 ML |
27122 | @opindex mips3d |
27123 | @opindex mno-mips3d | |
ddf6fe37 AA |
27124 | @item -mips3d |
27125 | @itemx -mno-mips3d | |
d77de738 ML |
27126 | Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}. |
27127 | The option @option{-mips3d} implies @option{-mpaired-single}. | |
27128 | ||
d77de738 ML |
27129 | @opindex mmicromips |
27130 | @opindex mno-mmicromips | |
ddf6fe37 AA |
27131 | @item -mmicromips |
27132 | @itemx -mno-micromips | |
d77de738 ML |
27133 | Generate (do not generate) microMIPS code. |
27134 | ||
27135 | MicroMIPS code generation can also be controlled on a per-function basis | |
27136 | by means of @code{micromips} and @code{nomicromips} attributes. | |
27137 | @xref{Function Attributes}, for more information. | |
27138 | ||
d77de738 ML |
27139 | @opindex mmt |
27140 | @opindex mno-mt | |
ddf6fe37 AA |
27141 | @item -mmt |
27142 | @itemx -mno-mt | |
d77de738 ML |
27143 | Use (do not use) MT Multithreading instructions. |
27144 | ||
d77de738 ML |
27145 | @opindex mmcu |
27146 | @opindex mno-mcu | |
ddf6fe37 AA |
27147 | @item -mmcu |
27148 | @itemx -mno-mcu | |
d77de738 ML |
27149 | Use (do not use) the MIPS MCU ASE instructions. |
27150 | ||
d77de738 ML |
27151 | @opindex meva |
27152 | @opindex mno-eva | |
ddf6fe37 AA |
27153 | @item -meva |
27154 | @itemx -mno-eva | |
d77de738 ML |
27155 | Use (do not use) the MIPS Enhanced Virtual Addressing instructions. |
27156 | ||
d77de738 ML |
27157 | @opindex mvirt |
27158 | @opindex mno-virt | |
ddf6fe37 AA |
27159 | @item -mvirt |
27160 | @itemx -mno-virt | |
d77de738 ML |
27161 | Use (do not use) the MIPS Virtualization (VZ) instructions. |
27162 | ||
d77de738 ML |
27163 | @opindex mxpa |
27164 | @opindex mno-xpa | |
ddf6fe37 AA |
27165 | @item -mxpa |
27166 | @itemx -mno-xpa | |
d77de738 ML |
27167 | Use (do not use) the MIPS eXtended Physical Address (XPA) instructions. |
27168 | ||
d77de738 ML |
27169 | @opindex mcrc |
27170 | @opindex mno-crc | |
ddf6fe37 AA |
27171 | @item -mcrc |
27172 | @itemx -mno-crc | |
d77de738 ML |
27173 | Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions. |
27174 | ||
d77de738 ML |
27175 | @opindex mginv |
27176 | @opindex mno-ginv | |
ddf6fe37 AA |
27177 | @item -mginv |
27178 | @itemx -mno-ginv | |
d77de738 ML |
27179 | Use (do not use) the MIPS Global INValidate (GINV) instructions. |
27180 | ||
d77de738 ML |
27181 | @opindex mloongson-mmi |
27182 | @opindex mno-loongson-mmi | |
ddf6fe37 AA |
27183 | @item -mloongson-mmi |
27184 | @itemx -mno-loongson-mmi | |
d77de738 ML |
27185 | Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI). |
27186 | ||
d77de738 ML |
27187 | @opindex mloongson-ext |
27188 | @opindex mno-loongson-ext | |
ddf6fe37 AA |
27189 | @item -mloongson-ext |
27190 | @itemx -mno-loongson-ext | |
d77de738 ML |
27191 | Use (do not use) the MIPS Loongson EXTensions (EXT) instructions. |
27192 | ||
d77de738 ML |
27193 | @opindex mloongson-ext2 |
27194 | @opindex mno-loongson-ext2 | |
ddf6fe37 AA |
27195 | @item -mloongson-ext2 |
27196 | @itemx -mno-loongson-ext2 | |
d77de738 ML |
27197 | Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions. |
27198 | ||
d77de738 | 27199 | @opindex mlong64 |
ddf6fe37 | 27200 | @item -mlong64 |
d77de738 ML |
27201 | Force @code{long} types to be 64 bits wide. See @option{-mlong32} for |
27202 | an explanation of the default and the way that the pointer size is | |
27203 | determined. | |
27204 | ||
d77de738 | 27205 | @opindex mlong32 |
ddf6fe37 | 27206 | @item -mlong32 |
d77de738 ML |
27207 | Force @code{long}, @code{int}, and pointer types to be 32 bits wide. |
27208 | ||
27209 | The default size of @code{int}s, @code{long}s and pointers depends on | |
27210 | the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI | |
27211 | uses 64-bit @code{long}s, as does the 64-bit EABI; the others use | |
27212 | 32-bit @code{long}s. Pointers are the same size as @code{long}s, | |
27213 | or the same size as integer registers, whichever is smaller. | |
27214 | ||
d77de738 ML |
27215 | @opindex msym32 |
27216 | @opindex mno-sym32 | |
ddf6fe37 AA |
27217 | @item -msym32 |
27218 | @itemx -mno-sym32 | |
d77de738 ML |
27219 | Assume (do not assume) that all symbols have 32-bit values, regardless |
27220 | of the selected ABI@. This option is useful in combination with | |
27221 | @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC | |
27222 | to generate shorter and faster references to symbolic addresses. | |
27223 | ||
d77de738 | 27224 | @opindex G |
ddf6fe37 | 27225 | @item -G @var{num} |
d77de738 ML |
27226 | Put definitions of externally-visible data in a small data section |
27227 | if that data is no bigger than @var{num} bytes. GCC can then generate | |
27228 | more efficient accesses to the data; see @option{-mgpopt} for details. | |
27229 | ||
27230 | The default @option{-G} option depends on the configuration. | |
27231 | ||
d77de738 ML |
27232 | @opindex mlocal-sdata |
27233 | @opindex mno-local-sdata | |
ddf6fe37 AA |
27234 | @item -mlocal-sdata |
27235 | @itemx -mno-local-sdata | |
d77de738 ML |
27236 | Extend (do not extend) the @option{-G} behavior to local data too, |
27237 | such as to static variables in C@. @option{-mlocal-sdata} is the | |
27238 | default for all configurations. | |
27239 | ||
27240 | If the linker complains that an application is using too much small data, | |
27241 | you might want to try rebuilding the less performance-critical parts with | |
27242 | @option{-mno-local-sdata}. You might also want to build large | |
27243 | libraries with @option{-mno-local-sdata}, so that the libraries leave | |
27244 | more room for the main program. | |
27245 | ||
d77de738 ML |
27246 | @opindex mextern-sdata |
27247 | @opindex mno-extern-sdata | |
ddf6fe37 AA |
27248 | @item -mextern-sdata |
27249 | @itemx -mno-extern-sdata | |
d77de738 ML |
27250 | Assume (do not assume) that externally-defined data is in |
27251 | a small data section if the size of that data is within the @option{-G} limit. | |
27252 | @option{-mextern-sdata} is the default for all configurations. | |
27253 | ||
27254 | If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G | |
27255 | @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var} | |
27256 | that is no bigger than @var{num} bytes, you must make sure that @var{Var} | |
27257 | is placed in a small data section. If @var{Var} is defined by another | |
27258 | module, you must either compile that module with a high-enough | |
27259 | @option{-G} setting or attach a @code{section} attribute to @var{Var}'s | |
27260 | definition. If @var{Var} is common, you must link the application | |
27261 | with a high-enough @option{-G} setting. | |
27262 | ||
27263 | The easiest way of satisfying these restrictions is to compile | |
27264 | and link every module with the same @option{-G} option. However, | |
27265 | you may wish to build a library that supports several different | |
27266 | small data limits. You can do this by compiling the library with | |
27267 | the highest supported @option{-G} setting and additionally using | |
27268 | @option{-mno-extern-sdata} to stop the library from making assumptions | |
27269 | about externally-defined data. | |
27270 | ||
d77de738 ML |
27271 | @opindex mgpopt |
27272 | @opindex mno-gpopt | |
ddf6fe37 AA |
27273 | @item -mgpopt |
27274 | @itemx -mno-gpopt | |
d77de738 ML |
27275 | Use (do not use) GP-relative accesses for symbols that are known to be |
27276 | in a small data section; see @option{-G}, @option{-mlocal-sdata} and | |
27277 | @option{-mextern-sdata}. @option{-mgpopt} is the default for all | |
27278 | configurations. | |
27279 | ||
27280 | @option{-mno-gpopt} is useful for cases where the @code{$gp} register | |
27281 | might not hold the value of @code{_gp}. For example, if the code is | |
27282 | part of a library that might be used in a boot monitor, programs that | |
27283 | call boot monitor routines pass an unknown value in @code{$gp}. | |
27284 | (In such situations, the boot monitor itself is usually compiled | |
27285 | with @option{-G0}.) | |
27286 | ||
27287 | @option{-mno-gpopt} implies @option{-mno-local-sdata} and | |
27288 | @option{-mno-extern-sdata}. | |
27289 | ||
d77de738 ML |
27290 | @opindex membedded-data |
27291 | @opindex mno-embedded-data | |
ddf6fe37 AA |
27292 | @item -membedded-data |
27293 | @itemx -mno-embedded-data | |
d77de738 ML |
27294 | Allocate variables to the read-only data section first if possible, then |
27295 | next in the small data section if possible, otherwise in data. This gives | |
27296 | slightly slower code than the default, but reduces the amount of RAM required | |
27297 | when executing, and thus may be preferred for some embedded systems. | |
27298 | ||
d77de738 ML |
27299 | @opindex muninit-const-in-rodata |
27300 | @opindex mno-uninit-const-in-rodata | |
ddf6fe37 AA |
27301 | @item -muninit-const-in-rodata |
27302 | @itemx -mno-uninit-const-in-rodata | |
d77de738 ML |
27303 | Put uninitialized @code{const} variables in the read-only data section. |
27304 | This option is only meaningful in conjunction with @option{-membedded-data}. | |
27305 | ||
d77de738 | 27306 | @opindex mcode-readable |
ddf6fe37 | 27307 | @item -mcode-readable=@var{setting} |
d77de738 ML |
27308 | Specify whether GCC may generate code that reads from executable sections. |
27309 | There are three possible settings: | |
27310 | ||
27311 | @table @gcctabopt | |
27312 | @item -mcode-readable=yes | |
27313 | Instructions may freely access executable sections. This is the | |
27314 | default setting. | |
27315 | ||
27316 | @item -mcode-readable=pcrel | |
27317 | MIPS16 PC-relative load instructions can access executable sections, | |
27318 | but other instructions must not do so. This option is useful on 4KSc | |
27319 | and 4KSd processors when the code TLBs have the Read Inhibit bit set. | |
27320 | It is also useful on processors that can be configured to have a dual | |
27321 | instruction/data SRAM interface and that, like the M4K, automatically | |
27322 | redirect PC-relative loads to the instruction RAM. | |
27323 | ||
27324 | @item -mcode-readable=no | |
27325 | Instructions must not access executable sections. This option can be | |
27326 | useful on targets that are configured to have a dual instruction/data | |
27327 | SRAM interface but that (unlike the M4K) do not automatically redirect | |
27328 | PC-relative loads to the instruction RAM. | |
27329 | @end table | |
27330 | ||
d77de738 ML |
27331 | @opindex msplit-addresses |
27332 | @opindex mno-split-addresses | |
ddf6fe37 AA |
27333 | @item -msplit-addresses |
27334 | @itemx -mno-split-addresses | |
d77de738 ML |
27335 | Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler |
27336 | relocation operators. This option has been superseded by | |
27337 | @option{-mexplicit-relocs} but is retained for backwards compatibility. | |
27338 | ||
d77de738 ML |
27339 | @opindex mexplicit-relocs |
27340 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
27341 | @item -mexplicit-relocs |
27342 | @itemx -mno-explicit-relocs | |
d77de738 ML |
27343 | Use (do not use) assembler relocation operators when dealing with symbolic |
27344 | addresses. The alternative, selected by @option{-mno-explicit-relocs}, | |
27345 | is to use assembler macros instead. | |
27346 | ||
27347 | @option{-mexplicit-relocs} is the default if GCC was configured | |
27348 | to use an assembler that supports relocation operators. | |
27349 | ||
d77de738 ML |
27350 | @opindex mcheck-zero-division |
27351 | @opindex mno-check-zero-division | |
ddf6fe37 AA |
27352 | @item -mcheck-zero-division |
27353 | @itemx -mno-check-zero-division | |
d77de738 ML |
27354 | Trap (do not trap) on integer division by zero. |
27355 | ||
27356 | The default is @option{-mcheck-zero-division}. | |
27357 | ||
d77de738 ML |
27358 | @opindex mdivide-traps |
27359 | @opindex mdivide-breaks | |
ddf6fe37 AA |
27360 | @item -mdivide-traps |
27361 | @itemx -mdivide-breaks | |
d77de738 ML |
27362 | MIPS systems check for division by zero by generating either a |
27363 | conditional trap or a break instruction. Using traps results in | |
27364 | smaller code, but is only supported on MIPS II and later. Also, some | |
27365 | versions of the Linux kernel have a bug that prevents trap from | |
27366 | generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to | |
27367 | allow conditional traps on architectures that support them and | |
27368 | @option{-mdivide-breaks} to force the use of breaks. | |
27369 | ||
27370 | The default is usually @option{-mdivide-traps}, but this can be | |
27371 | overridden at configure time using @option{--with-divide=breaks}. | |
27372 | Divide-by-zero checks can be completely disabled using | |
27373 | @option{-mno-check-zero-division}. | |
27374 | ||
d77de738 ML |
27375 | @opindex mload-store-pairs |
27376 | @opindex mno-load-store-pairs | |
ddf6fe37 AA |
27377 | @item -mload-store-pairs |
27378 | @itemx -mno-load-store-pairs | |
d77de738 ML |
27379 | Enable (disable) an optimization that pairs consecutive load or store |
27380 | instructions to enable load/store bonding. This option is enabled by | |
27381 | default but only takes effect when the selected architecture is known | |
27382 | to support bonding. | |
27383 | ||
d77de738 ML |
27384 | @opindex munaligned-access |
27385 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
27386 | @item -munaligned-access |
27387 | @itemx -mno-unaligned-access | |
d77de738 ML |
27388 | Enable (disable) direct unaligned access for MIPS Release 6. |
27389 | MIPSr6 requires load/store unaligned-access support, | |
27390 | by hardware or trap&emulate. | |
27391 | So @option{-mno-unaligned-access} may be needed by kernel. | |
27392 | ||
d77de738 ML |
27393 | @opindex mmemcpy |
27394 | @opindex mno-memcpy | |
ddf6fe37 AA |
27395 | @item -mmemcpy |
27396 | @itemx -mno-memcpy | |
d77de738 ML |
27397 | Force (do not force) the use of @code{memcpy} for non-trivial block |
27398 | moves. The default is @option{-mno-memcpy}, which allows GCC to inline | |
27399 | most constant-sized copies. | |
27400 | ||
d77de738 ML |
27401 | @opindex mlong-calls |
27402 | @opindex mno-long-calls | |
ddf6fe37 AA |
27403 | @item -mlong-calls |
27404 | @itemx -mno-long-calls | |
d77de738 ML |
27405 | Disable (do not disable) use of the @code{jal} instruction. Calling |
27406 | functions using @code{jal} is more efficient but requires the caller | |
27407 | and callee to be in the same 256 megabyte segment. | |
27408 | ||
27409 | This option has no effect on abicalls code. The default is | |
27410 | @option{-mno-long-calls}. | |
27411 | ||
d77de738 ML |
27412 | @opindex mmad |
27413 | @opindex mno-mad | |
ddf6fe37 AA |
27414 | @item -mmad |
27415 | @itemx -mno-mad | |
d77de738 ML |
27416 | Enable (disable) use of the @code{mad}, @code{madu} and @code{mul} |
27417 | instructions, as provided by the R4650 ISA@. | |
27418 | ||
d77de738 ML |
27419 | @opindex mimadd |
27420 | @opindex mno-imadd | |
ddf6fe37 AA |
27421 | @item -mimadd |
27422 | @itemx -mno-imadd | |
d77de738 ML |
27423 | Enable (disable) use of the @code{madd} and @code{msub} integer |
27424 | instructions. The default is @option{-mimadd} on architectures | |
27425 | that support @code{madd} and @code{msub} except for the 74k | |
27426 | architecture where it was found to generate slower code. | |
27427 | ||
d77de738 ML |
27428 | @opindex mfused-madd |
27429 | @opindex mno-fused-madd | |
ddf6fe37 AA |
27430 | @item -mfused-madd |
27431 | @itemx -mno-fused-madd | |
d77de738 ML |
27432 | Enable (disable) use of the floating-point multiply-accumulate |
27433 | instructions, when they are available. The default is | |
27434 | @option{-mfused-madd}. | |
27435 | ||
27436 | On the R8000 CPU when multiply-accumulate instructions are used, | |
27437 | the intermediate product is calculated to infinite precision | |
27438 | and is not subject to the FCSR Flush to Zero bit. This may be | |
27439 | undesirable in some circumstances. On other processors the result | |
27440 | is numerically identical to the equivalent computation using | |
27441 | separate multiply, add, subtract and negate instructions. | |
27442 | ||
d77de738 | 27443 | @opindex nocpp |
ddf6fe37 | 27444 | @item -nocpp |
d77de738 ML |
27445 | Tell the MIPS assembler to not run its preprocessor over user |
27446 | assembler files (with a @samp{.s} suffix) when assembling them. | |
27447 | ||
d77de738 ML |
27448 | @opindex mfix-24k |
27449 | @opindex mno-fix-24k | |
ddf6fe37 AA |
27450 | @item -mfix-24k |
27451 | @itemx -mno-fix-24k | |
d77de738 ML |
27452 | Work around the 24K E48 (lost data on stores during refill) errata. |
27453 | The workarounds are implemented by the assembler rather than by GCC@. | |
27454 | ||
d77de738 ML |
27455 | @opindex mfix-r4000 |
27456 | @opindex mno-fix-r4000 | |
ddf6fe37 AA |
27457 | @item -mfix-r4000 |
27458 | @itemx -mno-fix-r4000 | |
d77de738 ML |
27459 | Work around certain R4000 CPU errata: |
27460 | @itemize @minus | |
27461 | @item | |
27462 | A double-word or a variable shift may give an incorrect result if executed | |
27463 | immediately after starting an integer division. | |
27464 | @item | |
27465 | A double-word or a variable shift may give an incorrect result if executed | |
27466 | while an integer multiplication is in progress. | |
27467 | @item | |
27468 | An integer division may give an incorrect result if started in a delay slot | |
27469 | of a taken branch or a jump. | |
27470 | @end itemize | |
27471 | ||
d77de738 ML |
27472 | @opindex mfix-r4400 |
27473 | @opindex mno-fix-r4400 | |
ddf6fe37 AA |
27474 | @item -mfix-r4400 |
27475 | @itemx -mno-fix-r4400 | |
d77de738 ML |
27476 | Work around certain R4400 CPU errata: |
27477 | @itemize @minus | |
27478 | @item | |
27479 | A double-word or a variable shift may give an incorrect result if executed | |
27480 | immediately after starting an integer division. | |
27481 | @end itemize | |
27482 | ||
d77de738 ML |
27483 | @opindex mfix-r10000 |
27484 | @opindex mno-fix-r10000 | |
ddf6fe37 AA |
27485 | @item -mfix-r10000 |
27486 | @itemx -mno-fix-r10000 | |
d77de738 ML |
27487 | Work around certain R10000 errata: |
27488 | @itemize @minus | |
27489 | @item | |
27490 | @code{ll}/@code{sc} sequences may not behave atomically on revisions | |
27491 | prior to 3.0. They may deadlock on revisions 2.6 and earlier. | |
27492 | @end itemize | |
27493 | ||
27494 | This option can only be used if the target architecture supports | |
27495 | branch-likely instructions. @option{-mfix-r10000} is the default when | |
27496 | @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default | |
27497 | otherwise. | |
27498 | ||
ddf6fe37 | 27499 | @opindex mfix-r5900 |
d77de738 ML |
27500 | @item -mfix-r5900 |
27501 | @itemx -mno-fix-r5900 | |
d77de738 ML |
27502 | Do not attempt to schedule the preceding instruction into the delay slot |
27503 | of a branch instruction placed at the end of a short loop of six | |
27504 | instructions or fewer and always schedule a @code{nop} instruction there | |
27505 | instead. The short loop bug under certain conditions causes loops to | |
27506 | execute only once or twice, due to a hardware bug in the R5900 chip. The | |
27507 | workaround is implemented by the assembler rather than by GCC@. | |
27508 | ||
ddf6fe37 | 27509 | @opindex mfix-rm7000 |
d77de738 ML |
27510 | @item -mfix-rm7000 |
27511 | @itemx -mno-fix-rm7000 | |
d77de738 ML |
27512 | Work around the RM7000 @code{dmult}/@code{dmultu} errata. The |
27513 | workarounds are implemented by the assembler rather than by GCC@. | |
27514 | ||
ddf6fe37 | 27515 | @opindex mfix-vr4120 |
d77de738 ML |
27516 | @item -mfix-vr4120 |
27517 | @itemx -mno-fix-vr4120 | |
d77de738 ML |
27518 | Work around certain VR4120 errata: |
27519 | @itemize @minus | |
27520 | @item | |
27521 | @code{dmultu} does not always produce the correct result. | |
27522 | @item | |
27523 | @code{div} and @code{ddiv} do not always produce the correct result if one | |
27524 | of the operands is negative. | |
27525 | @end itemize | |
27526 | The workarounds for the division errata rely on special functions in | |
27527 | @file{libgcc.a}. At present, these functions are only provided by | |
27528 | the @code{mips64vr*-elf} configurations. | |
27529 | ||
27530 | Other VR4120 errata require a NOP to be inserted between certain pairs of | |
27531 | instructions. These errata are handled by the assembler, not by GCC itself. | |
27532 | ||
d77de738 | 27533 | @opindex mfix-vr4130 |
ddf6fe37 | 27534 | @item -mfix-vr4130 |
d77de738 ML |
27535 | Work around the VR4130 @code{mflo}/@code{mfhi} errata. The |
27536 | workarounds are implemented by the assembler rather than by GCC, | |
27537 | although GCC avoids using @code{mflo} and @code{mfhi} if the | |
27538 | VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi} | |
27539 | instructions are available instead. | |
27540 | ||
ddf6fe37 | 27541 | @opindex mfix-sb1 |
d77de738 ML |
27542 | @item -mfix-sb1 |
27543 | @itemx -mno-fix-sb1 | |
d77de738 ML |
27544 | Work around certain SB-1 CPU core errata. |
27545 | (This flag currently works around the SB-1 revision 2 | |
27546 | ``F1'' and ``F2'' floating-point errata.) | |
27547 | ||
d77de738 | 27548 | @opindex mr10k-cache-barrier |
ddf6fe37 | 27549 | @item -mr10k-cache-barrier=@var{setting} |
d77de738 ML |
27550 | Specify whether GCC should insert cache barriers to avoid the |
27551 | side effects of speculation on R10K processors. | |
27552 | ||
27553 | In common with many processors, the R10K tries to predict the outcome | |
27554 | of a conditional branch and speculatively executes instructions from | |
27555 | the ``taken'' branch. It later aborts these instructions if the | |
27556 | predicted outcome is wrong. However, on the R10K, even aborted | |
27557 | instructions can have side effects. | |
27558 | ||
27559 | This problem only affects kernel stores and, depending on the system, | |
27560 | kernel loads. As an example, a speculatively-executed store may load | |
27561 | the target memory into cache and mark the cache line as dirty, even if | |
27562 | the store itself is later aborted. If a DMA operation writes to the | |
27563 | same area of memory before the ``dirty'' line is flushed, the cached | |
27564 | data overwrites the DMA-ed data. See the R10K processor manual | |
27565 | for a full description, including other potential problems. | |
27566 | ||
27567 | One workaround is to insert cache barrier instructions before every memory | |
27568 | access that might be speculatively executed and that might have side | |
27569 | effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}} | |
27570 | controls GCC's implementation of this workaround. It assumes that | |
27571 | aborted accesses to any byte in the following regions does not have | |
27572 | side effects: | |
27573 | ||
27574 | @enumerate | |
27575 | @item | |
27576 | the memory occupied by the current function's stack frame; | |
27577 | ||
27578 | @item | |
27579 | the memory occupied by an incoming stack argument; | |
27580 | ||
27581 | @item | |
27582 | the memory occupied by an object with a link-time-constant address. | |
27583 | @end enumerate | |
27584 | ||
27585 | It is the kernel's responsibility to ensure that speculative | |
27586 | accesses to these regions are indeed safe. | |
27587 | ||
27588 | If the input program contains a function declaration such as: | |
27589 | ||
27590 | @smallexample | |
27591 | void foo (void); | |
27592 | @end smallexample | |
27593 | ||
27594 | then the implementation of @code{foo} must allow @code{j foo} and | |
27595 | @code{jal foo} to be executed speculatively. GCC honors this | |
27596 | restriction for functions it compiles itself. It expects non-GCC | |
27597 | functions (such as hand-written assembly code) to do the same. | |
27598 | ||
27599 | The option has three forms: | |
27600 | ||
27601 | @table @gcctabopt | |
27602 | @item -mr10k-cache-barrier=load-store | |
27603 | Insert a cache barrier before a load or store that might be | |
27604 | speculatively executed and that might have side effects even | |
27605 | if aborted. | |
27606 | ||
27607 | @item -mr10k-cache-barrier=store | |
27608 | Insert a cache barrier before a store that might be speculatively | |
27609 | executed and that might have side effects even if aborted. | |
27610 | ||
27611 | @item -mr10k-cache-barrier=none | |
27612 | Disable the insertion of cache barriers. This is the default setting. | |
27613 | @end table | |
27614 | ||
ddf6fe37 | 27615 | @opindex mflush-func |
d77de738 ML |
27616 | @item -mflush-func=@var{func} |
27617 | @itemx -mno-flush-func | |
d77de738 ML |
27618 | Specifies the function to call to flush the I and D caches, or to not |
27619 | call any such function. If called, the function must take the same | |
27620 | arguments as the common @code{_flush_func}, that is, the address of the | |
27621 | memory range for which the cache is being flushed, the size of the | |
27622 | memory range, and the number 3 (to flush both caches). The default | |
27623 | depends on the target GCC was configured for, but commonly is either | |
27624 | @code{_flush_func} or @code{__cpu_flush}. | |
27625 | ||
d77de738 | 27626 | @opindex mbranch-cost |
ddf6fe37 | 27627 | @item mbranch-cost=@var{num} |
d77de738 ML |
27628 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
27629 | This cost is only a heuristic and is not guaranteed to produce | |
27630 | consistent results across releases. A zero cost redundantly selects | |
27631 | the default, which is based on the @option{-mtune} setting. | |
27632 | ||
d77de738 ML |
27633 | @opindex mbranch-likely |
27634 | @opindex mno-branch-likely | |
ddf6fe37 AA |
27635 | @item -mbranch-likely |
27636 | @itemx -mno-branch-likely | |
d77de738 ML |
27637 | Enable or disable use of Branch Likely instructions, regardless of the |
27638 | default for the selected architecture. By default, Branch Likely | |
27639 | instructions may be generated if they are supported by the selected | |
27640 | architecture. An exception is for the MIPS32 and MIPS64 architectures | |
27641 | and processors that implement those architectures; for those, Branch | |
27642 | Likely instructions are not be generated by default because the MIPS32 | |
27643 | and MIPS64 architectures specifically deprecate their use. | |
27644 | ||
d77de738 ML |
27645 | @opindex mcompact-branches=never |
27646 | @opindex mcompact-branches=optimal | |
27647 | @opindex mcompact-branches=always | |
ddf6fe37 AA |
27648 | @item -mcompact-branches=never |
27649 | @itemx -mcompact-branches=optimal | |
27650 | @itemx -mcompact-branches=always | |
d77de738 ML |
27651 | These options control which form of branches will be generated. The |
27652 | default is @option{-mcompact-branches=optimal}. | |
27653 | ||
27654 | The @option{-mcompact-branches=never} option ensures that compact branch | |
27655 | instructions will never be generated. | |
27656 | ||
27657 | The @option{-mcompact-branches=always} option ensures that a compact | |
27658 | branch instruction will be generated if available for MIPS Release 6 onwards. | |
27659 | If a compact branch instruction is not available (or pre-R6), | |
27660 | a delay slot form of the branch will be used instead. | |
27661 | ||
27662 | If it is used for MIPS16/microMIPS targets, it will be just ignored now. | |
27663 | The behaviour for MIPS16/microMIPS may change in future, | |
27664 | since they do have some compact branch instructions. | |
27665 | ||
27666 | The @option{-mcompact-branches=optimal} option will cause a delay slot | |
27667 | branch to be used if one is available in the current ISA and the delay | |
27668 | slot is successfully filled. If the delay slot is not filled, a compact | |
27669 | branch will be chosen if one is available. | |
27670 | ||
ddf6fe37 | 27671 | @opindex mfp-exceptions |
d77de738 ML |
27672 | @item -mfp-exceptions |
27673 | @itemx -mno-fp-exceptions | |
d77de738 ML |
27674 | Specifies whether FP exceptions are enabled. This affects how |
27675 | FP instructions are scheduled for some processors. | |
27676 | The default is that FP exceptions are | |
27677 | enabled. | |
27678 | ||
27679 | For instance, on the SB-1, if FP exceptions are disabled, and we are emitting | |
27680 | 64-bit code, then we can use both FP pipes. Otherwise, we can only use one | |
27681 | FP pipe. | |
27682 | ||
ddf6fe37 | 27683 | @opindex mvr4130-align |
d77de738 ML |
27684 | @item -mvr4130-align |
27685 | @itemx -mno-vr4130-align | |
d77de738 ML |
27686 | The VR4130 pipeline is two-way superscalar, but can only issue two |
27687 | instructions together if the first one is 8-byte aligned. When this | |
27688 | option is enabled, GCC aligns pairs of instructions that it | |
27689 | thinks should execute in parallel. | |
27690 | ||
27691 | This option only has an effect when optimizing for the VR4130. | |
27692 | It normally makes code faster, but at the expense of making it bigger. | |
27693 | It is enabled by default at optimization level @option{-O3}. | |
27694 | ||
ddf6fe37 | 27695 | @opindex msynci |
d77de738 ML |
27696 | @item -msynci |
27697 | @itemx -mno-synci | |
d77de738 ML |
27698 | Enable (disable) generation of @code{synci} instructions on |
27699 | architectures that support it. The @code{synci} instructions (if | |
27700 | enabled) are generated when @code{__builtin___clear_cache} is | |
27701 | compiled. | |
27702 | ||
27703 | This option defaults to @option{-mno-synci}, but the default can be | |
27704 | overridden by configuring GCC with @option{--with-synci}. | |
27705 | ||
27706 | When compiling code for single processor systems, it is generally safe | |
27707 | to use @code{synci}. However, on many multi-core (SMP) systems, it | |
27708 | does not invalidate the instruction caches on all cores and may lead | |
27709 | to undefined behavior. | |
27710 | ||
ddf6fe37 | 27711 | @opindex mrelax-pic-calls |
d77de738 ML |
27712 | @item -mrelax-pic-calls |
27713 | @itemx -mno-relax-pic-calls | |
d77de738 ML |
27714 | Try to turn PIC calls that are normally dispatched via register |
27715 | @code{$25} into direct calls. This is only possible if the linker can | |
27716 | resolve the destination at link time and if the destination is within | |
27717 | range for a direct call. | |
27718 | ||
27719 | @option{-mrelax-pic-calls} is the default if GCC was configured to use | |
27720 | an assembler and a linker that support the @code{.reloc} assembly | |
27721 | directive and @option{-mexplicit-relocs} is in effect. With | |
27722 | @option{-mno-explicit-relocs}, this optimization can be performed by the | |
27723 | assembler and the linker alone without help from the compiler. | |
27724 | ||
d77de738 ML |
27725 | @opindex mmcount-ra-address |
27726 | @opindex mno-mcount-ra-address | |
ddf6fe37 AA |
27727 | @item -mmcount-ra-address |
27728 | @itemx -mno-mcount-ra-address | |
d77de738 ML |
27729 | Emit (do not emit) code that allows @code{_mcount} to modify the |
27730 | calling function's return address. When enabled, this option extends | |
27731 | the usual @code{_mcount} interface with a new @var{ra-address} | |
27732 | parameter, which has type @code{intptr_t *} and is passed in register | |
27733 | @code{$12}. @code{_mcount} can then modify the return address by | |
27734 | doing both of the following: | |
27735 | @itemize | |
27736 | @item | |
27737 | Returning the new address in register @code{$31}. | |
27738 | @item | |
27739 | Storing the new address in @code{*@var{ra-address}}, | |
27740 | if @var{ra-address} is nonnull. | |
27741 | @end itemize | |
27742 | ||
27743 | The default is @option{-mno-mcount-ra-address}. | |
27744 | ||
ddf6fe37 | 27745 | @opindex mframe-header-opt |
d77de738 ML |
27746 | @item -mframe-header-opt |
27747 | @itemx -mno-frame-header-opt | |
d77de738 ML |
27748 | Enable (disable) frame header optimization in the o32 ABI. When using the |
27749 | o32 ABI, calling functions will allocate 16 bytes on the stack for the called | |
27750 | function to write out register arguments. When enabled, this optimization | |
27751 | will suppress the allocation of the frame header if it can be determined that | |
27752 | it is unused. | |
27753 | ||
27754 | This optimization is off by default at all optimization levels. | |
27755 | ||
ddf6fe37 | 27756 | @opindex mlxc1-sxc1 |
d77de738 ML |
27757 | @item -mlxc1-sxc1 |
27758 | @itemx -mno-lxc1-sxc1 | |
d77de738 ML |
27759 | When applicable, enable (disable) the generation of @code{lwxc1}, |
27760 | @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default. | |
27761 | ||
ddf6fe37 | 27762 | @opindex mmadd4 |
d77de738 ML |
27763 | @item -mmadd4 |
27764 | @itemx -mno-madd4 | |
d77de738 ML |
27765 | When applicable, enable (disable) the generation of 4-operand @code{madd.s}, |
27766 | @code{madd.d} and related instructions. Enabled by default. | |
27767 | ||
27768 | @end table | |
27769 | ||
27770 | @node MMIX Options | |
27771 | @subsection MMIX Options | |
27772 | @cindex MMIX Options | |
27773 | ||
27774 | These options are defined for the MMIX: | |
27775 | ||
27776 | @table @gcctabopt | |
d77de738 ML |
27777 | @opindex mlibfuncs |
27778 | @opindex mno-libfuncs | |
ddf6fe37 AA |
27779 | @item -mlibfuncs |
27780 | @itemx -mno-libfuncs | |
d77de738 ML |
27781 | Specify that intrinsic library functions are being compiled, passing all |
27782 | values in registers, no matter the size. | |
27783 | ||
d77de738 ML |
27784 | @opindex mepsilon |
27785 | @opindex mno-epsilon | |
ddf6fe37 AA |
27786 | @item -mepsilon |
27787 | @itemx -mno-epsilon | |
d77de738 ML |
27788 | Generate floating-point comparison instructions that compare with respect |
27789 | to the @code{rE} epsilon register. | |
27790 | ||
d77de738 ML |
27791 | @opindex mabi=mmixware |
27792 | @opindex mabi=gnu | |
ddf6fe37 AA |
27793 | @item -mabi=mmixware |
27794 | @itemx -mabi=gnu | |
d77de738 ML |
27795 | Generate code that passes function parameters and return values that (in |
27796 | the called function) are seen as registers @code{$0} and up, as opposed to | |
27797 | the GNU ABI which uses global registers @code{$231} and up. | |
27798 | ||
d77de738 ML |
27799 | @opindex mzero-extend |
27800 | @opindex mno-zero-extend | |
ddf6fe37 AA |
27801 | @item -mzero-extend |
27802 | @itemx -mno-zero-extend | |
d77de738 ML |
27803 | When reading data from memory in sizes shorter than 64 bits, use (do not |
27804 | use) zero-extending load instructions by default, rather than | |
27805 | sign-extending ones. | |
27806 | ||
d77de738 ML |
27807 | @opindex mknuthdiv |
27808 | @opindex mno-knuthdiv | |
ddf6fe37 AA |
27809 | @item -mknuthdiv |
27810 | @itemx -mno-knuthdiv | |
d77de738 ML |
27811 | Make the result of a division yielding a remainder have the same sign as |
27812 | the divisor. With the default, @option{-mno-knuthdiv}, the sign of the | |
27813 | remainder follows the sign of the dividend. Both methods are | |
27814 | arithmetically valid, the latter being almost exclusively used. | |
27815 | ||
d77de738 ML |
27816 | @opindex mtoplevel-symbols |
27817 | @opindex mno-toplevel-symbols | |
ddf6fe37 AA |
27818 | @item -mtoplevel-symbols |
27819 | @itemx -mno-toplevel-symbols | |
d77de738 ML |
27820 | Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly |
27821 | code can be used with the @code{PREFIX} assembly directive. | |
27822 | ||
d77de738 | 27823 | @opindex melf |
ddf6fe37 | 27824 | @item -melf |
d77de738 ML |
27825 | Generate an executable in the ELF format, rather than the default |
27826 | @samp{mmo} format used by the @command{mmix} simulator. | |
27827 | ||
d77de738 ML |
27828 | @opindex mbranch-predict |
27829 | @opindex mno-branch-predict | |
ddf6fe37 AA |
27830 | @item -mbranch-predict |
27831 | @itemx -mno-branch-predict | |
d77de738 ML |
27832 | Use (do not use) the probable-branch instructions, when static branch |
27833 | prediction indicates a probable branch. | |
27834 | ||
d77de738 ML |
27835 | @opindex mbase-addresses |
27836 | @opindex mno-base-addresses | |
ddf6fe37 AA |
27837 | @item -mbase-addresses |
27838 | @itemx -mno-base-addresses | |
d77de738 ML |
27839 | Generate (do not generate) code that uses @emph{base addresses}. Using a |
27840 | base address automatically generates a request (handled by the assembler | |
27841 | and the linker) for a constant to be set up in a global register. The | |
27842 | register is used for one or more base address requests within the range 0 | |
27843 | to 255 from the value held in the register. The generally leads to short | |
27844 | and fast code, but the number of different data items that can be | |
27845 | addressed is limited. This means that a program that uses lots of static | |
27846 | data may require @option{-mno-base-addresses}. | |
27847 | ||
d77de738 ML |
27848 | @opindex msingle-exit |
27849 | @opindex mno-single-exit | |
ddf6fe37 AA |
27850 | @item -msingle-exit |
27851 | @itemx -mno-single-exit | |
d77de738 ML |
27852 | Force (do not force) generated code to have a single exit point in each |
27853 | function. | |
27854 | @end table | |
27855 | ||
27856 | @node MN10300 Options | |
27857 | @subsection MN10300 Options | |
27858 | @cindex MN10300 options | |
27859 | ||
27860 | These @option{-m} options are defined for Matsushita MN10300 architectures: | |
27861 | ||
27862 | @table @gcctabopt | |
d77de738 | 27863 | @opindex mmult-bug |
ddf6fe37 | 27864 | @item -mmult-bug |
d77de738 ML |
27865 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
27866 | processors. This is the default. | |
27867 | ||
d77de738 | 27868 | @opindex mno-mult-bug |
ddf6fe37 | 27869 | @item -mno-mult-bug |
d77de738 ML |
27870 | Do not generate code to avoid bugs in the multiply instructions for the |
27871 | MN10300 processors. | |
27872 | ||
d77de738 | 27873 | @opindex mam33 |
ddf6fe37 | 27874 | @item -mam33 |
d77de738 ML |
27875 | Generate code using features specific to the AM33 processor. |
27876 | ||
d77de738 | 27877 | @opindex mno-am33 |
ddf6fe37 | 27878 | @item -mno-am33 |
d77de738 ML |
27879 | Do not generate code using features specific to the AM33 processor. This |
27880 | is the default. | |
27881 | ||
d77de738 | 27882 | @opindex mam33-2 |
ddf6fe37 | 27883 | @item -mam33-2 |
d77de738 ML |
27884 | Generate code using features specific to the AM33/2.0 processor. |
27885 | ||
d77de738 | 27886 | @opindex mam34 |
ddf6fe37 | 27887 | @item -mam34 |
d77de738 ML |
27888 | Generate code using features specific to the AM34 processor. |
27889 | ||
d77de738 | 27890 | @opindex mtune |
ddf6fe37 | 27891 | @item -mtune=@var{cpu-type} |
d77de738 ML |
27892 | Use the timing characteristics of the indicated CPU type when |
27893 | scheduling instructions. This does not change the targeted processor | |
27894 | type. The CPU type must be one of @samp{mn10300}, @samp{am33}, | |
27895 | @samp{am33-2} or @samp{am34}. | |
27896 | ||
d77de738 | 27897 | @opindex mreturn-pointer-on-d0 |
ddf6fe37 | 27898 | @item -mreturn-pointer-on-d0 |
d77de738 ML |
27899 | When generating a function that returns a pointer, return the pointer |
27900 | in both @code{a0} and @code{d0}. Otherwise, the pointer is returned | |
27901 | only in @code{a0}, and attempts to call such functions without a prototype | |
27902 | result in errors. Note that this option is on by default; use | |
27903 | @option{-mno-return-pointer-on-d0} to disable it. | |
27904 | ||
d77de738 | 27905 | @opindex mno-crt0 |
ddf6fe37 | 27906 | @item -mno-crt0 |
d77de738 ML |
27907 | Do not link in the C run-time initialization object file. |
27908 | ||
d77de738 | 27909 | @opindex mrelax |
ddf6fe37 | 27910 | @item -mrelax |
d77de738 ML |
27911 | Indicate to the linker that it should perform a relaxation optimization pass |
27912 | to shorten branches, calls and absolute memory addresses. This option only | |
27913 | has an effect when used on the command line for the final link step. | |
27914 | ||
27915 | This option makes symbolic debugging impossible. | |
27916 | ||
d77de738 | 27917 | @opindex mliw |
ddf6fe37 | 27918 | @item -mliw |
d77de738 ML |
27919 | Allow the compiler to generate @emph{Long Instruction Word} |
27920 | instructions if the target is the @samp{AM33} or later. This is the | |
27921 | default. This option defines the preprocessor macro @code{__LIW__}. | |
27922 | ||
d77de738 | 27923 | @opindex mno-liw |
ddf6fe37 | 27924 | @item -mno-liw |
d77de738 ML |
27925 | Do not allow the compiler to generate @emph{Long Instruction Word} |
27926 | instructions. This option defines the preprocessor macro | |
27927 | @code{__NO_LIW__}. | |
27928 | ||
d77de738 | 27929 | @opindex msetlb |
ddf6fe37 | 27930 | @item -msetlb |
d77de738 ML |
27931 | Allow the compiler to generate the @emph{SETLB} and @emph{Lcc} |
27932 | instructions if the target is the @samp{AM33} or later. This is the | |
27933 | default. This option defines the preprocessor macro @code{__SETLB__}. | |
27934 | ||
d77de738 | 27935 | @opindex mno-setlb |
ddf6fe37 | 27936 | @item -mno-setlb |
d77de738 ML |
27937 | Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc} |
27938 | instructions. This option defines the preprocessor macro | |
27939 | @code{__NO_SETLB__}. | |
27940 | ||
27941 | @end table | |
27942 | ||
27943 | @node Moxie Options | |
27944 | @subsection Moxie Options | |
27945 | @cindex Moxie Options | |
27946 | ||
27947 | @table @gcctabopt | |
27948 | ||
d77de738 | 27949 | @opindex meb |
ddf6fe37 | 27950 | @item -meb |
d77de738 ML |
27951 | Generate big-endian code. This is the default for @samp{moxie-*-*} |
27952 | configurations. | |
27953 | ||
d77de738 | 27954 | @opindex mel |
ddf6fe37 | 27955 | @item -mel |
d77de738 ML |
27956 | Generate little-endian code. |
27957 | ||
d77de738 | 27958 | @opindex mmul.x |
ddf6fe37 | 27959 | @item -mmul.x |
d77de738 ML |
27960 | Generate mul.x and umul.x instructions. This is the default for |
27961 | @samp{moxiebox-*-*} configurations. | |
27962 | ||
d77de738 | 27963 | @opindex mno-crt0 |
ddf6fe37 | 27964 | @item -mno-crt0 |
d77de738 ML |
27965 | Do not link in the C run-time initialization object file. |
27966 | ||
27967 | @end table | |
27968 | ||
27969 | @node MSP430 Options | |
27970 | @subsection MSP430 Options | |
27971 | @cindex MSP430 Options | |
27972 | ||
27973 | These options are defined for the MSP430: | |
27974 | ||
27975 | @table @gcctabopt | |
27976 | ||
d77de738 | 27977 | @opindex masm-hex |
ddf6fe37 | 27978 | @item -masm-hex |
d77de738 ML |
27979 | Force assembly output to always use hex constants. Normally such |
27980 | constants are signed decimals, but this option is available for | |
27981 | testsuite and/or aesthetic purposes. | |
27982 | ||
d77de738 | 27983 | @opindex mmcu= |
ddf6fe37 | 27984 | @item -mmcu= |
d77de738 ML |
27985 | Select the MCU to target. This is used to create a C preprocessor |
27986 | symbol based upon the MCU name, converted to upper case and pre- and | |
27987 | post-fixed with @samp{__}. This in turn is used by the | |
27988 | @file{msp430.h} header file to select an MCU-specific supplementary | |
27989 | header file. | |
27990 | ||
27991 | The option also sets the ISA to use. If the MCU name is one that is | |
27992 | known to only support the 430 ISA then that is selected, otherwise the | |
27993 | 430X ISA is selected. A generic MCU name of @samp{msp430} can also be | |
27994 | used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU | |
27995 | name selects the 430X ISA. | |
27996 | ||
27997 | In addition an MCU-specific linker script is added to the linker | |
27998 | command line. The script's name is the name of the MCU with | |
27999 | @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc} | |
28000 | command line defines the C preprocessor symbol @code{__XXX__} and | |
28001 | cause the linker to search for a script called @file{xxx.ld}. | |
28002 | ||
28003 | The ISA and hardware multiply supported for the different MCUs is hard-coded | |
28004 | into GCC. However, an external @samp{devices.csv} file can be used to | |
28005 | extend device support beyond those that have been hard-coded. | |
28006 | ||
28007 | GCC searches for the @samp{devices.csv} file using the following methods in the | |
28008 | given precedence order, where the first method takes precendence over the | |
28009 | second which takes precedence over the third. | |
28010 | ||
28011 | @table @asis | |
28012 | @item Include path specified with @code{-I} and @code{-L} | |
28013 | @samp{devices.csv} will be searched for in each of the directories specified by | |
28014 | include paths and linker library search paths. | |
28015 | @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR} | |
28016 | Define the value of the global environment variable | |
28017 | @samp{MSP430_GCC_INCLUDE_DIR} | |
28018 | to the full path to the directory containing devices.csv, and GCC will search | |
28019 | this directory for devices.csv. If devices.csv is found, this directory will | |
28020 | also be registered as an include path, and linker library path. Header files | |
28021 | and linker scripts in this directory can therefore be used without manually | |
28022 | specifying @code{-I} and @code{-L} on the command line. | |
28023 | @item The @samp{msp430-elf@{,bare@}/include/devices} directory | |
28024 | Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the | |
28025 | toolchain root directory. This directory does not exist in a default | |
28026 | installation, but if the user has created it and copied @samp{devices.csv} | |
28027 | there, then the MCU data will be read. As above, this directory will | |
28028 | also be registered as an include path, and linker library path. | |
28029 | ||
28030 | @end table | |
28031 | If none of the above search methods find @samp{devices.csv}, then the | |
28032 | hard-coded MCU data is used. | |
28033 | ||
28034 | ||
d77de738 ML |
28035 | @opindex mwarn-mcu |
28036 | @opindex mno-warn-mcu | |
ddf6fe37 AA |
28037 | @item -mwarn-mcu |
28038 | @itemx -mno-warn-mcu | |
d77de738 ML |
28039 | This option enables or disables warnings about conflicts between the |
28040 | MCU name specified by the @option{-mmcu} option and the ISA set by the | |
28041 | @option{-mcpu} option and/or the hardware multiply support set by the | |
28042 | @option{-mhwmult} option. It also toggles warnings about unrecognized | |
28043 | MCU names. This option is on by default. | |
28044 | ||
d77de738 | 28045 | @opindex mcpu= |
ddf6fe37 | 28046 | @item -mcpu= |
d77de738 ML |
28047 | Specifies the ISA to use. Accepted values are @samp{msp430}, |
28048 | @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The | |
28049 | @option{-mmcu=} option should be used to select the ISA. | |
28050 | ||
d77de738 | 28051 | @opindex msim |
ddf6fe37 | 28052 | @item -msim |
d77de738 ML |
28053 | Link to the simulator runtime libraries and linker script. Overrides |
28054 | any scripts that would be selected by the @option{-mmcu=} option. | |
28055 | ||
d77de738 | 28056 | @opindex mlarge |
ddf6fe37 | 28057 | @item -mlarge |
d77de738 ML |
28058 | Use large-model addressing (20-bit pointers, 20-bit @code{size_t}). |
28059 | ||
d77de738 | 28060 | @opindex msmall |
ddf6fe37 | 28061 | @item -msmall |
d77de738 ML |
28062 | Use small-model addressing (16-bit pointers, 16-bit @code{size_t}). |
28063 | ||
d77de738 | 28064 | @opindex mrelax |
ddf6fe37 | 28065 | @item -mrelax |
d77de738 ML |
28066 | This option is passed to the assembler and linker, and allows the |
28067 | linker to perform certain optimizations that cannot be done until | |
28068 | the final link. | |
28069 | ||
d77de738 | 28070 | @opindex mhwmult= |
ddf6fe37 | 28071 | @item mhwmult= |
d77de738 ML |
28072 | Describes the type of hardware multiply supported by the target. |
28073 | Accepted values are @samp{none} for no hardware multiply, @samp{16bit} | |
28074 | for the original 16-bit-only multiply supported by early MCUs. | |
28075 | @samp{32bit} for the 16/32-bit multiply supported by later MCUs and | |
28076 | @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs. | |
28077 | A value of @samp{auto} can also be given. This tells GCC to deduce | |
28078 | the hardware multiply support based upon the MCU name provided by the | |
28079 | @option{-mmcu} option. If no @option{-mmcu} option is specified or if | |
28080 | the MCU name is not recognized then no hardware multiply support is | |
28081 | assumed. @code{auto} is the default setting. | |
28082 | ||
28083 | Hardware multiplies are normally performed by calling a library | |
28084 | routine. This saves space in the generated code. When compiling at | |
28085 | @option{-O3} or higher however the hardware multiplier is invoked | |
28086 | inline. This makes for bigger, but faster code. | |
28087 | ||
28088 | The hardware multiply routines disable interrupts whilst running and | |
28089 | restore the previous interrupt state when they finish. This makes | |
28090 | them safe to use inside interrupt handlers as well as in normal code. | |
28091 | ||
d77de738 | 28092 | @opindex minrt |
ddf6fe37 | 28093 | @item -minrt |
d77de738 ML |
28094 | Enable the use of a minimum runtime environment - no static |
28095 | initializers or constructors. This is intended for memory-constrained | |
28096 | devices. The compiler includes special symbols in some objects | |
28097 | that tell the linker and runtime which code fragments are required. | |
28098 | ||
d77de738 | 28099 | @opindex mtiny-printf |
ddf6fe37 | 28100 | @item -mtiny-printf |
d77de738 ML |
28101 | Enable reduced code size @code{printf} and @code{puts} library functions. |
28102 | The @samp{tiny} implementations of these functions are not reentrant, so | |
28103 | must be used with caution in multi-threaded applications. | |
28104 | ||
28105 | Support for streams has been removed and the string to be printed will | |
28106 | always be sent to stdout via the @code{write} syscall. The string is not | |
28107 | buffered before it is sent to write. | |
28108 | ||
28109 | This option requires Newlib Nano IO, so GCC must be configured with | |
28110 | @samp{--enable-newlib-nano-formatted-io}. | |
28111 | ||
d77de738 | 28112 | @opindex mmax-inline-shift= |
ddf6fe37 | 28113 | @item -mmax-inline-shift= |
d77de738 ML |
28114 | This option takes an integer between 0 and 64 inclusive, and sets |
28115 | the maximum number of inline shift instructions which should be emitted to | |
28116 | perform a shift operation by a constant amount. When this value needs to be | |
28117 | exceeded, an mspabi helper function is used instead. The default value is 4. | |
28118 | ||
28119 | This only affects cases where a shift by multiple positions cannot be | |
28120 | completed with a single instruction (e.g. all shifts >1 on the 430 ISA). | |
28121 | ||
28122 | Shifts of a 32-bit value are at least twice as costly, so the value passed for | |
28123 | this option is divided by 2 and the resulting value used instead. | |
28124 | ||
d77de738 ML |
28125 | @opindex mcode-region |
28126 | @opindex mdata-region | |
ddf6fe37 AA |
28127 | @item -mcode-region= |
28128 | @itemx -mdata-region= | |
d77de738 ML |
28129 | These options tell the compiler where to place functions and data that |
28130 | do not have one of the @code{lower}, @code{upper}, @code{either} or | |
28131 | @code{section} attributes. Possible values are @code{lower}, | |
28132 | @code{upper}, @code{either} or @code{any}. The first three behave | |
28133 | like the corresponding attribute. The fourth possible value - | |
28134 | @code{any} - is the default. It leaves placement entirely up to the | |
28135 | linker script and how it assigns the standard sections | |
28136 | (@code{.text}, @code{.data}, etc) to the memory regions. | |
28137 | ||
d77de738 | 28138 | @opindex msilicon-errata |
ddf6fe37 | 28139 | @item -msilicon-errata= |
d77de738 ML |
28140 | This option passes on a request to assembler to enable the fixes for |
28141 | the named silicon errata. | |
28142 | ||
d77de738 | 28143 | @opindex msilicon-errata-warn |
ddf6fe37 | 28144 | @item -msilicon-errata-warn= |
d77de738 ML |
28145 | This option passes on a request to the assembler to enable warning |
28146 | messages when a silicon errata might need to be applied. | |
28147 | ||
d77de738 ML |
28148 | @opindex mwarn-devices-csv |
28149 | @opindex mno-warn-devices-csv | |
ddf6fe37 AA |
28150 | @item -mwarn-devices-csv |
28151 | @itemx -mno-warn-devices-csv | |
d77de738 ML |
28152 | Warn if @samp{devices.csv} is not found or there are problem parsing it |
28153 | (default: on). | |
28154 | ||
28155 | @end table | |
28156 | ||
28157 | @node NDS32 Options | |
28158 | @subsection NDS32 Options | |
28159 | @cindex NDS32 Options | |
28160 | ||
28161 | These options are defined for NDS32 implementations: | |
28162 | ||
28163 | @table @gcctabopt | |
28164 | ||
d77de738 | 28165 | @opindex mbig-endian |
ddf6fe37 | 28166 | @item -mbig-endian |
d77de738 ML |
28167 | Generate code in big-endian mode. |
28168 | ||
d77de738 | 28169 | @opindex mlittle-endian |
ddf6fe37 | 28170 | @item -mlittle-endian |
d77de738 ML |
28171 | Generate code in little-endian mode. |
28172 | ||
d77de738 | 28173 | @opindex mreduced-regs |
ddf6fe37 | 28174 | @item -mreduced-regs |
d77de738 ML |
28175 | Use reduced-set registers for register allocation. |
28176 | ||
d77de738 | 28177 | @opindex mfull-regs |
ddf6fe37 | 28178 | @item -mfull-regs |
d77de738 ML |
28179 | Use full-set registers for register allocation. |
28180 | ||
d77de738 | 28181 | @opindex mcmov |
ddf6fe37 | 28182 | @item -mcmov |
d77de738 ML |
28183 | Generate conditional move instructions. |
28184 | ||
d77de738 | 28185 | @opindex mno-cmov |
ddf6fe37 | 28186 | @item -mno-cmov |
d77de738 ML |
28187 | Do not generate conditional move instructions. |
28188 | ||
d77de738 | 28189 | @opindex mext-perf |
ddf6fe37 | 28190 | @item -mext-perf |
d77de738 ML |
28191 | Generate performance extension instructions. |
28192 | ||
d77de738 | 28193 | @opindex mno-ext-perf |
ddf6fe37 | 28194 | @item -mno-ext-perf |
d77de738 ML |
28195 | Do not generate performance extension instructions. |
28196 | ||
d77de738 | 28197 | @opindex mext-perf2 |
ddf6fe37 | 28198 | @item -mext-perf2 |
d77de738 ML |
28199 | Generate performance extension 2 instructions. |
28200 | ||
d77de738 | 28201 | @opindex mno-ext-perf2 |
ddf6fe37 | 28202 | @item -mno-ext-perf2 |
d77de738 ML |
28203 | Do not generate performance extension 2 instructions. |
28204 | ||
d77de738 | 28205 | @opindex mext-string |
ddf6fe37 | 28206 | @item -mext-string |
d77de738 ML |
28207 | Generate string extension instructions. |
28208 | ||
d77de738 | 28209 | @opindex mno-ext-string |
ddf6fe37 | 28210 | @item -mno-ext-string |
d77de738 ML |
28211 | Do not generate string extension instructions. |
28212 | ||
d77de738 | 28213 | @opindex mv3push |
ddf6fe37 | 28214 | @item -mv3push |
d77de738 ML |
28215 | Generate v3 push25/pop25 instructions. |
28216 | ||
d77de738 | 28217 | @opindex mno-v3push |
ddf6fe37 | 28218 | @item -mno-v3push |
d77de738 ML |
28219 | Do not generate v3 push25/pop25 instructions. |
28220 | ||
d77de738 | 28221 | @opindex m16-bit |
ddf6fe37 | 28222 | @item -m16-bit |
d77de738 ML |
28223 | Generate 16-bit instructions. |
28224 | ||
d77de738 | 28225 | @opindex mno-16-bit |
ddf6fe37 | 28226 | @item -mno-16-bit |
d77de738 ML |
28227 | Do not generate 16-bit instructions. |
28228 | ||
d77de738 | 28229 | @opindex misr-vector-size |
ddf6fe37 | 28230 | @item -misr-vector-size=@var{num} |
d77de738 ML |
28231 | Specify the size of each interrupt vector, which must be 4 or 16. |
28232 | ||
d77de738 | 28233 | @opindex mcache-block-size |
ddf6fe37 | 28234 | @item -mcache-block-size=@var{num} |
d77de738 ML |
28235 | Specify the size of each cache block, |
28236 | which must be a power of 2 between 4 and 512. | |
28237 | ||
d77de738 | 28238 | @opindex march |
ddf6fe37 | 28239 | @item -march=@var{arch} |
d77de738 ML |
28240 | Specify the name of the target architecture. |
28241 | ||
d77de738 | 28242 | @opindex mcmodel |
ddf6fe37 | 28243 | @item -mcmodel=@var{code-model} |
d77de738 ML |
28244 | Set the code model to one of |
28245 | @table @asis | |
28246 | @item @samp{small} | |
28247 | All the data and read-only data segments must be within 512KB addressing space. | |
28248 | The text segment must be within 16MB addressing space. | |
28249 | @item @samp{medium} | |
28250 | The data segment must be within 512KB while the read-only data segment can be | |
28251 | within 4GB addressing space. The text segment should be still within 16MB | |
28252 | addressing space. | |
28253 | @item @samp{large} | |
28254 | All the text and data segments can be within 4GB addressing space. | |
28255 | @end table | |
28256 | ||
d77de738 | 28257 | @opindex mctor-dtor |
ddf6fe37 | 28258 | @item -mctor-dtor |
d77de738 ML |
28259 | Enable constructor/destructor feature. |
28260 | ||
d77de738 | 28261 | @opindex mrelax |
ddf6fe37 | 28262 | @item -mrelax |
d77de738 ML |
28263 | Guide linker to relax instructions. |
28264 | ||
28265 | @end table | |
28266 | ||
28267 | @node Nios II Options | |
28268 | @subsection Nios II Options | |
28269 | @cindex Nios II options | |
28270 | @cindex Altera Nios II options | |
28271 | ||
28272 | These are the options defined for the Altera Nios II processor. | |
28273 | ||
28274 | @table @gcctabopt | |
28275 | ||
d77de738 ML |
28276 | @opindex G |
28277 | @cindex smaller data references | |
f33d7a88 | 28278 | @item -G @var{num} |
d77de738 ML |
28279 | Put global and static objects less than or equal to @var{num} bytes |
28280 | into the small data or BSS sections instead of the normal data or BSS | |
28281 | sections. The default value of @var{num} is 8. | |
28282 | ||
ddf6fe37 AA |
28283 | @opindex mgpopt |
28284 | @opindex mno-gpopt | |
d77de738 ML |
28285 | @item -mgpopt=@var{option} |
28286 | @itemx -mgpopt | |
28287 | @itemx -mno-gpopt | |
d77de738 ML |
28288 | Generate (do not generate) GP-relative accesses. The following |
28289 | @var{option} names are recognized: | |
28290 | ||
28291 | @table @samp | |
28292 | ||
28293 | @item none | |
28294 | Do not generate GP-relative accesses. | |
28295 | ||
28296 | @item local | |
28297 | Generate GP-relative accesses for small data objects that are not | |
28298 | external, weak, or uninitialized common symbols. | |
28299 | Also use GP-relative addressing for objects that | |
28300 | have been explicitly placed in a small data section via a @code{section} | |
28301 | attribute. | |
28302 | ||
28303 | @item global | |
28304 | As for @samp{local}, but also generate GP-relative accesses for | |
28305 | small data objects that are external, weak, or common. If you use this option, | |
28306 | you must ensure that all parts of your program (including libraries) are | |
28307 | compiled with the same @option{-G} setting. | |
28308 | ||
28309 | @item data | |
28310 | Generate GP-relative accesses for all data objects in the program. If you | |
28311 | use this option, the entire data and BSS segments | |
28312 | of your program must fit in 64K of memory and you must use an appropriate | |
28313 | linker script to allocate them within the addressable range of the | |
28314 | global pointer. | |
28315 | ||
28316 | @item all | |
28317 | Generate GP-relative addresses for function pointers as well as data | |
28318 | pointers. If you use this option, the entire text, data, and BSS segments | |
28319 | of your program must fit in 64K of memory and you must use an appropriate | |
28320 | linker script to allocate them within the addressable range of the | |
28321 | global pointer. | |
28322 | ||
28323 | @end table | |
28324 | ||
28325 | @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and | |
28326 | @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}. | |
28327 | ||
28328 | The default is @option{-mgpopt} except when @option{-fpic} or | |
28329 | @option{-fPIC} is specified to generate position-independent code. | |
28330 | Note that the Nios II ABI does not permit GP-relative accesses from | |
28331 | shared libraries. | |
28332 | ||
28333 | You may need to specify @option{-mno-gpopt} explicitly when building | |
28334 | programs that include large amounts of small data, including large | |
28335 | GOT data sections. In this case, the 16-bit offset for GP-relative | |
28336 | addressing may not be large enough to allow access to the entire | |
28337 | small data section. | |
28338 | ||
d77de738 | 28339 | @opindex mgprel-sec |
ddf6fe37 | 28340 | @item -mgprel-sec=@var{regexp} |
d77de738 ML |
28341 | This option specifies additional section names that can be accessed via |
28342 | GP-relative addressing. It is most useful in conjunction with | |
28343 | @code{section} attributes on variable declarations | |
28344 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28345 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28346 | ||
28347 | This option does not affect the behavior of the @option{-G} option, and | |
28348 | the specified sections are in addition to the standard @code{.sdata} | |
28349 | and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}. | |
28350 | ||
d77de738 | 28351 | @opindex mr0rel-sec |
ddf6fe37 | 28352 | @item -mr0rel-sec=@var{regexp} |
d77de738 ML |
28353 | This option specifies names of sections that can be accessed via a |
28354 | 16-bit offset from @code{r0}; that is, in the low 32K or high 32K | |
28355 | of the 32-bit address space. It is most useful in conjunction with | |
28356 | @code{section} attributes on variable declarations | |
28357 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28358 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28359 | ||
28360 | In contrast to the use of GP-relative addressing for small data, | |
28361 | zero-based addressing is never generated by default and there are no | |
28362 | conventional section names used in standard linker scripts for sections | |
28363 | in the low or high areas of memory. | |
28364 | ||
d77de738 ML |
28365 | @opindex mel |
28366 | @opindex meb | |
ddf6fe37 AA |
28367 | @item -mel |
28368 | @itemx -meb | |
d77de738 ML |
28369 | Generate little-endian (default) or big-endian (experimental) code, |
28370 | respectively. | |
28371 | ||
d77de738 | 28372 | @opindex march |
ddf6fe37 | 28373 | @item -march=@var{arch} |
d77de738 ML |
28374 | This specifies the name of the target Nios II architecture. GCC uses this |
28375 | name to determine what kind of instructions it can emit when generating | |
28376 | assembly code. Permissible names are: @samp{r1}, @samp{r2}. | |
28377 | ||
28378 | The preprocessor macro @code{__nios2_arch__} is available to programs, | |
28379 | with value 1 or 2, indicating the targeted ISA level. | |
28380 | ||
d77de738 ML |
28381 | @opindex mno-bypass-cache |
28382 | @opindex mbypass-cache | |
ddf6fe37 AA |
28383 | @item -mbypass-cache |
28384 | @itemx -mno-bypass-cache | |
d77de738 ML |
28385 | Force all load and store instructions to always bypass cache by |
28386 | using I/O variants of the instructions. The default is not to | |
28387 | bypass the cache. | |
28388 | ||
d77de738 ML |
28389 | @opindex mcache-volatile |
28390 | @opindex mno-cache-volatile | |
ddf6fe37 AA |
28391 | @item -mno-cache-volatile |
28392 | @itemx -mcache-volatile | |
d77de738 ML |
28393 | Volatile memory access bypass the cache using the I/O variants of |
28394 | the load and store instructions. The default is not to bypass the cache. | |
28395 | ||
d77de738 ML |
28396 | @opindex mno-fast-sw-div |
28397 | @opindex mfast-sw-div | |
ddf6fe37 AA |
28398 | @item -mno-fast-sw-div |
28399 | @itemx -mfast-sw-div | |
d77de738 ML |
28400 | Do not use table-based fast divide for small numbers. The default |
28401 | is to use the fast divide at @option{-O3} and above. | |
28402 | ||
d77de738 ML |
28403 | @opindex mno-hw-mul |
28404 | @opindex mhw-mul | |
28405 | @opindex mno-hw-mulx | |
28406 | @opindex mhw-mulx | |
28407 | @opindex mno-hw-div | |
28408 | @opindex mhw-div | |
ddf6fe37 AA |
28409 | @item -mno-hw-mul |
28410 | @itemx -mhw-mul | |
28411 | @itemx -mno-hw-mulx | |
28412 | @itemx -mhw-mulx | |
28413 | @itemx -mno-hw-div | |
28414 | @itemx -mhw-div | |
d77de738 ML |
28415 | Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of |
28416 | instructions by the compiler. The default is to emit @code{mul} | |
28417 | and not emit @code{div} and @code{mulx}. | |
28418 | ||
28419 | @item -mbmx | |
28420 | @itemx -mno-bmx | |
28421 | @itemx -mcdx | |
28422 | @itemx -mno-cdx | |
28423 | Enable or disable generation of Nios II R2 BMX (bit manipulation) and | |
28424 | CDX (code density) instructions. Enabling these instructions also | |
28425 | requires @option{-march=r2}. Since these instructions are optional | |
28426 | extensions to the R2 architecture, the default is not to emit them. | |
28427 | ||
d77de738 ML |
28428 | @opindex mcustom-@var{insn} |
28429 | @opindex mno-custom-@var{insn} | |
ddf6fe37 AA |
28430 | @item -mcustom-@var{insn}=@var{N} |
28431 | @itemx -mno-custom-@var{insn} | |
d77de738 ML |
28432 | Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a |
28433 | custom instruction with encoding @var{N} when generating code that uses | |
28434 | @var{insn}. For example, @option{-mcustom-fadds=253} generates custom | |
28435 | instruction 253 for single-precision floating-point add operations instead | |
28436 | of the default behavior of using a library call. | |
28437 | ||
28438 | The following values of @var{insn} are supported. Except as otherwise | |
28439 | noted, floating-point operations are expected to be implemented with | |
28440 | normal IEEE 754 semantics and correspond directly to the C operators or the | |
28441 | equivalent GCC built-in functions (@pxref{Other Builtins}). | |
28442 | ||
28443 | Single-precision floating point: | |
28444 | @table @asis | |
28445 | ||
28446 | @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls} | |
28447 | Binary arithmetic operations. | |
28448 | ||
28449 | @item @samp{fnegs} | |
28450 | Unary negation. | |
28451 | ||
28452 | @item @samp{fabss} | |
28453 | Unary absolute value. | |
28454 | ||
28455 | @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes} | |
28456 | Comparison operations. | |
28457 | ||
28458 | @item @samp{fmins}, @samp{fmaxs} | |
28459 | Floating-point minimum and maximum. These instructions are only | |
28460 | generated if @option{-ffinite-math-only} is specified. | |
28461 | ||
28462 | @item @samp{fsqrts} | |
28463 | Unary square root operation. | |
28464 | ||
28465 | @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs} | |
28466 | Floating-point trigonometric and exponential functions. These instructions | |
28467 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28468 | ||
28469 | @end table | |
28470 | ||
28471 | Double-precision floating point: | |
28472 | @table @asis | |
28473 | ||
28474 | @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld} | |
28475 | Binary arithmetic operations. | |
28476 | ||
28477 | @item @samp{fnegd} | |
28478 | Unary negation. | |
28479 | ||
28480 | @item @samp{fabsd} | |
28481 | Unary absolute value. | |
28482 | ||
28483 | @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned} | |
28484 | Comparison operations. | |
28485 | ||
28486 | @item @samp{fmind}, @samp{fmaxd} | |
28487 | Double-precision minimum and maximum. These instructions are only | |
28488 | generated if @option{-ffinite-math-only} is specified. | |
28489 | ||
28490 | @item @samp{fsqrtd} | |
28491 | Unary square root operation. | |
28492 | ||
28493 | @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd} | |
28494 | Double-precision trigonometric and exponential functions. These instructions | |
28495 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28496 | ||
28497 | @end table | |
28498 | ||
28499 | Conversions: | |
28500 | @table @asis | |
28501 | @item @samp{fextsd} | |
28502 | Conversion from single precision to double precision. | |
28503 | ||
28504 | @item @samp{ftruncds} | |
28505 | Conversion from double precision to single precision. | |
28506 | ||
28507 | @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu} | |
28508 | Conversion from floating point to signed or unsigned integer types, with | |
28509 | truncation towards zero. | |
28510 | ||
28511 | @item @samp{round} | |
28512 | Conversion from single-precision floating point to signed integer, | |
28513 | rounding to the nearest integer and ties away from zero. | |
28514 | This corresponds to the @code{__builtin_lroundf} function when | |
28515 | @option{-fno-math-errno} is used. | |
28516 | ||
28517 | @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud} | |
28518 | Conversion from signed or unsigned integer types to floating-point types. | |
28519 | ||
28520 | @end table | |
28521 | ||
28522 | In addition, all of the following transfer instructions for internal | |
28523 | registers X and Y must be provided to use any of the double-precision | |
28524 | floating-point instructions. Custom instructions taking two | |
28525 | double-precision source operands expect the first operand in the | |
28526 | 64-bit register X. The other operand (or only operand of a unary | |
28527 | operation) is given to the custom arithmetic instruction with the | |
28528 | least significant half in source register @var{src1} and the most | |
28529 | significant half in @var{src2}. A custom instruction that returns a | |
28530 | double-precision result returns the most significant 32 bits in the | |
28531 | destination register and the other half in 32-bit register Y. | |
28532 | GCC automatically generates the necessary code sequences to write | |
28533 | register X and/or read register Y when double-precision floating-point | |
28534 | instructions are used. | |
28535 | ||
28536 | @table @asis | |
28537 | ||
28538 | @item @samp{fwrx} | |
28539 | Write @var{src1} into the least significant half of X and @var{src2} into | |
28540 | the most significant half of X. | |
28541 | ||
28542 | @item @samp{fwry} | |
28543 | Write @var{src1} into Y. | |
28544 | ||
28545 | @item @samp{frdxhi}, @samp{frdxlo} | |
28546 | Read the most or least (respectively) significant half of X and store it in | |
28547 | @var{dest}. | |
28548 | ||
28549 | @item @samp{frdy} | |
28550 | Read the value of Y and store it into @var{dest}. | |
28551 | @end table | |
28552 | ||
28553 | Note that you can gain more local control over generation of Nios II custom | |
28554 | instructions by using the @code{target("custom-@var{insn}=@var{N}")} | |
28555 | and @code{target("no-custom-@var{insn}")} function attributes | |
28556 | (@pxref{Function Attributes}) | |
28557 | or pragmas (@pxref{Function Specific Option Pragmas}). | |
28558 | ||
d77de738 | 28559 | @opindex mcustom-fpu-cfg |
ddf6fe37 | 28560 | @item -mcustom-fpu-cfg=@var{name} |
d77de738 ML |
28561 | |
28562 | This option enables a predefined, named set of custom instruction encodings | |
28563 | (see @option{-mcustom-@var{insn}} above). | |
28564 | Currently, the following sets are defined: | |
28565 | ||
28566 | @option{-mcustom-fpu-cfg=60-1} is equivalent to: | |
43b72ede AA |
28567 | @gccoptlist{-mcustom-fmuls=252 |
28568 | -mcustom-fadds=253 | |
28569 | -mcustom-fsubs=254 | |
d77de738 ML |
28570 | -fsingle-precision-constant} |
28571 | ||
28572 | @option{-mcustom-fpu-cfg=60-2} is equivalent to: | |
43b72ede AA |
28573 | @gccoptlist{-mcustom-fmuls=252 |
28574 | -mcustom-fadds=253 | |
28575 | -mcustom-fsubs=254 | |
28576 | -mcustom-fdivs=255 | |
d77de738 ML |
28577 | -fsingle-precision-constant} |
28578 | ||
28579 | @option{-mcustom-fpu-cfg=72-3} is equivalent to: | |
43b72ede AA |
28580 | @gccoptlist{-mcustom-floatus=243 |
28581 | -mcustom-fixsi=244 | |
28582 | -mcustom-floatis=245 | |
28583 | -mcustom-fcmpgts=246 | |
28584 | -mcustom-fcmples=249 | |
28585 | -mcustom-fcmpeqs=250 | |
28586 | -mcustom-fcmpnes=251 | |
28587 | -mcustom-fmuls=252 | |
28588 | -mcustom-fadds=253 | |
28589 | -mcustom-fsubs=254 | |
28590 | -mcustom-fdivs=255 | |
d77de738 ML |
28591 | -fsingle-precision-constant} |
28592 | ||
28593 | @option{-mcustom-fpu-cfg=fph2} is equivalent to: | |
43b72ede AA |
28594 | @gccoptlist{-mcustom-fabss=224 |
28595 | -mcustom-fnegs=225 | |
28596 | -mcustom-fcmpnes=226 | |
28597 | -mcustom-fcmpeqs=227 | |
28598 | -mcustom-fcmpges=228 | |
28599 | -mcustom-fcmpgts=229 | |
28600 | -mcustom-fcmples=230 | |
28601 | -mcustom-fcmplts=231 | |
28602 | -mcustom-fmaxs=232 | |
28603 | -mcustom-fmins=233 | |
28604 | -mcustom-round=248 | |
28605 | -mcustom-fixsi=249 | |
28606 | -mcustom-floatis=250 | |
28607 | -mcustom-fsqrts=251 | |
28608 | -mcustom-fmuls=252 | |
28609 | -mcustom-fadds=253 | |
28610 | -mcustom-fsubs=254 | |
28611 | -mcustom-fdivs=255} | |
d77de738 ML |
28612 | |
28613 | Custom instruction assignments given by individual | |
28614 | @option{-mcustom-@var{insn}=} options override those given by | |
28615 | @option{-mcustom-fpu-cfg=}, regardless of the | |
28616 | order of the options on the command line. | |
28617 | ||
28618 | Note that you can gain more local control over selection of a FPU | |
28619 | configuration by using the @code{target("custom-fpu-cfg=@var{name}")} | |
28620 | function attribute (@pxref{Function Attributes}) | |
28621 | or pragma (@pxref{Function Specific Option Pragmas}). | |
28622 | ||
28623 | The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point | |
28624 | Hardware 2 Component}. Please note that the custom instructions enabled by | |
28625 | @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated | |
28626 | if @option{-ffinite-math-only} is specified. The custom instruction enabled by | |
28627 | @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is | |
28628 | specified. In contrast to the other configurations, | |
28629 | @option{-fsingle-precision-constant} is not set. | |
28630 | ||
28631 | @end table | |
28632 | ||
28633 | These additional @samp{-m} options are available for the Altera Nios II | |
28634 | ELF (bare-metal) target: | |
28635 | ||
28636 | @table @gcctabopt | |
28637 | ||
d77de738 | 28638 | @opindex mhal |
ddf6fe37 | 28639 | @item -mhal |
d77de738 ML |
28640 | Link with HAL BSP. This suppresses linking with the GCC-provided C runtime |
28641 | startup and termination code, and is typically used in conjunction with | |
28642 | @option{-msys-crt0=} to specify the location of the alternate startup code | |
28643 | provided by the HAL BSP. | |
28644 | ||
d77de738 | 28645 | @opindex msmallc |
ddf6fe37 | 28646 | @item -msmallc |
d77de738 ML |
28647 | Link with a limited version of the C library, @option{-lsmallc}, rather than |
28648 | Newlib. | |
28649 | ||
d77de738 | 28650 | @opindex msys-crt0 |
ddf6fe37 | 28651 | @item -msys-crt0=@var{startfile} |
d77de738 ML |
28652 | @var{startfile} is the file name of the startfile (crt0) to use |
28653 | when linking. This option is only useful in conjunction with @option{-mhal}. | |
28654 | ||
d77de738 | 28655 | @opindex msys-lib |
ddf6fe37 | 28656 | @item -msys-lib=@var{systemlib} |
d77de738 ML |
28657 | @var{systemlib} is the library name of the library that provides |
28658 | low-level system calls required by the C library, | |
28659 | e.g.@: @code{read} and @code{write}. | |
28660 | This option is typically used to link with a library provided by a HAL BSP. | |
28661 | ||
28662 | @end table | |
28663 | ||
28664 | @node Nvidia PTX Options | |
28665 | @subsection Nvidia PTX Options | |
28666 | @cindex Nvidia PTX options | |
28667 | @cindex nvptx options | |
28668 | ||
28669 | These options are defined for Nvidia PTX: | |
28670 | ||
28671 | @table @gcctabopt | |
28672 | ||
d77de738 | 28673 | @opindex m64 |
ddf6fe37 | 28674 | @item -m64 |
d77de738 ML |
28675 | Ignored, but preserved for backward compatibility. Only 64-bit ABI is |
28676 | supported. | |
28677 | ||
d77de738 | 28678 | @opindex march |
ddf6fe37 | 28679 | @item -march=@var{architecture-string} |
d77de738 ML |
28680 | Generate code for the specified PTX ISA target architecture |
28681 | (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30}, | |
28682 | @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and | |
28683 | @samp{sm_80}. | |
28684 | The default depends on how the compiler has been configured, see | |
28685 | @option{--with-arch}. | |
28686 | ||
28687 | This option sets the value of the preprocessor macro | |
28688 | @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value | |
28689 | @samp{350}. | |
28690 | ||
d77de738 | 28691 | @opindex misa |
ddf6fe37 | 28692 | @item -misa=@var{architecture-string} |
d77de738 ML |
28693 | Alias of @option{-march=}. |
28694 | ||
d77de738 | 28695 | @opindex march |
ddf6fe37 | 28696 | @item -march-map=@var{architecture-string} |
d77de738 ML |
28697 | Select the closest available @option{-march=} value that is not more |
28698 | capable. For instance, for @option{-march-map=sm_50} select | |
28699 | @option{-march=sm_35}, and for @option{-march-map=sm_53} select | |
28700 | @option{-march=sm_53}. | |
28701 | ||
d77de738 | 28702 | @opindex mptx |
ddf6fe37 | 28703 | @item -mptx=@var{version-string} |
d77de738 ML |
28704 | Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}). |
28705 | Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and | |
28706 | @samp{7.0}. The default PTX ISA version is 6.0, unless a higher | |
28707 | version is required for specified PTX ISA target architecture via | |
28708 | option @option{-march=}. | |
28709 | ||
28710 | This option sets the values of the preprocessor macros | |
28711 | @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__}; | |
28712 | for instance, for @samp{3.1} the macros have the values @samp{3} and | |
28713 | @samp{1}, respectively. | |
28714 | ||
d77de738 | 28715 | @opindex mmainkernel |
ddf6fe37 | 28716 | @item -mmainkernel |
d77de738 ML |
28717 | Link in code for a __main kernel. This is for stand-alone instead of |
28718 | offloading execution. | |
28719 | ||
d77de738 | 28720 | @opindex moptimize |
ddf6fe37 | 28721 | @item -moptimize |
d77de738 ML |
28722 | Apply partitioned execution optimizations. This is the default when any |
28723 | level of optimization is selected. | |
28724 | ||
d77de738 | 28725 | @opindex msoft-stack |
ddf6fe37 | 28726 | @item -msoft-stack |
d77de738 ML |
28727 | Generate code that does not use @code{.local} memory |
28728 | directly for stack storage. Instead, a per-warp stack pointer is | |
28729 | maintained explicitly. This enables variable-length stack allocation (with | |
28730 | variable-length arrays or @code{alloca}), and when global memory is used for | |
28731 | underlying storage, makes it possible to access automatic variables from other | |
28732 | threads, or with atomic instructions. This code generation variant is used | |
28733 | for OpenMP offloading, but the option is exposed on its own for the purpose | |
28734 | of testing the compiler; to generate code suitable for linking into programs | |
28735 | using OpenMP offloading, use option @option{-mgomp}. | |
28736 | ||
d77de738 | 28737 | @opindex muniform-simt |
ddf6fe37 | 28738 | @item -muniform-simt |
d77de738 ML |
28739 | Switch to code generation variant that allows to execute all threads in each |
28740 | warp, while maintaining memory state and side effects as if only one thread | |
28741 | in each warp was active outside of OpenMP SIMD regions. All atomic operations | |
28742 | and calls to runtime (malloc, free, vprintf) are conditionally executed (iff | |
28743 | current lane index equals the master lane index), and the register being | |
28744 | assigned is copied via a shuffle instruction from the master lane. Outside of | |
28745 | SIMD regions lane 0 is the master; inside, each thread sees itself as the | |
28746 | master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or | |
28747 | all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD | |
28748 | regions). Each thread can bitwise-and the bitmask at position @code{tid.y} | |
28749 | with current lane index to compute the master lane index. | |
28750 | ||
d77de738 | 28751 | @opindex mgomp |
ddf6fe37 | 28752 | @item -mgomp |
d77de738 ML |
28753 | Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and |
28754 | @option{-muniform-simt} options, and selects corresponding multilib variant. | |
28755 | ||
28756 | @end table | |
28757 | ||
28758 | @node OpenRISC Options | |
28759 | @subsection OpenRISC Options | |
28760 | @cindex OpenRISC Options | |
28761 | ||
28762 | These options are defined for OpenRISC: | |
28763 | ||
28764 | @table @gcctabopt | |
28765 | ||
d77de738 | 28766 | @opindex mboard |
ddf6fe37 | 28767 | @item -mboard=@var{name} |
d77de738 ML |
28768 | Configure a board specific runtime. This will be passed to the linker for |
28769 | newlib board library linking. The default is @code{or1ksim}. | |
28770 | ||
d77de738 | 28771 | @opindex mnewlib |
ddf6fe37 | 28772 | @item -mnewlib |
d77de738 ML |
28773 | This option is ignored; it is for compatibility purposes only. This used to |
28774 | select linker and preprocessor options for use with newlib. | |
28775 | ||
d77de738 ML |
28776 | @opindex msoft-div |
28777 | @opindex mhard-div | |
ddf6fe37 AA |
28778 | @item -msoft-div |
28779 | @itemx -mhard-div | |
d77de738 ML |
28780 | Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions. |
28781 | This default is hardware divide. | |
28782 | ||
d77de738 ML |
28783 | @opindex msoft-mul |
28784 | @opindex mhard-mul | |
ddf6fe37 AA |
28785 | @item -msoft-mul |
28786 | @itemx -mhard-mul | |
d77de738 ML |
28787 | Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions. |
28788 | This default is hardware multiply. | |
28789 | ||
d77de738 ML |
28790 | @opindex msoft-float |
28791 | @opindex mhard-float | |
ddf6fe37 AA |
28792 | @item -msoft-float |
28793 | @itemx -mhard-float | |
d77de738 ML |
28794 | Select software or hardware for floating point operations. |
28795 | The default is software. | |
28796 | ||
d77de738 | 28797 | @opindex mdouble-float |
ddf6fe37 | 28798 | @item -mdouble-float |
d77de738 ML |
28799 | When @option{-mhard-float} is selected, enables generation of double-precision |
28800 | floating point instructions. By default functions from @file{libgcc} are used | |
28801 | to perform double-precision floating point operations. | |
28802 | ||
d77de738 | 28803 | @opindex munordered-float |
ddf6fe37 | 28804 | @item -munordered-float |
d77de738 ML |
28805 | When @option{-mhard-float} is selected, enables generation of unordered |
28806 | floating point compare and set flag (@code{lf.sfun*}) instructions. By default | |
28807 | functions from @file{libgcc} are used to perform unordered floating point | |
28808 | compare and set flag operations. | |
28809 | ||
d77de738 | 28810 | @opindex mcmov |
ddf6fe37 | 28811 | @item -mcmov |
d77de738 ML |
28812 | Enable generation of conditional move (@code{l.cmov}) instructions. By |
28813 | default the equivalent will be generated using set and branch. | |
28814 | ||
d77de738 | 28815 | @opindex mror |
ddf6fe37 | 28816 | @item -mror |
d77de738 ML |
28817 | Enable generation of rotate right (@code{l.ror}) instructions. By default |
28818 | functions from @file{libgcc} are used to perform rotate right operations. | |
28819 | ||
d77de738 | 28820 | @opindex mrori |
ddf6fe37 | 28821 | @item -mrori |
d77de738 ML |
28822 | Enable generation of rotate right with immediate (@code{l.rori}) instructions. |
28823 | By default functions from @file{libgcc} are used to perform rotate right with | |
28824 | immediate operations. | |
28825 | ||
d77de738 | 28826 | @opindex msext |
ddf6fe37 | 28827 | @item -msext |
d77de738 ML |
28828 | Enable generation of sign extension (@code{l.ext*}) instructions. By default |
28829 | memory loads are used to perform sign extension. | |
28830 | ||
d77de738 | 28831 | @opindex msfimm |
ddf6fe37 | 28832 | @item -msfimm |
d77de738 ML |
28833 | Enable generation of compare and set flag with immediate (@code{l.sf*i}) |
28834 | instructions. By default extra instructions will be generated to store the | |
28835 | immediate to a register first. | |
28836 | ||
d77de738 | 28837 | @opindex mshftimm |
ddf6fe37 | 28838 | @item -mshftimm |
d77de738 ML |
28839 | Enable generation of shift with immediate (@code{l.srai}, @code{l.srli}, |
28840 | @code{l.slli}) instructions. By default extra instructions will be generated | |
28841 | to store the immediate to a register first. | |
28842 | ||
d77de738 | 28843 | @opindex mcmodel=small |
ddf6fe37 | 28844 | @item -mcmodel=small |
d77de738 ML |
28845 | Generate OpenRISC code for the small model: The GOT is limited to 64k. This is |
28846 | the default model. | |
28847 | ||
d77de738 | 28848 | @opindex mcmodel=large |
ddf6fe37 | 28849 | @item -mcmodel=large |
d77de738 ML |
28850 | Generate OpenRISC code for the large model: The GOT may grow up to 4G in size. |
28851 | ||
28852 | ||
28853 | @end table | |
28854 | ||
28855 | @node PDP-11 Options | |
28856 | @subsection PDP-11 Options | |
28857 | @cindex PDP-11 Options | |
28858 | ||
28859 | These options are defined for the PDP-11: | |
28860 | ||
28861 | @table @gcctabopt | |
d77de738 | 28862 | @opindex mfpu |
ddf6fe37 | 28863 | @item -mfpu |
d77de738 ML |
28864 | Use hardware FPP floating point. This is the default. (FIS floating |
28865 | point on the PDP-11/40 is not supported.) Implies -m45. | |
28866 | ||
d77de738 | 28867 | @opindex msoft-float |
ddf6fe37 | 28868 | @item -msoft-float |
d77de738 ML |
28869 | Do not use hardware floating point. |
28870 | ||
d77de738 | 28871 | @opindex mac0 |
ddf6fe37 | 28872 | @item -mac0 |
d77de738 ML |
28873 | Return floating-point results in ac0 (fr0 in Unix assembler syntax). |
28874 | ||
d77de738 | 28875 | @opindex mno-ac0 |
ddf6fe37 | 28876 | @item -mno-ac0 |
d77de738 ML |
28877 | Return floating-point results in memory. This is the default. |
28878 | ||
d77de738 | 28879 | @opindex m40 |
ddf6fe37 | 28880 | @item -m40 |
d77de738 ML |
28881 | Generate code for a PDP-11/40. Implies -msoft-float -mno-split. |
28882 | ||
d77de738 | 28883 | @opindex m45 |
ddf6fe37 | 28884 | @item -m45 |
d77de738 ML |
28885 | Generate code for a PDP-11/45. This is the default. |
28886 | ||
d77de738 | 28887 | @opindex m10 |
ddf6fe37 | 28888 | @item -m10 |
d77de738 ML |
28889 | Generate code for a PDP-11/10. Implies -msoft-float -mno-split. |
28890 | ||
d77de738 ML |
28891 | @opindex mint16 |
28892 | @opindex mno-int32 | |
ddf6fe37 AA |
28893 | @item -mint16 |
28894 | @itemx -mno-int32 | |
d77de738 ML |
28895 | Use 16-bit @code{int}. This is the default. |
28896 | ||
d77de738 ML |
28897 | @opindex mint32 |
28898 | @opindex mno-int16 | |
ddf6fe37 AA |
28899 | @item -mint32 |
28900 | @itemx -mno-int16 | |
d77de738 ML |
28901 | Use 32-bit @code{int}. |
28902 | ||
d77de738 | 28903 | @opindex msplit |
ddf6fe37 | 28904 | @item -msplit |
d77de738 ML |
28905 | Target has split instruction and data space. Implies -m45. |
28906 | ||
d77de738 | 28907 | @opindex munix-asm |
ddf6fe37 | 28908 | @item -munix-asm |
d77de738 ML |
28909 | Use Unix assembler syntax. |
28910 | ||
d77de738 | 28911 | @opindex mdec-asm |
ddf6fe37 | 28912 | @item -mdec-asm |
d77de738 ML |
28913 | Use DEC assembler syntax. |
28914 | ||
d77de738 | 28915 | @opindex mgnu-asm |
ddf6fe37 | 28916 | @item -mgnu-asm |
d77de738 ML |
28917 | Use GNU assembler syntax. This is the default. |
28918 | ||
d77de738 | 28919 | @opindex mlra |
ddf6fe37 | 28920 | @item -mlra |
d77de738 ML |
28921 | Use the new LRA register allocator. By default, the old ``reload'' |
28922 | allocator is used. | |
28923 | @end table | |
28924 | ||
d77de738 ML |
28925 | @node PowerPC Options |
28926 | @subsection PowerPC Options | |
28927 | @cindex PowerPC options | |
28928 | ||
28929 | These are listed under @xref{RS/6000 and PowerPC Options}. | |
28930 | ||
28931 | @node PRU Options | |
28932 | @subsection PRU Options | |
28933 | @cindex PRU Options | |
28934 | ||
28935 | These command-line options are defined for PRU target: | |
28936 | ||
28937 | @table @gcctabopt | |
d77de738 | 28938 | @opindex minrt |
ddf6fe37 | 28939 | @item -minrt |
d77de738 ML |
28940 | Link with a minimum runtime environment, with no support for static |
28941 | initializers and constructors. Using this option can significantly reduce | |
28942 | the size of the final ELF binary. Beware that the compiler could still | |
28943 | generate code with static initializers and constructors. It is up to the | |
28944 | programmer to ensure that the source program will not use those features. | |
28945 | ||
d77de738 | 28946 | @opindex mmcu |
ddf6fe37 | 28947 | @item -mmcu=@var{mcu} |
d77de738 ML |
28948 | Specify the PRU MCU variant to use. Check Newlib for the exact list of |
28949 | supported MCUs. | |
28950 | ||
d77de738 | 28951 | @opindex mno-relax |
ddf6fe37 | 28952 | @item -mno-relax |
d77de738 ML |
28953 | Make GCC pass the @option{--no-relax} command-line option to the linker |
28954 | instead of the @option{--relax} option. | |
28955 | ||
d77de738 | 28956 | @opindex mloop |
ddf6fe37 | 28957 | @item -mloop |
d77de738 ML |
28958 | Allow (or do not allow) GCC to use the LOOP instruction. |
28959 | ||
d77de738 | 28960 | @opindex mabi |
ddf6fe37 | 28961 | @item -mabi=@var{variant} |
d77de738 ML |
28962 | Specify the ABI variant to output code for. @option{-mabi=ti} selects the |
28963 | unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes | |
28964 | more naturally with certain GCC assumptions. These are the differences: | |
28965 | ||
28966 | @table @samp | |
28967 | @item Function Pointer Size | |
28968 | TI ABI specifies that function (code) pointers are 16-bit, whereas GNU | |
28969 | supports only 32-bit data and code pointers. | |
28970 | ||
28971 | @item Optional Return Value Pointer | |
28972 | Function return values larger than 64 bits are passed by using a hidden | |
28973 | pointer as the first argument of the function. TI ABI, though, mandates that | |
28974 | the pointer can be NULL in case the caller is not using the returned value. | |
28975 | GNU always passes and expects a valid return value pointer. | |
28976 | ||
28977 | @end table | |
28978 | ||
28979 | The current @option{-mabi=ti} implementation simply raises a compile error | |
28980 | when any of the above code constructs is detected. As a consequence | |
28981 | the standard C library cannot be built and it is omitted when linking with | |
28982 | @option{-mabi=ti}. | |
28983 | ||
28984 | Relaxation is a GNU feature and for safety reasons is disabled when using | |
28985 | @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx | |
28986 | instructions, so the GNU linker cannot adjust them when shortening adjacent | |
28987 | LDI32 pseudo instructions. | |
28988 | ||
28989 | @end table | |
28990 | ||
28991 | @node RISC-V Options | |
28992 | @subsection RISC-V Options | |
28993 | @cindex RISC-V Options | |
28994 | ||
28995 | These command-line options are defined for RISC-V targets: | |
28996 | ||
28997 | @table @gcctabopt | |
d77de738 | 28998 | @opindex mbranch-cost |
ddf6fe37 | 28999 | @item -mbranch-cost=@var{n} |
d77de738 ML |
29000 | Set the cost of branches to roughly @var{n} instructions. |
29001 | ||
ddf6fe37 | 29002 | @opindex plt |
d77de738 ML |
29003 | @item -mplt |
29004 | @itemx -mno-plt | |
d77de738 ML |
29005 | When generating PIC code, do or don't allow the use of PLTs. Ignored for |
29006 | non-PIC. The default is @option{-mplt}. | |
29007 | ||
d77de738 | 29008 | @opindex mabi |
ddf6fe37 | 29009 | @item -mabi=@var{ABI-string} |
d77de738 ML |
29010 | Specify integer and floating-point calling convention. @var{ABI-string} |
29011 | contains two parts: the size of integer types and the registers used for | |
29012 | floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that | |
29013 | @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be | |
29014 | 32-bit), and that floating-point values up to 64 bits wide are passed in F | |
29015 | registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still | |
29016 | allows the compiler to generate code that uses the F and D extensions but only | |
29017 | allows floating-point values up to 32 bits long to be passed in registers; or | |
29018 | @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be | |
29019 | passed in registers. | |
29020 | ||
29021 | The default for this argument is system dependent, users who want a specific | |
29022 | calling convention should specify one explicitly. The valid calling | |
29023 | conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64}, | |
29024 | @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to | |
29025 | implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is | |
29026 | invalid because the ABI requires 64-bit values be passed in F registers, but F | |
29027 | registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can | |
29028 | only be used with the @samp{rv32e} architecture. This ABI is not well | |
29029 | specified at present, and is subject to change. | |
29030 | ||
ddf6fe37 | 29031 | @opindex mfdiv |
d77de738 ML |
29032 | @item -mfdiv |
29033 | @itemx -mno-fdiv | |
d77de738 ML |
29034 | Do or don't use hardware floating-point divide and square root instructions. |
29035 | This requires the F or D extensions for floating-point registers. The default | |
29036 | is to use them if the specified architecture has these instructions. | |
29037 | ||
ddf6fe37 | 29038 | @opindex mdiv |
d77de738 ML |
29039 | @item -mdiv |
29040 | @itemx -mno-div | |
d77de738 ML |
29041 | Do or don't use hardware instructions for integer division. This requires the |
29042 | M extension. The default is to use them if the specified architecture has | |
29043 | these instructions. | |
29044 | ||
d77de738 | 29045 | @opindex misa-spec |
ddf6fe37 | 29046 | @item -misa-spec=@var{ISA-spec-string} |
d77de738 ML |
29047 | Specify the version of the RISC-V Unprivileged (formerly User-Level) |
29048 | ISA specification to produce code conforming to. The possibilities | |
29049 | for @var{ISA-spec-string} are: | |
29050 | @table @code | |
29051 | @item 2.2 | |
29052 | Produce code conforming to version 2.2. | |
29053 | @item 20190608 | |
29054 | Produce code conforming to version 20190608. | |
29055 | @item 20191213 | |
29056 | Produce code conforming to version 20191213. | |
29057 | @end table | |
29058 | The default is @option{-misa-spec=20191213} unless GCC has been configured | |
29059 | with @option{--with-isa-spec=} specifying a different default version. | |
29060 | ||
d77de738 | 29061 | @opindex march |
ddf6fe37 | 29062 | @item -march=@var{ISA-string} |
d77de738 ML |
29063 | Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be |
29064 | lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and | |
29065 | @samp{rv32imaf}. | |
29066 | ||
29067 | When @option{-march=} is not specified, use the setting from @option{-mcpu}. | |
29068 | ||
29069 | If both @option{-march} and @option{-mcpu=} are not specified, the default for | |
29070 | this argument is system dependent, users who want a specific architecture | |
29071 | extensions should specify one explicitly. | |
29072 | ||
d77de738 | 29073 | @opindex mcpu |
ddf6fe37 | 29074 | @item -mcpu=@var{processor-string} |
d77de738 ML |
29075 | Use architecture of and optimize the output for the given processor, specified |
29076 | by particular CPU name. | |
29077 | Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21}, | |
29078 | @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76}, | |
29079 | @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76}, | |
aa37a91c | 29080 | @samp{sifive-u54}, and @samp{sifive-u74}. |
d77de738 | 29081 | |
d77de738 | 29082 | @opindex mtune |
ddf6fe37 | 29083 | @item -mtune=@var{processor-string} |
d77de738 ML |
29084 | Optimize the output for the given processor, specified by microarchitecture or |
29085 | particular CPU name. Permissible values for this option are: @samp{rocket}, | |
29086 | @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series}, | |
aa37a91c | 29087 | @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. |
d77de738 ML |
29088 | |
29089 | When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, | |
29090 | the default is @samp{rocket} if both are not specified. | |
29091 | ||
29092 | The @samp{size} choice is not intended for use by end-users. This is used | |
29093 | when @option{-Os} is specified. It overrides the instruction cost info | |
29094 | provided by @option{-mtune=}, but does not override the pipeline info. This | |
29095 | helps reduce code size while still giving good performance. | |
29096 | ||
d77de738 | 29097 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 29098 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
29099 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
29100 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
29101 | the default is 4 (16 bytes or 128-bits). | |
29102 | ||
29103 | @strong{Warning:} If you use this switch, then you must build all modules with | |
29104 | the same value, including any libraries. This includes the system libraries | |
29105 | and startup modules. | |
29106 | ||
d77de738 | 29107 | @opindex msmall-data-limit |
ddf6fe37 | 29108 | @item -msmall-data-limit=@var{n} |
d77de738 ML |
29109 | Put global and static data smaller than @var{n} bytes into a special section |
29110 | (on some targets). | |
29111 | ||
ddf6fe37 | 29112 | @opindex msave-restore |
d77de738 ML |
29113 | @item -msave-restore |
29114 | @itemx -mno-save-restore | |
d77de738 ML |
29115 | Do or don't use smaller but slower prologue and epilogue code that uses |
29116 | library function calls. The default is to use fast inline prologues and | |
29117 | epilogues. | |
29118 | ||
f797260a PN |
29119 | @opindex minline-atomics |
29120 | @item -minline-atomics | |
29121 | @itemx -mno-inline-atomics | |
29122 | Do or don't use smaller but slower subword atomic emulation code that uses | |
29123 | libatomic function calls. The default is to use fast inline subword atomics | |
29124 | that do not require libatomic. | |
29125 | ||
ddf6fe37 | 29126 | @opindex mshorten-memrefs |
d77de738 ML |
29127 | @item -mshorten-memrefs |
29128 | @itemx -mno-shorten-memrefs | |
d77de738 ML |
29129 | Do or do not attempt to make more use of compressed load/store instructions by |
29130 | replacing a load/store of 'base register + large offset' with a new load/store | |
29131 | of 'new base + small offset'. If the new base gets stored in a compressed | |
29132 | register, then the new load/store can be compressed. Currently targets 32-bit | |
29133 | integer load/stores only. | |
29134 | ||
ddf6fe37 | 29135 | @opindex mstrict-align |
d77de738 ML |
29136 | @item -mstrict-align |
29137 | @itemx -mno-strict-align | |
d77de738 ML |
29138 | Do not or do generate unaligned memory accesses. The default is set depending |
29139 | on whether the processor we are optimizing for supports fast unaligned access | |
29140 | or not. | |
29141 | ||
d77de738 | 29142 | @opindex mcmodel=medlow |
ddf6fe37 | 29143 | @item -mcmodel=medlow |
d77de738 ML |
29144 | Generate code for the medium-low code model. The program and its statically |
29145 | defined symbols must lie within a single 2 GiB address range and must lie | |
29146 | between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be | |
29147 | statically or dynamically linked. This is the default code model. | |
29148 | ||
d77de738 | 29149 | @opindex mcmodel=medany |
ddf6fe37 | 29150 | @item -mcmodel=medany |
d77de738 ML |
29151 | Generate code for the medium-any code model. The program and its statically |
29152 | defined symbols must be within any single 2 GiB address range. Programs can be | |
29153 | statically or dynamically linked. | |
29154 | ||
29155 | The code generated by the medium-any code model is position-independent, but is | |
29156 | not guaranteed to function correctly when linked into position-independent | |
29157 | executables or libraries. | |
29158 | ||
29159 | @item -mexplicit-relocs | |
29160 | @itemx -mno-exlicit-relocs | |
29161 | Use or do not use assembler relocation operators when dealing with symbolic | |
29162 | addresses. The alternative is to use assembler macros instead, which may | |
29163 | limit optimization. | |
29164 | ||
ddf6fe37 | 29165 | @opindex mrelax |
d77de738 ML |
29166 | @item -mrelax |
29167 | @itemx -mno-relax | |
d77de738 ML |
29168 | Take advantage of linker relaxations to reduce the number of instructions |
29169 | required to materialize symbol addresses. The default is to take advantage of | |
29170 | linker relaxations. | |
29171 | ||
ddf6fe37 | 29172 | @opindex mriscv-attribute |
d77de738 ML |
29173 | @item -mriscv-attribute |
29174 | @itemx -mno-riscv-attribute | |
d77de738 ML |
29175 | Emit (do not emit) RISC-V attribute to record extra information into ELF |
29176 | objects. This feature requires at least binutils 2.32. | |
29177 | ||
ddf6fe37 | 29178 | @opindex mcsr-check |
d77de738 ML |
29179 | @item -mcsr-check |
29180 | @itemx -mno-csr-check | |
d77de738 ML |
29181 | Enables or disables the CSR checking. |
29182 | ||
d77de738 | 29183 | @opindex malign-data |
ddf6fe37 | 29184 | @item -malign-data=@var{type} |
d77de738 ML |
29185 | Control how GCC aligns variables and constants of array, structure, or union |
29186 | types. Supported values for @var{type} are @samp{xlen} which uses x register | |
29187 | width as the alignment value, and @samp{natural} which uses natural alignment. | |
29188 | @samp{xlen} is the default. | |
29189 | ||
d77de738 | 29190 | @opindex mbig-endian |
ddf6fe37 | 29191 | @item -mbig-endian |
d77de738 ML |
29192 | Generate big-endian code. This is the default when GCC is configured for a |
29193 | @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target. | |
29194 | ||
d77de738 | 29195 | @opindex mlittle-endian |
ddf6fe37 | 29196 | @item -mlittle-endian |
d77de738 ML |
29197 | Generate little-endian code. This is the default when GCC is configured for a |
29198 | @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or | |
29199 | @samp{riscv32be-*-*} target. | |
29200 | ||
d77de738 ML |
29201 | @opindex mstack-protector-guard |
29202 | @opindex mstack-protector-guard-reg | |
29203 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
29204 | @item -mstack-protector-guard=@var{guard} |
29205 | @itemx -mstack-protector-guard-reg=@var{reg} | |
29206 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
29207 | Generate stack protection code using canary at @var{guard}. Supported |
29208 | locations are @samp{global} for a global canary or @samp{tls} for per-thread | |
29209 | canary in the TLS block. | |
29210 | ||
29211 | With the latter choice the options | |
29212 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
29213 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
29214 | which register to use as base register for reading the canary, | |
29215 | and from what offset from that base register. There is no default | |
29216 | register or offset as this is entirely for use within the Linux | |
29217 | kernel. | |
29218 | @end table | |
29219 | ||
29220 | @node RL78 Options | |
29221 | @subsection RL78 Options | |
29222 | @cindex RL78 Options | |
29223 | ||
29224 | @table @gcctabopt | |
29225 | ||
d77de738 | 29226 | @opindex msim |
ddf6fe37 | 29227 | @item -msim |
d77de738 ML |
29228 | Links in additional target libraries to support operation within a |
29229 | simulator. | |
29230 | ||
ddf6fe37 | 29231 | @opindex mmul |
d77de738 ML |
29232 | @item -mmul=none |
29233 | @itemx -mmul=g10 | |
29234 | @itemx -mmul=g13 | |
29235 | @itemx -mmul=g14 | |
29236 | @itemx -mmul=rl78 | |
d77de738 ML |
29237 | Specifies the type of hardware multiplication and division support to |
29238 | be used. The simplest is @code{none}, which uses software for both | |
29239 | multiplication and division. This is the default. The @code{g13} | |
29240 | value is for the hardware multiply/divide peripheral found on the | |
29241 | RL78/G13 (S2 core) targets. The @code{g14} value selects the use of | |
29242 | the multiplication and division instructions supported by the RL78/G14 | |
29243 | (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and | |
29244 | the value @code{mg10} is an alias for @code{none}. | |
29245 | ||
29246 | In addition a C preprocessor macro is defined, based upon the setting | |
29247 | of this option. Possible values are: @code{__RL78_MUL_NONE__}, | |
29248 | @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}. | |
29249 | ||
ddf6fe37 | 29250 | @opindex mcpu |
d77de738 ML |
29251 | @item -mcpu=g10 |
29252 | @itemx -mcpu=g13 | |
29253 | @itemx -mcpu=g14 | |
29254 | @itemx -mcpu=rl78 | |
d77de738 ML |
29255 | Specifies the RL78 core to target. The default is the G14 core, also |
29256 | known as an S3 core or just RL78. The G13 or S2 core does not have | |
29257 | multiply or divide instructions, instead it uses a hardware peripheral | |
29258 | for these operations. The G10 or S1 core does not have register | |
29259 | banks, so it uses a different calling convention. | |
29260 | ||
29261 | If this option is set it also selects the type of hardware multiply | |
29262 | support to use, unless this is overridden by an explicit | |
29263 | @option{-mmul=none} option on the command line. Thus specifying | |
29264 | @option{-mcpu=g13} enables the use of the G13 hardware multiply | |
29265 | peripheral and specifying @option{-mcpu=g10} disables the use of | |
29266 | hardware multiplications altogether. | |
29267 | ||
29268 | Note, although the RL78/G14 core is the default target, specifying | |
29269 | @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does | |
29270 | change the behavior of the toolchain since it also enables G14 | |
29271 | hardware multiply support. If these options are not specified on the | |
29272 | command line then software multiplication routines will be used even | |
29273 | though the code targets the RL78 core. This is for backwards | |
29274 | compatibility with older toolchains which did not have hardware | |
29275 | multiply and divide support. | |
29276 | ||
29277 | In addition a C preprocessor macro is defined, based upon the setting | |
29278 | of this option. Possible values are: @code{__RL78_G10__}, | |
29279 | @code{__RL78_G13__} or @code{__RL78_G14__}. | |
29280 | ||
d77de738 ML |
29281 | @opindex mg10 |
29282 | @opindex mg13 | |
29283 | @opindex mg14 | |
29284 | @opindex mrl78 | |
ddf6fe37 AA |
29285 | @item -mg10 |
29286 | @itemx -mg13 | |
29287 | @itemx -mg14 | |
29288 | @itemx -mrl78 | |
d77de738 ML |
29289 | These are aliases for the corresponding @option{-mcpu=} option. They |
29290 | are provided for backwards compatibility. | |
29291 | ||
d77de738 | 29292 | @opindex mallregs |
ddf6fe37 | 29293 | @item -mallregs |
d77de738 ML |
29294 | Allow the compiler to use all of the available registers. By default |
29295 | registers @code{r24..r31} are reserved for use in interrupt handlers. | |
29296 | With this option enabled these registers can be used in ordinary | |
29297 | functions as well. | |
29298 | ||
d77de738 ML |
29299 | @opindex m64bit-doubles |
29300 | @opindex m32bit-doubles | |
ddf6fe37 AA |
29301 | @item -m64bit-doubles |
29302 | @itemx -m32bit-doubles | |
d77de738 ML |
29303 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
29304 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
29305 | @option{-m32bit-doubles}. | |
29306 | ||
d77de738 ML |
29307 | @opindex msave-mduc-in-interrupts |
29308 | @opindex mno-save-mduc-in-interrupts | |
ddf6fe37 AA |
29309 | @item -msave-mduc-in-interrupts |
29310 | @itemx -mno-save-mduc-in-interrupts | |
d77de738 ML |
29311 | Specifies that interrupt handler functions should preserve the |
29312 | MDUC registers. This is only necessary if normal code might use | |
29313 | the MDUC registers, for example because it performs multiplication | |
29314 | and division operations. The default is to ignore the MDUC registers | |
29315 | as this makes the interrupt handlers faster. The target option -mg13 | |
29316 | needs to be passed for this to work as this feature is only available | |
29317 | on the G13 target (S2 core). The MDUC registers will only be saved | |
29318 | if the interrupt handler performs a multiplication or division | |
29319 | operation or it calls another function. | |
29320 | ||
29321 | @end table | |
29322 | ||
29323 | @node RS/6000 and PowerPC Options | |
29324 | @subsection IBM RS/6000 and PowerPC Options | |
29325 | @cindex RS/6000 and PowerPC Options | |
29326 | @cindex IBM RS/6000 and PowerPC Options | |
29327 | ||
29328 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
29329 | @table @gcctabopt | |
29330 | @item -mpowerpc-gpopt | |
29331 | @itemx -mno-powerpc-gpopt | |
29332 | @itemx -mpowerpc-gfxopt | |
29333 | @itemx -mno-powerpc-gfxopt | |
29334 | @need 800 | |
29335 | @itemx -mpowerpc64 | |
29336 | @itemx -mno-powerpc64 | |
29337 | @itemx -mmfcrf | |
29338 | @itemx -mno-mfcrf | |
29339 | @itemx -mpopcntb | |
29340 | @itemx -mno-popcntb | |
29341 | @itemx -mpopcntd | |
29342 | @itemx -mno-popcntd | |
29343 | @itemx -mfprnd | |
29344 | @itemx -mno-fprnd | |
29345 | @need 800 | |
d77de738 ML |
29346 | @opindex mpowerpc-gpopt |
29347 | @opindex mno-powerpc-gpopt | |
29348 | @opindex mpowerpc-gfxopt | |
29349 | @opindex mno-powerpc-gfxopt | |
29350 | @opindex mpowerpc64 | |
29351 | @opindex mno-powerpc64 | |
29352 | @opindex mmfcrf | |
29353 | @opindex mno-mfcrf | |
29354 | @opindex mpopcntb | |
29355 | @opindex mno-popcntb | |
29356 | @opindex mpopcntd | |
29357 | @opindex mno-popcntd | |
29358 | @opindex mfprnd | |
29359 | @opindex mno-fprnd | |
29360 | @opindex mcmpb | |
29361 | @opindex mno-cmpb | |
29362 | @opindex mhard-dfp | |
29363 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
29364 | @itemx -mcmpb |
29365 | @itemx -mno-cmpb | |
29366 | @itemx -mhard-dfp | |
29367 | @itemx -mno-hard-dfp | |
d77de738 ML |
29368 | You use these options to specify which instructions are available on the |
29369 | processor you are using. The default value of these options is | |
29370 | determined when configuring GCC@. Specifying the | |
29371 | @option{-mcpu=@var{cpu_type}} overrides the specification of these | |
29372 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
29373 | rather than the options listed above. | |
29374 | ||
29375 | Specifying @option{-mpowerpc-gpopt} allows | |
29376 | GCC to use the optional PowerPC architecture instructions in the | |
29377 | General Purpose group, including floating-point square root. Specifying | |
29378 | @option{-mpowerpc-gfxopt} allows GCC to | |
29379 | use the optional PowerPC architecture instructions in the Graphics | |
29380 | group, including floating-point select. | |
29381 | ||
29382 | The @option{-mmfcrf} option allows GCC to generate the move from | |
29383 | condition register field instruction implemented on the POWER4 | |
29384 | processor and other processors that support the PowerPC V2.01 | |
29385 | architecture. | |
29386 | The @option{-mpopcntb} option allows GCC to generate the popcount and | |
29387 | double-precision FP reciprocal estimate instruction implemented on the | |
29388 | POWER5 processor and other processors that support the PowerPC V2.02 | |
29389 | architecture. | |
29390 | The @option{-mpopcntd} option allows GCC to generate the popcount | |
29391 | instruction implemented on the POWER7 processor and other processors | |
29392 | that support the PowerPC V2.06 architecture. | |
29393 | The @option{-mfprnd} option allows GCC to generate the FP round to | |
29394 | integer instructions implemented on the POWER5+ processor and other | |
29395 | processors that support the PowerPC V2.03 architecture. | |
29396 | The @option{-mcmpb} option allows GCC to generate the compare bytes | |
29397 | instruction implemented on the POWER6 processor and other processors | |
29398 | that support the PowerPC V2.05 architecture. | |
29399 | The @option{-mhard-dfp} option allows GCC to generate the decimal | |
29400 | floating-point instructions implemented on some POWER processors. | |
29401 | ||
29402 | The @option{-mpowerpc64} option allows GCC to generate the additional | |
29403 | 64-bit instructions that are found in the full PowerPC64 architecture | |
29404 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to | |
29405 | @option{-mno-powerpc64}. | |
29406 | ||
d77de738 | 29407 | @opindex mcpu |
ddf6fe37 | 29408 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
29409 | Set architecture type, register usage, and |
29410 | instruction scheduling parameters for machine type @var{cpu_type}. | |
29411 | Supported values for @var{cpu_type} are @samp{401}, @samp{403}, | |
29412 | @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp}, | |
29413 | @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603}, | |
29414 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740}, | |
29415 | @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823}, | |
29416 | @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2}, | |
29417 | @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500}, | |
29418 | @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5}, | |
29419 | @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+}, | |
29420 | @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8}, | |
29421 | @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64}, | |
29422 | @samp{powerpc64le}, @samp{rs64}, and @samp{native}. | |
29423 | ||
29424 | @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and | |
29425 | @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either | |
29426 | endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC | |
29427 | architecture machine types, with an appropriate, generic processor | |
29428 | model assumed for scheduling purposes. | |
29429 | ||
29430 | Specifying @samp{native} as cpu type detects and selects the | |
29431 | architecture option that corresponds to the host processor of the | |
29432 | system performing the compilation. | |
29433 | @option{-mcpu=native} has no effect if GCC does not recognize the | |
29434 | processor. | |
29435 | ||
29436 | The other options specify a specific processor. Code generated under | |
29437 | those options runs best on that processor, and may not run at all on | |
29438 | others. | |
29439 | ||
29440 | The @option{-mcpu} options automatically enable or disable the | |
29441 | following options: | |
29442 | ||
43b72ede AA |
29443 | @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple |
29444 | -mpopcntb -mpopcntd -mpowerpc64 | |
29445 | -mpowerpc-gpopt -mpowerpc-gfxopt | |
29446 | -mmulhw -mdlmzb -mmfpgpr -mvsx | |
29447 | -mcrypto -mhtm -mpower8-fusion -mpower8-vector | |
29448 | -mquad-memory -mquad-memory-atomic -mfloat128 | |
29449 | -mfloat128-hardware -mprefixed -mpcrel -mmma | |
d77de738 ML |
29450 | -mrop-protect} |
29451 | ||
29452 | The particular options set for any particular CPU varies between | |
29453 | compiler versions, depending on what setting seems to produce optimal | |
29454 | code for that CPU; it doesn't necessarily reflect the actual hardware's | |
29455 | capabilities. If you wish to set an individual option to a particular | |
29456 | value, you may specify it after the @option{-mcpu} option, like | |
29457 | @option{-mcpu=970 -mno-altivec}. | |
29458 | ||
29459 | On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are | |
29460 | not enabled or disabled by the @option{-mcpu} option at present because | |
29461 | AIX does not have full support for these options. You may still | |
29462 | enable or disable them individually if you're sure it'll work in your | |
29463 | environment. | |
29464 | ||
d77de738 | 29465 | @opindex mtune |
ddf6fe37 | 29466 | @item -mtune=@var{cpu_type} |
d77de738 ML |
29467 | Set the instruction scheduling parameters for machine type |
29468 | @var{cpu_type}, but do not set the architecture type or register usage, | |
29469 | as @option{-mcpu=@var{cpu_type}} does. The same | |
29470 | values for @var{cpu_type} are used for @option{-mtune} as for | |
29471 | @option{-mcpu}. If both are specified, the code generated uses the | |
29472 | architecture and registers set by @option{-mcpu}, but the | |
29473 | scheduling parameters set by @option{-mtune}. | |
29474 | ||
d77de738 | 29475 | @opindex mcmodel=small |
ddf6fe37 | 29476 | @item -mcmodel=small |
d77de738 ML |
29477 | Generate PowerPC64 code for the small model: The TOC is limited to |
29478 | 64k. | |
29479 | ||
d77de738 | 29480 | @opindex mcmodel=medium |
ddf6fe37 | 29481 | @item -mcmodel=medium |
d77de738 ML |
29482 | Generate PowerPC64 code for the medium model: The TOC and other static |
29483 | data may be up to a total of 4G in size. This is the default for 64-bit | |
29484 | Linux. | |
29485 | ||
d77de738 | 29486 | @opindex mcmodel=large |
ddf6fe37 | 29487 | @item -mcmodel=large |
d77de738 ML |
29488 | Generate PowerPC64 code for the large model: The TOC may be up to 4G |
29489 | in size. Other data and code is only limited by the 64-bit address | |
29490 | space. | |
29491 | ||
d77de738 ML |
29492 | @opindex maltivec |
29493 | @opindex mno-altivec | |
ddf6fe37 AA |
29494 | @item -maltivec |
29495 | @itemx -mno-altivec | |
d77de738 ML |
29496 | Generate code that uses (does not use) AltiVec instructions, and also |
29497 | enable the use of built-in functions that allow more direct access to | |
29498 | the AltiVec instruction set. You may also need to set | |
29499 | @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI | |
29500 | enhancements. | |
29501 | ||
29502 | When @option{-maltivec} is used, the element order for AltiVec intrinsics | |
29503 | such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert} | |
29504 | match array element order corresponding to the endianness of the | |
29505 | target. That is, element zero identifies the leftmost element in a | |
29506 | vector register when targeting a big-endian platform, and identifies | |
29507 | the rightmost element in a vector register when targeting a | |
29508 | little-endian platform. | |
29509 | ||
d77de738 ML |
29510 | @opindex mvrsave |
29511 | @opindex mno-vrsave | |
ddf6fe37 AA |
29512 | @item -mvrsave |
29513 | @itemx -mno-vrsave | |
d77de738 ML |
29514 | Generate VRSAVE instructions when generating AltiVec code. |
29515 | ||
d77de738 | 29516 | @opindex msecure-plt |
ddf6fe37 | 29517 | @item -msecure-plt |
d77de738 ML |
29518 | Generate code that allows @command{ld} and @command{ld.so} |
29519 | to build executables and shared | |
29520 | libraries with non-executable @code{.plt} and @code{.got} sections. | |
29521 | This is a PowerPC | |
29522 | 32-bit SYSV ABI option. | |
29523 | ||
d77de738 | 29524 | @opindex mbss-plt |
ddf6fe37 | 29525 | @item -mbss-plt |
d77de738 ML |
29526 | Generate code that uses a BSS @code{.plt} section that @command{ld.so} |
29527 | fills in, and | |
29528 | requires @code{.plt} and @code{.got} | |
29529 | sections that are both writable and executable. | |
29530 | This is a PowerPC 32-bit SYSV ABI option. | |
29531 | ||
d77de738 ML |
29532 | @opindex misel |
29533 | @opindex mno-isel | |
ddf6fe37 AA |
29534 | @item -misel |
29535 | @itemx -mno-isel | |
d77de738 ML |
29536 | This switch enables or disables the generation of ISEL instructions. |
29537 | ||
d77de738 ML |
29538 | @opindex mvsx |
29539 | @opindex mno-vsx | |
ddf6fe37 AA |
29540 | @item -mvsx |
29541 | @itemx -mno-vsx | |
d77de738 ML |
29542 | Generate code that uses (does not use) vector/scalar (VSX) |
29543 | instructions, and also enable the use of built-in functions that allow | |
29544 | more direct access to the VSX instruction set. | |
29545 | ||
d77de738 ML |
29546 | @opindex mcrypto |
29547 | @opindex mno-crypto | |
ddf6fe37 AA |
29548 | @item -mcrypto |
29549 | @itemx -mno-crypto | |
d77de738 ML |
29550 | Enable the use (disable) of the built-in functions that allow direct |
29551 | access to the cryptographic instructions that were added in version | |
29552 | 2.07 of the PowerPC ISA. | |
29553 | ||
d77de738 ML |
29554 | @opindex mhtm |
29555 | @opindex mno-htm | |
ddf6fe37 AA |
29556 | @item -mhtm |
29557 | @itemx -mno-htm | |
d77de738 ML |
29558 | Enable (disable) the use of the built-in functions that allow direct |
29559 | access to the Hardware Transactional Memory (HTM) instructions that | |
29560 | were added in version 2.07 of the PowerPC ISA. | |
29561 | ||
d77de738 ML |
29562 | @opindex mpower8-fusion |
29563 | @opindex mno-power8-fusion | |
ddf6fe37 AA |
29564 | @item -mpower8-fusion |
29565 | @itemx -mno-power8-fusion | |
d77de738 ML |
29566 | Generate code that keeps (does not keeps) some integer operations |
29567 | adjacent so that the instructions can be fused together on power8 and | |
29568 | later processors. | |
29569 | ||
d77de738 ML |
29570 | @opindex mpower8-vector |
29571 | @opindex mno-power8-vector | |
ddf6fe37 AA |
29572 | @item -mpower8-vector |
29573 | @itemx -mno-power8-vector | |
d77de738 ML |
29574 | Generate code that uses (does not use) the vector and scalar |
29575 | instructions that were added in version 2.07 of the PowerPC ISA. Also | |
29576 | enable the use of built-in functions that allow more direct access to | |
29577 | the vector instructions. | |
29578 | ||
d77de738 ML |
29579 | @opindex mquad-memory |
29580 | @opindex mno-quad-memory | |
ddf6fe37 AA |
29581 | @item -mquad-memory |
29582 | @itemx -mno-quad-memory | |
d77de738 ML |
29583 | Generate code that uses (does not use) the non-atomic quad word memory |
29584 | instructions. The @option{-mquad-memory} option requires use of | |
29585 | 64-bit mode. | |
29586 | ||
d77de738 ML |
29587 | @opindex mquad-memory-atomic |
29588 | @opindex mno-quad-memory-atomic | |
ddf6fe37 AA |
29589 | @item -mquad-memory-atomic |
29590 | @itemx -mno-quad-memory-atomic | |
d77de738 ML |
29591 | Generate code that uses (does not use) the atomic quad word memory |
29592 | instructions. The @option{-mquad-memory-atomic} option requires use of | |
29593 | 64-bit mode. | |
29594 | ||
d77de738 ML |
29595 | @opindex mfloat128 |
29596 | @opindex mno-float128 | |
ddf6fe37 AA |
29597 | @item -mfloat128 |
29598 | @itemx -mno-float128 | |
d77de738 ML |
29599 | Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point |
29600 | and use either software emulation for IEEE 128-bit floating point or | |
29601 | hardware instructions. | |
29602 | ||
29603 | The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE | |
29604 | 128-bit floating point support. The IEEE 128-bit floating point is only | |
29605 | supported on Linux. | |
29606 | ||
29607 | The default for @option{-mfloat128} is enabled on PowerPC Linux | |
29608 | systems using the VSX instruction set, and disabled on other systems. | |
29609 | ||
29610 | If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or | |
29611 | @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating | |
29612 | point support will also enable the generation of ISA 3.0 IEEE 128-bit | |
29613 | floating point instructions. Otherwise, if you do not specify to | |
29614 | generate ISA 3.0 instructions or you are targeting a 32-bit big endian | |
29615 | system, IEEE 128-bit floating point will be done with software | |
29616 | emulation. | |
29617 | ||
d77de738 ML |
29618 | @opindex mfloat128-hardware |
29619 | @opindex mno-float128-hardware | |
ddf6fe37 AA |
29620 | @item -mfloat128-hardware |
29621 | @itemx -mno-float128-hardware | |
d77de738 ML |
29622 | Enable/disable using ISA 3.0 hardware instructions to support the |
29623 | @var{__float128} data type. | |
29624 | ||
29625 | The default for @option{-mfloat128-hardware} is enabled on PowerPC | |
29626 | Linux systems using the ISA 3.0 instruction set, and disabled on other | |
29627 | systems. | |
29628 | ||
d77de738 ML |
29629 | @opindex m32 |
29630 | @opindex m64 | |
ddf6fe37 AA |
29631 | @item -m32 |
29632 | @itemx -m64 | |
d77de738 ML |
29633 | Generate code for 32-bit or 64-bit environments of Darwin and SVR4 |
29634 | targets (including GNU/Linux). The 32-bit environment sets int, long | |
29635 | and pointer to 32 bits and generates code that runs on any PowerPC | |
29636 | variant. The 64-bit environment sets int to 32 bits and long and | |
29637 | pointer to 64 bits, and generates code for PowerPC64, as for | |
29638 | @option{-mpowerpc64}. | |
29639 | ||
d77de738 ML |
29640 | @opindex mfull-toc |
29641 | @opindex mno-fp-in-toc | |
29642 | @opindex mno-sum-in-toc | |
29643 | @opindex mminimal-toc | |
ddf6fe37 AA |
29644 | @item -mfull-toc |
29645 | @itemx -mno-fp-in-toc | |
29646 | @itemx -mno-sum-in-toc | |
29647 | @itemx -mminimal-toc | |
d77de738 ML |
29648 | Modify generation of the TOC (Table Of Contents), which is created for |
29649 | every executable file. The @option{-mfull-toc} option is selected by | |
29650 | default. In that case, GCC allocates at least one TOC entry for | |
29651 | each unique non-automatic variable reference in your program. GCC | |
29652 | also places floating-point constants in the TOC@. However, only | |
29653 | 16,384 entries are available in the TOC@. | |
29654 | ||
29655 | If you receive a linker error message that saying you have overflowed | |
29656 | the available TOC space, you can reduce the amount of TOC space used | |
29657 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. | |
29658 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
29659 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
29660 | generate code to calculate the sum of an address and a constant at | |
29661 | run time instead of putting that sum into the TOC@. You may specify one | |
29662 | or both of these options. Each causes GCC to produce very slightly | |
29663 | slower and larger code at the expense of conserving TOC space. | |
29664 | ||
29665 | If you still run out of space in the TOC even when you specify both of | |
29666 | these options, specify @option{-mminimal-toc} instead. This option causes | |
29667 | GCC to make only one TOC entry for every file. When you specify this | |
29668 | option, GCC produces code that is slower and larger but which | |
29669 | uses extremely little TOC space. You may wish to use this option | |
29670 | only on files that contain less frequently-executed code. | |
29671 | ||
d77de738 ML |
29672 | @opindex maix64 |
29673 | @opindex maix32 | |
ddf6fe37 AA |
29674 | @item -maix64 |
29675 | @itemx -maix32 | |
d77de738 ML |
29676 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
29677 | @code{long} type, and the infrastructure needed to support them. | |
29678 | Specifying @option{-maix64} implies @option{-mpowerpc64}, | |
29679 | while @option{-maix32} disables the 64-bit ABI and | |
29680 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
29681 | ||
d77de738 ML |
29682 | @opindex mxl-compat |
29683 | @opindex mno-xl-compat | |
ddf6fe37 AA |
29684 | @item -mxl-compat |
29685 | @itemx -mno-xl-compat | |
d77de738 ML |
29686 | Produce code that conforms more closely to IBM XL compiler semantics |
29687 | when using AIX-compatible ABI@. Pass floating-point arguments to | |
29688 | prototyped functions beyond the register save area (RSA) on the stack | |
29689 | in addition to argument FPRs. Do not assume that most significant | |
29690 | double in 128-bit long double value is properly rounded when comparing | |
29691 | values and converting to double. Use XL symbol names for long double | |
29692 | support routines. | |
29693 | ||
29694 | The AIX calling convention was extended but not initially documented to | |
29695 | handle an obscure K&R C case of calling a function that takes the | |
29696 | address of its arguments with fewer arguments than declared. IBM XL | |
29697 | compilers access floating-point arguments that do not fit in the | |
29698 | RSA from the stack when a subroutine is compiled without | |
29699 | optimization. Because always storing floating-point arguments on the | |
29700 | stack is inefficient and rarely needed, this option is not enabled by | |
29701 | default and only is necessary when calling subroutines compiled by IBM | |
29702 | XL compilers without optimization. | |
29703 | ||
d77de738 | 29704 | @opindex mpe |
ddf6fe37 | 29705 | @item -mpe |
d77de738 ML |
29706 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
29707 | application written to use message passing with special startup code to | |
29708 | enable the application to run. The system must have PE installed in the | |
29709 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
29710 | must be overridden with the @option{-specs=} option to specify the | |
29711 | appropriate directory location. The Parallel Environment does not | |
29712 | support threads, so the @option{-mpe} option and the @option{-pthread} | |
29713 | option are incompatible. | |
29714 | ||
d77de738 ML |
29715 | @opindex malign-natural |
29716 | @opindex malign-power | |
ddf6fe37 AA |
29717 | @item -malign-natural |
29718 | @itemx -malign-power | |
d77de738 ML |
29719 | On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option |
29720 | @option{-malign-natural} overrides the ABI-defined alignment of larger | |
29721 | types, such as floating-point doubles, on their natural size-based boundary. | |
29722 | The option @option{-malign-power} instructs GCC to follow the ABI-specified | |
29723 | alignment rules. GCC defaults to the standard alignment defined in the ABI@. | |
29724 | ||
29725 | On 64-bit Darwin, natural alignment is the default, and @option{-malign-power} | |
29726 | is not supported. | |
29727 | ||
d77de738 ML |
29728 | @opindex msoft-float |
29729 | @opindex mhard-float | |
ddf6fe37 AA |
29730 | @item -msoft-float |
29731 | @itemx -mhard-float | |
d77de738 ML |
29732 | Generate code that does not use (uses) the floating-point register set. |
29733 | Software floating-point emulation is provided if you use the | |
29734 | @option{-msoft-float} option, and pass the option to GCC when linking. | |
29735 | ||
d77de738 ML |
29736 | @opindex mmultiple |
29737 | @opindex mno-multiple | |
ddf6fe37 AA |
29738 | @item -mmultiple |
29739 | @itemx -mno-multiple | |
d77de738 ML |
29740 | Generate code that uses (does not use) the load multiple word |
29741 | instructions and the store multiple word instructions. These | |
29742 | instructions are generated by default on POWER systems, and not | |
29743 | generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian | |
29744 | PowerPC systems, since those instructions do not work when the | |
29745 | processor is in little-endian mode. The exceptions are PPC740 and | |
29746 | PPC750 which permit these instructions in little-endian mode. | |
29747 | ||
d77de738 ML |
29748 | @opindex mupdate |
29749 | @opindex mno-update | |
ddf6fe37 AA |
29750 | @item -mupdate |
29751 | @itemx -mno-update | |
d77de738 ML |
29752 | Generate code that uses (does not use) the load or store instructions |
29753 | that update the base register to the address of the calculated memory | |
29754 | location. These instructions are generated by default. If you use | |
29755 | @option{-mno-update}, there is a small window between the time that the | |
29756 | stack pointer is updated and the address of the previous frame is | |
29757 | stored, which means code that walks the stack frame across interrupts or | |
29758 | signals may get corrupted data. | |
29759 | ||
d77de738 ML |
29760 | @opindex mavoid-indexed-addresses |
29761 | @opindex mno-avoid-indexed-addresses | |
ddf6fe37 AA |
29762 | @item -mavoid-indexed-addresses |
29763 | @itemx -mno-avoid-indexed-addresses | |
d77de738 ML |
29764 | Generate code that tries to avoid (not avoid) the use of indexed load |
29765 | or store instructions. These instructions can incur a performance | |
29766 | penalty on Power6 processors in certain situations, such as when | |
29767 | stepping through large arrays that cross a 16M boundary. This option | |
29768 | is enabled by default when targeting Power6 and disabled otherwise. | |
29769 | ||
d77de738 ML |
29770 | @opindex mfused-madd |
29771 | @opindex mno-fused-madd | |
ddf6fe37 AA |
29772 | @item -mfused-madd |
29773 | @itemx -mno-fused-madd | |
d77de738 ML |
29774 | Generate code that uses (does not use) the floating-point multiply and |
29775 | accumulate instructions. These instructions are generated by default | |
29776 | if hardware floating point is used. The machine-dependent | |
29777 | @option{-mfused-madd} option is now mapped to the machine-independent | |
29778 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
29779 | mapped to @option{-ffp-contract=off}. | |
29780 | ||
d77de738 ML |
29781 | @opindex mmulhw |
29782 | @opindex mno-mulhw | |
ddf6fe37 AA |
29783 | @item -mmulhw |
29784 | @itemx -mno-mulhw | |
d77de738 ML |
29785 | Generate code that uses (does not use) the half-word multiply and |
29786 | multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. | |
29787 | These instructions are generated by default when targeting those | |
29788 | processors. | |
29789 | ||
d77de738 ML |
29790 | @opindex mdlmzb |
29791 | @opindex mno-dlmzb | |
ddf6fe37 AA |
29792 | @item -mdlmzb |
29793 | @itemx -mno-dlmzb | |
d77de738 ML |
29794 | Generate code that uses (does not use) the string-search @samp{dlmzb} |
29795 | instruction on the IBM 405, 440, 464 and 476 processors. This instruction is | |
29796 | generated by default when targeting those processors. | |
29797 | ||
d77de738 ML |
29798 | @opindex mno-bit-align |
29799 | @opindex mbit-align | |
ddf6fe37 AA |
29800 | @item -mno-bit-align |
29801 | @itemx -mbit-align | |
d77de738 ML |
29802 | On System V.4 and embedded PowerPC systems do not (do) force structures |
29803 | and unions that contain bit-fields to be aligned to the base type of the | |
29804 | bit-field. | |
29805 | ||
29806 | For example, by default a structure containing nothing but 8 | |
29807 | @code{unsigned} bit-fields of length 1 is aligned to a 4-byte | |
29808 | boundary and has a size of 4 bytes. By using @option{-mno-bit-align}, | |
29809 | the structure is aligned to a 1-byte boundary and is 1 byte in | |
29810 | size. | |
29811 | ||
d77de738 ML |
29812 | @opindex mno-strict-align |
29813 | @opindex mstrict-align | |
ddf6fe37 AA |
29814 | @item -mno-strict-align |
29815 | @itemx -mstrict-align | |
d77de738 ML |
29816 | On System V.4 and embedded PowerPC systems do not (do) assume that |
29817 | unaligned memory references are handled by the system. | |
29818 | ||
d77de738 ML |
29819 | @opindex mrelocatable |
29820 | @opindex mno-relocatable | |
ddf6fe37 AA |
29821 | @item -mrelocatable |
29822 | @itemx -mno-relocatable | |
d77de738 ML |
29823 | Generate code that allows (does not allow) a static executable to be |
29824 | relocated to a different address at run time. A simple embedded | |
29825 | PowerPC system loader should relocate the entire contents of | |
29826 | @code{.got2} and 4-byte locations listed in the @code{.fixup} section, | |
29827 | a table of 32-bit addresses generated by this option. For this to | |
29828 | work, all objects linked together must be compiled with | |
29829 | @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
29830 | @option{-mrelocatable} code aligns the stack to an 8-byte boundary. | |
29831 | ||
d77de738 ML |
29832 | @opindex mrelocatable-lib |
29833 | @opindex mno-relocatable-lib | |
ddf6fe37 AA |
29834 | @item -mrelocatable-lib |
29835 | @itemx -mno-relocatable-lib | |
d77de738 ML |
29836 | Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a |
29837 | @code{.fixup} section to allow static executables to be relocated at | |
29838 | run time, but @option{-mrelocatable-lib} does not use the smaller stack | |
29839 | alignment of @option{-mrelocatable}. Objects compiled with | |
29840 | @option{-mrelocatable-lib} may be linked with objects compiled with | |
29841 | any combination of the @option{-mrelocatable} options. | |
29842 | ||
d77de738 ML |
29843 | @opindex mno-toc |
29844 | @opindex mtoc | |
ddf6fe37 AA |
29845 | @item -mno-toc |
29846 | @itemx -mtoc | |
d77de738 ML |
29847 | On System V.4 and embedded PowerPC systems do not (do) assume that |
29848 | register 2 contains a pointer to a global area pointing to the addresses | |
29849 | used in the program. | |
29850 | ||
d77de738 ML |
29851 | @opindex mlittle |
29852 | @opindex mlittle-endian | |
ddf6fe37 AA |
29853 | @item -mlittle |
29854 | @itemx -mlittle-endian | |
d77de738 ML |
29855 | On System V.4 and embedded PowerPC systems compile code for the |
29856 | processor in little-endian mode. The @option{-mlittle-endian} option is | |
29857 | the same as @option{-mlittle}. | |
29858 | ||
d77de738 ML |
29859 | @opindex mbig |
29860 | @opindex mbig-endian | |
ddf6fe37 AA |
29861 | @item -mbig |
29862 | @itemx -mbig-endian | |
d77de738 ML |
29863 | On System V.4 and embedded PowerPC systems compile code for the |
29864 | processor in big-endian mode. The @option{-mbig-endian} option is | |
29865 | the same as @option{-mbig}. | |
29866 | ||
d77de738 | 29867 | @opindex mdynamic-no-pic |
ddf6fe37 | 29868 | @item -mdynamic-no-pic |
d77de738 ML |
29869 | On Darwin and Mac OS X systems, compile code so that it is not |
29870 | relocatable, but that its external references are relocatable. The | |
29871 | resulting code is suitable for applications, but not shared | |
29872 | libraries. | |
29873 | ||
d77de738 | 29874 | @opindex msingle-pic-base |
ddf6fe37 | 29875 | @item -msingle-pic-base |
d77de738 ML |
29876 | Treat the register used for PIC addressing as read-only, rather than |
29877 | loading it in the prologue for each function. The runtime system is | |
29878 | responsible for initializing this register with an appropriate value | |
29879 | before execution begins. | |
29880 | ||
d77de738 | 29881 | @opindex mprioritize-restricted-insns |
ddf6fe37 | 29882 | @item -mprioritize-restricted-insns=@var{priority} |
d77de738 ML |
29883 | This option controls the priority that is assigned to |
29884 | dispatch-slot restricted instructions during the second scheduling | |
29885 | pass. The argument @var{priority} takes the value @samp{0}, @samp{1}, | |
29886 | or @samp{2} to assign no, highest, or second-highest (respectively) | |
29887 | priority to dispatch-slot restricted | |
29888 | instructions. | |
29889 | ||
d77de738 | 29890 | @opindex msched-costly-dep |
ddf6fe37 | 29891 | @item -msched-costly-dep=@var{dependence_type} |
d77de738 ML |
29892 | This option controls which dependences are considered costly |
29893 | by the target during instruction scheduling. The argument | |
29894 | @var{dependence_type} takes one of the following values: | |
29895 | ||
29896 | @table @asis | |
29897 | @item @samp{no} | |
29898 | No dependence is costly. | |
29899 | ||
29900 | @item @samp{all} | |
29901 | All dependences are costly. | |
29902 | ||
29903 | @item @samp{true_store_to_load} | |
29904 | A true dependence from store to load is costly. | |
29905 | ||
29906 | @item @samp{store_to_load} | |
29907 | Any dependence from store to load is costly. | |
29908 | ||
29909 | @item @var{number} | |
29910 | Any dependence for which the latency is greater than or equal to | |
29911 | @var{number} is costly. | |
29912 | @end table | |
29913 | ||
d77de738 | 29914 | @opindex minsert-sched-nops |
ddf6fe37 | 29915 | @item -minsert-sched-nops=@var{scheme} |
d77de738 ML |
29916 | This option controls which NOP insertion scheme is used during |
29917 | the second scheduling pass. The argument @var{scheme} takes one of the | |
29918 | following values: | |
29919 | ||
29920 | @table @asis | |
29921 | @item @samp{no} | |
29922 | Don't insert NOPs. | |
29923 | ||
29924 | @item @samp{pad} | |
29925 | Pad with NOPs any dispatch group that has vacant issue slots, | |
29926 | according to the scheduler's grouping. | |
29927 | ||
29928 | @item @samp{regroup_exact} | |
29929 | Insert NOPs to force costly dependent insns into | |
29930 | separate groups. Insert exactly as many NOPs as needed to force an insn | |
29931 | to a new group, according to the estimated processor grouping. | |
29932 | ||
29933 | @item @var{number} | |
29934 | Insert NOPs to force costly dependent insns into | |
29935 | separate groups. Insert @var{number} NOPs to force an insn to a new group. | |
29936 | @end table | |
29937 | ||
d77de738 | 29938 | @opindex mcall-sysv |
ddf6fe37 | 29939 | @item -mcall-sysv |
d77de738 ML |
29940 | On System V.4 and embedded PowerPC systems compile code using calling |
29941 | conventions that adhere to the March 1995 draft of the System V | |
29942 | Application Binary Interface, PowerPC processor supplement. This is the | |
29943 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
29944 | ||
d77de738 ML |
29945 | @opindex mcall-sysv-eabi |
29946 | @opindex mcall-eabi | |
ddf6fe37 AA |
29947 | @item -mcall-sysv-eabi |
29948 | @itemx -mcall-eabi | |
d77de738 ML |
29949 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
29950 | ||
d77de738 | 29951 | @opindex mcall-sysv-noeabi |
ddf6fe37 | 29952 | @item -mcall-sysv-noeabi |
d77de738 ML |
29953 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
29954 | ||
d7971cf7 | 29955 | @opindex mcall-aixdesc |
ddf6fe37 | 29956 | @item -mcall-aixdesc |
d77de738 ML |
29957 | On System V.4 and embedded PowerPC systems compile code for the AIX |
29958 | operating system. | |
29959 | ||
d77de738 | 29960 | @opindex mcall-linux |
ddf6fe37 | 29961 | @item -mcall-linux |
d77de738 ML |
29962 | On System V.4 and embedded PowerPC systems compile code for the |
29963 | Linux-based GNU system. | |
29964 | ||
d77de738 | 29965 | @opindex mcall-freebsd |
ddf6fe37 | 29966 | @item -mcall-freebsd |
d77de738 ML |
29967 | On System V.4 and embedded PowerPC systems compile code for the |
29968 | FreeBSD operating system. | |
29969 | ||
d77de738 | 29970 | @opindex mcall-netbsd |
ddf6fe37 | 29971 | @item -mcall-netbsd |
d77de738 ML |
29972 | On System V.4 and embedded PowerPC systems compile code for the |
29973 | NetBSD operating system. | |
29974 | ||
d7971cf7 | 29975 | @opindex mcall-openbsd |
ddf6fe37 | 29976 | @item -mcall-openbsd |
d77de738 ML |
29977 | On System V.4 and embedded PowerPC systems compile code for the |
29978 | OpenBSD operating system. | |
29979 | ||
d77de738 | 29980 | @opindex mtraceback |
ddf6fe37 | 29981 | @item -mtraceback=@var{traceback_type} |
d77de738 ML |
29982 | Select the type of traceback table. Valid values for @var{traceback_type} |
29983 | are @samp{full}, @samp{part}, and @samp{no}. | |
29984 | ||
d77de738 | 29985 | @opindex maix-struct-return |
ddf6fe37 | 29986 | @item -maix-struct-return |
d77de738 ML |
29987 | Return all structures in memory (as specified by the AIX ABI)@. |
29988 | ||
d77de738 | 29989 | @opindex msvr4-struct-return |
ddf6fe37 | 29990 | @item -msvr4-struct-return |
d77de738 ML |
29991 | Return structures smaller than 8 bytes in registers (as specified by the |
29992 | SVR4 ABI)@. | |
29993 | ||
d77de738 | 29994 | @opindex mabi |
ddf6fe37 | 29995 | @item -mabi=@var{abi-type} |
d77de738 ML |
29996 | Extend the current ABI with a particular extension, or remove such extension. |
29997 | Valid values are: @samp{altivec}, @samp{no-altivec}, | |
29998 | @samp{ibmlongdouble}, @samp{ieeelongdouble}, | |
29999 | @samp{elfv1}, @samp{elfv2}, | |
30000 | and for AIX: @samp{vec-extabi}, @samp{vec-default}@. | |
30001 | ||
d77de738 | 30002 | @opindex mabi=ibmlongdouble |
ddf6fe37 | 30003 | @item -mabi=ibmlongdouble |
d77de738 ML |
30004 | Change the current ABI to use IBM extended-precision long double. |
30005 | This is not likely to work if your system defaults to using IEEE | |
30006 | extended-precision long double. If you change the long double type | |
30007 | from IEEE extended-precision, the compiler will issue a warning unless | |
30008 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30009 | to be enabled. | |
30010 | ||
d77de738 | 30011 | @opindex mabi=ieeelongdouble |
ddf6fe37 | 30012 | @item -mabi=ieeelongdouble |
d77de738 ML |
30013 | Change the current ABI to use IEEE extended-precision long double. |
30014 | This is not likely to work if your system defaults to using IBM | |
30015 | extended-precision long double. If you change the long double type | |
30016 | from IBM extended-precision, the compiler will issue a warning unless | |
30017 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30018 | to be enabled. | |
30019 | ||
d77de738 | 30020 | @opindex mabi=elfv1 |
ddf6fe37 | 30021 | @item -mabi=elfv1 |
d77de738 ML |
30022 | Change the current ABI to use the ELFv1 ABI. |
30023 | This is the default ABI for big-endian PowerPC 64-bit Linux. | |
30024 | Overriding the default ABI requires special system support and is | |
30025 | likely to fail in spectacular ways. | |
30026 | ||
d77de738 | 30027 | @opindex mabi=elfv2 |
ddf6fe37 | 30028 | @item -mabi=elfv2 |
d77de738 ML |
30029 | Change the current ABI to use the ELFv2 ABI. |
30030 | This is the default ABI for little-endian PowerPC 64-bit Linux. | |
30031 | Overriding the default ABI requires special system support and is | |
30032 | likely to fail in spectacular ways. | |
30033 | ||
d77de738 ML |
30034 | @opindex mgnu-attribute |
30035 | @opindex mno-gnu-attribute | |
ddf6fe37 AA |
30036 | @item -mgnu-attribute |
30037 | @itemx -mno-gnu-attribute | |
d77de738 ML |
30038 | Emit .gnu_attribute assembly directives to set tag/value pairs in a |
30039 | .gnu.attributes section that specify ABI variations in function | |
30040 | parameters or return values. | |
30041 | ||
d77de738 ML |
30042 | @opindex mprototype |
30043 | @opindex mno-prototype | |
ddf6fe37 AA |
30044 | @item -mprototype |
30045 | @itemx -mno-prototype | |
d77de738 ML |
30046 | On System V.4 and embedded PowerPC systems assume that all calls to |
30047 | variable argument functions are properly prototyped. Otherwise, the | |
30048 | compiler must insert an instruction before every non-prototyped call to | |
30049 | set or clear bit 6 of the condition code register (@code{CR}) to | |
30050 | indicate whether floating-point values are passed in the floating-point | |
30051 | registers in case the function takes variable arguments. With | |
30052 | @option{-mprototype}, only calls to prototyped variable argument functions | |
30053 | set or clear the bit. | |
30054 | ||
d77de738 | 30055 | @opindex msim |
ddf6fe37 | 30056 | @item -msim |
d77de738 ML |
30057 | On embedded PowerPC systems, assume that the startup module is called |
30058 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
30059 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim} | |
30060 | configurations. | |
30061 | ||
d77de738 | 30062 | @opindex mmvme |
ddf6fe37 | 30063 | @item -mmvme |
d77de738 ML |
30064 | On embedded PowerPC systems, assume that the startup module is called |
30065 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and | |
30066 | @file{libc.a}. | |
30067 | ||
d77de738 | 30068 | @opindex mads |
ddf6fe37 | 30069 | @item -mads |
d77de738 ML |
30070 | On embedded PowerPC systems, assume that the startup module is called |
30071 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
30072 | @file{libc.a}. | |
30073 | ||
d77de738 | 30074 | @opindex myellowknife |
ddf6fe37 | 30075 | @item -myellowknife |
d77de738 ML |
30076 | On embedded PowerPC systems, assume that the startup module is called |
30077 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
30078 | @file{libc.a}. | |
30079 | ||
d77de738 | 30080 | @opindex mvxworks |
ddf6fe37 | 30081 | @item -mvxworks |
d77de738 ML |
30082 | On System V.4 and embedded PowerPC systems, specify that you are |
30083 | compiling for a VxWorks system. | |
30084 | ||
d77de738 | 30085 | @opindex memb |
ddf6fe37 | 30086 | @item -memb |
d77de738 ML |
30087 | On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags |
30088 | header to indicate that @samp{eabi} extended relocations are used. | |
30089 | ||
d77de738 ML |
30090 | @opindex meabi |
30091 | @opindex mno-eabi | |
ddf6fe37 AA |
30092 | @item -meabi |
30093 | @itemx -mno-eabi | |
d77de738 ML |
30094 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
30095 | Embedded Applications Binary Interface (EABI), which is a set of | |
30096 | modifications to the System V.4 specifications. Selecting @option{-meabi} | |
30097 | means that the stack is aligned to an 8-byte boundary, a function | |
30098 | @code{__eabi} is called from @code{main} to set up the EABI | |
30099 | environment, and the @option{-msdata} option can use both @code{r2} and | |
30100 | @code{r13} to point to two separate small data areas. Selecting | |
30101 | @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary, | |
30102 | no EABI initialization function is called from @code{main}, and the | |
30103 | @option{-msdata} option only uses @code{r13} to point to a single | |
30104 | small data area. The @option{-meabi} option is on by default if you | |
30105 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
30106 | ||
d77de738 | 30107 | @opindex msdata=eabi |
ddf6fe37 | 30108 | @item -msdata=eabi |
d77de738 ML |
30109 | On System V.4 and embedded PowerPC systems, put small initialized |
30110 | @code{const} global and static data in the @code{.sdata2} section, which | |
30111 | is pointed to by register @code{r2}. Put small initialized | |
30112 | non-@code{const} global and static data in the @code{.sdata} section, | |
30113 | which is pointed to by register @code{r13}. Put small uninitialized | |
30114 | global and static data in the @code{.sbss} section, which is adjacent to | |
30115 | the @code{.sdata} section. The @option{-msdata=eabi} option is | |
30116 | incompatible with the @option{-mrelocatable} option. The | |
30117 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
30118 | ||
d77de738 | 30119 | @opindex msdata=sysv |
ddf6fe37 | 30120 | @item -msdata=sysv |
d77de738 ML |
30121 | On System V.4 and embedded PowerPC systems, put small global and static |
30122 | data in the @code{.sdata} section, which is pointed to by register | |
30123 | @code{r13}. Put small uninitialized global and static data in the | |
30124 | @code{.sbss} section, which is adjacent to the @code{.sdata} section. | |
30125 | The @option{-msdata=sysv} option is incompatible with the | |
30126 | @option{-mrelocatable} option. | |
30127 | ||
d77de738 ML |
30128 | @opindex msdata=default |
30129 | @opindex msdata | |
ddf6fe37 AA |
30130 | @item -msdata=default |
30131 | @itemx -msdata | |
d77de738 ML |
30132 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
30133 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
30134 | same as @option{-msdata=sysv}. | |
30135 | ||
d77de738 | 30136 | @opindex msdata=data |
ddf6fe37 | 30137 | @item -msdata=data |
d77de738 ML |
30138 | On System V.4 and embedded PowerPC systems, put small global |
30139 | data in the @code{.sdata} section. Put small uninitialized global | |
30140 | data in the @code{.sbss} section. Do not use register @code{r13} | |
30141 | to address small data however. This is the default behavior unless | |
30142 | other @option{-msdata} options are used. | |
30143 | ||
d77de738 ML |
30144 | @opindex msdata=none |
30145 | @opindex mno-sdata | |
ddf6fe37 AA |
30146 | @item -msdata=none |
30147 | @itemx -mno-sdata | |
d77de738 ML |
30148 | On embedded PowerPC systems, put all initialized global and static data |
30149 | in the @code{.data} section, and all uninitialized data in the | |
30150 | @code{.bss} section. | |
30151 | ||
d77de738 ML |
30152 | @opindex mreadonly-in-sdata |
30153 | @opindex mno-readonly-in-sdata | |
ddf6fe37 | 30154 | @item -mreadonly-in-sdata |
d77de738 ML |
30155 | Put read-only objects in the @code{.sdata} section as well. This is the |
30156 | default. | |
30157 | ||
d77de738 | 30158 | @opindex mblock-move-inline-limit |
ddf6fe37 | 30159 | @item -mblock-move-inline-limit=@var{num} |
d77de738 ML |
30160 | Inline all block moves (such as calls to @code{memcpy} or structure |
30161 | copies) less than or equal to @var{num} bytes. The minimum value for | |
30162 | @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit | |
30163 | targets. The default value is target-specific. | |
30164 | ||
d77de738 | 30165 | @opindex mblock-compare-inline-limit |
ddf6fe37 | 30166 | @item -mblock-compare-inline-limit=@var{num} |
d77de738 ML |
30167 | Generate non-looping inline code for all block compares (such as calls |
30168 | to @code{memcmp} or structure compares) less than or equal to @var{num} | |
30169 | bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of | |
30170 | block compare is disabled. The default value is target-specific. | |
30171 | ||
d77de738 | 30172 | @opindex mblock-compare-inline-loop-limit |
ddf6fe37 | 30173 | @item -mblock-compare-inline-loop-limit=@var{num} |
d77de738 ML |
30174 | Generate an inline expansion using loop code for all block compares that |
30175 | are less than or equal to @var{num} bytes, but greater than the limit | |
30176 | for non-loop inline block compare expansion. If the block length is not | |
30177 | constant, at most @var{num} bytes will be compared before @code{memcmp} | |
30178 | is called to compare the remainder of the block. The default value is | |
30179 | target-specific. | |
30180 | ||
d77de738 | 30181 | @opindex mstring-compare-inline-limit |
ddf6fe37 | 30182 | @item -mstring-compare-inline-limit=@var{num} |
d77de738 ML |
30183 | Compare at most @var{num} string bytes with inline code. |
30184 | If the difference or end of string is not found at the | |
30185 | end of the inline compare a call to @code{strcmp} or @code{strncmp} will | |
30186 | take care of the rest of the comparison. The default is 64 bytes. | |
30187 | ||
d77de738 ML |
30188 | @opindex G |
30189 | @cindex smaller data references (PowerPC) | |
30190 | @cindex .sdata/.sdata2 references (PowerPC) | |
f33d7a88 | 30191 | @item -G @var{num} |
d77de738 ML |
30192 | On embedded PowerPC systems, put global and static items less than or |
30193 | equal to @var{num} bytes into the small data or BSS sections instead of | |
30194 | the normal data or BSS section. By default, @var{num} is 8. The | |
30195 | @option{-G @var{num}} switch is also passed to the linker. | |
30196 | All modules should be compiled with the same @option{-G @var{num}} value. | |
30197 | ||
d77de738 ML |
30198 | @opindex mregnames |
30199 | @opindex mno-regnames | |
ddf6fe37 AA |
30200 | @item -mregnames |
30201 | @itemx -mno-regnames | |
d77de738 ML |
30202 | On System V.4 and embedded PowerPC systems do (do not) emit register |
30203 | names in the assembly language output using symbolic forms. | |
30204 | ||
d77de738 ML |
30205 | @opindex mlongcall |
30206 | @opindex mno-longcall | |
ddf6fe37 AA |
30207 | @item -mlongcall |
30208 | @itemx -mno-longcall | |
d77de738 ML |
30209 | By default assume that all calls are far away so that a longer and more |
30210 | expensive calling sequence is required. This is required for calls | |
30211 | farther than 32 megabytes (33,554,432 bytes) from the current location. | |
30212 | A short call is generated if the compiler knows | |
30213 | the call cannot be that far away. This setting can be overridden by | |
30214 | the @code{shortcall} function attribute, or by @code{#pragma | |
30215 | longcall(0)}. | |
30216 | ||
30217 | Some linkers are capable of detecting out-of-range calls and generating | |
30218 | glue code on the fly. On these systems, long calls are unnecessary and | |
30219 | generate slower code. As of this writing, the AIX linker can do this, | |
30220 | as can the GNU linker for PowerPC/64. It is planned to add this feature | |
30221 | to the GNU linker for 32-bit PowerPC systems as well. | |
30222 | ||
30223 | On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers, | |
30224 | GCC can generate long calls using an inline PLT call sequence (see | |
30225 | @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64 | |
30226 | ELFv1 (big-endian) do not support inline PLT calls. | |
30227 | ||
30228 | On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr | |
30229 | callee, L42}, plus a @dfn{branch island} (glue code). The two target | |
30230 | addresses represent the callee and the branch island. The | |
30231 | Darwin/PPC linker prefers the first address and generates a @code{bl | |
30232 | callee} if the PPC @code{bl} instruction reaches the callee directly; | |
30233 | otherwise, the linker generates @code{bl L42} to call the branch | |
30234 | island. The branch island is appended to the body of the | |
30235 | calling function; it computes the full 32-bit address of the callee | |
30236 | and jumps to it. | |
30237 | ||
30238 | On Mach-O (Darwin) systems, this option directs the compiler emit to | |
30239 | the glue for every direct call, and the Darwin linker decides whether | |
30240 | to use or discard it. | |
30241 | ||
30242 | In the future, GCC may ignore all longcall specifications | |
30243 | when the linker is known to generate glue. | |
30244 | ||
d77de738 ML |
30245 | @opindex mpltseq |
30246 | @opindex mno-pltseq | |
ddf6fe37 AA |
30247 | @item -mpltseq |
30248 | @itemx -mno-pltseq | |
d77de738 ML |
30249 | Implement (do not implement) -fno-plt and long calls using an inline |
30250 | PLT call sequence that supports lazy linking and long calls to | |
30251 | functions in dlopen'd shared libraries. Inline PLT calls are only | |
30252 | supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU | |
30253 | linkers, and are enabled by default if the support is detected when | |
30254 | configuring GCC, and, in the case of 32-bit PowerPC, if GCC is | |
30255 | configured with @option{--enable-secureplt}. @option{-mpltseq} code | |
30256 | and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be | |
30257 | linked together. | |
30258 | ||
d77de738 ML |
30259 | @opindex mtls-markers |
30260 | @opindex mno-tls-markers | |
ddf6fe37 AA |
30261 | @item -mtls-markers |
30262 | @itemx -mno-tls-markers | |
d77de738 ML |
30263 | Mark (do not mark) calls to @code{__tls_get_addr} with a relocation |
30264 | specifying the function argument. The relocation allows the linker to | |
30265 | reliably associate function call with argument setup instructions for | |
30266 | TLS optimization, which in turn allows GCC to better schedule the | |
30267 | sequence. | |
30268 | ||
ddf6fe37 | 30269 | @opindex mrecip |
d77de738 ML |
30270 | @item -mrecip |
30271 | @itemx -mno-recip | |
d77de738 ML |
30272 | This option enables use of the reciprocal estimate and |
30273 | reciprocal square root estimate instructions with additional | |
30274 | Newton-Raphson steps to increase precision instead of doing a divide or | |
30275 | square root and divide for floating-point arguments. You should use | |
30276 | the @option{-ffast-math} option when using @option{-mrecip} (or at | |
30277 | least @option{-funsafe-math-optimizations}, | |
30278 | @option{-ffinite-math-only}, @option{-freciprocal-math} and | |
30279 | @option{-fno-trapping-math}). Note that while the throughput of the | |
30280 | sequence is generally higher than the throughput of the non-reciprocal | |
30281 | instruction, the precision of the sequence can be decreased by up to 2 | |
30282 | ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square | |
30283 | roots. | |
30284 | ||
d77de738 | 30285 | @opindex mrecip=opt |
ddf6fe37 | 30286 | @item -mrecip=@var{opt} |
d77de738 ML |
30287 | This option controls which reciprocal estimate instructions |
30288 | may be used. @var{opt} is a comma-separated list of options, which may | |
30289 | be preceded by a @code{!} to invert the option: | |
30290 | ||
30291 | @table @samp | |
30292 | ||
30293 | @item all | |
30294 | Enable all estimate instructions. | |
30295 | ||
30296 | @item default | |
30297 | Enable the default instructions, equivalent to @option{-mrecip}. | |
30298 | ||
30299 | @item none | |
30300 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
30301 | ||
30302 | @item div | |
30303 | Enable the reciprocal approximation instructions for both | |
30304 | single and double precision. | |
30305 | ||
30306 | @item divf | |
30307 | Enable the single-precision reciprocal approximation instructions. | |
30308 | ||
30309 | @item divd | |
30310 | Enable the double-precision reciprocal approximation instructions. | |
30311 | ||
30312 | @item rsqrt | |
30313 | Enable the reciprocal square root approximation instructions for both | |
30314 | single and double precision. | |
30315 | ||
30316 | @item rsqrtf | |
30317 | Enable the single-precision reciprocal square root approximation instructions. | |
30318 | ||
30319 | @item rsqrtd | |
30320 | Enable the double-precision reciprocal square root approximation instructions. | |
30321 | ||
30322 | @end table | |
30323 | ||
30324 | So, for example, @option{-mrecip=all,!rsqrtd} enables | |
30325 | all of the reciprocal estimate instructions, except for the | |
30326 | @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions | |
30327 | which handle the double-precision reciprocal square root calculations. | |
30328 | ||
ddf6fe37 | 30329 | @opindex mrecip-precision |
d77de738 ML |
30330 | @item -mrecip-precision |
30331 | @itemx -mno-recip-precision | |
d77de738 ML |
30332 | Assume (do not assume) that the reciprocal estimate instructions |
30333 | provide higher-precision estimates than is mandated by the PowerPC | |
30334 | ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or | |
30335 | @option{-mcpu=power8} automatically selects @option{-mrecip-precision}. | |
30336 | The double-precision square root estimate instructions are not generated by | |
30337 | default on low-precision machines, since they do not provide an | |
30338 | estimate that converges after three steps. | |
30339 | ||
d77de738 | 30340 | @opindex mveclibabi |
ddf6fe37 | 30341 | @item -mveclibabi=@var{type} |
d77de738 ML |
30342 | Specifies the ABI type to use for vectorizing intrinsics using an |
30343 | external library. The only type supported at present is @samp{mass}, | |
30344 | which specifies to use IBM's Mathematical Acceleration Subsystem | |
30345 | (MASS) libraries for vectorizing intrinsics using external libraries. | |
30346 | GCC currently emits calls to @code{acosd2}, @code{acosf4}, | |
30347 | @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4}, | |
30348 | @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4}, | |
30349 | @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4}, | |
30350 | @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4}, | |
30351 | @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4}, | |
30352 | @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4}, | |
30353 | @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4}, | |
30354 | @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4}, | |
30355 | @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4}, | |
30356 | @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4}, | |
30357 | @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2}, | |
30358 | @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2}, | |
30359 | @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code | |
30360 | for power7. Both @option{-ftree-vectorize} and | |
30361 | @option{-funsafe-math-optimizations} must also be enabled. The MASS | |
30362 | libraries must be specified at link time. | |
30363 | ||
ddf6fe37 | 30364 | @opindex mfriz |
d77de738 ML |
30365 | @item -mfriz |
30366 | @itemx -mno-friz | |
d77de738 ML |
30367 | Generate (do not generate) the @code{friz} instruction when the |
30368 | @option{-funsafe-math-optimizations} option is used to optimize | |
30369 | rounding of floating-point values to 64-bit integer and back to floating | |
30370 | point. The @code{friz} instruction does not return the same value if | |
30371 | the floating-point number is too large to fit in an integer. | |
30372 | ||
ddf6fe37 | 30373 | @opindex mpointers-to-nested-functions |
d77de738 ML |
30374 | @item -mpointers-to-nested-functions |
30375 | @itemx -mno-pointers-to-nested-functions | |
d77de738 ML |
30376 | Generate (do not generate) code to load up the static chain register |
30377 | (@code{r11}) when calling through a pointer on AIX and 64-bit Linux | |
30378 | systems where a function pointer points to a 3-word descriptor giving | |
30379 | the function address, TOC value to be loaded in register @code{r2}, and | |
30380 | static chain value to be loaded in register @code{r11}. The | |
30381 | @option{-mpointers-to-nested-functions} is on by default. You cannot | |
30382 | call through pointers to nested functions or pointers | |
30383 | to functions compiled in other languages that use the static chain if | |
30384 | you use @option{-mno-pointers-to-nested-functions}. | |
30385 | ||
ddf6fe37 | 30386 | @opindex msave-toc-indirect |
d77de738 ML |
30387 | @item -msave-toc-indirect |
30388 | @itemx -mno-save-toc-indirect | |
d77de738 ML |
30389 | Generate (do not generate) code to save the TOC value in the reserved |
30390 | stack location in the function prologue if the function calls through | |
30391 | a pointer on AIX and 64-bit Linux systems. If the TOC value is not | |
30392 | saved in the prologue, it is saved just before the call through the | |
30393 | pointer. The @option{-mno-save-toc-indirect} option is the default. | |
30394 | ||
ddf6fe37 | 30395 | @opindex mcompat-align-parm |
d77de738 ML |
30396 | @item -mcompat-align-parm |
30397 | @itemx -mno-compat-align-parm | |
d77de738 ML |
30398 | Generate (do not generate) code to pass structure parameters with a |
30399 | maximum alignment of 64 bits, for compatibility with older versions | |
30400 | of GCC. | |
30401 | ||
30402 | Older versions of GCC (prior to 4.9.0) incorrectly did not align a | |
30403 | structure parameter on a 128-bit boundary when that structure contained | |
30404 | a member requiring 128-bit alignment. This is corrected in more | |
30405 | recent versions of GCC. This option may be used to generate code | |
30406 | that is compatible with functions compiled with older versions of | |
30407 | GCC. | |
30408 | ||
30409 | The @option{-mno-compat-align-parm} option is the default. | |
30410 | ||
d77de738 ML |
30411 | @opindex mstack-protector-guard |
30412 | @opindex mstack-protector-guard-reg | |
30413 | @opindex mstack-protector-guard-offset | |
30414 | @opindex mstack-protector-guard-symbol | |
ddf6fe37 AA |
30415 | @item -mstack-protector-guard=@var{guard} |
30416 | @itemx -mstack-protector-guard-reg=@var{reg} | |
30417 | @itemx -mstack-protector-guard-offset=@var{offset} | |
30418 | @itemx -mstack-protector-guard-symbol=@var{symbol} | |
d77de738 ML |
30419 | Generate stack protection code using canary at @var{guard}. Supported |
30420 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
30421 | canary in the TLS block (the default with GNU libc version 2.4 or later). | |
30422 | ||
30423 | With the latter choice the options | |
30424 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
30425 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
30426 | which register to use as base register for reading the canary, and from what | |
30427 | offset from that base register. The default for those is as specified in the | |
30428 | relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides | |
30429 | the offset with a symbol reference to a canary in the TLS block. | |
30430 | ||
d77de738 ML |
30431 | @opindex mpcrel |
30432 | @opindex mno-pcrel | |
ddf6fe37 AA |
30433 | @item -mpcrel |
30434 | @itemx -mno-pcrel | |
d77de738 ML |
30435 | Generate (do not generate) pc-relative addressing. The @option{-mpcrel} |
30436 | option requires that the medium code model (@option{-mcmodel=medium}) | |
30437 | and prefixed addressing (@option{-mprefixed}) options are enabled. | |
30438 | ||
d77de738 ML |
30439 | @opindex mprefixed |
30440 | @opindex mno-prefixed | |
ddf6fe37 AA |
30441 | @item -mprefixed |
30442 | @itemx -mno-prefixed | |
d77de738 ML |
30443 | Generate (do not generate) addressing modes using prefixed load and |
30444 | store instructions. The @option{-mprefixed} option requires that | |
30445 | the option @option{-mcpu=power10} (or later) is enabled. | |
30446 | ||
d77de738 ML |
30447 | @opindex mmma |
30448 | @opindex mno-mma | |
ddf6fe37 AA |
30449 | @item -mmma |
30450 | @itemx -mno-mma | |
d77de738 ML |
30451 | Generate (do not generate) the MMA instructions. The @option{-mma} |
30452 | option requires that the option @option{-mcpu=power10} (or later) | |
30453 | is enabled. | |
30454 | ||
d77de738 ML |
30455 | @opindex mrop-protect |
30456 | @opindex mno-rop-protect | |
ddf6fe37 AA |
30457 | @item -mrop-protect |
30458 | @itemx -mno-rop-protect | |
d77de738 ML |
30459 | Generate (do not generate) ROP protection instructions when the target |
30460 | processor supports them. Currently this option disables the shrink-wrap | |
30461 | optimization (@option{-fshrink-wrap}). | |
30462 | ||
d77de738 ML |
30463 | @opindex mprivileged |
30464 | @opindex mno-privileged | |
ddf6fe37 AA |
30465 | @item -mprivileged |
30466 | @itemx -mno-privileged | |
d77de738 ML |
30467 | Generate (do not generate) code that will run in privileged state. |
30468 | ||
d77de738 ML |
30469 | @opindex block-ops-unaligned-vsx |
30470 | @opindex no-block-ops-unaligned-vsx | |
ddf6fe37 AA |
30471 | @item -mblock-ops-unaligned-vsx |
30472 | @itemx -mno-block-ops-unaligned-vsx | |
d77de738 ML |
30473 | Generate (do not generate) unaligned vsx loads and stores for |
30474 | inline expansion of @code{memcpy} and @code{memmove}. | |
30475 | ||
30476 | @item --param rs6000-vect-unroll-limit= | |
30477 | The vectorizer will check with target information to determine whether it | |
30478 | would be beneficial to unroll the main vectorized loop and by how much. This | |
30479 | parameter sets the upper bound of how much the vectorizer will unroll the main | |
30480 | loop. The default value is four. | |
30481 | ||
30482 | @end table | |
30483 | ||
30484 | @node RX Options | |
30485 | @subsection RX Options | |
30486 | @cindex RX Options | |
30487 | ||
30488 | These command-line options are defined for RX targets: | |
30489 | ||
30490 | @table @gcctabopt | |
d77de738 ML |
30491 | @opindex m64bit-doubles |
30492 | @opindex m32bit-doubles | |
ddf6fe37 AA |
30493 | @item -m64bit-doubles |
30494 | @itemx -m32bit-doubles | |
d77de738 ML |
30495 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
30496 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
30497 | @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only | |
30498 | works on 32-bit values, which is why the default is | |
30499 | @option{-m32bit-doubles}. | |
30500 | ||
d77de738 ML |
30501 | @opindex fpu |
30502 | @opindex nofpu | |
ddf6fe37 AA |
30503 | @item -fpu |
30504 | @itemx -nofpu | |
d77de738 ML |
30505 | Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX |
30506 | floating-point hardware. The default is enabled for the RX600 | |
30507 | series and disabled for the RX200 series. | |
30508 | ||
30509 | Floating-point instructions are only generated for 32-bit floating-point | |
30510 | values, however, so the FPU hardware is not used for doubles if the | |
30511 | @option{-m64bit-doubles} option is used. | |
30512 | ||
30513 | @emph{Note} If the @option{-fpu} option is enabled then | |
30514 | @option{-funsafe-math-optimizations} is also enabled automatically. | |
30515 | This is because the RX FPU instructions are themselves unsafe. | |
30516 | ||
d77de738 | 30517 | @opindex mcpu |
ddf6fe37 | 30518 | @item -mcpu=@var{name} |
d77de738 ML |
30519 | Selects the type of RX CPU to be targeted. Currently three types are |
30520 | supported, the generic @samp{RX600} and @samp{RX200} series hardware and | |
30521 | the specific @samp{RX610} CPU. The default is @samp{RX600}. | |
30522 | ||
30523 | The only difference between @samp{RX600} and @samp{RX610} is that the | |
30524 | @samp{RX610} does not support the @code{MVTIPL} instruction. | |
30525 | ||
30526 | The @samp{RX200} series does not have a hardware floating-point unit | |
30527 | and so @option{-nofpu} is enabled by default when this type is | |
30528 | selected. | |
30529 | ||
d77de738 ML |
30530 | @opindex mbig-endian-data |
30531 | @opindex mlittle-endian-data | |
ddf6fe37 AA |
30532 | @item -mbig-endian-data |
30533 | @itemx -mlittle-endian-data | |
d77de738 ML |
30534 | Store data (but not code) in the big-endian format. The default is |
30535 | @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian | |
30536 | format. | |
30537 | ||
d77de738 | 30538 | @opindex msmall-data-limit |
ddf6fe37 | 30539 | @item -msmall-data-limit=@var{N} |
d77de738 ML |
30540 | Specifies the maximum size in bytes of global and static variables |
30541 | which can be placed into the small data area. Using the small data | |
30542 | area can lead to smaller and faster code, but the size of area is | |
30543 | limited and it is up to the programmer to ensure that the area does | |
30544 | not overflow. Also when the small data area is used one of the RX's | |
30545 | registers (usually @code{r13}) is reserved for use pointing to this | |
30546 | area, so it is no longer available for use by the compiler. This | |
30547 | could result in slower and/or larger code if variables are pushed onto | |
30548 | the stack instead of being held in this register. | |
30549 | ||
30550 | Note, common variables (variables that have not been initialized) and | |
30551 | constants are not placed into the small data area as they are assigned | |
30552 | to other sections in the output executable. | |
30553 | ||
30554 | The default value is zero, which disables this feature. Note, this | |
30555 | feature is not enabled by default with higher optimization levels | |
30556 | (@option{-O2} etc) because of the potentially detrimental effects of | |
30557 | reserving a register. It is up to the programmer to experiment and | |
30558 | discover whether this feature is of benefit to their program. See the | |
30559 | description of the @option{-mpid} option for a description of how the | |
30560 | actual register to hold the small data area pointer is chosen. | |
30561 | ||
d77de738 ML |
30562 | @opindex msim |
30563 | @opindex mno-sim | |
ddf6fe37 AA |
30564 | @item -msim |
30565 | @itemx -mno-sim | |
d77de738 ML |
30566 | Use the simulator runtime. The default is to use the libgloss |
30567 | board-specific runtime. | |
30568 | ||
d77de738 ML |
30569 | @opindex mas100-syntax |
30570 | @opindex mno-as100-syntax | |
ddf6fe37 AA |
30571 | @item -mas100-syntax |
30572 | @itemx -mno-as100-syntax | |
d77de738 ML |
30573 | When generating assembler output use a syntax that is compatible with |
30574 | Renesas's AS100 assembler. This syntax can also be handled by the GAS | |
30575 | assembler, but it has some restrictions so it is not generated by default. | |
30576 | ||
d77de738 | 30577 | @opindex mmax-constant-size |
ddf6fe37 | 30578 | @item -mmax-constant-size=@var{N} |
d77de738 ML |
30579 | Specifies the maximum size, in bytes, of a constant that can be used as |
30580 | an operand in a RX instruction. Although the RX instruction set does | |
30581 | allow constants of up to 4 bytes in length to be used in instructions, | |
30582 | a longer value equates to a longer instruction. Thus in some | |
30583 | circumstances it can be beneficial to restrict the size of constants | |
30584 | that are used in instructions. Constants that are too big are instead | |
30585 | placed into a constant pool and referenced via register indirection. | |
30586 | ||
30587 | The value @var{N} can be between 0 and 4. A value of 0 (the default) | |
30588 | or 4 means that constants of any size are allowed. | |
30589 | ||
d77de738 | 30590 | @opindex mrelax |
ddf6fe37 | 30591 | @item -mrelax |
d77de738 ML |
30592 | Enable linker relaxation. Linker relaxation is a process whereby the |
30593 | linker attempts to reduce the size of a program by finding shorter | |
30594 | versions of various instructions. Disabled by default. | |
30595 | ||
d77de738 | 30596 | @opindex mint-register |
ddf6fe37 | 30597 | @item -mint-register=@var{N} |
d77de738 ML |
30598 | Specify the number of registers to reserve for fast interrupt handler |
30599 | functions. The value @var{N} can be between 0 and 4. A value of 1 | |
30600 | means that register @code{r13} is reserved for the exclusive use | |
30601 | of fast interrupt handlers. A value of 2 reserves @code{r13} and | |
30602 | @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and | |
30603 | @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}. | |
30604 | A value of 0, the default, does not reserve any registers. | |
30605 | ||
d77de738 | 30606 | @opindex msave-acc-in-interrupts |
ddf6fe37 | 30607 | @item -msave-acc-in-interrupts |
d77de738 ML |
30608 | Specifies that interrupt handler functions should preserve the |
30609 | accumulator register. This is only necessary if normal code might use | |
30610 | the accumulator register, for example because it performs 64-bit | |
30611 | multiplications. The default is to ignore the accumulator as this | |
30612 | makes the interrupt handlers faster. | |
30613 | ||
d77de738 ML |
30614 | @opindex mpid |
30615 | @opindex mno-pid | |
ddf6fe37 AA |
30616 | @item -mpid |
30617 | @itemx -mno-pid | |
d77de738 ML |
30618 | Enables the generation of position independent data. When enabled any |
30619 | access to constant data is done via an offset from a base address | |
30620 | held in a register. This allows the location of constant data to be | |
30621 | determined at run time without requiring the executable to be | |
30622 | relocated, which is a benefit to embedded applications with tight | |
30623 | memory constraints. Data that can be modified is not affected by this | |
30624 | option. | |
30625 | ||
30626 | Note, using this feature reserves a register, usually @code{r13}, for | |
30627 | the constant data base address. This can result in slower and/or | |
30628 | larger code, especially in complicated functions. | |
30629 | ||
30630 | The actual register chosen to hold the constant data base address | |
30631 | depends upon whether the @option{-msmall-data-limit} and/or the | |
30632 | @option{-mint-register} command-line options are enabled. Starting | |
30633 | with register @code{r13} and proceeding downwards, registers are | |
30634 | allocated first to satisfy the requirements of @option{-mint-register}, | |
30635 | then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it | |
30636 | is possible for the small data area register to be @code{r8} if both | |
30637 | @option{-mint-register=4} and @option{-mpid} are specified on the | |
30638 | command line. | |
30639 | ||
30640 | By default this feature is not enabled. The default can be restored | |
30641 | via the @option{-mno-pid} command-line option. | |
30642 | ||
d77de738 ML |
30643 | @opindex mno-warn-multiple-fast-interrupts |
30644 | @opindex mwarn-multiple-fast-interrupts | |
ddf6fe37 AA |
30645 | @item -mno-warn-multiple-fast-interrupts |
30646 | @itemx -mwarn-multiple-fast-interrupts | |
d77de738 ML |
30647 | Prevents GCC from issuing a warning message if it finds more than one |
30648 | fast interrupt handler when it is compiling a file. The default is to | |
30649 | issue a warning for each extra fast interrupt handler found, as the RX | |
30650 | only supports one such interrupt. | |
30651 | ||
d77de738 ML |
30652 | @opindex mallow-string-insns |
30653 | @opindex mno-allow-string-insns | |
ddf6fe37 AA |
30654 | @item -mallow-string-insns |
30655 | @itemx -mno-allow-string-insns | |
d77de738 ML |
30656 | Enables or disables the use of the string manipulation instructions |
30657 | @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL} | |
30658 | @code{SWHILE} and also the @code{RMPA} instruction. These | |
30659 | instructions may prefetch data, which is not safe to do if accessing | |
30660 | an I/O register. (See section 12.2.7 of the RX62N Group User's Manual | |
30661 | for more information). | |
30662 | ||
30663 | The default is to allow these instructions, but it is not possible for | |
30664 | GCC to reliably detect all circumstances where a string instruction | |
30665 | might be used to access an I/O register, so their use cannot be | |
30666 | disabled automatically. Instead it is reliant upon the programmer to | |
30667 | use the @option{-mno-allow-string-insns} option if their program | |
30668 | accesses I/O space. | |
30669 | ||
30670 | When the instructions are enabled GCC defines the C preprocessor | |
30671 | symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the | |
30672 | symbol @code{__RX_DISALLOW_STRING_INSNS__}. | |
30673 | ||
d77de738 ML |
30674 | @opindex mjsr |
30675 | @opindex mno-jsr | |
ddf6fe37 AA |
30676 | @item -mjsr |
30677 | @itemx -mno-jsr | |
d77de738 ML |
30678 | Use only (or not only) @code{JSR} instructions to access functions. |
30679 | This option can be used when code size exceeds the range of @code{BSR} | |
30680 | instructions. Note that @option{-mno-jsr} does not mean to not use | |
30681 | @code{JSR} but instead means that any type of branch may be used. | |
30682 | @end table | |
30683 | ||
30684 | @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}} | |
30685 | has special significance to the RX port when used with the | |
30686 | @code{interrupt} function attribute. This attribute indicates a | |
30687 | function intended to process fast interrupts. GCC ensures | |
30688 | that it only uses the registers @code{r10}, @code{r11}, @code{r12} | |
30689 | and/or @code{r13} and only provided that the normal use of the | |
30690 | corresponding registers have been restricted via the | |
30691 | @option{-ffixed-@var{reg}} or @option{-mint-register} command-line | |
30692 | options. | |
30693 | ||
30694 | @node S/390 and zSeries Options | |
30695 | @subsection S/390 and zSeries Options | |
30696 | @cindex S/390 and zSeries Options | |
30697 | ||
30698 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
30699 | ||
30700 | @table @gcctabopt | |
d77de738 ML |
30701 | @opindex mhard-float |
30702 | @opindex msoft-float | |
ddf6fe37 AA |
30703 | @item -mhard-float |
30704 | @itemx -msoft-float | |
d77de738 ML |
30705 | Use (do not use) the hardware floating-point instructions and registers |
30706 | for floating-point operations. When @option{-msoft-float} is specified, | |
30707 | functions in @file{libgcc.a} are used to perform floating-point | |
30708 | operations. When @option{-mhard-float} is specified, the compiler | |
30709 | generates IEEE floating-point instructions. This is the default. | |
30710 | ||
d77de738 ML |
30711 | @opindex mhard-dfp |
30712 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
30713 | @item -mhard-dfp |
30714 | @itemx -mno-hard-dfp | |
d77de738 ML |
30715 | Use (do not use) the hardware decimal-floating-point instructions for |
30716 | decimal-floating-point operations. When @option{-mno-hard-dfp} is | |
30717 | specified, functions in @file{libgcc.a} are used to perform | |
30718 | decimal-floating-point operations. When @option{-mhard-dfp} is | |
30719 | specified, the compiler generates decimal-floating-point hardware | |
30720 | instructions. This is the default for @option{-march=z9-ec} or higher. | |
30721 | ||
d77de738 ML |
30722 | @opindex mlong-double-64 |
30723 | @opindex mlong-double-128 | |
ddf6fe37 AA |
30724 | @item -mlong-double-64 |
30725 | @itemx -mlong-double-128 | |
d77de738 ML |
30726 | These switches control the size of @code{long double} type. A size |
30727 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
30728 | type. This is the default. | |
30729 | ||
d77de738 ML |
30730 | @opindex mbackchain |
30731 | @opindex mno-backchain | |
ddf6fe37 AA |
30732 | @item -mbackchain |
30733 | @itemx -mno-backchain | |
d77de738 ML |
30734 | Store (do not store) the address of the caller's frame as backchain pointer |
30735 | into the callee's stack frame. | |
30736 | A backchain may be needed to allow debugging using tools that do not understand | |
30737 | DWARF call frame information. | |
30738 | When @option{-mno-packed-stack} is in effect, the backchain pointer is stored | |
30739 | at the bottom of the stack frame; when @option{-mpacked-stack} is in effect, | |
30740 | the backchain is placed into the topmost word of the 96/160 byte register | |
30741 | save area. | |
30742 | ||
30743 | In general, code compiled with @option{-mbackchain} is call-compatible with | |
30744 | code compiled with @option{-mno-backchain}; however, use of the backchain | |
30745 | for debugging purposes usually requires that the whole binary is built with | |
30746 | @option{-mbackchain}. Note that the combination of @option{-mbackchain}, | |
30747 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
30748 | to build a linux kernel use @option{-msoft-float}. | |
30749 | ||
30750 | The default is to not maintain the backchain. | |
30751 | ||
d77de738 ML |
30752 | @opindex mpacked-stack |
30753 | @opindex mno-packed-stack | |
ddf6fe37 AA |
30754 | @item -mpacked-stack |
30755 | @itemx -mno-packed-stack | |
d77de738 ML |
30756 | Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is |
30757 | specified, the compiler uses the all fields of the 96/160 byte register save | |
30758 | area only for their default purpose; unused fields still take up stack space. | |
30759 | When @option{-mpacked-stack} is specified, register save slots are densely | |
30760 | packed at the top of the register save area; unused space is reused for other | |
30761 | purposes, allowing for more efficient use of the available stack space. | |
30762 | However, when @option{-mbackchain} is also in effect, the topmost word of | |
30763 | the save area is always used to store the backchain, and the return address | |
30764 | register is always saved two words below the backchain. | |
30765 | ||
30766 | As long as the stack frame backchain is not used, code generated with | |
30767 | @option{-mpacked-stack} is call-compatible with code generated with | |
30768 | @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for | |
30769 | S/390 or zSeries generated code that uses the stack frame backchain at run | |
30770 | time, not just for debugging purposes. Such code is not call-compatible | |
30771 | with code compiled with @option{-mpacked-stack}. Also, note that the | |
30772 | combination of @option{-mbackchain}, | |
30773 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
30774 | to build a linux kernel use @option{-msoft-float}. | |
30775 | ||
30776 | The default is to not use the packed stack layout. | |
30777 | ||
d77de738 ML |
30778 | @opindex msmall-exec |
30779 | @opindex mno-small-exec | |
ddf6fe37 AA |
30780 | @item -msmall-exec |
30781 | @itemx -mno-small-exec | |
d77de738 ML |
30782 | Generate (or do not generate) code using the @code{bras} instruction |
30783 | to do subroutine calls. | |
30784 | This only works reliably if the total executable size does not | |
30785 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
30786 | which does not have this limitation. | |
30787 | ||
d77de738 ML |
30788 | @opindex m64 |
30789 | @opindex m31 | |
ddf6fe37 AA |
30790 | @item -m64 |
30791 | @itemx -m31 | |
d77de738 ML |
30792 | When @option{-m31} is specified, generate code compliant to the |
30793 | GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate | |
30794 | code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in | |
30795 | particular to generate 64-bit instructions. For the @samp{s390} | |
30796 | targets, the default is @option{-m31}, while the @samp{s390x} | |
30797 | targets default to @option{-m64}. | |
30798 | ||
d77de738 ML |
30799 | @opindex mzarch |
30800 | @opindex mesa | |
ddf6fe37 AA |
30801 | @item -mzarch |
30802 | @itemx -mesa | |
d77de738 ML |
30803 | When @option{-mzarch} is specified, generate code using the |
30804 | instructions available on z/Architecture. | |
30805 | When @option{-mesa} is specified, generate code using the | |
30806 | instructions available on ESA/390. Note that @option{-mesa} is | |
30807 | not possible with @option{-m64}. | |
30808 | When generating code compliant to the GNU/Linux for S/390 ABI, | |
30809 | the default is @option{-mesa}. When generating code compliant | |
30810 | to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}. | |
30811 | ||
d77de738 ML |
30812 | @opindex mhtm |
30813 | @opindex mno-htm | |
ddf6fe37 AA |
30814 | @item -mhtm |
30815 | @itemx -mno-htm | |
d77de738 ML |
30816 | The @option{-mhtm} option enables a set of builtins making use of |
30817 | instructions available with the transactional execution facility | |
30818 | introduced with the IBM zEnterprise EC12 machine generation | |
30819 | @ref{S/390 System z Built-in Functions}. | |
30820 | @option{-mhtm} is enabled by default when using @option{-march=zEC12}. | |
30821 | ||
d77de738 ML |
30822 | @opindex mvx |
30823 | @opindex mno-vx | |
ddf6fe37 AA |
30824 | @item -mvx |
30825 | @itemx -mno-vx | |
d77de738 ML |
30826 | When @option{-mvx} is specified, generate code using the instructions |
30827 | available with the vector extension facility introduced with the IBM | |
30828 | z13 machine generation. | |
30829 | This option changes the ABI for some vector type values with regard to | |
30830 | alignment and calling conventions. In case vector type values are | |
30831 | being used in an ABI-relevant context a GAS @samp{.gnu_attribute} | |
30832 | command will be added to mark the resulting binary with the ABI used. | |
30833 | @option{-mvx} is enabled by default when using @option{-march=z13}. | |
30834 | ||
d77de738 ML |
30835 | @opindex mzvector |
30836 | @opindex mno-zvector | |
ddf6fe37 AA |
30837 | @item -mzvector |
30838 | @itemx -mno-zvector | |
d77de738 ML |
30839 | The @option{-mzvector} option enables vector language extensions and |
30840 | builtins using instructions available with the vector extension | |
30841 | facility introduced with the IBM z13 machine generation. | |
30842 | This option adds support for @samp{vector} to be used as a keyword to | |
30843 | define vector type variables and arguments. @samp{vector} is only | |
30844 | available when GNU extensions are enabled. It will not be expanded | |
30845 | when requesting strict standard compliance e.g.@: with @option{-std=c99}. | |
30846 | In addition to the GCC low-level builtins @option{-mzvector} enables | |
30847 | a set of builtins added for compatibility with AltiVec-style | |
30848 | implementations like Power and Cell. In order to make use of these | |
30849 | builtins the header file @file{vecintrin.h} needs to be included. | |
30850 | @option{-mzvector} is disabled by default. | |
30851 | ||
d77de738 ML |
30852 | @opindex mmvcle |
30853 | @opindex mno-mvcle | |
ddf6fe37 AA |
30854 | @item -mmvcle |
30855 | @itemx -mno-mvcle | |
d77de738 ML |
30856 | Generate (or do not generate) code using the @code{mvcle} instruction |
30857 | to perform block moves. When @option{-mno-mvcle} is specified, | |
30858 | use a @code{mvc} loop instead. This is the default unless optimizing for | |
30859 | size. | |
30860 | ||
d77de738 ML |
30861 | @opindex mdebug |
30862 | @opindex mno-debug | |
ddf6fe37 AA |
30863 | @item -mdebug |
30864 | @itemx -mno-debug | |
d77de738 ML |
30865 | Print (or do not print) additional debug information when compiling. |
30866 | The default is to not print debug information. | |
30867 | ||
d77de738 | 30868 | @opindex march |
ddf6fe37 | 30869 | @item -march=@var{cpu-type} |
d77de738 ML |
30870 | Generate code that runs on @var{cpu-type}, which is the name of a |
30871 | system representing a certain processor type. Possible values for | |
30872 | @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6}, | |
30873 | @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8}, | |
30874 | @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11}, | |
30875 | @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13}, | |
30876 | @samp{z16}/@samp{arch14}, and @samp{native}. | |
30877 | ||
30878 | The default is @option{-march=z900}. | |
30879 | ||
30880 | Specifying @samp{native} as cpu type can be used to select the best | |
30881 | architecture option for the host processor. | |
30882 | @option{-march=native} has no effect if GCC does not recognize the | |
30883 | processor. | |
30884 | ||
d77de738 | 30885 | @opindex mtune |
ddf6fe37 | 30886 | @item -mtune=@var{cpu-type} |
d77de738 ML |
30887 | Tune to @var{cpu-type} everything applicable about the generated code, |
30888 | except for the ABI and the set of available instructions. | |
30889 | The list of @var{cpu-type} values is the same as for @option{-march}. | |
30890 | The default is the value used for @option{-march}. | |
30891 | ||
d77de738 ML |
30892 | @opindex mtpf-trace |
30893 | @opindex mno-tpf-trace | |
ddf6fe37 AA |
30894 | @item -mtpf-trace |
30895 | @itemx -mno-tpf-trace | |
d77de738 ML |
30896 | Generate code that adds (does not add) in TPF OS specific branches to trace |
30897 | routines in the operating system. This option is off by default, even | |
30898 | when compiling for the TPF OS@. | |
30899 | ||
d77de738 ML |
30900 | @opindex mtpf-trace-skip |
30901 | @opindex mno-tpf-trace-skip | |
ddf6fe37 AA |
30902 | @item -mtpf-trace-skip |
30903 | @itemx -mno-tpf-trace-skip | |
d77de738 ML |
30904 | Generate code that changes (does not change) the default branch |
30905 | targets enabled by @option{-mtpf-trace} to point to specialized trace | |
30906 | routines providing the ability of selectively skipping function trace | |
30907 | entries for the TPF OS. This option is off by default, even when | |
30908 | compiling for the TPF OS and specifying @option{-mtpf-trace}. | |
30909 | ||
d77de738 ML |
30910 | @opindex mfused-madd |
30911 | @opindex mno-fused-madd | |
ddf6fe37 AA |
30912 | @item -mfused-madd |
30913 | @itemx -mno-fused-madd | |
d77de738 ML |
30914 | Generate code that uses (does not use) the floating-point multiply and |
30915 | accumulate instructions. These instructions are generated by default if | |
30916 | hardware floating point is used. | |
30917 | ||
d77de738 | 30918 | @opindex mwarn-framesize |
ddf6fe37 | 30919 | @item -mwarn-framesize=@var{framesize} |
d77de738 ML |
30920 | Emit a warning if the current function exceeds the given frame size. Because |
30921 | this is a compile-time check it doesn't need to be a real problem when the program | |
30922 | runs. It is intended to identify functions that most probably cause | |
30923 | a stack overflow. It is useful to be used in an environment with limited stack | |
30924 | size e.g.@: the linux kernel. | |
30925 | ||
d77de738 | 30926 | @opindex mwarn-dynamicstack |
ddf6fe37 | 30927 | @item -mwarn-dynamicstack |
d77de738 ML |
30928 | Emit a warning if the function calls @code{alloca} or uses dynamically-sized |
30929 | arrays. This is generally a bad idea with a limited stack size. | |
30930 | ||
d77de738 ML |
30931 | @opindex mstack-guard |
30932 | @opindex mstack-size | |
ddf6fe37 AA |
30933 | @item -mstack-guard=@var{stack-guard} |
30934 | @itemx -mstack-size=@var{stack-size} | |
d77de738 ML |
30935 | If these options are provided the S/390 back end emits additional instructions in |
30936 | the function prologue that trigger a trap if the stack size is @var{stack-guard} | |
30937 | bytes above the @var{stack-size} (remember that the stack on S/390 grows downward). | |
30938 | If the @var{stack-guard} option is omitted the smallest power of 2 larger than | |
30939 | the frame size of the compiled function is chosen. | |
30940 | These options are intended to be used to help debugging stack overflow problems. | |
30941 | The additionally emitted code causes only little overhead and hence can also be | |
30942 | used in production-like systems without greater performance degradation. The given | |
30943 | values have to be exact powers of 2 and @var{stack-size} has to be greater than | |
30944 | @var{stack-guard} without exceeding 64k. | |
30945 | In order to be efficient the extra code makes the assumption that the stack starts | |
30946 | at an address aligned to the value given by @var{stack-size}. | |
30947 | The @var{stack-guard} option can only be used in conjunction with @var{stack-size}. | |
30948 | ||
d77de738 | 30949 | @opindex mhotpatch |
ddf6fe37 | 30950 | @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords} |
d77de738 ML |
30951 | If the hotpatch option is enabled, a ``hot-patching'' function |
30952 | prologue is generated for all functions in the compilation unit. | |
30953 | The funtion label is prepended with the given number of two-byte | |
30954 | NOP instructions (@var{pre-halfwords}, maximum 1000000). After | |
30955 | the label, 2 * @var{post-halfwords} bytes are appended, using the | |
30956 | largest NOP like instructions the architecture allows (maximum | |
30957 | 1000000). | |
30958 | ||
30959 | If both arguments are zero, hotpatching is disabled. | |
30960 | ||
30961 | This option can be overridden for individual functions with the | |
30962 | @code{hotpatch} attribute. | |
30963 | @end table | |
30964 | ||
d77de738 ML |
30965 | @node SH Options |
30966 | @subsection SH Options | |
30967 | ||
30968 | These @samp{-m} options are defined for the SH implementations: | |
30969 | ||
30970 | @table @gcctabopt | |
d77de738 | 30971 | @opindex m1 |
ddf6fe37 | 30972 | @item -m1 |
d77de738 ML |
30973 | Generate code for the SH1. |
30974 | ||
d77de738 | 30975 | @opindex m2 |
ddf6fe37 | 30976 | @item -m2 |
d77de738 ML |
30977 | Generate code for the SH2. |
30978 | ||
30979 | @item -m2e | |
30980 | Generate code for the SH2e. | |
30981 | ||
d77de738 | 30982 | @opindex m2a-nofpu |
ddf6fe37 | 30983 | @item -m2a-nofpu |
d77de738 ML |
30984 | Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way |
30985 | that the floating-point unit is not used. | |
30986 | ||
d77de738 | 30987 | @opindex m2a-single-only |
ddf6fe37 | 30988 | @item -m2a-single-only |
d77de738 ML |
30989 | Generate code for the SH2a-FPU, in such a way that no double-precision |
30990 | floating-point operations are used. | |
30991 | ||
d77de738 | 30992 | @opindex m2a-single |
ddf6fe37 | 30993 | @item -m2a-single |
d77de738 ML |
30994 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
30995 | single-precision mode by default. | |
30996 | ||
d77de738 | 30997 | @opindex m2a |
ddf6fe37 | 30998 | @item -m2a |
d77de738 ML |
30999 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
31000 | double-precision mode by default. | |
31001 | ||
d77de738 | 31002 | @opindex m3 |
ddf6fe37 | 31003 | @item -m3 |
d77de738 ML |
31004 | Generate code for the SH3. |
31005 | ||
d77de738 | 31006 | @opindex m3e |
ddf6fe37 | 31007 | @item -m3e |
d77de738 ML |
31008 | Generate code for the SH3e. |
31009 | ||
d77de738 | 31010 | @opindex m4-nofpu |
ddf6fe37 | 31011 | @item -m4-nofpu |
d77de738 ML |
31012 | Generate code for the SH4 without a floating-point unit. |
31013 | ||
d77de738 | 31014 | @opindex m4-single-only |
ddf6fe37 | 31015 | @item -m4-single-only |
d77de738 ML |
31016 | Generate code for the SH4 with a floating-point unit that only |
31017 | supports single-precision arithmetic. | |
31018 | ||
d77de738 | 31019 | @opindex m4-single |
ddf6fe37 | 31020 | @item -m4-single |
d77de738 ML |
31021 | Generate code for the SH4 assuming the floating-point unit is in |
31022 | single-precision mode by default. | |
31023 | ||
d77de738 | 31024 | @opindex m4 |
ddf6fe37 | 31025 | @item -m4 |
d77de738 ML |
31026 | Generate code for the SH4. |
31027 | ||
d77de738 | 31028 | @opindex m4-100 |
ddf6fe37 | 31029 | @item -m4-100 |
d77de738 ML |
31030 | Generate code for SH4-100. |
31031 | ||
d77de738 | 31032 | @opindex m4-100-nofpu |
ddf6fe37 | 31033 | @item -m4-100-nofpu |
d77de738 ML |
31034 | Generate code for SH4-100 in such a way that the |
31035 | floating-point unit is not used. | |
31036 | ||
d77de738 | 31037 | @opindex m4-100-single |
ddf6fe37 | 31038 | @item -m4-100-single |
d77de738 ML |
31039 | Generate code for SH4-100 assuming the floating-point unit is in |
31040 | single-precision mode by default. | |
31041 | ||
d77de738 | 31042 | @opindex m4-100-single-only |
ddf6fe37 | 31043 | @item -m4-100-single-only |
d77de738 ML |
31044 | Generate code for SH4-100 in such a way that no double-precision |
31045 | floating-point operations are used. | |
31046 | ||
d77de738 | 31047 | @opindex m4-200 |
ddf6fe37 | 31048 | @item -m4-200 |
d77de738 ML |
31049 | Generate code for SH4-200. |
31050 | ||
d77de738 | 31051 | @opindex m4-200-nofpu |
ddf6fe37 | 31052 | @item -m4-200-nofpu |
d77de738 ML |
31053 | Generate code for SH4-200 without in such a way that the |
31054 | floating-point unit is not used. | |
31055 | ||
d77de738 | 31056 | @opindex m4-200-single |
ddf6fe37 | 31057 | @item -m4-200-single |
d77de738 ML |
31058 | Generate code for SH4-200 assuming the floating-point unit is in |
31059 | single-precision mode by default. | |
31060 | ||
d77de738 | 31061 | @opindex m4-200-single-only |
ddf6fe37 | 31062 | @item -m4-200-single-only |
d77de738 ML |
31063 | Generate code for SH4-200 in such a way that no double-precision |
31064 | floating-point operations are used. | |
31065 | ||
d77de738 | 31066 | @opindex m4-300 |
ddf6fe37 | 31067 | @item -m4-300 |
d77de738 ML |
31068 | Generate code for SH4-300. |
31069 | ||
d77de738 | 31070 | @opindex m4-300-nofpu |
ddf6fe37 | 31071 | @item -m4-300-nofpu |
d77de738 ML |
31072 | Generate code for SH4-300 without in such a way that the |
31073 | floating-point unit is not used. | |
31074 | ||
d77de738 | 31075 | @opindex m4-300-single |
ddf6fe37 | 31076 | @item -m4-300-single |
d77de738 ML |
31077 | Generate code for SH4-300 in such a way that no double-precision |
31078 | floating-point operations are used. | |
31079 | ||
d77de738 | 31080 | @opindex m4-300-single-only |
ddf6fe37 | 31081 | @item -m4-300-single-only |
d77de738 ML |
31082 | Generate code for SH4-300 in such a way that no double-precision |
31083 | floating-point operations are used. | |
31084 | ||
d77de738 | 31085 | @opindex m4-340 |
ddf6fe37 | 31086 | @item -m4-340 |
d77de738 ML |
31087 | Generate code for SH4-340 (no MMU, no FPU). |
31088 | ||
d77de738 | 31089 | @opindex m4-500 |
ddf6fe37 | 31090 | @item -m4-500 |
d77de738 ML |
31091 | Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the |
31092 | assembler. | |
31093 | ||
d77de738 | 31094 | @opindex m4a-nofpu |
ddf6fe37 | 31095 | @item -m4a-nofpu |
d77de738 ML |
31096 | Generate code for the SH4al-dsp, or for a SH4a in such a way that the |
31097 | floating-point unit is not used. | |
31098 | ||
d77de738 | 31099 | @opindex m4a-single-only |
ddf6fe37 | 31100 | @item -m4a-single-only |
d77de738 ML |
31101 | Generate code for the SH4a, in such a way that no double-precision |
31102 | floating-point operations are used. | |
31103 | ||
d77de738 | 31104 | @opindex m4a-single |
ddf6fe37 | 31105 | @item -m4a-single |
d77de738 ML |
31106 | Generate code for the SH4a assuming the floating-point unit is in |
31107 | single-precision mode by default. | |
31108 | ||
d77de738 | 31109 | @opindex m4a |
ddf6fe37 | 31110 | @item -m4a |
d77de738 ML |
31111 | Generate code for the SH4a. |
31112 | ||
d77de738 | 31113 | @opindex m4al |
ddf6fe37 | 31114 | @item -m4al |
d77de738 ML |
31115 | Same as @option{-m4a-nofpu}, except that it implicitly passes |
31116 | @option{-dsp} to the assembler. GCC doesn't generate any DSP | |
31117 | instructions at the moment. | |
31118 | ||
d77de738 | 31119 | @opindex mb |
ddf6fe37 | 31120 | @item -mb |
d77de738 ML |
31121 | Compile code for the processor in big-endian mode. |
31122 | ||
d77de738 | 31123 | @opindex ml |
ddf6fe37 | 31124 | @item -ml |
d77de738 ML |
31125 | Compile code for the processor in little-endian mode. |
31126 | ||
d77de738 | 31127 | @opindex mdalign |
ddf6fe37 | 31128 | @item -mdalign |
d77de738 ML |
31129 | Align doubles at 64-bit boundaries. Note that this changes the calling |
31130 | conventions, and thus some functions from the standard C library do | |
31131 | not work unless you recompile it first with @option{-mdalign}. | |
31132 | ||
d77de738 | 31133 | @opindex mrelax |
ddf6fe37 | 31134 | @item -mrelax |
d77de738 ML |
31135 | Shorten some address references at link time, when possible; uses the |
31136 | linker option @option{-relax}. | |
31137 | ||
d77de738 | 31138 | @opindex mbigtable |
ddf6fe37 | 31139 | @item -mbigtable |
d77de738 ML |
31140 | Use 32-bit offsets in @code{switch} tables. The default is to use |
31141 | 16-bit offsets. | |
31142 | ||
d77de738 | 31143 | @opindex mbitops |
ddf6fe37 | 31144 | @item -mbitops |
d77de738 ML |
31145 | Enable the use of bit manipulation instructions on SH2A. |
31146 | ||
d77de738 | 31147 | @opindex mfmovd |
ddf6fe37 | 31148 | @item -mfmovd |
d77de738 ML |
31149 | Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for |
31150 | alignment constraints. | |
31151 | ||
d77de738 | 31152 | @opindex mrenesas |
ddf6fe37 | 31153 | @item -mrenesas |
d77de738 ML |
31154 | Comply with the calling conventions defined by Renesas. |
31155 | ||
d77de738 | 31156 | @opindex mno-renesas |
ddf6fe37 | 31157 | @item -mno-renesas |
d77de738 ML |
31158 | Comply with the calling conventions defined for GCC before the Renesas |
31159 | conventions were available. This option is the default for all | |
31160 | targets of the SH toolchain. | |
31161 | ||
d77de738 | 31162 | @opindex mnomacsave |
ddf6fe37 | 31163 | @item -mnomacsave |
d77de738 ML |
31164 | Mark the @code{MAC} register as call-clobbered, even if |
31165 | @option{-mrenesas} is given. | |
31166 | ||
d77de738 ML |
31167 | @opindex mieee |
31168 | @opindex mno-ieee | |
ddf6fe37 AA |
31169 | @item -mieee |
31170 | @itemx -mno-ieee | |
d77de738 ML |
31171 | Control the IEEE compliance of floating-point comparisons, which affects the |
31172 | handling of cases where the result of a comparison is unordered. By default | |
31173 | @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is | |
31174 | enabled @option{-mno-ieee} is implicitly set, which results in faster | |
31175 | floating-point greater-equal and less-equal comparisons. The implicit settings | |
31176 | can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}. | |
31177 | ||
d77de738 | 31178 | @opindex minline-ic_invalidate |
ddf6fe37 | 31179 | @item -minline-ic_invalidate |
d77de738 ML |
31180 | Inline code to invalidate instruction cache entries after setting up |
31181 | nested function trampolines. | |
31182 | This option has no effect if @option{-musermode} is in effect and the selected | |
31183 | code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi} | |
31184 | instruction. | |
31185 | If the selected code generation option does not allow the use of the @code{icbi} | |
31186 | instruction, and @option{-musermode} is not in effect, the inlined code | |
31187 | manipulates the instruction cache address array directly with an associative | |
31188 | write. This not only requires privileged mode at run time, but it also | |
31189 | fails if the cache line had been mapped via the TLB and has become unmapped. | |
31190 | ||
d77de738 | 31191 | @opindex misize |
ddf6fe37 | 31192 | @item -misize |
d77de738 ML |
31193 | Dump instruction size and location in the assembly code. |
31194 | ||
d77de738 | 31195 | @opindex mpadstruct |
ddf6fe37 | 31196 | @item -mpadstruct |
d77de738 ML |
31197 | This option is deprecated. It pads structures to multiple of 4 bytes, |
31198 | which is incompatible with the SH ABI@. | |
31199 | ||
d77de738 | 31200 | @opindex matomic-model=@var{model} |
ddf6fe37 | 31201 | @item -matomic-model=@var{model} |
d77de738 ML |
31202 | Sets the model of atomic operations and additional parameters as a comma |
31203 | separated list. For details on the atomic built-in functions see | |
31204 | @ref{__atomic Builtins}. The following models and parameters are supported: | |
31205 | ||
31206 | @table @samp | |
31207 | ||
31208 | @item none | |
31209 | Disable compiler generated atomic sequences and emit library calls for atomic | |
31210 | operations. This is the default if the target is not @code{sh*-*-linux*}. | |
31211 | ||
31212 | @item soft-gusa | |
31213 | Generate GNU/Linux compatible gUSA software atomic sequences for the atomic | |
31214 | built-in functions. The generated atomic sequences require additional support | |
31215 | from the interrupt/exception handling code of the system and are only suitable | |
31216 | for SH3* and SH4* single-core systems. This option is enabled by default when | |
31217 | the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A, | |
31218 | this option also partially utilizes the hardware atomic instructions | |
31219 | @code{movli.l} and @code{movco.l} to create more efficient code, unless | |
31220 | @samp{strict} is specified. | |
31221 | ||
31222 | @item soft-tcb | |
31223 | Generate software atomic sequences that use a variable in the thread control | |
31224 | block. This is a variation of the gUSA sequences which can also be used on | |
31225 | SH1* and SH2* targets. The generated atomic sequences require additional | |
31226 | support from the interrupt/exception handling code of the system and are only | |
31227 | suitable for single-core systems. When using this model, the @samp{gbr-offset=} | |
31228 | parameter has to be specified as well. | |
31229 | ||
31230 | @item soft-imask | |
31231 | Generate software atomic sequences that temporarily disable interrupts by | |
31232 | setting @code{SR.IMASK = 1111}. This model works only when the program runs | |
31233 | in privileged mode and is only suitable for single-core systems. Additional | |
31234 | support from the interrupt/exception handling code of the system is not | |
31235 | required. This model is enabled by default when the target is | |
31236 | @code{sh*-*-linux*} and SH1* or SH2*. | |
31237 | ||
31238 | @item hard-llcs | |
31239 | Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l} | |
31240 | instructions only. This is only available on SH4A and is suitable for | |
31241 | multi-core systems. Since the hardware instructions support only 32 bit atomic | |
31242 | variables access to 8 or 16 bit variables is emulated with 32 bit accesses. | |
31243 | Code compiled with this option is also compatible with other software | |
31244 | atomic model interrupt/exception handling systems if executed on an SH4A | |
31245 | system. Additional support from the interrupt/exception handling code of the | |
31246 | system is not required for this model. | |
31247 | ||
31248 | @item gbr-offset= | |
31249 | This parameter specifies the offset in bytes of the variable in the thread | |
31250 | control block structure that should be used by the generated atomic sequences | |
31251 | when the @samp{soft-tcb} model has been selected. For other models this | |
31252 | parameter is ignored. The specified value must be an integer multiple of four | |
31253 | and in the range 0-1020. | |
31254 | ||
31255 | @item strict | |
31256 | This parameter prevents mixed usage of multiple atomic models, even if they | |
31257 | are compatible, and makes the compiler generate atomic sequences of the | |
31258 | specified model only. | |
31259 | ||
31260 | @end table | |
31261 | ||
d77de738 | 31262 | @opindex mtas |
ddf6fe37 | 31263 | @item -mtas |
d77de738 ML |
31264 | Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}. |
31265 | Notice that depending on the particular hardware and software configuration | |
31266 | this can degrade overall performance due to the operand cache line flushes | |
31267 | that are implied by the @code{tas.b} instruction. On multi-core SH4A | |
31268 | processors the @code{tas.b} instruction must be used with caution since it | |
31269 | can result in data corruption for certain cache configurations. | |
31270 | ||
d77de738 | 31271 | @opindex mprefergot |
ddf6fe37 | 31272 | @item -mprefergot |
d77de738 ML |
31273 | When generating position-independent code, emit function calls using |
31274 | the Global Offset Table instead of the Procedure Linkage Table. | |
31275 | ||
d77de738 ML |
31276 | @opindex musermode |
31277 | @opindex mno-usermode | |
ddf6fe37 AA |
31278 | @item -musermode |
31279 | @itemx -mno-usermode | |
d77de738 ML |
31280 | Don't allow (allow) the compiler generating privileged mode code. Specifying |
31281 | @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the | |
31282 | inlined code would not work in user mode. @option{-musermode} is the default | |
31283 | when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2* | |
31284 | @option{-musermode} has no effect, since there is no user mode. | |
31285 | ||
d77de738 | 31286 | @opindex multcost=@var{number} |
ddf6fe37 | 31287 | @item -multcost=@var{number} |
d77de738 ML |
31288 | Set the cost to assume for a multiply insn. |
31289 | ||
d77de738 | 31290 | @opindex mdiv=@var{strategy} |
ddf6fe37 | 31291 | @item -mdiv=@var{strategy} |
d77de738 ML |
31292 | Set the division strategy to be used for integer division operations. |
31293 | @var{strategy} can be one of: | |
31294 | ||
31295 | @table @samp | |
31296 | ||
31297 | @item call-div1 | |
31298 | Calls a library function that uses the single-step division instruction | |
31299 | @code{div1} to perform the operation. Division by zero calculates an | |
31300 | unspecified result and does not trap. This is the default except for SH4, | |
31301 | SH2A and SHcompact. | |
31302 | ||
31303 | @item call-fp | |
31304 | Calls a library function that performs the operation in double precision | |
31305 | floating point. Division by zero causes a floating-point exception. This is | |
31306 | the default for SHcompact with FPU. Specifying this for targets that do not | |
31307 | have a double precision FPU defaults to @code{call-div1}. | |
31308 | ||
31309 | @item call-table | |
31310 | Calls a library function that uses a lookup table for small divisors and | |
31311 | the @code{div1} instruction with case distinction for larger divisors. Division | |
31312 | by zero calculates an unspecified result and does not trap. This is the default | |
31313 | for SH4. Specifying this for targets that do not have dynamic shift | |
31314 | instructions defaults to @code{call-div1}. | |
31315 | ||
31316 | @end table | |
31317 | ||
31318 | When a division strategy has not been specified the default strategy is | |
31319 | selected based on the current target. For SH2A the default strategy is to | |
31320 | use the @code{divs} and @code{divu} instructions instead of library function | |
31321 | calls. | |
31322 | ||
d77de738 | 31323 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 31324 | @item -maccumulate-outgoing-args |
d77de738 ML |
31325 | Reserve space once for outgoing arguments in the function prologue rather |
31326 | than around each call. Generally beneficial for performance and size. Also | |
31327 | needed for unwinding to avoid changing the stack frame around conditional code. | |
31328 | ||
d77de738 | 31329 | @opindex mdivsi3_libfunc=@var{name} |
ddf6fe37 | 31330 | @item -mdivsi3_libfunc=@var{name} |
d77de738 ML |
31331 | Set the name of the library function used for 32-bit signed division to |
31332 | @var{name}. | |
31333 | This only affects the name used in the @samp{call} division strategies, and | |
31334 | the compiler still expects the same sets of input/output/clobbered registers as | |
31335 | if this option were not present. | |
31336 | ||
d77de738 | 31337 | @opindex mfixed-range |
ddf6fe37 | 31338 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
31339 | Generate code treating the given register range as fixed registers. |
31340 | A fixed register is one that the register allocator cannot use. This is | |
31341 | useful when compiling kernel code. A register range is specified as | |
31342 | two registers separated by a dash. Multiple register ranges can be | |
31343 | specified separated by a comma. | |
31344 | ||
d77de738 | 31345 | @opindex mbranch-cost=@var{num} |
ddf6fe37 | 31346 | @item -mbranch-cost=@var{num} |
d77de738 ML |
31347 | Assume @var{num} to be the cost for a branch instruction. Higher numbers |
31348 | make the compiler try to generate more branch-free code if possible. | |
31349 | If not specified the value is selected depending on the processor type that | |
31350 | is being compiled for. | |
31351 | ||
d77de738 ML |
31352 | @opindex mzdcbranch |
31353 | @opindex mno-zdcbranch | |
ddf6fe37 AA |
31354 | @item -mzdcbranch |
31355 | @itemx -mno-zdcbranch | |
d77de738 ML |
31356 | Assume (do not assume) that zero displacement conditional branch instructions |
31357 | @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the | |
31358 | compiler prefers zero displacement branch code sequences. This is | |
31359 | enabled by default when generating code for SH4 and SH4A. It can be explicitly | |
31360 | disabled by specifying @option{-mno-zdcbranch}. | |
31361 | ||
d77de738 | 31362 | @opindex mcbranch-force-delay-slot |
ddf6fe37 | 31363 | @item -mcbranch-force-delay-slot |
d77de738 ML |
31364 | Force the usage of delay slots for conditional branches, which stuffs the delay |
31365 | slot with a @code{nop} if a suitable instruction cannot be found. By default | |
31366 | this option is disabled. It can be enabled to work around hardware bugs as | |
31367 | found in the original SH7055. | |
31368 | ||
d77de738 ML |
31369 | @opindex mfused-madd |
31370 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31371 | @item -mfused-madd |
31372 | @itemx -mno-fused-madd | |
d77de738 ML |
31373 | Generate code that uses (does not use) the floating-point multiply and |
31374 | accumulate instructions. These instructions are generated by default | |
31375 | if hardware floating point is used. The machine-dependent | |
31376 | @option{-mfused-madd} option is now mapped to the machine-independent | |
31377 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
31378 | mapped to @option{-ffp-contract=off}. | |
31379 | ||
d77de738 ML |
31380 | @opindex mfsca |
31381 | @opindex mno-fsca | |
ddf6fe37 AA |
31382 | @item -mfsca |
31383 | @itemx -mno-fsca | |
d77de738 ML |
31384 | Allow or disallow the compiler to emit the @code{fsca} instruction for sine |
31385 | and cosine approximations. The option @option{-mfsca} must be used in | |
31386 | combination with @option{-funsafe-math-optimizations}. It is enabled by default | |
31387 | when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine | |
31388 | approximations even if @option{-funsafe-math-optimizations} is in effect. | |
31389 | ||
d77de738 ML |
31390 | @opindex mfsrra |
31391 | @opindex mno-fsrra | |
ddf6fe37 AA |
31392 | @item -mfsrra |
31393 | @itemx -mno-fsrra | |
d77de738 ML |
31394 | Allow or disallow the compiler to emit the @code{fsrra} instruction for |
31395 | reciprocal square root approximations. The option @option{-mfsrra} must be used | |
31396 | in combination with @option{-funsafe-math-optimizations} and | |
31397 | @option{-ffinite-math-only}. It is enabled by default when generating code for | |
31398 | SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations | |
31399 | even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are | |
31400 | in effect. | |
31401 | ||
d77de738 | 31402 | @opindex mpretend-cmove |
ddf6fe37 | 31403 | @item -mpretend-cmove |
d77de738 ML |
31404 | Prefer zero-displacement conditional branches for conditional move instruction |
31405 | patterns. This can result in faster code on the SH4 processor. | |
31406 | ||
d77de738 | 31407 | @opindex fdpic |
ddf6fe37 | 31408 | @item -mfdpic |
d77de738 ML |
31409 | Generate code using the FDPIC ABI. |
31410 | ||
31411 | @end table | |
31412 | ||
31413 | @node Solaris 2 Options | |
31414 | @subsection Solaris 2 Options | |
31415 | @cindex Solaris 2 options | |
31416 | ||
31417 | These @samp{-m} options are supported on Solaris 2: | |
31418 | ||
31419 | @table @gcctabopt | |
d77de738 | 31420 | @opindex mclear-hwcap |
ddf6fe37 | 31421 | @item -mclear-hwcap |
d77de738 ML |
31422 | @option{-mclear-hwcap} tells the compiler to remove the hardware |
31423 | capabilities generated by the Solaris assembler. This is only necessary | |
31424 | when object files use ISA extensions not supported by the current | |
31425 | machine, but check at runtime whether or not to use them. | |
31426 | ||
d77de738 | 31427 | @opindex mimpure-text |
ddf6fe37 | 31428 | @item -mimpure-text |
d77de738 ML |
31429 | @option{-mimpure-text}, used in addition to @option{-shared}, tells |
31430 | the compiler to not pass @option{-z text} to the linker when linking a | |
31431 | shared object. Using this option, you can link position-dependent | |
31432 | code into a shared object. | |
31433 | ||
31434 | @option{-mimpure-text} suppresses the ``relocations remain against | |
31435 | allocatable but non-writable sections'' linker error message. | |
31436 | However, the necessary relocations trigger copy-on-write, and the | |
31437 | shared object is not actually shared across processes. Instead of | |
31438 | using @option{-mimpure-text}, you should compile all source code with | |
31439 | @option{-fpic} or @option{-fPIC}. | |
31440 | ||
31441 | @end table | |
31442 | ||
31443 | These switches are supported in addition to the above on Solaris 2: | |
31444 | ||
31445 | @table @gcctabopt | |
d77de738 | 31446 | @opindex pthreads |
ddf6fe37 | 31447 | @item -pthreads |
d77de738 ML |
31448 | This is a synonym for @option{-pthread}. |
31449 | @end table | |
31450 | ||
31451 | @node SPARC Options | |
31452 | @subsection SPARC Options | |
31453 | @cindex SPARC options | |
31454 | ||
31455 | These @samp{-m} options are supported on the SPARC: | |
31456 | ||
31457 | @table @gcctabopt | |
d77de738 ML |
31458 | @opindex mno-app-regs |
31459 | @opindex mapp-regs | |
ddf6fe37 AA |
31460 | @item -mno-app-regs |
31461 | @itemx -mapp-regs | |
d77de738 ML |
31462 | Specify @option{-mapp-regs} to generate output using the global registers |
31463 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the | |
31464 | global register 1, each global register 2 through 4 is then treated as an | |
31465 | allocable register that is clobbered by function calls. This is the default. | |
31466 | ||
31467 | To be fully SVR4 ABI-compliant at the cost of some performance loss, | |
31468 | specify @option{-mno-app-regs}. You should compile libraries and system | |
31469 | software with this option. | |
31470 | ||
d77de738 ML |
31471 | @opindex mflat |
31472 | @opindex mno-flat | |
ddf6fe37 AA |
31473 | @item -mflat |
31474 | @itemx -mno-flat | |
d77de738 ML |
31475 | With @option{-mflat}, the compiler does not generate save/restore instructions |
31476 | and uses a ``flat'' or single register window model. This model is compatible | |
31477 | with the regular register window model. The local registers and the input | |
31478 | registers (0--5) are still treated as ``call-saved'' registers and are | |
31479 | saved on the stack as needed. | |
31480 | ||
31481 | With @option{-mno-flat} (the default), the compiler generates save/restore | |
31482 | instructions (except for leaf functions). This is the normal operating mode. | |
31483 | ||
d77de738 ML |
31484 | @opindex mfpu |
31485 | @opindex mhard-float | |
ddf6fe37 AA |
31486 | @item -mfpu |
31487 | @itemx -mhard-float | |
d77de738 ML |
31488 | Generate output containing floating-point instructions. This is the |
31489 | default. | |
31490 | ||
d77de738 ML |
31491 | @opindex mno-fpu |
31492 | @opindex msoft-float | |
ddf6fe37 AA |
31493 | @item -mno-fpu |
31494 | @itemx -msoft-float | |
d77de738 ML |
31495 | Generate output containing library calls for floating point. |
31496 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
31497 | targets. Normally the facilities of the machine's usual C compiler are | |
31498 | used, but this cannot be done directly in cross-compilation. You must make | |
31499 | your own arrangements to provide suitable library functions for | |
31500 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
31501 | @samp{sparclite-*-*} do provide software floating-point support. | |
31502 | ||
31503 | @option{-msoft-float} changes the calling convention in the output file; | |
31504 | therefore, it is only useful if you compile @emph{all} of a program with | |
31505 | this option. In particular, you need to compile @file{libgcc.a}, the | |
31506 | library that comes with GCC, with @option{-msoft-float} in order for | |
31507 | this to work. | |
31508 | ||
d77de738 | 31509 | @opindex mhard-quad-float |
ddf6fe37 | 31510 | @item -mhard-quad-float |
d77de738 ML |
31511 | Generate output containing quad-word (long double) floating-point |
31512 | instructions. | |
31513 | ||
d77de738 | 31514 | @opindex msoft-quad-float |
ddf6fe37 | 31515 | @item -msoft-quad-float |
d77de738 ML |
31516 | Generate output containing library calls for quad-word (long double) |
31517 | floating-point instructions. The functions called are those specified | |
31518 | in the SPARC ABI@. This is the default. | |
31519 | ||
31520 | As of this writing, there are no SPARC implementations that have hardware | |
31521 | support for the quad-word floating-point instructions. They all invoke | |
31522 | a trap handler for one of these instructions, and then the trap handler | |
31523 | emulates the effect of the instruction. Because of the trap handler overhead, | |
31524 | this is much slower than calling the ABI library routines. Thus the | |
31525 | @option{-msoft-quad-float} option is the default. | |
31526 | ||
d77de738 ML |
31527 | @opindex mno-unaligned-doubles |
31528 | @opindex munaligned-doubles | |
ddf6fe37 AA |
31529 | @item -mno-unaligned-doubles |
31530 | @itemx -munaligned-doubles | |
d77de738 ML |
31531 | Assume that doubles have 8-byte alignment. This is the default. |
31532 | ||
31533 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte | |
31534 | alignment only if they are contained in another type, or if they have an | |
31535 | absolute address. Otherwise, it assumes they have 4-byte alignment. | |
31536 | Specifying this option avoids some rare compatibility problems with code | |
31537 | generated by other compilers. It is not the default because it results | |
31538 | in a performance loss, especially for floating-point code. | |
31539 | ||
d77de738 ML |
31540 | @opindex muser-mode |
31541 | @opindex mno-user-mode | |
ddf6fe37 AA |
31542 | @item -muser-mode |
31543 | @itemx -mno-user-mode | |
d77de738 ML |
31544 | Do not generate code that can only run in supervisor mode. This is relevant |
31545 | only for the @code{casa} instruction emitted for the LEON3 processor. This | |
31546 | is the default. | |
31547 | ||
d77de738 ML |
31548 | @opindex mfaster-structs |
31549 | @opindex mno-faster-structs | |
ddf6fe37 AA |
31550 | @item -mfaster-structs |
31551 | @itemx -mno-faster-structs | |
d77de738 ML |
31552 | With @option{-mfaster-structs}, the compiler assumes that structures |
31553 | should have 8-byte alignment. This enables the use of pairs of | |
31554 | @code{ldd} and @code{std} instructions for copies in structure | |
31555 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
31556 | However, the use of this changed alignment directly violates the SPARC | |
31557 | ABI@. Thus, it's intended only for use on targets where the developer | |
31558 | acknowledges that their resulting code is not directly in line with | |
31559 | the rules of the ABI@. | |
31560 | ||
d77de738 ML |
31561 | @opindex mstd-struct-return |
31562 | @opindex mno-std-struct-return | |
ddf6fe37 AA |
31563 | @item -mstd-struct-return |
31564 | @itemx -mno-std-struct-return | |
d77de738 ML |
31565 | With @option{-mstd-struct-return}, the compiler generates checking code |
31566 | in functions returning structures or unions to detect size mismatches | |
31567 | between the two sides of function calls, as per the 32-bit ABI@. | |
31568 | ||
31569 | The default is @option{-mno-std-struct-return}. This option has no effect | |
31570 | in 64-bit mode. | |
31571 | ||
d77de738 ML |
31572 | @opindex mlra |
31573 | @opindex mno-lra | |
ddf6fe37 AA |
31574 | @item -mlra |
31575 | @itemx -mno-lra | |
d77de738 ML |
31576 | Enable Local Register Allocation. This is the default for SPARC since GCC 7 |
31577 | so @option{-mno-lra} needs to be passed to get old Reload. | |
31578 | ||
d77de738 | 31579 | @opindex mcpu |
ddf6fe37 | 31580 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
31581 | Set the instruction set, register set, and instruction scheduling parameters |
31582 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
31583 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc}, | |
31584 | @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite}, | |
31585 | @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701}, | |
31586 | @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara}, | |
31587 | @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and | |
31588 | @samp{m8}. | |
31589 | ||
31590 | Native Solaris and GNU/Linux toolchains also support the value @samp{native}, | |
31591 | which selects the best architecture option for the host processor. | |
31592 | @option{-mcpu=native} has no effect if GCC does not recognize | |
31593 | the processor. | |
31594 | ||
31595 | Default instruction scheduling parameters are used for values that select | |
31596 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
31597 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
31598 | ||
31599 | Here is a list of each supported architecture and their supported | |
31600 | implementations. | |
31601 | ||
31602 | @table @asis | |
31603 | @item v7 | |
31604 | cypress, leon3v7 | |
31605 | ||
31606 | @item v8 | |
31607 | supersparc, hypersparc, leon, leon3, leon5 | |
31608 | ||
31609 | @item sparclite | |
31610 | f930, f934, sparclite86x | |
31611 | ||
31612 | @item sparclet | |
31613 | tsc701 | |
31614 | ||
31615 | @item v9 | |
31616 | ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, | |
31617 | niagara7, m8 | |
31618 | @end table | |
31619 | ||
31620 | By default (unless configured otherwise), GCC generates code for the V7 | |
31621 | variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler | |
31622 | additionally optimizes it for the Cypress CY7C602 chip, as used in the | |
31623 | SPARCStation/SPARCServer 3xx series. This is also appropriate for the older | |
31624 | SPARCStation 1, 2, IPX etc. | |
31625 | ||
31626 | With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC | |
31627 | architecture. The only difference from V7 code is that the compiler emits | |
31628 | the integer multiply and integer divide instructions which exist in SPARC-V8 | |
31629 | but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally | |
31630 | optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and | |
31631 | 2000 series. | |
31632 | ||
31633 | With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of | |
31634 | the SPARC architecture. This adds the integer multiply, integer divide step | |
31635 | and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7. | |
31636 | With @option{-mcpu=f930}, the compiler additionally optimizes it for the | |
31637 | Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With | |
31638 | @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu | |
31639 | MB86934 chip, which is the more recent SPARClite with FPU@. | |
31640 | ||
31641 | With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of | |
31642 | the SPARC architecture. This adds the integer multiply, multiply/accumulate, | |
31643 | integer divide step and scan (@code{ffs}) instructions which exist in SPARClet | |
31644 | but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally | |
31645 | optimizes it for the TEMIC SPARClet chip. | |
31646 | ||
31647 | With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC | |
31648 | architecture. This adds 64-bit integer and floating-point move instructions, | |
31649 | 3 additional floating-point condition code registers and conditional move | |
31650 | instructions. With @option{-mcpu=ultrasparc}, the compiler additionally | |
31651 | optimizes it for the Sun UltraSPARC I/II/IIi chips. With | |
31652 | @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the | |
31653 | Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With | |
31654 | @option{-mcpu=niagara}, the compiler additionally optimizes it for | |
31655 | Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler | |
31656 | additionally optimizes it for Sun UltraSPARC T2 chips. With | |
31657 | @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun | |
31658 | UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler | |
31659 | additionally optimizes it for Sun UltraSPARC T4 chips. With | |
31660 | @option{-mcpu=niagara7}, the compiler additionally optimizes it for | |
31661 | Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler | |
31662 | additionally optimizes it for Oracle M8 chips. | |
31663 | ||
d77de738 | 31664 | @opindex mtune |
ddf6fe37 | 31665 | @item -mtune=@var{cpu_type} |
d77de738 ML |
31666 | Set the instruction scheduling parameters for machine type |
31667 | @var{cpu_type}, but do not set the instruction set or register set that the | |
31668 | option @option{-mcpu=@var{cpu_type}} does. | |
31669 | ||
31670 | The same values for @option{-mcpu=@var{cpu_type}} can be used for | |
31671 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
31672 | that select a particular CPU implementation. Those are | |
31673 | @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon}, | |
31674 | @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934}, | |
31675 | @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, | |
31676 | @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3}, | |
31677 | @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris | |
31678 | and GNU/Linux toolchains, @samp{native} can also be used. | |
31679 | ||
d77de738 ML |
31680 | @opindex mv8plus |
31681 | @opindex mno-v8plus | |
ddf6fe37 AA |
31682 | @item -mv8plus |
31683 | @itemx -mno-v8plus | |
d77de738 ML |
31684 | With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The |
31685 | difference from the V8 ABI is that the global and out registers are | |
31686 | considered 64 bits wide. This is enabled by default on Solaris in 32-bit | |
31687 | mode for all SPARC-V9 processors. | |
31688 | ||
d77de738 ML |
31689 | @opindex mvis |
31690 | @opindex mno-vis | |
ddf6fe37 AA |
31691 | @item -mvis |
31692 | @itemx -mno-vis | |
d77de738 ML |
31693 | With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC |
31694 | Visual Instruction Set extensions. The default is @option{-mno-vis}. | |
31695 | ||
d77de738 ML |
31696 | @opindex mvis2 |
31697 | @opindex mno-vis2 | |
ddf6fe37 AA |
31698 | @item -mvis2 |
31699 | @itemx -mno-vis2 | |
d77de738 ML |
31700 | With @option{-mvis2}, GCC generates code that takes advantage of |
31701 | version 2.0 of the UltraSPARC Visual Instruction Set extensions. The | |
31702 | default is @option{-mvis2} when targeting a cpu that supports such | |
31703 | instructions, such as UltraSPARC-III and later. Setting @option{-mvis2} | |
31704 | also sets @option{-mvis}. | |
31705 | ||
d77de738 ML |
31706 | @opindex mvis3 |
31707 | @opindex mno-vis3 | |
ddf6fe37 AA |
31708 | @item -mvis3 |
31709 | @itemx -mno-vis3 | |
d77de738 ML |
31710 | With @option{-mvis3}, GCC generates code that takes advantage of |
31711 | version 3.0 of the UltraSPARC Visual Instruction Set extensions. The | |
31712 | default is @option{-mvis3} when targeting a cpu that supports such | |
31713 | instructions, such as niagara-3 and later. Setting @option{-mvis3} | |
31714 | also sets @option{-mvis2} and @option{-mvis}. | |
31715 | ||
d77de738 ML |
31716 | @opindex mvis4 |
31717 | @opindex mno-vis4 | |
ddf6fe37 AA |
31718 | @item -mvis4 |
31719 | @itemx -mno-vis4 | |
d77de738 ML |
31720 | With @option{-mvis4}, GCC generates code that takes advantage of |
31721 | version 4.0 of the UltraSPARC Visual Instruction Set extensions. The | |
31722 | default is @option{-mvis4} when targeting a cpu that supports such | |
31723 | instructions, such as niagara-7 and later. Setting @option{-mvis4} | |
31724 | also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}. | |
31725 | ||
d77de738 ML |
31726 | @opindex mvis4b |
31727 | @opindex mno-vis4b | |
ddf6fe37 AA |
31728 | @item -mvis4b |
31729 | @itemx -mno-vis4b | |
d77de738 ML |
31730 | With @option{-mvis4b}, GCC generates code that takes advantage of |
31731 | version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus | |
31732 | the additional VIS instructions introduced in the Oracle SPARC | |
31733 | Architecture 2017. The default is @option{-mvis4b} when targeting a | |
31734 | cpu that supports such instructions, such as m8 and later. Setting | |
31735 | @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3}, | |
31736 | @option{-mvis2} and @option{-mvis}. | |
31737 | ||
d77de738 ML |
31738 | @opindex mcbcond |
31739 | @opindex mno-cbcond | |
ddf6fe37 AA |
31740 | @item -mcbcond |
31741 | @itemx -mno-cbcond | |
d77de738 ML |
31742 | With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC |
31743 | Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond} | |
31744 | when targeting a CPU that supports such instructions, such as Niagara-4 and | |
31745 | later. | |
31746 | ||
d77de738 ML |
31747 | @opindex mfmaf |
31748 | @opindex mno-fmaf | |
ddf6fe37 AA |
31749 | @item -mfmaf |
31750 | @itemx -mno-fmaf | |
d77de738 ML |
31751 | With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC |
31752 | Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf} | |
31753 | when targeting a CPU that supports such instructions, such as Niagara-3 and | |
31754 | later. | |
31755 | ||
d77de738 ML |
31756 | @opindex mfsmuld |
31757 | @opindex mno-fsmuld | |
ddf6fe37 AA |
31758 | @item -mfsmuld |
31759 | @itemx -mno-fsmuld | |
d77de738 ML |
31760 | With @option{-mfsmuld}, GCC generates code that takes advantage of the |
31761 | Floating-point Multiply Single to Double (FsMULd) instruction. The default is | |
31762 | @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8 | |
31763 | or V9 with FPU except @option{-mcpu=leon}. | |
31764 | ||
d77de738 ML |
31765 | @opindex mpopc |
31766 | @opindex mno-popc | |
ddf6fe37 AA |
31767 | @item -mpopc |
31768 | @itemx -mno-popc | |
d77de738 ML |
31769 | With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC |
31770 | Population Count instruction. The default is @option{-mpopc} | |
31771 | when targeting a CPU that supports such an instruction, such as Niagara-2 and | |
31772 | later. | |
31773 | ||
d77de738 ML |
31774 | @opindex msubxc |
31775 | @opindex mno-subxc | |
ddf6fe37 AA |
31776 | @item -msubxc |
31777 | @itemx -mno-subxc | |
d77de738 ML |
31778 | With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC |
31779 | Subtract-Extended-with-Carry instruction. The default is @option{-msubxc} | |
31780 | when targeting a CPU that supports such an instruction, such as Niagara-7 and | |
31781 | later. | |
31782 | ||
d77de738 | 31783 | @opindex mfix-at697f |
ddf6fe37 | 31784 | @item -mfix-at697f |
d77de738 ML |
31785 | Enable the documented workaround for the single erratum of the Atmel AT697F |
31786 | processor (which corresponds to erratum #13 of the AT697E processor). | |
31787 | ||
d77de738 | 31788 | @opindex mfix-ut699 |
ddf6fe37 | 31789 | @item -mfix-ut699 |
d77de738 ML |
31790 | Enable the documented workarounds for the floating-point errata and the data |
31791 | cache nullify errata of the UT699 processor. | |
31792 | ||
d77de738 | 31793 | @opindex mfix-ut700 |
ddf6fe37 | 31794 | @item -mfix-ut700 |
d77de738 ML |
31795 | Enable the documented workaround for the back-to-back store errata of |
31796 | the UT699E/UT700 processor. | |
31797 | ||
d77de738 | 31798 | @opindex mfix-gr712rc |
ddf6fe37 | 31799 | @item -mfix-gr712rc |
d77de738 ML |
31800 | Enable the documented workaround for the back-to-back store errata of |
31801 | the GR712RC processor. | |
31802 | @end table | |
31803 | ||
31804 | These @samp{-m} options are supported in addition to the above | |
31805 | on SPARC-V9 processors in 64-bit environments: | |
31806 | ||
31807 | @table @gcctabopt | |
d77de738 ML |
31808 | @opindex m32 |
31809 | @opindex m64 | |
ddf6fe37 AA |
31810 | @item -m32 |
31811 | @itemx -m64 | |
d77de738 ML |
31812 | Generate code for a 32-bit or 64-bit environment. |
31813 | The 32-bit environment sets int, long and pointer to 32 bits. | |
31814 | The 64-bit environment sets int to 32 bits and long and pointer | |
31815 | to 64 bits. | |
31816 | ||
d77de738 | 31817 | @opindex mcmodel |
ddf6fe37 | 31818 | @item -mcmodel=@var{which} |
d77de738 ML |
31819 | Set the code model to one of |
31820 | ||
31821 | @table @samp | |
31822 | @item medlow | |
31823 | The Medium/Low code model: 64-bit addresses, programs | |
31824 | must be linked in the low 32 bits of memory. Programs can be statically | |
31825 | or dynamically linked. | |
31826 | ||
31827 | @item medmid | |
31828 | The Medium/Middle code model: 64-bit addresses, programs | |
31829 | must be linked in the low 44 bits of memory, the text and data segments must | |
31830 | be less than 2GB in size and the data segment must be located within 2GB of | |
31831 | the text segment. | |
31832 | ||
31833 | @item medany | |
31834 | The Medium/Anywhere code model: 64-bit addresses, programs | |
31835 | may be linked anywhere in memory, the text and data segments must be less | |
31836 | than 2GB in size and the data segment must be located within 2GB of the | |
31837 | text segment. | |
31838 | ||
31839 | @item embmedany | |
31840 | The Medium/Anywhere code model for embedded systems: | |
31841 | 64-bit addresses, the text and data segments must be less than 2GB in | |
31842 | size, both starting anywhere in memory (determined at link time). The | |
31843 | global register %g4 points to the base of the data segment. Programs | |
31844 | are statically linked and PIC is not supported. | |
31845 | @end table | |
31846 | ||
d77de738 | 31847 | @opindex mmemory-model |
ddf6fe37 | 31848 | @item -mmemory-model=@var{mem-model} |
d77de738 ML |
31849 | Set the memory model in force on the processor to one of |
31850 | ||
31851 | @table @samp | |
31852 | @item default | |
31853 | The default memory model for the processor and operating system. | |
31854 | ||
31855 | @item rmo | |
31856 | Relaxed Memory Order | |
31857 | ||
31858 | @item pso | |
31859 | Partial Store Order | |
31860 | ||
31861 | @item tso | |
31862 | Total Store Order | |
31863 | ||
31864 | @item sc | |
31865 | Sequential Consistency | |
31866 | @end table | |
31867 | ||
31868 | These memory models are formally defined in Appendix D of the SPARC-V9 | |
31869 | architecture manual, as set in the processor's @code{PSTATE.MM} field. | |
31870 | ||
d77de738 ML |
31871 | @opindex mstack-bias |
31872 | @opindex mno-stack-bias | |
ddf6fe37 AA |
31873 | @item -mstack-bias |
31874 | @itemx -mno-stack-bias | |
d77de738 ML |
31875 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
31876 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
31877 | when making stack frame references. This is the default in 64-bit mode. | |
31878 | Otherwise, assume no such offset is present. | |
31879 | @end table | |
31880 | ||
31881 | @node System V Options | |
31882 | @subsection Options for System V | |
31883 | ||
31884 | These additional options are available on System V Release 4 for | |
31885 | compatibility with other compilers on those systems: | |
31886 | ||
31887 | @table @gcctabopt | |
d77de738 | 31888 | @opindex G |
ddf6fe37 | 31889 | @item -G |
d77de738 ML |
31890 | Create a shared object. |
31891 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. | |
31892 | ||
d77de738 | 31893 | @opindex Qy |
ddf6fe37 | 31894 | @item -Qy |
d77de738 ML |
31895 | Identify the versions of each tool used by the compiler, in a |
31896 | @code{.ident} assembler directive in the output. | |
31897 | ||
d77de738 | 31898 | @opindex Qn |
ddf6fe37 | 31899 | @item -Qn |
d77de738 ML |
31900 | Refrain from adding @code{.ident} directives to the output file (this is |
31901 | the default). | |
31902 | ||
d77de738 | 31903 | @opindex YP |
ddf6fe37 | 31904 | @item -YP,@var{dirs} |
d77de738 ML |
31905 | Search the directories @var{dirs}, and no others, for libraries |
31906 | specified with @option{-l}. | |
31907 | ||
d77de738 | 31908 | @opindex Ym |
ddf6fe37 | 31909 | @item -Ym,@var{dir} |
d77de738 ML |
31910 | Look in the directory @var{dir} to find the M4 preprocessor. |
31911 | The assembler uses this option. | |
31912 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
31913 | @c the generic assembler that comes with Solaris takes just -Ym. | |
31914 | @end table | |
31915 | ||
31916 | @node V850 Options | |
31917 | @subsection V850 Options | |
31918 | @cindex V850 Options | |
31919 | ||
31920 | These @samp{-m} options are defined for V850 implementations: | |
31921 | ||
31922 | @table @gcctabopt | |
d77de738 ML |
31923 | @opindex mlong-calls |
31924 | @opindex mno-long-calls | |
ddf6fe37 AA |
31925 | @item -mlong-calls |
31926 | @itemx -mno-long-calls | |
d77de738 ML |
31927 | Treat all calls as being far away (near). If calls are assumed to be |
31928 | far away, the compiler always loads the function's address into a | |
31929 | register, and calls indirect through the pointer. | |
31930 | ||
d77de738 ML |
31931 | @opindex mno-ep |
31932 | @opindex mep | |
ddf6fe37 AA |
31933 | @item -mno-ep |
31934 | @itemx -mep | |
d77de738 ML |
31935 | Do not optimize (do optimize) basic blocks that use the same index |
31936 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
31937 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} | |
31938 | option is on by default if you optimize. | |
31939 | ||
d77de738 ML |
31940 | @opindex mno-prolog-function |
31941 | @opindex mprolog-function | |
ddf6fe37 AA |
31942 | @item -mno-prolog-function |
31943 | @itemx -mprolog-function | |
d77de738 ML |
31944 | Do not use (do use) external functions to save and restore registers |
31945 | at the prologue and epilogue of a function. The external functions | |
31946 | are slower, but use less code space if more than one function saves | |
31947 | the same number of registers. The @option{-mprolog-function} option | |
31948 | is on by default if you optimize. | |
31949 | ||
d77de738 | 31950 | @opindex mspace |
ddf6fe37 | 31951 | @item -mspace |
d77de738 ML |
31952 | Try to make the code as small as possible. At present, this just turns |
31953 | on the @option{-mep} and @option{-mprolog-function} options. | |
31954 | ||
d77de738 | 31955 | @opindex mtda |
ddf6fe37 | 31956 | @item -mtda=@var{n} |
d77de738 ML |
31957 | Put static or global variables whose size is @var{n} bytes or less into |
31958 | the tiny data area that register @code{ep} points to. The tiny data | |
31959 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
31960 | ||
d77de738 | 31961 | @opindex msda |
ddf6fe37 | 31962 | @item -msda=@var{n} |
d77de738 ML |
31963 | Put static or global variables whose size is @var{n} bytes or less into |
31964 | the small data area that register @code{gp} points to. The small data | |
31965 | area can hold up to 64 kilobytes. | |
31966 | ||
d77de738 | 31967 | @opindex mzda |
ddf6fe37 | 31968 | @item -mzda=@var{n} |
d77de738 ML |
31969 | Put static or global variables whose size is @var{n} bytes or less into |
31970 | the first 32 kilobytes of memory. | |
31971 | ||
d77de738 | 31972 | @opindex mv850 |
ddf6fe37 | 31973 | @item -mv850 |
d77de738 ML |
31974 | Specify that the target processor is the V850. |
31975 | ||
d77de738 | 31976 | @opindex mv850e3v5 |
ddf6fe37 | 31977 | @item -mv850e3v5 |
d77de738 ML |
31978 | Specify that the target processor is the V850E3V5. The preprocessor |
31979 | constant @code{__v850e3v5__} is defined if this option is used. | |
31980 | ||
d77de738 | 31981 | @opindex mv850e2v4 |
ddf6fe37 | 31982 | @item -mv850e2v4 |
d77de738 ML |
31983 | Specify that the target processor is the V850E3V5. This is an alias for |
31984 | the @option{-mv850e3v5} option. | |
31985 | ||
d77de738 | 31986 | @opindex mv850e2v3 |
ddf6fe37 | 31987 | @item -mv850e2v3 |
d77de738 ML |
31988 | Specify that the target processor is the V850E2V3. The preprocessor |
31989 | constant @code{__v850e2v3__} is defined if this option is used. | |
31990 | ||
d77de738 | 31991 | @opindex mv850e2 |
ddf6fe37 | 31992 | @item -mv850e2 |
d77de738 ML |
31993 | Specify that the target processor is the V850E2. The preprocessor |
31994 | constant @code{__v850e2__} is defined if this option is used. | |
31995 | ||
d77de738 | 31996 | @opindex mv850e1 |
ddf6fe37 | 31997 | @item -mv850e1 |
d77de738 ML |
31998 | Specify that the target processor is the V850E1. The preprocessor |
31999 | constants @code{__v850e1__} and @code{__v850e__} are defined if | |
32000 | this option is used. | |
32001 | ||
d77de738 | 32002 | @opindex mv850es |
ddf6fe37 | 32003 | @item -mv850es |
d77de738 ML |
32004 | Specify that the target processor is the V850ES. This is an alias for |
32005 | the @option{-mv850e1} option. | |
32006 | ||
d77de738 | 32007 | @opindex mv850e |
ddf6fe37 | 32008 | @item -mv850e |
d77de738 ML |
32009 | Specify that the target processor is the V850E@. The preprocessor |
32010 | constant @code{__v850e__} is defined if this option is used. | |
32011 | ||
32012 | If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1} | |
32013 | nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5} | |
32014 | are defined then a default target processor is chosen and the | |
32015 | relevant @samp{__v850*__} preprocessor constant is defined. | |
32016 | ||
32017 | The preprocessor constants @code{__v850} and @code{__v851__} are always | |
32018 | defined, regardless of which processor variant is the target. | |
32019 | ||
d77de738 ML |
32020 | @opindex mdisable-callt |
32021 | @opindex mno-disable-callt | |
ddf6fe37 AA |
32022 | @item -mdisable-callt |
32023 | @itemx -mno-disable-callt | |
d77de738 ML |
32024 | This option suppresses generation of the @code{CALLT} instruction for the |
32025 | v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850 | |
32026 | architecture. | |
32027 | ||
32028 | This option is enabled by default when the RH850 ABI is | |
32029 | in use (see @option{-mrh850-abi}), and disabled by default when the | |
32030 | GCC ABI is in use. If @code{CALLT} instructions are being generated | |
32031 | then the C preprocessor symbol @code{__V850_CALLT__} is defined. | |
32032 | ||
d77de738 ML |
32033 | @opindex mrelax |
32034 | @opindex mno-relax | |
ddf6fe37 AA |
32035 | @item -mrelax |
32036 | @itemx -mno-relax | |
d77de738 ML |
32037 | Pass on (or do not pass on) the @option{-mrelax} command-line option |
32038 | to the assembler. | |
32039 | ||
d77de738 ML |
32040 | @opindex mlong-jumps |
32041 | @opindex mno-long-jumps | |
ddf6fe37 AA |
32042 | @item -mlong-jumps |
32043 | @itemx -mno-long-jumps | |
d77de738 ML |
32044 | Disable (or re-enable) the generation of PC-relative jump instructions. |
32045 | ||
d77de738 ML |
32046 | @opindex msoft-float |
32047 | @opindex mhard-float | |
ddf6fe37 AA |
32048 | @item -msoft-float |
32049 | @itemx -mhard-float | |
d77de738 ML |
32050 | Disable (or re-enable) the generation of hardware floating point |
32051 | instructions. This option is only significant when the target | |
32052 | architecture is @samp{V850E2V3} or higher. If hardware floating point | |
32053 | instructions are being generated then the C preprocessor symbol | |
32054 | @code{__FPU_OK__} is defined, otherwise the symbol | |
32055 | @code{__NO_FPU__} is defined. | |
32056 | ||
d77de738 | 32057 | @opindex mloop |
ddf6fe37 | 32058 | @item -mloop |
d77de738 ML |
32059 | Enables the use of the e3v5 LOOP instruction. The use of this |
32060 | instruction is not enabled by default when the e3v5 architecture is | |
32061 | selected because its use is still experimental. | |
32062 | ||
d77de738 ML |
32063 | @opindex mrh850-abi |
32064 | @opindex mghs | |
ddf6fe37 AA |
32065 | @item -mrh850-abi |
32066 | @itemx -mghs | |
d77de738 ML |
32067 | Enables support for the RH850 version of the V850 ABI. This is the |
32068 | default. With this version of the ABI the following rules apply: | |
32069 | ||
32070 | @itemize | |
32071 | @item | |
32072 | Integer sized structures and unions are returned via a memory pointer | |
32073 | rather than a register. | |
32074 | ||
32075 | @item | |
32076 | Large structures and unions (more than 8 bytes in size) are passed by | |
32077 | value. | |
32078 | ||
32079 | @item | |
32080 | Functions are aligned to 16-bit boundaries. | |
32081 | ||
32082 | @item | |
32083 | The @option{-m8byte-align} command-line option is supported. | |
32084 | ||
32085 | @item | |
32086 | The @option{-mdisable-callt} command-line option is enabled by | |
32087 | default. The @option{-mno-disable-callt} command-line option is not | |
32088 | supported. | |
32089 | @end itemize | |
32090 | ||
32091 | When this version of the ABI is enabled the C preprocessor symbol | |
32092 | @code{__V850_RH850_ABI__} is defined. | |
32093 | ||
d77de738 | 32094 | @opindex mgcc-abi |
ddf6fe37 | 32095 | @item -mgcc-abi |
d77de738 ML |
32096 | Enables support for the old GCC version of the V850 ABI. With this |
32097 | version of the ABI the following rules apply: | |
32098 | ||
32099 | @itemize | |
32100 | @item | |
32101 | Integer sized structures and unions are returned in register @code{r10}. | |
32102 | ||
32103 | @item | |
32104 | Large structures and unions (more than 8 bytes in size) are passed by | |
32105 | reference. | |
32106 | ||
32107 | @item | |
32108 | Functions are aligned to 32-bit boundaries, unless optimizing for | |
32109 | size. | |
32110 | ||
32111 | @item | |
32112 | The @option{-m8byte-align} command-line option is not supported. | |
32113 | ||
32114 | @item | |
32115 | The @option{-mdisable-callt} command-line option is supported but not | |
32116 | enabled by default. | |
32117 | @end itemize | |
32118 | ||
32119 | When this version of the ABI is enabled the C preprocessor symbol | |
32120 | @code{__V850_GCC_ABI__} is defined. | |
32121 | ||
d77de738 ML |
32122 | @opindex m8byte-align |
32123 | @opindex mno-8byte-align | |
ddf6fe37 AA |
32124 | @item -m8byte-align |
32125 | @itemx -mno-8byte-align | |
d77de738 ML |
32126 | Enables support for @code{double} and @code{long long} types to be |
32127 | aligned on 8-byte boundaries. The default is to restrict the | |
32128 | alignment of all objects to at most 4-bytes. When | |
32129 | @option{-m8byte-align} is in effect the C preprocessor symbol | |
32130 | @code{__V850_8BYTE_ALIGN__} is defined. | |
32131 | ||
d77de738 | 32132 | @opindex mbig-switch |
ddf6fe37 | 32133 | @item -mbig-switch |
d77de738 ML |
32134 | Generate code suitable for big switch tables. Use this option only if |
32135 | the assembler/linker complain about out of range branches within a switch | |
32136 | table. | |
32137 | ||
d77de738 | 32138 | @opindex mapp-regs |
ddf6fe37 | 32139 | @item -mapp-regs |
d77de738 ML |
32140 | This option causes r2 and r5 to be used in the code generated by |
32141 | the compiler. This setting is the default. | |
32142 | ||
d77de738 | 32143 | @opindex mno-app-regs |
ddf6fe37 | 32144 | @item -mno-app-regs |
d77de738 ML |
32145 | This option causes r2 and r5 to be treated as fixed registers. |
32146 | ||
32147 | @end table | |
32148 | ||
32149 | @node VAX Options | |
32150 | @subsection VAX Options | |
32151 | @cindex VAX options | |
32152 | ||
32153 | These @samp{-m} options are defined for the VAX: | |
32154 | ||
32155 | @table @gcctabopt | |
d77de738 | 32156 | @opindex munix |
ddf6fe37 | 32157 | @item -munix |
d77de738 ML |
32158 | Do not output certain jump instructions (@code{aobleq} and so on) |
32159 | that the Unix assembler for the VAX cannot handle across long | |
32160 | ranges. | |
32161 | ||
d77de738 | 32162 | @opindex mgnu |
ddf6fe37 | 32163 | @item -mgnu |
d77de738 ML |
32164 | Do output those jump instructions, on the assumption that the |
32165 | GNU assembler is being used. | |
32166 | ||
d77de738 | 32167 | @opindex mg |
ddf6fe37 | 32168 | @item -mg |
d77de738 ML |
32169 | Output code for G-format floating-point numbers instead of D-format. |
32170 | ||
d77de738 ML |
32171 | @opindex mlra |
32172 | @opindex mno-lra | |
ddf6fe37 AA |
32173 | @item -mlra |
32174 | @itemx -mno-lra | |
d77de738 ML |
32175 | Enable Local Register Allocation. This is still experimental for the VAX, |
32176 | so by default the compiler uses standard reload. | |
32177 | @end table | |
32178 | ||
32179 | @node Visium Options | |
32180 | @subsection Visium Options | |
32181 | @cindex Visium options | |
32182 | ||
32183 | @table @gcctabopt | |
32184 | ||
d77de738 | 32185 | @opindex mdebug |
ddf6fe37 | 32186 | @item -mdebug |
d77de738 ML |
32187 | A program which performs file I/O and is destined to run on an MCM target |
32188 | should be linked with this option. It causes the libraries libc.a and | |
32189 | libdebug.a to be linked. The program should be run on the target under | |
32190 | the control of the GDB remote debugging stub. | |
32191 | ||
d77de738 | 32192 | @opindex msim |
ddf6fe37 | 32193 | @item -msim |
d77de738 ML |
32194 | A program which performs file I/O and is destined to run on the simulator |
32195 | should be linked with option. This causes libraries libc.a and libsim.a to | |
32196 | be linked. | |
32197 | ||
d77de738 ML |
32198 | @opindex mfpu |
32199 | @opindex mhard-float | |
ddf6fe37 AA |
32200 | @item -mfpu |
32201 | @itemx -mhard-float | |
d77de738 ML |
32202 | Generate code containing floating-point instructions. This is the |
32203 | default. | |
32204 | ||
d77de738 ML |
32205 | @opindex mno-fpu |
32206 | @opindex msoft-float | |
ddf6fe37 AA |
32207 | @item -mno-fpu |
32208 | @itemx -msoft-float | |
d77de738 ML |
32209 | Generate code containing library calls for floating-point. |
32210 | ||
32211 | @option{-msoft-float} changes the calling convention in the output file; | |
32212 | therefore, it is only useful if you compile @emph{all} of a program with | |
32213 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32214 | library that comes with GCC, with @option{-msoft-float} in order for | |
32215 | this to work. | |
32216 | ||
d77de738 | 32217 | @opindex mcpu |
ddf6fe37 | 32218 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32219 | Set the instruction set, register set, and instruction scheduling parameters |
32220 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32221 | @samp{mcm}, @samp{gr5} and @samp{gr6}. | |
32222 | ||
32223 | @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility. | |
32224 | ||
32225 | By default (unless configured otherwise), GCC generates code for the GR5 | |
32226 | variant of the Visium architecture. | |
32227 | ||
32228 | With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium | |
32229 | architecture. The only difference from GR5 code is that the compiler will | |
32230 | generate block move instructions. | |
32231 | ||
d77de738 | 32232 | @opindex mtune |
ddf6fe37 | 32233 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32234 | Set the instruction scheduling parameters for machine type @var{cpu_type}, |
32235 | but do not set the instruction set or register set that the option | |
32236 | @option{-mcpu=@var{cpu_type}} would. | |
32237 | ||
d77de738 | 32238 | @opindex msv-mode |
ddf6fe37 | 32239 | @item -msv-mode |
d77de738 ML |
32240 | Generate code for the supervisor mode, where there are no restrictions on |
32241 | the access to general registers. This is the default. | |
32242 | ||
d77de738 | 32243 | @opindex muser-mode |
ddf6fe37 | 32244 | @item -muser-mode |
d77de738 ML |
32245 | Generate code for the user mode, where the access to some general registers |
32246 | is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this | |
32247 | mode; on the GR6, only registers r29 to r31 are affected. | |
32248 | @end table | |
32249 | ||
32250 | @node VMS Options | |
32251 | @subsection VMS Options | |
32252 | ||
32253 | These @samp{-m} options are defined for the VMS implementations: | |
32254 | ||
32255 | @table @gcctabopt | |
d77de738 | 32256 | @opindex mvms-return-codes |
ddf6fe37 | 32257 | @item -mvms-return-codes |
d77de738 ML |
32258 | Return VMS condition codes from @code{main}. The default is to return POSIX-style |
32259 | condition (e.g.@: error) codes. | |
32260 | ||
d77de738 | 32261 | @opindex mdebug-main=@var{prefix} |
ddf6fe37 | 32262 | @item -mdebug-main=@var{prefix} |
d77de738 ML |
32263 | Flag the first routine whose name starts with @var{prefix} as the main |
32264 | routine for the debugger. | |
32265 | ||
d77de738 | 32266 | @opindex mmalloc64 |
ddf6fe37 | 32267 | @item -mmalloc64 |
d77de738 ML |
32268 | Default to 64-bit memory allocation routines. |
32269 | ||
d77de738 | 32270 | @opindex mpointer-size=@var{size} |
ddf6fe37 | 32271 | @item -mpointer-size=@var{size} |
d77de738 ML |
32272 | Set the default size of pointers. Possible options for @var{size} are |
32273 | @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long} | |
32274 | for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers. | |
32275 | The later option disables @code{pragma pointer_size}. | |
32276 | @end table | |
32277 | ||
32278 | @node VxWorks Options | |
32279 | @subsection VxWorks Options | |
32280 | @cindex VxWorks Options | |
32281 | ||
32282 | The options in this section are defined for all VxWorks targets. | |
32283 | Options specific to the target hardware are listed with the other | |
32284 | options for that target. | |
32285 | ||
32286 | @table @gcctabopt | |
d77de738 | 32287 | @opindex mrtp |
ddf6fe37 | 32288 | @item -mrtp |
d77de738 ML |
32289 | GCC can generate code for both VxWorks kernels and real time processes |
32290 | (RTPs). This option switches from the former to the latter. It also | |
32291 | defines the preprocessor macro @code{__RTP__}. | |
32292 | ||
d77de738 | 32293 | @opindex non-static |
ddf6fe37 | 32294 | @item -non-static |
d77de738 ML |
32295 | Link an RTP executable against shared libraries rather than static |
32296 | libraries. The options @option{-static} and @option{-shared} can | |
32297 | also be used for RTPs (@pxref{Link Options}); @option{-static} | |
32298 | is the default. | |
32299 | ||
d77de738 ML |
32300 | @opindex Bstatic |
32301 | @opindex Bdynamic | |
ddf6fe37 AA |
32302 | @item -Bstatic |
32303 | @itemx -Bdynamic | |
d77de738 ML |
32304 | These options are passed down to the linker. They are defined for |
32305 | compatibility with Diab. | |
32306 | ||
d77de738 | 32307 | @opindex Xbind-lazy |
ddf6fe37 | 32308 | @item -Xbind-lazy |
d77de738 ML |
32309 | Enable lazy binding of function calls. This option is equivalent to |
32310 | @option{-Wl,-z,now} and is defined for compatibility with Diab. | |
32311 | ||
d77de738 | 32312 | @opindex Xbind-now |
ddf6fe37 | 32313 | @item -Xbind-now |
d77de738 ML |
32314 | Disable lazy binding of function calls. This option is the default and |
32315 | is defined for compatibility with Diab. | |
32316 | @end table | |
32317 | ||
32318 | @node x86 Options | |
32319 | @subsection x86 Options | |
32320 | @cindex x86 Options | |
32321 | ||
32322 | These @samp{-m} options are defined for the x86 family of computers. | |
32323 | ||
32324 | @table @gcctabopt | |
32325 | ||
d77de738 | 32326 | @opindex march |
ddf6fe37 | 32327 | @item -march=@var{cpu-type} |
d77de738 ML |
32328 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
32329 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
32330 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
32331 | to generate code that may not run at all on processors other than the one | |
32332 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
32333 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
32334 | ||
32335 | The choices for @var{cpu-type} are: | |
32336 | ||
32337 | @table @samp | |
32338 | @item native | |
32339 | This selects the CPU to generate code for at compilation time by determining | |
32340 | the processor type of the compiling machine. Using @option{-march=native} | |
32341 | enables all instruction subsets supported by the local machine (hence | |
32342 | the result might not run on different machines). Using @option{-mtune=native} | |
32343 | produces code optimized for the local machine under the constraints | |
32344 | of the selected instruction set. | |
32345 | ||
32346 | @item x86-64 | |
32347 | A generic CPU with 64-bit extensions. | |
32348 | ||
32349 | @item x86-64-v2 | |
32350 | @itemx x86-64-v3 | |
32351 | @itemx x86-64-v4 | |
32352 | These choices for @var{cpu-type} select the corresponding | |
32353 | micro-architecture level from the x86-64 psABI. On ABIs other than | |
32354 | the x86-64 psABI they select the same CPU features as the x86-64 psABI | |
32355 | documents for the particular micro-architecture level. | |
32356 | ||
32357 | Since these @var{cpu-type} values do not have a corresponding | |
32358 | @option{-mtune} setting, using @option{-march} with these values enables | |
32359 | generic tuning. Specific tuning can be enabled using the | |
32360 | @option{-mtune=@var{other-cpu-type}} option with an appropriate | |
32361 | @var{other-cpu-type} value. | |
32362 | ||
32363 | @item i386 | |
32364 | Original Intel i386 CPU@. | |
32365 | ||
32366 | @item i486 | |
32367 | Intel i486 CPU@. (No scheduling is implemented for this chip.) | |
32368 | ||
32369 | @item i586 | |
32370 | @itemx pentium | |
32371 | Intel Pentium CPU with no MMX support. | |
32372 | ||
32373 | @item lakemont | |
32374 | Intel Lakemont MCU, based on Intel Pentium CPU. | |
32375 | ||
32376 | @item pentium-mmx | |
32377 | Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support. | |
32378 | ||
32379 | @item pentiumpro | |
32380 | Intel Pentium Pro CPU@. | |
32381 | ||
32382 | @item i686 | |
32383 | When used with @option{-march}, the Pentium Pro | |
32384 | instruction set is used, so the code runs on all i686 family chips. | |
32385 | When used with @option{-mtune}, it has the same meaning as @samp{generic}. | |
32386 | ||
32387 | @item pentium2 | |
32388 | Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction | |
32389 | set support. | |
32390 | ||
32391 | @item pentium3 | |
32392 | @itemx pentium3m | |
32393 | Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE | |
32394 | instruction set support. | |
32395 | ||
32396 | @item pentium-m | |
32397 | Intel Pentium M; low-power version of Intel Pentium III CPU | |
32398 | with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino | |
32399 | notebooks. | |
32400 | ||
32401 | @item pentium4 | |
32402 | @itemx pentium4m | |
32403 | Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support. | |
32404 | ||
32405 | @item prescott | |
32406 | Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR | |
32407 | instruction set support. | |
32408 | ||
32409 | @item nocona | |
32410 | Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, | |
32411 | SSE2, SSE3 and FXSR instruction set support. | |
32412 | ||
32413 | @item core2 | |
32414 | Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16, | |
32415 | SAHF and FXSR instruction set support. | |
32416 | ||
32417 | @item nehalem | |
32418 | Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32419 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support. | |
32420 | ||
32421 | @item westmere | |
32422 | Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32423 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support. | |
32424 | ||
32425 | @item sandybridge | |
32426 | Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32427 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set | |
32428 | support. | |
32429 | ||
32430 | @item ivybridge | |
32431 | Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32432 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND | |
32433 | and F16C instruction set support. | |
32434 | ||
32435 | @item haswell | |
32436 | Intel Haswell 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 and HLE instruction set support. | |
32439 | ||
32440 | @item broadwell | |
32441 | Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32442 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32443 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW | |
32444 | instruction set support. | |
32445 | ||
32446 | @item skylake | |
32447 | Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32448 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32449 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32450 | CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. | |
32451 | ||
32452 | @item bonnell | |
32453 | Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32454 | instruction set support. | |
32455 | ||
32456 | @item silvermont | |
32457 | Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32458 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND | |
32459 | instruction set support. | |
32460 | ||
32461 | @item goldmont | |
32462 | Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32463 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32464 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction | |
32465 | set support. | |
32466 | ||
32467 | @item goldmont-plus | |
32468 | Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32469 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, | |
32470 | SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, | |
32471 | RDPID and SGX instruction set support. | |
32472 | ||
32473 | @item tremont | |
32474 | Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32475 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32476 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID, | |
32477 | SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set | |
32478 | support. | |
32479 | ||
32480 | @item sierraforest | |
32481 | Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32482 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32483 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32484 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32485 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32486 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support. | |
32487 | ||
32488 | @item grandridge | |
32489 | Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32490 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32491 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32492 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32493 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32494 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set | |
32495 | support. | |
32496 | ||
32497 | @item knl | |
32498 | Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32499 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32500 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32501 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support. | |
32502 | ||
32503 | @item knm | |
32504 | Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32505 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32506 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32507 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW, | |
32508 | AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support. | |
32509 | ||
32510 | @item skylake-avx512 | |
32511 | Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32512 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32513 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32514 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, | |
32515 | AVX512DQ and AVX512CD instruction set support. | |
32516 | ||
32517 | @item cannonlake | |
32518 | Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
32519 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, | |
32520 | FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, | |
32521 | PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, | |
32522 | AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set | |
32523 | support. | |
32524 | ||
32525 | @item icelake-client | |
32526 | Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32527 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32528 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32529 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32530 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
32531 | , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
32532 | ||
32533 | @item icelake-server | |
32534 | Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32535 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32536 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32537 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32538 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
32539 | , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB | |
32540 | instruction set support. | |
32541 | ||
32542 | @item cascadelake | |
32543 | Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32544 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32545 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32546 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
32547 | AVX512CD and AVX512VNNI instruction set support. | |
32548 | ||
32549 | @item cooperlake | |
32550 | Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32551 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32552 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32553 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
32554 | AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. | |
32555 | ||
32556 | @item tigerlake | |
32557 | Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32558 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32559 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32560 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
32561 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32562 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, | |
32563 | AVX512VP2INTERSECT and KEYLOCKER instruction set support. | |
32564 | ||
32565 | @item sapphirerapids | |
32566 | Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32567 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32568 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32569 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32570 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32571 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
32572 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, | |
29ecb952 | 32573 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16 |
d77de738 ML |
32574 | instruction set support. |
32575 | ||
32576 | @item alderlake | |
32577 | Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32578 | SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, | |
32579 | XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, | |
32580 | CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, | |
32581 | VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set | |
32582 | support. | |
32583 | ||
32584 | @item rocketlake | |
32585 | Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 | |
32586 | , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32587 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32588 | CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
32589 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32590 | VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
32591 | ||
32592 | @item graniterapids | |
32593 | Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32594 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32595 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32596 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32597 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32598 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
32599 | MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, | |
29ecb952 | 32600 | SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, |
d77de738 ML |
32601 | AVX512BF16, AMX-FP16 and PREFETCHI instruction set support. |
32602 | ||
32603 | @item k6 | |
32604 | AMD K6 CPU with MMX instruction set support. | |
32605 | ||
32606 | @item k6-2 | |
32607 | @itemx k6-3 | |
32608 | Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support. | |
32609 | ||
32610 | @item athlon | |
32611 | @itemx athlon-tbird | |
32612 | AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions | |
32613 | support. | |
32614 | ||
32615 | @item athlon-4 | |
32616 | @itemx athlon-xp | |
32617 | @itemx athlon-mp | |
32618 | Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE | |
32619 | instruction set support. | |
32620 | ||
32621 | @item k8 | |
32622 | @itemx opteron | |
32623 | @itemx athlon64 | |
32624 | @itemx athlon-fx | |
32625 | Processors based on the AMD K8 core with x86-64 instruction set support, | |
32626 | including the AMD Opteron, Athlon 64, and Athlon 64 FX processors. | |
32627 | (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit | |
32628 | instruction set extensions.) | |
32629 | ||
32630 | @item k8-sse3 | |
32631 | @itemx opteron-sse3 | |
32632 | @itemx athlon64-sse3 | |
32633 | Improved versions of AMD K8 cores with SSE3 instruction set support. | |
32634 | ||
32635 | @item amdfam10 | |
32636 | @itemx barcelona | |
32637 | CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This | |
32638 | supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit | |
32639 | instruction set extensions.) | |
32640 | ||
32641 | @item bdver1 | |
32642 | CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This | |
32643 | supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, | |
32644 | SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.) | |
32645 | ||
32646 | @item bdver2 | |
32647 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
32648 | supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, | |
32649 | SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set | |
32650 | extensions.) | |
32651 | ||
32652 | @item bdver3 | |
32653 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
32654 | supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES, | |
32655 | PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and | |
32656 | 64-bit instruction set extensions.) | |
32657 | ||
32658 | @item bdver4 | |
32659 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
32660 | supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP, | |
32661 | AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, | |
32662 | SSE4.2, ABM and 64-bit instruction set extensions.) | |
32663 | ||
32664 | @item znver1 | |
32665 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
32666 | supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, | |
32667 | SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, | |
32668 | SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit | |
32669 | instruction set extensions.) | |
32670 | ||
32671 | @item znver2 | |
32672 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
32673 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
32674 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
32675 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
32676 | WBNOINVD, and 64-bit instruction set extensions.) | |
32677 | ||
32678 | @item znver3 | |
32679 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
32680 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
32681 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
32682 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
32683 | WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.) | |
32684 | ||
32685 | @item znver4 | |
32686 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
32687 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
32688 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
32689 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
32690 | WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, | |
32691 | AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, | |
32692 | AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.) | |
32693 | ||
32694 | @item btver1 | |
32695 | CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This | |
32696 | supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit | |
32697 | instruction set extensions.) | |
32698 | ||
32699 | @item btver2 | |
32700 | CPUs based on AMD Family 16h cores with x86-64 instruction set support. This | |
32701 | includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM, | |
32702 | SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions. | |
32703 | ||
32704 | @item winchip-c6 | |
32705 | IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction | |
32706 | set support. | |
32707 | ||
32708 | @item winchip2 | |
32709 | IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@: | |
32710 | instruction set support. | |
32711 | ||
32712 | @item c3 | |
32713 | VIA C3 CPU with MMX and 3DNow!@: instruction set support. | |
32714 | (No scheduling is implemented for this chip.) | |
32715 | ||
32716 | @item c3-2 | |
32717 | VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support. | |
32718 | (No scheduling is implemented for this chip.) | |
32719 | ||
32720 | @item c7 | |
32721 | VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
32722 | (No scheduling is implemented for this chip.) | |
32723 | ||
32724 | @item samuel-2 | |
32725 | VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support. | |
32726 | (No scheduling is implemented for this chip.) | |
32727 | ||
32728 | @item nehemiah | |
32729 | VIA Eden Nehemiah CPU with MMX and SSE instruction set support. | |
32730 | (No scheduling is implemented for this chip.) | |
32731 | ||
32732 | @item esther | |
32733 | VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
32734 | (No scheduling is implemented for this chip.) | |
32735 | ||
32736 | @item eden-x2 | |
32737 | VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support. | |
32738 | (No scheduling is implemented for this chip.) | |
32739 | ||
32740 | @item eden-x4 | |
32741 | VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, | |
32742 | AVX and AVX2 instruction set support. | |
32743 | (No scheduling is implemented for this chip.) | |
32744 | ||
32745 | @item nano | |
32746 | Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32747 | instruction set support. | |
32748 | (No scheduling is implemented for this chip.) | |
32749 | ||
32750 | @item nano-1000 | |
32751 | VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32752 | instruction set support. | |
32753 | (No scheduling is implemented for this chip.) | |
32754 | ||
32755 | @item nano-2000 | |
32756 | VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32757 | instruction set support. | |
32758 | (No scheduling is implemented for this chip.) | |
32759 | ||
32760 | @item nano-3000 | |
32761 | VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
32762 | instruction set support. | |
32763 | (No scheduling is implemented for this chip.) | |
32764 | ||
32765 | @item nano-x2 | |
32766 | VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
32767 | instruction set support. | |
32768 | (No scheduling is implemented for this chip.) | |
32769 | ||
32770 | @item nano-x4 | |
32771 | VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
32772 | instruction set support. | |
32773 | (No scheduling is implemented for this chip.) | |
32774 | ||
32775 | @item lujiazui | |
32776 | ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
32777 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
32778 | ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support. | |
32779 | ||
32780 | @item geode | |
32781 | AMD Geode embedded processor with MMX and 3DNow!@: instruction set support. | |
32782 | @end table | |
32783 | ||
d77de738 | 32784 | @opindex mtune |
ddf6fe37 | 32785 | @item -mtune=@var{cpu-type} |
d77de738 ML |
32786 | Tune to @var{cpu-type} everything applicable about the generated code, except |
32787 | for the ABI and the set of available instructions. | |
32788 | While picking a specific @var{cpu-type} schedules things appropriately | |
32789 | for that particular chip, the compiler does not generate any code that | |
32790 | cannot run on the default machine type unless you use a | |
32791 | @option{-march=@var{cpu-type}} option. | |
32792 | For example, if GCC is configured for i686-pc-linux-gnu | |
32793 | then @option{-mtune=pentium4} generates code that is tuned for Pentium 4 | |
32794 | but still runs on i686 machines. | |
32795 | ||
32796 | The choices for @var{cpu-type} are the same as for @option{-march}. | |
32797 | In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}: | |
32798 | ||
32799 | @table @samp | |
32800 | @item generic | |
32801 | Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors. | |
32802 | If you know the CPU on which your code will run, then you should use | |
32803 | the corresponding @option{-mtune} or @option{-march} option instead of | |
32804 | @option{-mtune=generic}. But, if you do not know exactly what CPU users | |
32805 | of your application will have, then you should use this option. | |
32806 | ||
32807 | As new processors are deployed in the marketplace, the behavior of this | |
32808 | option will change. Therefore, if you upgrade to a newer version of | |
32809 | GCC, code generation controlled by this option will change to reflect | |
32810 | the processors | |
32811 | that are most common at the time that version of GCC is released. | |
32812 | ||
32813 | There is no @option{-march=generic} option because @option{-march} | |
32814 | indicates the instruction set the compiler can use, and there is no | |
32815 | generic instruction set applicable to all processors. In contrast, | |
32816 | @option{-mtune} indicates the processor (or, in this case, collection of | |
32817 | processors) for which the code is optimized. | |
32818 | ||
32819 | @item intel | |
32820 | Produce code optimized for the most current Intel processors, which are | |
32821 | Haswell and Silvermont for this version of GCC. If you know the CPU | |
32822 | on which your code will run, then you should use the corresponding | |
32823 | @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}. | |
32824 | But, if you want your application performs better on both Haswell and | |
32825 | Silvermont, then you should use this option. | |
32826 | ||
32827 | As new Intel processors are deployed in the marketplace, the behavior of | |
32828 | this option will change. Therefore, if you upgrade to a newer version of | |
32829 | GCC, code generation controlled by this option will change to reflect | |
32830 | the most current Intel processors at the time that version of GCC is | |
32831 | released. | |
32832 | ||
32833 | There is no @option{-march=intel} option because @option{-march} indicates | |
32834 | the instruction set the compiler can use, and there is no common | |
32835 | instruction set applicable to all processors. In contrast, | |
32836 | @option{-mtune} indicates the processor (or, in this case, collection of | |
32837 | processors) for which the code is optimized. | |
32838 | @end table | |
32839 | ||
d77de738 | 32840 | @opindex mcpu |
ddf6fe37 | 32841 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
32842 | A deprecated synonym for @option{-mtune}. |
32843 | ||
d77de738 | 32844 | @opindex mfpmath |
ddf6fe37 | 32845 | @item -mfpmath=@var{unit} |
d77de738 ML |
32846 | Generate floating-point arithmetic for selected unit @var{unit}. The choices |
32847 | for @var{unit} are: | |
32848 | ||
32849 | @table @samp | |
32850 | @item 387 | |
32851 | Use the standard 387 floating-point coprocessor present on the majority of chips and | |
32852 | emulated otherwise. Code compiled with this option runs almost everywhere. | |
32853 | The temporary results are computed in 80-bit precision instead of the precision | |
32854 | specified by the type, resulting in slightly different results compared to most | |
32855 | of other chips. See @option{-ffloat-store} for more detailed description. | |
32856 | ||
32857 | This is the default choice for non-Darwin x86-32 targets. | |
32858 | ||
32859 | @item sse | |
32860 | Use scalar floating-point instructions present in the SSE instruction set. | |
32861 | This instruction set is supported by Pentium III and newer chips, | |
32862 | and in the AMD line | |
32863 | by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE | |
32864 | instruction set supports only single-precision arithmetic, thus the double and | |
32865 | extended-precision arithmetic are still done using 387. A later version, present | |
32866 | only in Pentium 4 and AMD x86-64 chips, supports double-precision | |
32867 | arithmetic too. | |
32868 | ||
32869 | For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse} | |
32870 | or @option{-msse2} switches to enable SSE extensions and make this option | |
32871 | effective. For the x86-64 compiler, these extensions are enabled by default. | |
32872 | ||
32873 | The resulting code should be considerably faster in the majority of cases and avoid | |
32874 | the numerical instability problems of 387 code, but may break some existing | |
32875 | code that expects temporaries to be 80 bits. | |
32876 | ||
32877 | This is the default choice for the x86-64 compiler, Darwin x86-32 targets, | |
32878 | and the default choice for x86-32 targets with the SSE2 instruction set | |
32879 | when @option{-ffast-math} is enabled. | |
32880 | ||
32881 | @item sse,387 | |
32882 | @itemx sse+387 | |
32883 | @itemx both | |
32884 | Attempt to utilize both instruction sets at once. This effectively doubles the | |
32885 | amount of available registers, and on chips with separate execution units for | |
32886 | 387 and SSE the execution resources too. Use this option with care, as it is | |
32887 | still experimental, because the GCC register allocator does not model separate | |
32888 | functional units well, resulting in unstable performance. | |
32889 | @end table | |
32890 | ||
d77de738 | 32891 | @opindex masm=@var{dialect} |
ddf6fe37 | 32892 | @item -masm=@var{dialect} |
d77de738 ML |
32893 | Output assembly instructions using selected @var{dialect}. Also affects |
32894 | which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and | |
32895 | extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect | |
32896 | order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does | |
32897 | not support @samp{intel}. | |
32898 | ||
d77de738 ML |
32899 | @opindex mieee-fp |
32900 | @opindex mno-ieee-fp | |
ddf6fe37 AA |
32901 | @item -mieee-fp |
32902 | @itemx -mno-ieee-fp | |
d77de738 ML |
32903 | Control whether or not the compiler uses IEEE floating-point |
32904 | comparisons. These correctly handle the case where the result of a | |
32905 | comparison is unordered. | |
32906 | ||
30348d30 | 32907 | @opindex m80387 |
d77de738 | 32908 | @opindex mhard-float |
ddf6fe37 AA |
32909 | @item -m80387 |
32910 | @itemx -mhard-float | |
d77de738 ML |
32911 | Generate output containing 80387 instructions for floating point. |
32912 | ||
d77de738 ML |
32913 | @opindex no-80387 |
32914 | @opindex msoft-float | |
ddf6fe37 AA |
32915 | @item -mno-80387 |
32916 | @itemx -msoft-float | |
d77de738 ML |
32917 | Generate output containing library calls for floating point. |
32918 | ||
32919 | @strong{Warning:} the requisite libraries are not part of GCC@. | |
32920 | Normally the facilities of the machine's usual C compiler are used, but | |
32921 | this cannot be done directly in cross-compilation. You must make your | |
32922 | own arrangements to provide suitable library functions for | |
32923 | cross-compilation. | |
32924 | ||
32925 | On machines where a function returns floating-point results in the 80387 | |
32926 | register stack, some floating-point opcodes may be emitted even if | |
32927 | @option{-msoft-float} is used. | |
32928 | ||
d77de738 ML |
32929 | @opindex mno-fp-ret-in-387 |
32930 | @opindex mfp-ret-in-387 | |
ddf6fe37 | 32931 | @item -mno-fp-ret-in-387 |
d77de738 ML |
32932 | Do not use the FPU registers for return values of functions. |
32933 | ||
32934 | The usual calling convention has functions return values of types | |
32935 | @code{float} and @code{double} in an FPU register, even if there | |
32936 | is no FPU@. The idea is that the operating system should emulate | |
32937 | an FPU@. | |
32938 | ||
32939 | The option @option{-mno-fp-ret-in-387} causes such values to be returned | |
32940 | in ordinary CPU registers instead. | |
32941 | ||
d77de738 ML |
32942 | @opindex mno-fancy-math-387 |
32943 | @opindex mfancy-math-387 | |
ddf6fe37 | 32944 | @item -mno-fancy-math-387 |
d77de738 ML |
32945 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
32946 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
32947 | generating those instructions. | |
32948 | This option is overridden when @option{-march} | |
32949 | indicates that the target CPU always has an FPU and so the | |
32950 | instruction does not need emulation. These | |
32951 | instructions are not generated unless you also use the | |
32952 | @option{-funsafe-math-optimizations} switch. | |
32953 | ||
d77de738 ML |
32954 | @opindex malign-double |
32955 | @opindex mno-align-double | |
ddf6fe37 AA |
32956 | @item -malign-double |
32957 | @itemx -mno-align-double | |
d77de738 ML |
32958 | Control whether GCC aligns @code{double}, @code{long double}, and |
32959 | @code{long long} variables on a two-word boundary or a one-word | |
32960 | boundary. Aligning @code{double} variables on a two-word boundary | |
32961 | produces code that runs somewhat faster on a Pentium at the | |
32962 | expense of more memory. | |
32963 | ||
32964 | On x86-64, @option{-malign-double} is enabled by default. | |
32965 | ||
32966 | @strong{Warning:} if you use the @option{-malign-double} switch, | |
32967 | structures containing the above types are aligned differently than | |
32968 | the published application binary interface specifications for the x86-32 | |
32969 | and are not binary compatible with structures in code compiled | |
32970 | without that switch. | |
32971 | ||
d77de738 ML |
32972 | @opindex m96bit-long-double |
32973 | @opindex m128bit-long-double | |
ddf6fe37 AA |
32974 | @item -m96bit-long-double |
32975 | @itemx -m128bit-long-double | |
d77de738 ML |
32976 | These switches control the size of @code{long double} type. The x86-32 |
32977 | application binary interface specifies the size to be 96 bits, | |
32978 | so @option{-m96bit-long-double} is the default in 32-bit mode. | |
32979 | ||
32980 | Modern architectures (Pentium and newer) prefer @code{long double} | |
32981 | to be aligned to an 8- or 16-byte boundary. In arrays or structures | |
32982 | conforming to the ABI, this is not possible. So specifying | |
32983 | @option{-m128bit-long-double} aligns @code{long double} | |
32984 | to a 16-byte boundary by padding the @code{long double} with an additional | |
32985 | 32-bit zero. | |
32986 | ||
32987 | In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as | |
32988 | its ABI specifies that @code{long double} is aligned on 16-byte boundary. | |
32989 | ||
32990 | Notice that neither of these options enable any extra precision over the x87 | |
32991 | standard of 80 bits for a @code{long double}. | |
32992 | ||
32993 | @strong{Warning:} if you override the default value for your target ABI, this | |
32994 | changes the size of | |
32995 | structures and arrays containing @code{long double} variables, | |
32996 | as well as modifying the function calling convention for functions taking | |
32997 | @code{long double}. Hence they are not binary-compatible | |
32998 | with code compiled without that switch. | |
32999 | ||
d77de738 ML |
33000 | @opindex mlong-double-64 |
33001 | @opindex mlong-double-80 | |
33002 | @opindex mlong-double-128 | |
ddf6fe37 AA |
33003 | @item -mlong-double-64 |
33004 | @itemx -mlong-double-80 | |
33005 | @itemx -mlong-double-128 | |
d77de738 ML |
33006 | These switches control the size of @code{long double} type. A size |
33007 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
33008 | type. This is the default for 32-bit Bionic C library. A size | |
33009 | of 128 bits makes the @code{long double} type equivalent to the | |
33010 | @code{__float128} type. This is the default for 64-bit Bionic C library. | |
33011 | ||
33012 | @strong{Warning:} if you override the default value for your target ABI, this | |
33013 | changes the size of | |
33014 | structures and arrays containing @code{long double} variables, | |
33015 | as well as modifying the function calling convention for functions taking | |
33016 | @code{long double}. Hence they are not binary-compatible | |
33017 | with code compiled without that switch. | |
33018 | ||
d77de738 | 33019 | @opindex malign-data |
ddf6fe37 | 33020 | @item -malign-data=@var{type} |
d77de738 ML |
33021 | Control how GCC aligns variables. Supported values for @var{type} are |
33022 | @samp{compat} uses increased alignment value compatible uses GCC 4.8 | |
33023 | and earlier, @samp{abi} uses alignment value as specified by the | |
33024 | psABI, and @samp{cacheline} uses increased alignment value to match | |
33025 | the cache line size. @samp{compat} is the default. | |
33026 | ||
d77de738 | 33027 | @opindex mlarge-data-threshold |
ddf6fe37 | 33028 | @item -mlarge-data-threshold=@var{threshold} |
d77de738 ML |
33029 | When @option{-mcmodel=medium} is specified, data objects larger than |
33030 | @var{threshold} are placed in the large data section. This value must be the | |
33031 | same across all objects linked into the binary, and defaults to 65535. | |
33032 | ||
d77de738 | 33033 | @opindex mrtd |
ddf6fe37 | 33034 | @item -mrtd |
d77de738 ML |
33035 | Use a different function-calling convention, in which functions that |
33036 | take a fixed number of arguments return with the @code{ret @var{num}} | |
33037 | instruction, which pops their arguments while returning. This saves one | |
33038 | instruction in the caller since there is no need to pop the arguments | |
33039 | there. | |
33040 | ||
33041 | You can specify that an individual function is called with this calling | |
33042 | sequence with the function attribute @code{stdcall}. You can also | |
33043 | override the @option{-mrtd} option by using the function attribute | |
33044 | @code{cdecl}. @xref{Function Attributes}. | |
33045 | ||
33046 | @strong{Warning:} this calling convention is incompatible with the one | |
33047 | normally used on Unix, so you cannot use it if you need to call | |
33048 | libraries compiled with the Unix compiler. | |
33049 | ||
33050 | Also, you must provide function prototypes for all functions that | |
33051 | take variable numbers of arguments (including @code{printf}); | |
33052 | otherwise incorrect code is generated for calls to those | |
33053 | functions. | |
33054 | ||
33055 | In addition, seriously incorrect code results if you call a | |
33056 | function with too many arguments. (Normally, extra arguments are | |
33057 | harmlessly ignored.) | |
33058 | ||
d77de738 | 33059 | @opindex mregparm |
ddf6fe37 | 33060 | @item -mregparm=@var{num} |
d77de738 ML |
33061 | Control how many registers are used to pass integer arguments. By |
33062 | default, no registers are used to pass arguments, and at most 3 | |
33063 | registers can be used. You can control this behavior for a specific | |
33064 | function by using the function attribute @code{regparm}. | |
33065 | @xref{Function Attributes}. | |
33066 | ||
33067 | @strong{Warning:} if you use this switch, and | |
33068 | @var{num} is nonzero, then you must build all modules with the same | |
33069 | value, including any libraries. This includes the system libraries and | |
33070 | startup modules. | |
33071 | ||
d77de738 | 33072 | @opindex msseregparm |
ddf6fe37 | 33073 | @item -msseregparm |
d77de738 ML |
33074 | Use SSE register passing conventions for float and double arguments |
33075 | and return values. You can control this behavior for a specific | |
33076 | function by using the function attribute @code{sseregparm}. | |
33077 | @xref{Function Attributes}. | |
33078 | ||
33079 | @strong{Warning:} if you use this switch then you must build all | |
33080 | modules with the same value, including any libraries. This includes | |
33081 | the system libraries and startup modules. | |
33082 | ||
d77de738 | 33083 | @opindex mvect8-ret-in-mem |
ddf6fe37 | 33084 | @item -mvect8-ret-in-mem |
d77de738 ML |
33085 | Return 8-byte vectors in memory instead of MMX registers. This is the |
33086 | default on VxWorks to match the ABI of the Sun Studio compilers until | |
33087 | version 12. @emph{Only} use this option if you need to remain | |
33088 | compatible with existing code produced by those previous compiler | |
33089 | versions or older versions of GCC@. | |
33090 | ||
d77de738 ML |
33091 | @opindex mpc32 |
33092 | @opindex mpc64 | |
33093 | @opindex mpc80 | |
ddf6fe37 AA |
33094 | @item -mpc32 |
33095 | @itemx -mpc64 | |
33096 | @itemx -mpc80 | |
d77de738 ML |
33097 | |
33098 | Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32} | |
33099 | is specified, the significands of results of floating-point operations are | |
33100 | rounded to 24 bits (single precision); @option{-mpc64} rounds the | |
33101 | significands of results of floating-point operations to 53 bits (double | |
33102 | precision) and @option{-mpc80} rounds the significands of results of | |
33103 | floating-point operations to 64 bits (extended double precision), which is | |
33104 | the default. When this option is used, floating-point operations in higher | |
33105 | precisions are not available to the programmer without setting the FPU | |
33106 | control word explicitly. | |
33107 | ||
33108 | Setting the rounding of floating-point operations to less than the default | |
33109 | 80 bits can speed some programs by 2% or more. Note that some mathematical | |
33110 | libraries assume that extended-precision (80-bit) floating-point operations | |
33111 | are enabled by default; routines in such libraries could suffer significant | |
33112 | loss of accuracy, typically through so-called ``catastrophic cancellation'', | |
33113 | when this option is used to set the precision to less than extended precision. | |
33114 | ||
e54375d8 | 33115 | @opindex mdaz-ftz |
ddf6fe37 | 33116 | @item -mdaz-ftz |
e54375d8 | 33117 | |
33118 | The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register | |
33119 | are used to control floating-point calculations.SSE and AVX instructions | |
33120 | including scalar and vector instructions could benefit from enabling the FTZ | |
33121 | and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags | |
33122 | when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz} | |
33123 | will set FTZ/DAZ flags even with @option{-shared}. | |
33124 | ||
d77de738 | 33125 | @opindex mstackrealign |
ddf6fe37 | 33126 | @item -mstackrealign |
d77de738 ML |
33127 | Realign the stack at entry. On the x86, the @option{-mstackrealign} |
33128 | option generates an alternate prologue and epilogue that realigns the | |
33129 | run-time stack if necessary. This supports mixing legacy codes that keep | |
33130 | 4-byte stack alignment with modern codes that keep 16-byte stack alignment for | |
33131 | SSE compatibility. See also the attribute @code{force_align_arg_pointer}, | |
33132 | applicable to individual functions. | |
33133 | ||
d77de738 | 33134 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 33135 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
33136 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
33137 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
33138 | the default is 4 (16 bytes or 128 bits). | |
33139 | ||
33140 | @strong{Warning:} When generating code for the x86-64 architecture with | |
33141 | SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be | |
33142 | used to keep the stack boundary aligned to 8 byte boundary. Since | |
33143 | x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and | |
33144 | intended to be used in controlled environment where stack space is | |
33145 | important limitation. This option leads to wrong code when functions | |
33146 | compiled with 16 byte stack alignment (such as functions from a standard | |
33147 | library) are called with misaligned stack. In this case, SSE | |
33148 | instructions may lead to misaligned memory access traps. In addition, | |
33149 | variable arguments are handled incorrectly for 16 byte aligned | |
33150 | objects (including x87 long double and __int128), leading to wrong | |
33151 | results. You must build all modules with | |
33152 | @option{-mpreferred-stack-boundary=3}, including any libraries. This | |
33153 | includes the system libraries and startup modules. | |
33154 | ||
d77de738 | 33155 | @opindex mincoming-stack-boundary |
ddf6fe37 | 33156 | @item -mincoming-stack-boundary=@var{num} |
d77de738 ML |
33157 | Assume the incoming stack is aligned to a 2 raised to @var{num} byte |
33158 | boundary. If @option{-mincoming-stack-boundary} is not specified, | |
33159 | the one specified by @option{-mpreferred-stack-boundary} is used. | |
33160 | ||
33161 | On Pentium and Pentium Pro, @code{double} and @code{long double} values | |
33162 | should be aligned to an 8-byte boundary (see @option{-malign-double}) or | |
33163 | suffer significant run time performance penalties. On Pentium III, the | |
33164 | Streaming SIMD Extension (SSE) data type @code{__m128} may not work | |
33165 | properly if it is not 16-byte aligned. | |
33166 | ||
33167 | To ensure proper alignment of this values on the stack, the stack boundary | |
33168 | must be as aligned as that required by any value stored on the stack. | |
33169 | Further, every function must be generated such that it keeps the stack | |
33170 | aligned. Thus calling a function compiled with a higher preferred | |
33171 | stack boundary from a function compiled with a lower preferred stack | |
33172 | boundary most likely misaligns the stack. It is recommended that | |
33173 | libraries that use callbacks always use the default setting. | |
33174 | ||
33175 | This extra alignment does consume extra stack space, and generally | |
33176 | increases code size. Code that is sensitive to stack space usage, such | |
33177 | as embedded systems and operating system kernels, may want to reduce the | |
33178 | preferred alignment to @option{-mpreferred-stack-boundary=2}. | |
33179 | ||
33180 | @need 200 | |
d77de738 | 33181 | @opindex mmmx |
ddf6fe37 | 33182 | @item -mmmx |
d77de738 | 33183 | @need 200 |
d77de738 | 33184 | @opindex msse |
ddf6fe37 | 33185 | @itemx -msse |
d77de738 | 33186 | @need 200 |
d77de738 | 33187 | @opindex msse2 |
ddf6fe37 | 33188 | @itemx -msse2 |
d77de738 | 33189 | @need 200 |
d77de738 | 33190 | @opindex msse3 |
ddf6fe37 | 33191 | @itemx -msse3 |
d77de738 | 33192 | @need 200 |
d77de738 | 33193 | @opindex mssse3 |
ddf6fe37 | 33194 | @itemx -mssse3 |
d77de738 | 33195 | @need 200 |
d77de738 | 33196 | @opindex msse4 |
ddf6fe37 | 33197 | @itemx -msse4 |
d77de738 | 33198 | @need 200 |
d77de738 | 33199 | @opindex msse4a |
ddf6fe37 | 33200 | @itemx -msse4a |
d77de738 | 33201 | @need 200 |
d77de738 | 33202 | @opindex msse4.1 |
ddf6fe37 | 33203 | @itemx -msse4.1 |
d77de738 | 33204 | @need 200 |
d77de738 | 33205 | @opindex msse4.2 |
ddf6fe37 | 33206 | @itemx -msse4.2 |
d77de738 | 33207 | @need 200 |
d77de738 | 33208 | @opindex mavx |
ddf6fe37 | 33209 | @itemx -mavx |
d77de738 | 33210 | @need 200 |
d77de738 | 33211 | @opindex mavx2 |
ddf6fe37 | 33212 | @itemx -mavx2 |
d77de738 | 33213 | @need 200 |
d77de738 | 33214 | @opindex mavx512f |
ddf6fe37 | 33215 | @itemx -mavx512f |
d77de738 | 33216 | @need 200 |
d77de738 | 33217 | @opindex mavx512pf |
ddf6fe37 | 33218 | @itemx -mavx512pf |
d77de738 | 33219 | @need 200 |
d77de738 | 33220 | @opindex mavx512er |
ddf6fe37 | 33221 | @itemx -mavx512er |
d77de738 | 33222 | @need 200 |
d77de738 | 33223 | @opindex mavx512cd |
ddf6fe37 | 33224 | @itemx -mavx512cd |
d77de738 | 33225 | @need 200 |
d77de738 | 33226 | @opindex mavx512vl |
ddf6fe37 | 33227 | @itemx -mavx512vl |
d77de738 | 33228 | @need 200 |
d77de738 | 33229 | @opindex mavx512bw |
ddf6fe37 | 33230 | @itemx -mavx512bw |
d77de738 | 33231 | @need 200 |
d77de738 | 33232 | @opindex mavx512dq |
ddf6fe37 | 33233 | @itemx -mavx512dq |
d77de738 | 33234 | @need 200 |
d77de738 | 33235 | @opindex mavx512ifma |
ddf6fe37 | 33236 | @itemx -mavx512ifma |
d77de738 | 33237 | @need 200 |
d77de738 | 33238 | @opindex mavx512vbmi |
ddf6fe37 | 33239 | @itemx -mavx512vbmi |
d77de738 | 33240 | @need 200 |
d77de738 | 33241 | @opindex msha |
ddf6fe37 | 33242 | @itemx -msha |
d77de738 | 33243 | @need 200 |
d77de738 | 33244 | @opindex maes |
ddf6fe37 | 33245 | @itemx -maes |
d77de738 | 33246 | @need 200 |
d77de738 | 33247 | @opindex mpclmul |
ddf6fe37 | 33248 | @itemx -mpclmul |
d77de738 | 33249 | @need 200 |
d77de738 | 33250 | @opindex mclflushopt |
ddf6fe37 | 33251 | @itemx -mclflushopt |
d77de738 | 33252 | @need 200 |
d77de738 | 33253 | @opindex mclwb |
ddf6fe37 | 33254 | @itemx -mclwb |
d77de738 | 33255 | @need 200 |
d77de738 | 33256 | @opindex mfsgsbase |
ddf6fe37 | 33257 | @itemx -mfsgsbase |
d77de738 | 33258 | @need 200 |
d77de738 | 33259 | @opindex mptwrite |
ddf6fe37 | 33260 | @itemx -mptwrite |
d77de738 | 33261 | @need 200 |
d77de738 | 33262 | @opindex mrdrnd |
ddf6fe37 | 33263 | @itemx -mrdrnd |
d77de738 | 33264 | @need 200 |
d77de738 | 33265 | @opindex mf16c |
ddf6fe37 | 33266 | @itemx -mf16c |
d77de738 | 33267 | @need 200 |
d77de738 | 33268 | @opindex mfma |
ddf6fe37 | 33269 | @itemx -mfma |
d77de738 | 33270 | @need 200 |
d77de738 | 33271 | @opindex mpconfig |
ddf6fe37 | 33272 | @itemx -mpconfig |
d77de738 | 33273 | @need 200 |
d77de738 | 33274 | @opindex mwbnoinvd |
ddf6fe37 | 33275 | @itemx -mwbnoinvd |
d77de738 | 33276 | @need 200 |
d77de738 | 33277 | @opindex mfma4 |
ddf6fe37 | 33278 | @itemx -mfma4 |
d77de738 | 33279 | @need 200 |
d77de738 | 33280 | @opindex mprfchw |
ddf6fe37 | 33281 | @itemx -mprfchw |
d77de738 | 33282 | @need 200 |
d77de738 | 33283 | @opindex mrdpid |
ddf6fe37 | 33284 | @itemx -mrdpid |
d77de738 | 33285 | @need 200 |
d77de738 | 33286 | @opindex mprefetchwt1 |
ddf6fe37 | 33287 | @itemx -mprefetchwt1 |
d77de738 | 33288 | @need 200 |
d77de738 | 33289 | @opindex mrdseed |
ddf6fe37 | 33290 | @itemx -mrdseed |
d77de738 | 33291 | @need 200 |
d77de738 | 33292 | @opindex msgx |
ddf6fe37 | 33293 | @itemx -msgx |
d77de738 | 33294 | @need 200 |
d77de738 | 33295 | @opindex mxop |
ddf6fe37 | 33296 | @itemx -mxop |
d77de738 | 33297 | @need 200 |
d77de738 | 33298 | @opindex mlwp |
ddf6fe37 | 33299 | @itemx -mlwp |
d77de738 | 33300 | @need 200 |
d77de738 | 33301 | @opindex m3dnow |
ddf6fe37 | 33302 | @itemx -m3dnow |
d77de738 | 33303 | @need 200 |
d77de738 | 33304 | @opindex m3dnowa |
ddf6fe37 | 33305 | @itemx -m3dnowa |
d77de738 | 33306 | @need 200 |
d77de738 | 33307 | @opindex mpopcnt |
ddf6fe37 | 33308 | @itemx -mpopcnt |
d77de738 | 33309 | @need 200 |
d77de738 | 33310 | @opindex mabm |
ddf6fe37 | 33311 | @itemx -mabm |
d77de738 | 33312 | @need 200 |
d77de738 | 33313 | @opindex madx |
ddf6fe37 | 33314 | @itemx -madx |
d77de738 | 33315 | @need 200 |
d77de738 | 33316 | @opindex mbmi |
ddf6fe37 | 33317 | @itemx -mbmi |
d77de738 | 33318 | @need 200 |
d77de738 | 33319 | @opindex mbmi2 |
ddf6fe37 | 33320 | @itemx -mbmi2 |
d77de738 | 33321 | @need 200 |
d77de738 | 33322 | @opindex mlzcnt |
ddf6fe37 | 33323 | @itemx -mlzcnt |
d77de738 | 33324 | @need 200 |
d77de738 | 33325 | @opindex mfxsr |
ddf6fe37 | 33326 | @itemx -mfxsr |
d77de738 | 33327 | @need 200 |
d77de738 | 33328 | @opindex mxsave |
ddf6fe37 | 33329 | @itemx -mxsave |
d77de738 | 33330 | @need 200 |
d77de738 | 33331 | @opindex mxsaveopt |
ddf6fe37 | 33332 | @itemx -mxsaveopt |
d77de738 | 33333 | @need 200 |
d77de738 | 33334 | @opindex mxsavec |
ddf6fe37 | 33335 | @itemx -mxsavec |
d77de738 | 33336 | @need 200 |
d77de738 | 33337 | @opindex mxsaves |
ddf6fe37 | 33338 | @itemx -mxsaves |
d77de738 | 33339 | @need 200 |
d77de738 | 33340 | @opindex mrtm |
ddf6fe37 | 33341 | @itemx -mrtm |
d77de738 | 33342 | @need 200 |
d77de738 | 33343 | @opindex mhle |
ddf6fe37 | 33344 | @itemx -mhle |
d77de738 | 33345 | @need 200 |
d77de738 | 33346 | @opindex mtbm |
ddf6fe37 | 33347 | @itemx -mtbm |
d77de738 | 33348 | @need 200 |
d77de738 | 33349 | @opindex mmwaitx |
ddf6fe37 | 33350 | @itemx -mmwaitx |
d77de738 | 33351 | @need 200 |
d77de738 | 33352 | @opindex mclzero |
ddf6fe37 | 33353 | @itemx -mclzero |
d77de738 | 33354 | @need 200 |
d77de738 | 33355 | @opindex mpku |
ddf6fe37 | 33356 | @itemx -mpku |
d77de738 | 33357 | @need 200 |
d77de738 | 33358 | @opindex mavx512vbmi2 |
ddf6fe37 | 33359 | @itemx -mavx512vbmi2 |
d77de738 | 33360 | @need 200 |
d77de738 | 33361 | @opindex mavx512bf16 |
ddf6fe37 | 33362 | @itemx -mavx512bf16 |
d77de738 | 33363 | @need 200 |
d77de738 | 33364 | @opindex mavx512fp16 |
ddf6fe37 | 33365 | @itemx -mavx512fp16 |
d77de738 | 33366 | @need 200 |
d77de738 | 33367 | @opindex mgfni |
ddf6fe37 | 33368 | @itemx -mgfni |
d77de738 | 33369 | @need 200 |
d77de738 | 33370 | @opindex mvaes |
ddf6fe37 | 33371 | @itemx -mvaes |
d77de738 | 33372 | @need 200 |
d77de738 | 33373 | @opindex mwaitpkg |
ddf6fe37 | 33374 | @itemx -mwaitpkg |
d77de738 | 33375 | @need 200 |
d77de738 | 33376 | @opindex mvpclmulqdq |
ddf6fe37 | 33377 | @itemx -mvpclmulqdq |
d77de738 | 33378 | @need 200 |
d77de738 | 33379 | @opindex mavx512bitalg |
ddf6fe37 | 33380 | @itemx -mavx512bitalg |
d77de738 | 33381 | @need 200 |
d77de738 | 33382 | @opindex mmovdiri |
ddf6fe37 | 33383 | @itemx -mmovdiri |
d77de738 | 33384 | @need 200 |
d77de738 | 33385 | @opindex mmovdir64b |
ddf6fe37 | 33386 | @itemx -mmovdir64b |
d77de738 | 33387 | @need 200 |
d77de738 | 33388 | @opindex menqcmd |
d77de738 | 33389 | @opindex muintr |
ddf6fe37 AA |
33390 | @itemx -menqcmd |
33391 | @itemx -muintr | |
d77de738 | 33392 | @need 200 |
d77de738 | 33393 | @opindex mtsxldtrk |
ddf6fe37 | 33394 | @itemx -mtsxldtrk |
d77de738 | 33395 | @need 200 |
d77de738 | 33396 | @opindex mavx512vpopcntdq |
ddf6fe37 | 33397 | @itemx -mavx512vpopcntdq |
d77de738 | 33398 | @need 200 |
d77de738 | 33399 | @opindex mavx512vp2intersect |
ddf6fe37 | 33400 | @itemx -mavx512vp2intersect |
d77de738 | 33401 | @need 200 |
d77de738 | 33402 | @opindex mavx5124fmaps |
ddf6fe37 | 33403 | @itemx -mavx5124fmaps |
d77de738 | 33404 | @need 200 |
d77de738 | 33405 | @opindex mavx512vnni |
ddf6fe37 | 33406 | @itemx -mavx512vnni |
d77de738 | 33407 | @need 200 |
d77de738 | 33408 | @opindex mavxvnni |
ddf6fe37 | 33409 | @itemx -mavxvnni |
d77de738 | 33410 | @need 200 |
d77de738 | 33411 | @opindex mavx5124vnniw |
ddf6fe37 | 33412 | @itemx -mavx5124vnniw |
d77de738 | 33413 | @need 200 |
d77de738 | 33414 | @opindex mcldemote |
ddf6fe37 | 33415 | @itemx -mcldemote |
d77de738 | 33416 | @need 200 |
d77de738 | 33417 | @opindex mserialize |
ddf6fe37 | 33418 | @itemx -mserialize |
d77de738 | 33419 | @need 200 |
d77de738 | 33420 | @opindex mamx-tile |
ddf6fe37 | 33421 | @itemx -mamx-tile |
d77de738 | 33422 | @need 200 |
d77de738 | 33423 | @opindex mamx-int8 |
ddf6fe37 | 33424 | @itemx -mamx-int8 |
d77de738 | 33425 | @need 200 |
d77de738 | 33426 | @opindex mamx-bf16 |
ddf6fe37 | 33427 | @itemx -mamx-bf16 |
d77de738 | 33428 | @need 200 |
d77de738 | 33429 | @opindex mhreset |
d77de738 | 33430 | @opindex mkl |
ddf6fe37 AA |
33431 | @itemx -mhreset |
33432 | @itemx -mkl | |
d77de738 | 33433 | @need 200 |
d77de738 | 33434 | @opindex mwidekl |
ddf6fe37 | 33435 | @itemx -mwidekl |
d77de738 | 33436 | @need 200 |
d77de738 | 33437 | @opindex mavxifma |
ddf6fe37 | 33438 | @itemx -mavxifma |
d77de738 | 33439 | @need 200 |
d77de738 | 33440 | @opindex mavxvnniint8 |
ddf6fe37 | 33441 | @itemx -mavxvnniint8 |
d77de738 | 33442 | @need 200 |
d77de738 | 33443 | @opindex mavxneconvert |
ddf6fe37 | 33444 | @itemx -mavxneconvert |
d77de738 | 33445 | @need 200 |
d77de738 | 33446 | @opindex mcmpccxadd |
ddf6fe37 | 33447 | @itemx -mcmpccxadd |
d77de738 | 33448 | @need 200 |
d77de738 | 33449 | @opindex mamx-fp16 |
ddf6fe37 | 33450 | @itemx -mamx-fp16 |
d77de738 | 33451 | @need 200 |
d77de738 | 33452 | @opindex mprefetchi |
ddf6fe37 | 33453 | @itemx -mprefetchi |
d77de738 | 33454 | @need 200 |
d77de738 | 33455 | @opindex mraoint |
ddf6fe37 | 33456 | @itemx -mraoint |
efa6a82b HJ |
33457 | @need 200 |
33458 | @opindex mamx-complex | |
33459 | @itemx -mamx-complex | |
d77de738 ML |
33460 | These switches enable the use of instructions in the MMX, SSE, |
33461 | SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF, | |
33462 | AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, | |
33463 | AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG, | |
33464 | WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP, | |
33465 | 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, | |
33466 | XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, | |
33467 | GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, | |
33468 | ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE, | |
29ecb952 | 33469 | UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, |
efa6a82b HJ |
33470 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT, |
33471 | AMX-COMPLEX or CLDEMOTE extended instruction sets. Each has a corresponding | |
33472 | @option{-mno-} option to disable use of these instructions. | |
d77de738 ML |
33473 | |
33474 | These extensions are also available as built-in functions: see | |
33475 | @ref{x86 Built-in Functions}, for details of the functions enabled and | |
33476 | disabled by these switches. | |
33477 | ||
33478 | To generate SSE/SSE2 instructions automatically from floating-point | |
33479 | code (as opposed to 387 instructions), see @option{-mfpmath=sse}. | |
33480 | ||
33481 | GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it | |
33482 | generates new AVX instructions or AVX equivalence for all SSEx instructions | |
33483 | when needed. | |
33484 | ||
33485 | These options enable GCC to use these extended instructions in | |
33486 | generated code, even without @option{-mfpmath=sse}. Applications that | |
33487 | perform run-time CPU detection must compile separate files for each | |
33488 | supported architecture, using the appropriate flags. In particular, | |
33489 | the file containing the CPU detection code should be compiled without | |
33490 | these options. | |
33491 | ||
d77de738 | 33492 | @opindex mdump-tune-features |
ddf6fe37 | 33493 | @item -mdump-tune-features |
d77de738 ML |
33494 | This option instructs GCC to dump the names of the x86 performance |
33495 | tuning features and default settings. The names can be used in | |
33496 | @option{-mtune-ctrl=@var{feature-list}}. | |
33497 | ||
d77de738 | 33498 | @opindex mtune-ctrl=@var{feature-list} |
ddf6fe37 | 33499 | @item -mtune-ctrl=@var{feature-list} |
d77de738 ML |
33500 | This option is used to do fine grain control of x86 code generation features. |
33501 | @var{feature-list} is a comma separated list of @var{feature} names. See also | |
33502 | @option{-mdump-tune-features}. When specified, the @var{feature} is turned | |
33503 | on if it is not preceded with @samp{^}, otherwise, it is turned off. | |
33504 | @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC | |
33505 | developers. Using it may lead to code paths not covered by testing and can | |
33506 | potentially result in compiler ICEs or runtime errors. | |
33507 | ||
d77de738 | 33508 | @opindex mno-default |
ddf6fe37 | 33509 | @item -mno-default |
d77de738 ML |
33510 | This option instructs GCC to turn off all tunable features. See also |
33511 | @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}. | |
33512 | ||
d77de738 | 33513 | @opindex mcld |
ddf6fe37 | 33514 | @item -mcld |
d77de738 ML |
33515 | This option instructs GCC to emit a @code{cld} instruction in the prologue |
33516 | of functions that use string instructions. String instructions depend on | |
33517 | the DF flag to select between autoincrement or autodecrement mode. While the | |
33518 | ABI specifies the DF flag to be cleared on function entry, some operating | |
33519 | systems violate this specification by not clearing the DF flag in their | |
33520 | exception dispatchers. The exception handler can be invoked with the DF flag | |
33521 | set, which leads to wrong direction mode when string instructions are used. | |
33522 | This option can be enabled by default on 32-bit x86 targets by configuring | |
33523 | GCC with the @option{--enable-cld} configure option. Generation of @code{cld} | |
33524 | instructions can be suppressed with the @option{-mno-cld} compiler option | |
33525 | in this case. | |
33526 | ||
d77de738 | 33527 | @opindex mvzeroupper |
ddf6fe37 | 33528 | @item -mvzeroupper |
d77de738 ML |
33529 | This option instructs GCC to emit a @code{vzeroupper} instruction |
33530 | before a transfer of control flow out of the function to minimize | |
33531 | the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper} | |
33532 | intrinsics. | |
33533 | ||
d77de738 | 33534 | @opindex mprefer-avx128 |
ddf6fe37 | 33535 | @item -mprefer-avx128 |
d77de738 ML |
33536 | This option instructs GCC to use 128-bit AVX instructions instead of |
33537 | 256-bit AVX instructions in the auto-vectorizer. | |
33538 | ||
d77de738 | 33539 | @opindex mprefer-vector-width |
ddf6fe37 | 33540 | @item -mprefer-vector-width=@var{opt} |
d77de738 ML |
33541 | This option instructs GCC to use @var{opt}-bit vector width in instructions |
33542 | instead of default on the selected platform. | |
33543 | ||
d77de738 | 33544 | @opindex mmove-max |
ddf6fe37 | 33545 | @item -mmove-max=@var{bits} |
d77de738 ML |
33546 | This option instructs GCC to set the maximum number of bits can be |
33547 | moved from memory to memory efficiently to @var{bits}. The valid | |
33548 | @var{bits} are 128, 256 and 512. | |
33549 | ||
d77de738 | 33550 | @opindex mstore-max |
ddf6fe37 | 33551 | @item -mstore-max=@var{bits} |
d77de738 ML |
33552 | This option instructs GCC to set the maximum number of bits can be |
33553 | stored to memory efficiently to @var{bits}. The valid @var{bits} are | |
33554 | 128, 256 and 512. | |
33555 | ||
33556 | @table @samp | |
33557 | @item none | |
33558 | No extra limitations applied to GCC other than defined by the selected platform. | |
33559 | ||
33560 | @item 128 | |
33561 | Prefer 128-bit vector width for instructions. | |
33562 | ||
33563 | @item 256 | |
33564 | Prefer 256-bit vector width for instructions. | |
33565 | ||
33566 | @item 512 | |
33567 | Prefer 512-bit vector width for instructions. | |
33568 | @end table | |
33569 | ||
d77de738 | 33570 | @opindex mcx16 |
ddf6fe37 | 33571 | @item -mcx16 |
d77de738 ML |
33572 | This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit |
33573 | code to implement compare-and-exchange operations on 16-byte aligned 128-bit | |
33574 | objects. This is useful for atomic updates of data structures exceeding one | |
33575 | machine word in size. The compiler uses this instruction to implement | |
33576 | @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on | |
33577 | 128-bit integers, a library call is always used. | |
33578 | ||
d77de738 | 33579 | @opindex msahf |
ddf6fe37 | 33580 | @item -msahf |
d77de738 ML |
33581 | This option enables generation of @code{SAHF} instructions in 64-bit code. |
33582 | Early Intel Pentium 4 CPUs with Intel 64 support, | |
33583 | prior to the introduction of Pentium 4 G1 step in December 2005, | |
33584 | lacked the @code{LAHF} and @code{SAHF} instructions | |
33585 | which are supported by AMD64. | |
33586 | These are load and store instructions, respectively, for certain status flags. | |
33587 | In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod}, | |
33588 | @code{drem}, and @code{remainder} built-in functions; | |
33589 | see @ref{Other Builtins} for details. | |
33590 | ||
d77de738 | 33591 | @opindex mmovbe |
ddf6fe37 | 33592 | @item -mmovbe |
d77de738 ML |
33593 | This option enables use of the @code{movbe} instruction to implement |
33594 | @code{__builtin_bswap32} and @code{__builtin_bswap64}. | |
33595 | ||
d77de738 | 33596 | @opindex mshstk |
ddf6fe37 | 33597 | @item -mshstk |
d77de738 ML |
33598 | The @option{-mshstk} option enables shadow stack built-in functions |
33599 | from x86 Control-flow Enforcement Technology (CET). | |
33600 | ||
d77de738 | 33601 | @opindex mcrc32 |
ddf6fe37 | 33602 | @item -mcrc32 |
d77de738 ML |
33603 | This option enables built-in functions @code{__builtin_ia32_crc32qi}, |
33604 | @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and | |
33605 | @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction. | |
33606 | ||
d77de738 | 33607 | @opindex mmwait |
ddf6fe37 | 33608 | @item -mmwait |
d77de738 ML |
33609 | This option enables built-in functions @code{__builtin_ia32_monitor}, |
33610 | and @code{__builtin_ia32_mwait} to generate the @code{monitor} and | |
33611 | @code{mwait} machine instructions. | |
33612 | ||
d77de738 | 33613 | @opindex mrecip |
ddf6fe37 | 33614 | @item -mrecip |
d77de738 ML |
33615 | This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions |
33616 | (and their vectorized variants @code{RCPPS} and @code{RSQRTPS}) | |
33617 | with an additional Newton-Raphson step | |
33618 | to increase precision instead of @code{DIVSS} and @code{SQRTSS} | |
33619 | (and their vectorized | |
33620 | variants) for single-precision floating-point arguments. These instructions | |
33621 | are generated only when @option{-funsafe-math-optimizations} is enabled | |
33622 | together with @option{-ffinite-math-only} and @option{-fno-trapping-math}. | |
33623 | Note that while the throughput of the sequence is higher than the throughput | |
33624 | of the non-reciprocal instruction, the precision of the sequence can be | |
33625 | decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994). | |
33626 | ||
33627 | Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS} | |
33628 | (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option | |
33629 | combination), and doesn't need @option{-mrecip}. | |
33630 | ||
33631 | Also note that GCC emits the above sequence with additional Newton-Raphson step | |
33632 | for vectorized single-float division and vectorized @code{sqrtf(@var{x})} | |
33633 | already with @option{-ffast-math} (or the above option combination), and | |
33634 | doesn't need @option{-mrecip}. | |
33635 | ||
d77de738 | 33636 | @opindex mrecip=opt |
ddf6fe37 | 33637 | @item -mrecip=@var{opt} |
d77de738 ML |
33638 | This option controls which reciprocal estimate instructions |
33639 | may be used. @var{opt} is a comma-separated list of options, which may | |
33640 | be preceded by a @samp{!} to invert the option: | |
33641 | ||
33642 | @table @samp | |
33643 | @item all | |
33644 | Enable all estimate instructions. | |
33645 | ||
33646 | @item default | |
33647 | Enable the default instructions, equivalent to @option{-mrecip}. | |
33648 | ||
33649 | @item none | |
33650 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
33651 | ||
33652 | @item div | |
33653 | Enable the approximation for scalar division. | |
33654 | ||
33655 | @item vec-div | |
33656 | Enable the approximation for vectorized division. | |
33657 | ||
33658 | @item sqrt | |
33659 | Enable the approximation for scalar square root. | |
33660 | ||
33661 | @item vec-sqrt | |
33662 | Enable the approximation for vectorized square root. | |
33663 | @end table | |
33664 | ||
33665 | So, for example, @option{-mrecip=all,!sqrt} enables | |
33666 | all of the reciprocal approximations, except for square root. | |
33667 | ||
d77de738 | 33668 | @opindex mveclibabi |
ddf6fe37 | 33669 | @item -mveclibabi=@var{type} |
d77de738 ML |
33670 | Specifies the ABI type to use for vectorizing intrinsics using an |
33671 | external library. Supported values for @var{type} are @samp{svml} | |
33672 | for the Intel short | |
33673 | vector math library and @samp{acml} for the AMD math core library. | |
33674 | To use this option, both @option{-ftree-vectorize} and | |
33675 | @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML | |
33676 | ABI-compatible library must be specified at link time. | |
33677 | ||
33678 | GCC currently emits calls to @code{vmldExp2}, | |
33679 | @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2}, | |
33680 | @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2}, | |
33681 | @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2}, | |
33682 | @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2}, | |
33683 | @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4}, | |
33684 | @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4}, | |
33685 | @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4}, | |
33686 | @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4}, | |
33687 | @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding | |
33688 | function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin}, | |
33689 | @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2}, | |
33690 | @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf}, | |
33691 | @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f}, | |
33692 | @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type | |
33693 | when @option{-mveclibabi=acml} is used. | |
33694 | ||
d77de738 | 33695 | @opindex mabi |
ddf6fe37 | 33696 | @item -mabi=@var{name} |
d77de738 ML |
33697 | Generate code for the specified calling convention. Permissible values |
33698 | are @samp{sysv} for the ABI used on GNU/Linux and other systems, and | |
33699 | @samp{ms} for the Microsoft ABI. The default is to use the Microsoft | |
33700 | ABI when targeting Microsoft Windows and the SysV ABI on all other systems. | |
33701 | You can control this behavior for specific functions by | |
33702 | using the function attributes @code{ms_abi} and @code{sysv_abi}. | |
33703 | @xref{Function Attributes}. | |
33704 | ||
d77de738 | 33705 | @opindex mforce-indirect-call |
ddf6fe37 | 33706 | @item -mforce-indirect-call |
d77de738 ML |
33707 | Force all calls to functions to be indirect. This is useful |
33708 | when using Intel Processor Trace where it generates more precise timing | |
33709 | information for function calls. | |
33710 | ||
d77de738 | 33711 | @opindex mmanual-endbr |
ddf6fe37 | 33712 | @item -mmanual-endbr |
d77de738 ML |
33713 | Insert ENDBR instruction at function entry only via the @code{cf_check} |
33714 | function attribute. This is useful when used with the option | |
33715 | @option{-fcf-protection=branch} to control ENDBR insertion at the | |
33716 | function entry. | |
33717 | ||
d77de738 | 33718 | @opindex mcet-switch |
ddf6fe37 | 33719 | @item -mcet-switch |
d77de738 ML |
33720 | By default, CET instrumentation is turned off on switch statements that |
33721 | use a jump table and indirect branch track is disabled. Since jump | |
33722 | tables are stored in read-only memory, this does not result in a direct | |
33723 | loss of hardening. But if the jump table index is attacker-controlled, | |
33724 | the indirect jump may not be constrained by CET. This option turns on | |
33725 | CET instrumentation to enable indirect branch track for switch statements | |
33726 | with jump tables which leads to the jump targets reachable via any indirect | |
33727 | jumps. | |
33728 | ||
d77de738 ML |
33729 | @opindex mcall-ms2sysv-xlogues |
33730 | @opindex mno-call-ms2sysv-xlogues | |
ddf6fe37 | 33731 | @item -mcall-ms2sysv-xlogues |
d77de738 ML |
33732 | Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a |
33733 | System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By | |
33734 | default, the code for saving and restoring these registers is emitted inline, | |
33735 | resulting in fairly lengthy prologues and epilogues. Using | |
33736 | @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that | |
33737 | use stubs in the static portion of libgcc to perform these saves and restores, | |
33738 | thus reducing function size at the cost of a few extra instructions. | |
33739 | ||
d77de738 | 33740 | @opindex mtls-dialect |
ddf6fe37 | 33741 | @item -mtls-dialect=@var{type} |
d77de738 ML |
33742 | Generate code to access thread-local storage using the @samp{gnu} or |
33743 | @samp{gnu2} conventions. @samp{gnu} is the conservative default; | |
33744 | @samp{gnu2} is more efficient, but it may add compile- and run-time | |
33745 | requirements that cannot be satisfied on all systems. | |
33746 | ||
d77de738 ML |
33747 | @opindex mpush-args |
33748 | @opindex mno-push-args | |
ddf6fe37 AA |
33749 | @item -mpush-args |
33750 | @itemx -mno-push-args | |
d77de738 ML |
33751 | Use PUSH operations to store outgoing parameters. This method is shorter |
33752 | and usually equally fast as method using SUB/MOV operations and is enabled | |
33753 | by default. In some cases disabling it may improve performance because of | |
33754 | improved scheduling and reduced dependencies. | |
33755 | ||
d77de738 | 33756 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 33757 | @item -maccumulate-outgoing-args |
d77de738 ML |
33758 | If enabled, the maximum amount of space required for outgoing arguments is |
33759 | computed in the function prologue. This is faster on most modern CPUs | |
33760 | because of reduced dependencies, improved scheduling and reduced stack usage | |
33761 | when the preferred stack boundary is not equal to 2. The drawback is a notable | |
33762 | increase in code size. This switch implies @option{-mno-push-args}. | |
33763 | ||
d77de738 | 33764 | @opindex mthreads |
ddf6fe37 | 33765 | @item -mthreads |
d77de738 ML |
33766 | Support thread-safe exception handling on MinGW. Programs that rely |
33767 | on thread-safe exception handling must compile and link all code with the | |
33768 | @option{-mthreads} option. When compiling, @option{-mthreads} defines | |
33769 | @option{-D_MT}; when linking, it links in a special thread helper library | |
33770 | @option{-lmingwthrd} which cleans up per-thread exception-handling data. | |
33771 | ||
d77de738 ML |
33772 | @opindex mms-bitfields |
33773 | @opindex mno-ms-bitfields | |
ddf6fe37 AA |
33774 | @item -mms-bitfields |
33775 | @itemx -mno-ms-bitfields | |
d77de738 ML |
33776 | |
33777 | Enable/disable bit-field layout compatible with the native Microsoft | |
33778 | Windows compiler. | |
33779 | ||
33780 | If @code{packed} is used on a structure, or if bit-fields are used, | |
33781 | it may be that the Microsoft ABI lays out the structure differently | |
33782 | than the way GCC normally does. Particularly when moving packed | |
33783 | data between functions compiled with GCC and the native Microsoft compiler | |
33784 | (either via function call or as data in a file), it may be necessary to access | |
33785 | either format. | |
33786 | ||
33787 | This option is enabled by default for Microsoft Windows | |
33788 | targets. This behavior can also be controlled locally by use of variable | |
33789 | or type attributes. For more information, see @ref{x86 Variable Attributes} | |
33790 | and @ref{x86 Type Attributes}. | |
33791 | ||
33792 | The Microsoft structure layout algorithm is fairly simple with the exception | |
33793 | of the bit-field packing. | |
33794 | The padding and alignment of members of structures and whether a bit-field | |
33795 | can straddle a storage-unit boundary are determine by these rules: | |
33796 | ||
33797 | @enumerate | |
33798 | @item Structure members are stored sequentially in the order in which they are | |
33799 | declared: the first member has the lowest memory address and the last member | |
33800 | the highest. | |
33801 | ||
33802 | @item Every data object has an alignment requirement. The alignment requirement | |
33803 | for all data except structures, unions, and arrays is either the size of the | |
33804 | object or the current packing size (specified with either the | |
33805 | @code{aligned} attribute or the @code{pack} pragma), | |
33806 | whichever is less. For structures, unions, and arrays, | |
33807 | the alignment requirement is the largest alignment requirement of its members. | |
33808 | Every object is allocated an offset so that: | |
33809 | ||
33810 | @smallexample | |
33811 | offset % alignment_requirement == 0 | |
33812 | @end smallexample | |
33813 | ||
33814 | @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation | |
33815 | unit if the integral types are the same size and if the next bit-field fits | |
33816 | into the current allocation unit without crossing the boundary imposed by the | |
33817 | common alignment requirements of the bit-fields. | |
33818 | @end enumerate | |
33819 | ||
33820 | MSVC interprets zero-length bit-fields in the following ways: | |
33821 | ||
33822 | @enumerate | |
33823 | @item If a zero-length bit-field is inserted between two bit-fields that | |
33824 | are normally coalesced, the bit-fields are not coalesced. | |
33825 | ||
33826 | For example: | |
33827 | ||
33828 | @smallexample | |
33829 | struct | |
33830 | @{ | |
33831 | unsigned long bf_1 : 12; | |
33832 | unsigned long : 0; | |
33833 | unsigned long bf_2 : 12; | |
33834 | @} t1; | |
33835 | @end smallexample | |
33836 | ||
33837 | @noindent | |
33838 | The size of @code{t1} is 8 bytes with the zero-length bit-field. If the | |
33839 | zero-length bit-field were removed, @code{t1}'s size would be 4 bytes. | |
33840 | ||
33841 | @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the | |
33842 | alignment of the zero-length bit-field is greater than the member that follows it, | |
33843 | @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field. | |
33844 | ||
33845 | For example: | |
33846 | ||
33847 | @smallexample | |
33848 | struct | |
33849 | @{ | |
33850 | char foo : 4; | |
33851 | short : 0; | |
33852 | char bar; | |
33853 | @} t2; | |
33854 | ||
33855 | struct | |
33856 | @{ | |
33857 | char foo : 4; | |
33858 | short : 0; | |
33859 | double bar; | |
33860 | @} t3; | |
33861 | @end smallexample | |
33862 | ||
33863 | @noindent | |
33864 | For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1. | |
33865 | Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length | |
33866 | bit-field does not affect the alignment of @code{bar} or, as a result, the size | |
33867 | of the structure. | |
33868 | ||
33869 | Taking this into account, it is important to note the following: | |
33870 | ||
33871 | @enumerate | |
33872 | @item If a zero-length bit-field follows a normal bit-field, the type of the | |
33873 | zero-length bit-field may affect the alignment of the structure as whole. For | |
33874 | example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a | |
33875 | normal bit-field, and is of type short. | |
33876 | ||
33877 | @item Even if a zero-length bit-field is not followed by a normal bit-field, it may | |
33878 | still affect the alignment of the structure: | |
33879 | ||
33880 | @smallexample | |
33881 | struct | |
33882 | @{ | |
33883 | char foo : 6; | |
33884 | long : 0; | |
33885 | @} t4; | |
33886 | @end smallexample | |
33887 | ||
33888 | @noindent | |
33889 | Here, @code{t4} takes up 4 bytes. | |
33890 | @end enumerate | |
33891 | ||
33892 | @item Zero-length bit-fields following non-bit-field members are ignored: | |
33893 | ||
33894 | @smallexample | |
33895 | struct | |
33896 | @{ | |
33897 | char foo; | |
33898 | long : 0; | |
33899 | char bar; | |
33900 | @} t5; | |
33901 | @end smallexample | |
33902 | ||
33903 | @noindent | |
33904 | Here, @code{t5} takes up 2 bytes. | |
33905 | @end enumerate | |
33906 | ||
33907 | ||
d77de738 ML |
33908 | @opindex mno-align-stringops |
33909 | @opindex malign-stringops | |
ddf6fe37 | 33910 | @item -mno-align-stringops |
d77de738 ML |
33911 | Do not align the destination of inlined string operations. This switch reduces |
33912 | code size and improves performance in case the destination is already aligned, | |
33913 | but GCC doesn't know about it. | |
33914 | ||
d77de738 | 33915 | @opindex minline-all-stringops |
ddf6fe37 | 33916 | @item -minline-all-stringops |
d77de738 ML |
33917 | By default GCC inlines string operations only when the destination is |
33918 | known to be aligned to least a 4-byte boundary. | |
33919 | This enables more inlining and increases code | |
33920 | size, but may improve performance of code that depends on fast | |
33921 | @code{memcpy} and @code{memset} for short lengths. | |
33922 | The option enables inline expansion of @code{strlen} for all | |
33923 | pointer alignments. | |
33924 | ||
d77de738 | 33925 | @opindex minline-stringops-dynamically |
ddf6fe37 | 33926 | @item -minline-stringops-dynamically |
d77de738 ML |
33927 | For string operations of unknown size, use run-time checks with |
33928 | inline code for small blocks and a library call for large blocks. | |
33929 | ||
d77de738 | 33930 | @opindex mstringop-strategy=@var{alg} |
ddf6fe37 | 33931 | @item -mstringop-strategy=@var{alg} |
d77de738 ML |
33932 | Override the internal decision heuristic for the particular algorithm to use |
33933 | for inlining string operations. The allowed values for @var{alg} are: | |
33934 | ||
33935 | @table @samp | |
33936 | @item rep_byte | |
33937 | @itemx rep_4byte | |
33938 | @itemx rep_8byte | |
33939 | Expand using i386 @code{rep} prefix of the specified size. | |
33940 | ||
33941 | @item byte_loop | |
33942 | @itemx loop | |
33943 | @itemx unrolled_loop | |
33944 | Expand into an inline loop. | |
33945 | ||
33946 | @item libcall | |
33947 | Always use a library call. | |
33948 | @end table | |
33949 | ||
d77de738 | 33950 | @opindex mmemcpy-strategy=@var{strategy} |
ddf6fe37 | 33951 | @item -mmemcpy-strategy=@var{strategy} |
d77de738 ML |
33952 | Override the internal decision heuristic to decide if @code{__builtin_memcpy} |
33953 | should be inlined and what inline algorithm to use when the expected size | |
33954 | of the copy operation is known. @var{strategy} | |
33955 | is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets. | |
33956 | @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies | |
33957 | the max byte size with which inline algorithm @var{alg} is allowed. For the last | |
33958 | triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets | |
33959 | in the list must be specified in increasing order. The minimal byte size for | |
33960 | @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the | |
33961 | preceding range. | |
33962 | ||
d77de738 | 33963 | @opindex mmemset-strategy=@var{strategy} |
ddf6fe37 | 33964 | @item -mmemset-strategy=@var{strategy} |
d77de738 ML |
33965 | The option is similar to @option{-mmemcpy-strategy=} except that it is to control |
33966 | @code{__builtin_memset} expansion. | |
33967 | ||
d77de738 | 33968 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 33969 | @item -momit-leaf-frame-pointer |
d77de738 ML |
33970 | Don't keep the frame pointer in a register for leaf functions. This |
33971 | avoids the instructions to save, set up, and restore frame pointers and | |
33972 | makes an extra register available in leaf functions. The option | |
33973 | @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions, | |
33974 | which might make debugging harder. | |
33975 | ||
ddf6fe37 | 33976 | @opindex mtls-direct-seg-refs |
d77de738 ML |
33977 | @item -mtls-direct-seg-refs |
33978 | @itemx -mno-tls-direct-seg-refs | |
d77de738 ML |
33979 | Controls whether TLS variables may be accessed with offsets from the |
33980 | TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit), | |
33981 | or whether the thread base pointer must be added. Whether or not this | |
33982 | is valid depends on the operating system, and whether it maps the | |
33983 | segment to cover the entire TLS area. | |
33984 | ||
33985 | For systems that use the GNU C Library, the default is on. | |
33986 | ||
ddf6fe37 | 33987 | @opindex msse2avx |
d77de738 ML |
33988 | @item -msse2avx |
33989 | @itemx -mno-sse2avx | |
d77de738 ML |
33990 | Specify that the assembler should encode SSE instructions with VEX |
33991 | prefix. The option @option{-mavx} turns this on by default. | |
33992 | ||
ddf6fe37 | 33993 | @opindex mfentry |
d77de738 ML |
33994 | @item -mfentry |
33995 | @itemx -mno-fentry | |
d77de738 ML |
33996 | If profiling is active (@option{-pg}), put the profiling |
33997 | counter call before the prologue. | |
33998 | Note: On x86 architectures the attribute @code{ms_hook_prologue} | |
33999 | isn't possible at the moment for @option{-mfentry} and @option{-pg}. | |
34000 | ||
ddf6fe37 | 34001 | @opindex mrecord-mcount |
d77de738 ML |
34002 | @item -mrecord-mcount |
34003 | @itemx -mno-record-mcount | |
d77de738 ML |
34004 | If profiling is active (@option{-pg}), generate a __mcount_loc section |
34005 | that contains pointers to each profiling call. This is useful for | |
34006 | automatically patching and out calls. | |
34007 | ||
ddf6fe37 | 34008 | @opindex mnop-mcount |
d77de738 ML |
34009 | @item -mnop-mcount |
34010 | @itemx -mno-nop-mcount | |
d77de738 ML |
34011 | If profiling is active (@option{-pg}), generate the calls to |
34012 | the profiling functions as NOPs. This is useful when they | |
34013 | should be patched in later dynamically. This is likely only | |
34014 | useful together with @option{-mrecord-mcount}. | |
34015 | ||
d77de738 | 34016 | @opindex minstrument-return |
ddf6fe37 | 34017 | @item -minstrument-return=@var{type} |
d77de738 ML |
34018 | Instrument function exit in -pg -mfentry instrumented functions with |
34019 | call to specified function. This only instruments true returns ending | |
34020 | with ret, but not sibling calls ending with jump. Valid types | |
34021 | are @var{none} to not instrument, @var{call} to generate a call to __return__, | |
34022 | or @var{nop5} to generate a 5 byte nop. | |
34023 | ||
ddf6fe37 | 34024 | @opindex mrecord-return |
d77de738 ML |
34025 | @item -mrecord-return |
34026 | @itemx -mno-record-return | |
d77de738 ML |
34027 | Generate a __return_loc section pointing to all return instrumentation code. |
34028 | ||
d77de738 | 34029 | @opindex mfentry-name |
ddf6fe37 | 34030 | @item -mfentry-name=@var{name} |
d77de738 ML |
34031 | Set name of __fentry__ symbol called at function entry for -pg -mfentry functions. |
34032 | ||
d77de738 | 34033 | @opindex mfentry-section |
ddf6fe37 | 34034 | @item -mfentry-section=@var{name} |
d77de738 ML |
34035 | Set name of section to record -mrecord-mcount calls (default __mcount_loc). |
34036 | ||
ddf6fe37 | 34037 | @opindex mskip-rax-setup |
d77de738 ML |
34038 | @item -mskip-rax-setup |
34039 | @itemx -mno-skip-rax-setup | |
d77de738 ML |
34040 | When generating code for the x86-64 architecture with SSE extensions |
34041 | disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX | |
34042 | register when there are no variable arguments passed in vector registers. | |
34043 | ||
34044 | @strong{Warning:} Since RAX register is used to avoid unnecessarily | |
34045 | saving vector registers on stack when passing variable arguments, the | |
34046 | impacts of this option are callees may waste some stack space, | |
34047 | misbehave or jump to a random location. GCC 4.4 or newer don't have | |
34048 | those issues, regardless the RAX register value. | |
34049 | ||
ddf6fe37 | 34050 | @opindex m8bit-idiv |
d77de738 ML |
34051 | @item -m8bit-idiv |
34052 | @itemx -mno-8bit-idiv | |
d77de738 ML |
34053 | On some processors, like Intel Atom, 8-bit unsigned integer divide is |
34054 | much faster than 32-bit/64-bit integer divide. This option generates a | |
34055 | run-time check. If both dividend and divisor are within range of 0 | |
34056 | to 255, 8-bit unsigned integer divide is used instead of | |
34057 | 32-bit/64-bit integer divide. | |
34058 | ||
d77de738 ML |
34059 | @opindex mavx256-split-unaligned-load |
34060 | @opindex mavx256-split-unaligned-store | |
ddf6fe37 AA |
34061 | @item -mavx256-split-unaligned-load |
34062 | @itemx -mavx256-split-unaligned-store | |
d77de738 ML |
34063 | Split 32-byte AVX unaligned load and store. |
34064 | ||
d77de738 ML |
34065 | @opindex mstack-protector-guard |
34066 | @opindex mstack-protector-guard-reg | |
34067 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
34068 | @item -mstack-protector-guard=@var{guard} |
34069 | @itemx -mstack-protector-guard-reg=@var{reg} | |
34070 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
34071 | Generate stack protection code using canary at @var{guard}. Supported |
34072 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
34073 | canary in the TLS block (the default). This option has effect only when | |
34074 | @option{-fstack-protector} or @option{-fstack-protector-all} is specified. | |
34075 | ||
34076 | With the latter choice the options | |
34077 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
34078 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
34079 | which segment register (@code{%fs} or @code{%gs}) to use as base register | |
34080 | for reading the canary, and from what offset from that base register. | |
34081 | The default for those is as specified in the relevant ABI. | |
34082 | ||
d77de738 | 34083 | @opindex mgeneral-regs-only |
ddf6fe37 | 34084 | @item -mgeneral-regs-only |
d77de738 ML |
34085 | Generate code that uses only the general-purpose registers. This |
34086 | prevents the compiler from using floating-point, vector, mask and bound | |
34087 | registers. | |
34088 | ||
d77de738 | 34089 | @opindex mrelax-cmpxchg-loop |
ddf6fe37 | 34090 | @item -mrelax-cmpxchg-loop |
85966f0d AM |
34091 | When emitting a compare-and-swap loop for @ref{__sync Builtins} |
34092 | and @ref{__atomic Builtins} lacking a native instruction, optimize | |
34093 | for the highly contended case by issuing an atomic load before the | |
34094 | @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction | |
34095 | to save CPU power when restarting the loop. | |
d77de738 | 34096 | |
d77de738 | 34097 | @opindex mindirect-branch |
ddf6fe37 | 34098 | @item -mindirect-branch=@var{choice} |
d77de738 ML |
34099 | Convert indirect call and jump with @var{choice}. The default is |
34100 | @samp{keep}, which keeps indirect call and jump unmodified. | |
34101 | @samp{thunk} converts indirect call and jump to call and return thunk. | |
34102 | @samp{thunk-inline} converts indirect call and jump to inlined call | |
34103 | and return thunk. @samp{thunk-extern} converts indirect call and jump | |
34104 | to external call and return thunk provided in a separate object file. | |
34105 | You can control this behavior for a specific function by using the | |
34106 | function attribute @code{indirect_branch}. @xref{Function Attributes}. | |
34107 | ||
34108 | Note that @option{-mcmodel=large} is incompatible with | |
34109 | @option{-mindirect-branch=thunk} and | |
34110 | @option{-mindirect-branch=thunk-extern} since the thunk function may | |
34111 | not be reachable in the large code model. | |
34112 | ||
34113 | Note that @option{-mindirect-branch=thunk-extern} is compatible with | |
34114 | @option{-fcf-protection=branch} since the external thunk can be made | |
34115 | to enable control-flow check. | |
34116 | ||
d77de738 | 34117 | @opindex mfunction-return |
ddf6fe37 | 34118 | @item -mfunction-return=@var{choice} |
d77de738 ML |
34119 | Convert function return with @var{choice}. The default is @samp{keep}, |
34120 | which keeps function return unmodified. @samp{thunk} converts function | |
34121 | return to call and return thunk. @samp{thunk-inline} converts function | |
34122 | return to inlined call and return thunk. @samp{thunk-extern} converts | |
34123 | function return to external call and return thunk provided in a separate | |
34124 | object file. You can control this behavior for a specific function by | |
34125 | using the function attribute @code{function_return}. | |
34126 | @xref{Function Attributes}. | |
34127 | ||
34128 | Note that @option{-mindirect-return=thunk-extern} is compatible with | |
34129 | @option{-fcf-protection=branch} since the external thunk can be made | |
34130 | to enable control-flow check. | |
34131 | ||
34132 | Note that @option{-mcmodel=large} is incompatible with | |
34133 | @option{-mfunction-return=thunk} and | |
34134 | @option{-mfunction-return=thunk-extern} since the thunk function may | |
34135 | not be reachable in the large code model. | |
34136 | ||
34137 | ||
d77de738 | 34138 | @opindex mindirect-branch-register |
ddf6fe37 | 34139 | @item -mindirect-branch-register |
d77de738 ML |
34140 | Force indirect call and jump via register. |
34141 | ||
d77de738 | 34142 | @opindex mharden-sls |
ddf6fe37 | 34143 | @item -mharden-sls=@var{choice} |
d77de738 ML |
34144 | Generate code to mitigate against straight line speculation (SLS) with |
34145 | @var{choice}. The default is @samp{none} which disables all SLS | |
34146 | hardening. @samp{return} enables SLS hardening for function returns. | |
34147 | @samp{indirect-jmp} enables SLS hardening for indirect jumps. | |
34148 | @samp{all} enables all SLS hardening. | |
34149 | ||
d77de738 | 34150 | @opindex mindirect-branch-cs-prefix |
ddf6fe37 | 34151 | @item -mindirect-branch-cs-prefix |
d77de738 ML |
34152 | Add CS prefix to call and jmp to indirect thunk with branch target in |
34153 | r8-r15 registers so that the call and jmp instruction length is 6 bytes | |
34154 | to allow them to be replaced with @samp{lfence; call *%r8-r15} or | |
34155 | @samp{lfence; jmp *%r8-r15} at run-time. | |
34156 | ||
34157 | @end table | |
34158 | ||
34159 | These @samp{-m} switches are supported in addition to the above | |
34160 | on x86-64 processors in 64-bit environments. | |
34161 | ||
34162 | @table @gcctabopt | |
d77de738 ML |
34163 | @opindex m32 |
34164 | @opindex m64 | |
34165 | @opindex mx32 | |
34166 | @opindex m16 | |
34167 | @opindex miamcu | |
ddf6fe37 AA |
34168 | @item -m32 |
34169 | @itemx -m64 | |
34170 | @itemx -mx32 | |
34171 | @itemx -m16 | |
34172 | @itemx -miamcu | |
d77de738 ML |
34173 | Generate code for a 16-bit, 32-bit or 64-bit environment. |
34174 | The @option{-m32} option sets @code{int}, @code{long}, and pointer types | |
34175 | to 32 bits, and | |
eeb92704 | 34176 | generates code that runs in 32-bit mode. |
d77de738 ML |
34177 | |
34178 | The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer | |
34179 | types to 64 bits, and generates code for the x86-64 architecture. | |
34180 | For Darwin only the @option{-m64} option also turns off the @option{-fno-pic} | |
34181 | and @option{-mdynamic-no-pic} options. | |
34182 | ||
34183 | The @option{-mx32} option sets @code{int}, @code{long}, and pointer types | |
34184 | to 32 bits, and | |
34185 | generates code for the x86-64 architecture. | |
34186 | ||
34187 | The @option{-m16} option is the same as @option{-m32}, except for that | |
34188 | it outputs the @code{.code16gcc} assembly directive at the beginning of | |
34189 | the assembly output so that the binary can run in 16-bit mode. | |
34190 | ||
34191 | The @option{-miamcu} option generates code which conforms to Intel MCU | |
34192 | psABI. It requires the @option{-m32} option to be turned on. | |
34193 | ||
d77de738 ML |
34194 | @opindex mno-red-zone |
34195 | @opindex mred-zone | |
ddf6fe37 | 34196 | @item -mno-red-zone |
d77de738 ML |
34197 | Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated |
34198 | by the x86-64 ABI; it is a 128-byte area beyond the location of the | |
34199 | stack pointer that is not modified by signal or interrupt handlers | |
34200 | and therefore can be used for temporary data without adjusting the stack | |
34201 | pointer. The flag @option{-mno-red-zone} disables this red zone. | |
34202 | ||
d77de738 | 34203 | @opindex mcmodel=small |
ddf6fe37 | 34204 | @item -mcmodel=small |
d77de738 ML |
34205 | Generate code for the small code model: the program and its symbols must |
34206 | be linked in the lower 2 GB of the address space. Pointers are 64 bits. | |
34207 | Programs can be statically or dynamically linked. This is the default | |
34208 | code model. | |
34209 | ||
d77de738 | 34210 | @opindex mcmodel=kernel |
ddf6fe37 | 34211 | @item -mcmodel=kernel |
d77de738 ML |
34212 | Generate code for the kernel code model. The kernel runs in the |
34213 | negative 2 GB of the address space. | |
34214 | This model has to be used for Linux kernel code. | |
34215 | ||
d77de738 | 34216 | @opindex mcmodel=medium |
ddf6fe37 | 34217 | @item -mcmodel=medium |
d77de738 ML |
34218 | Generate code for the medium model: the program is linked in the lower 2 |
34219 | GB of the address space. Small symbols are also placed there. Symbols | |
34220 | with sizes larger than @option{-mlarge-data-threshold} are put into | |
34221 | large data or BSS sections and can be located above 2GB. Programs can | |
34222 | be statically or dynamically linked. | |
34223 | ||
d77de738 | 34224 | @opindex mcmodel=large |
ddf6fe37 | 34225 | @item -mcmodel=large |
d77de738 ML |
34226 | Generate code for the large model. This model makes no assumptions |
34227 | about addresses and sizes of sections. | |
34228 | ||
d77de738 | 34229 | @opindex maddress-mode=long |
ddf6fe37 | 34230 | @item -maddress-mode=long |
d77de738 ML |
34231 | Generate code for long address mode. This is only supported for 64-bit |
34232 | and x32 environments. It is the default address mode for 64-bit | |
34233 | environments. | |
34234 | ||
d77de738 | 34235 | @opindex maddress-mode=short |
ddf6fe37 | 34236 | @item -maddress-mode=short |
d77de738 ML |
34237 | Generate code for short address mode. This is only supported for 32-bit |
34238 | and x32 environments. It is the default address mode for 32-bit and | |
34239 | x32 environments. | |
34240 | ||
ddf6fe37 | 34241 | @opindex mneeded |
d77de738 ML |
34242 | @item -mneeded |
34243 | @itemx -mno-needed | |
d77de738 ML |
34244 | Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to |
34245 | indicate the micro-architecture ISA level required to execute the binary. | |
34246 | ||
d77de738 ML |
34247 | @opindex mno-direct-extern-access |
34248 | @opindex mdirect-extern-access | |
ddf6fe37 | 34249 | @item -mno-direct-extern-access |
d77de738 ML |
34250 | Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer |
34251 | to access external symbols. With @option{-fpic} or @option{-fPIC}, | |
34252 | treat access to protected symbols as local symbols. The default is | |
34253 | @option{-mdirect-extern-access}. | |
34254 | ||
34255 | @strong{Warning:} shared libraries compiled with | |
34256 | @option{-mno-direct-extern-access} and executable compiled with | |
34257 | @option{-mdirect-extern-access} may not be binary compatible if | |
34258 | protected symbols are used in shared libraries and executable. | |
ce51e843 | 34259 | |
ce51e843 ML |
34260 | @opindex munroll-only-small-loops |
34261 | @opindex mno-unroll-only-small-loops | |
ddf6fe37 | 34262 | @item -munroll-only-small-loops |
ce51e843 ML |
34263 | Controls conservative small loop unrolling. It is default enabled by |
34264 | O2, and unrolls loop with less than 4 insns by 1 time. Explicit | |
34265 | -f[no-]unroll-[all-]loops would disable this flag to avoid any | |
34266 | unintended unrolling behavior that user does not want. | |
bb576017 | 34267 | |
bb576017 | 34268 | @opindex mlam |
ddf6fe37 | 34269 | @item -mlam=@var{choice} |
bb576017 | 34270 | LAM(linear-address masking) allows special bits in the pointer to be used |
34271 | for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in | |
34272 | positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in | |
34273 | positions 62:57 can be used for metadata. | |
d77de738 ML |
34274 | @end table |
34275 | ||
34276 | @node x86 Windows Options | |
34277 | @subsection x86 Windows Options | |
34278 | @cindex x86 Windows Options | |
34279 | @cindex Windows Options for x86 | |
34280 | ||
34281 | These additional options are available for Microsoft Windows targets: | |
34282 | ||
34283 | @table @gcctabopt | |
d77de738 | 34284 | @opindex mconsole |
ddf6fe37 | 34285 | @item -mconsole |
d77de738 ML |
34286 | This option |
34287 | specifies that a console application is to be generated, by | |
34288 | instructing the linker to set the PE header subsystem type | |
34289 | required for console applications. | |
34290 | This option is available for Cygwin and MinGW targets and is | |
34291 | enabled by default on those targets. | |
34292 | ||
d77de738 | 34293 | @opindex mdll |
ddf6fe37 | 34294 | @item -mdll |
d77de738 ML |
34295 | This option is available for Cygwin and MinGW targets. It |
34296 | specifies that a DLL---a dynamic link library---is to be | |
34297 | generated, enabling the selection of the required runtime | |
34298 | startup object and entry point. | |
34299 | ||
d77de738 | 34300 | @opindex mnop-fun-dllimport |
ddf6fe37 | 34301 | @item -mnop-fun-dllimport |
d77de738 ML |
34302 | This option is available for Cygwin and MinGW targets. It |
34303 | specifies that the @code{dllimport} attribute should be ignored. | |
34304 | ||
d77de738 | 34305 | @opindex mthreads |
ddf6fe37 | 34306 | @item -mthreads |
d77de738 ML |
34307 | This option is available for MinGW targets. It specifies |
34308 | that MinGW-specific thread support is to be used. | |
34309 | ||
d77de738 | 34310 | @opindex municode |
ddf6fe37 | 34311 | @item -municode |
d77de738 ML |
34312 | This option is available for MinGW-w64 targets. It causes |
34313 | the @code{UNICODE} preprocessor macro to be predefined, and | |
34314 | chooses Unicode-capable runtime startup code. | |
34315 | ||
d77de738 | 34316 | @opindex mwin32 |
ddf6fe37 | 34317 | @item -mwin32 |
d77de738 ML |
34318 | This option is available for Cygwin and MinGW targets. It |
34319 | specifies that the typical Microsoft Windows predefined macros are to | |
34320 | be set in the pre-processor, but does not influence the choice | |
34321 | of runtime library/startup code. | |
34322 | ||
d77de738 | 34323 | @opindex mwindows |
ddf6fe37 | 34324 | @item -mwindows |
d77de738 ML |
34325 | This option is available for Cygwin and MinGW targets. It |
34326 | specifies that a GUI application is to be generated by | |
34327 | instructing the linker to set the PE header subsystem type | |
34328 | appropriately. | |
34329 | ||
d77de738 ML |
34330 | @opindex fno-set-stack-executable |
34331 | @opindex fset-stack-executable | |
ddf6fe37 | 34332 | @item -fno-set-stack-executable |
d77de738 ML |
34333 | This option is available for MinGW targets. It specifies that |
34334 | the executable flag for the stack used by nested functions isn't | |
34335 | set. This is necessary for binaries running in kernel mode of | |
34336 | Microsoft Windows, as there the User32 API, which is used to set executable | |
34337 | privileges, isn't available. | |
34338 | ||
d77de738 ML |
34339 | @opindex fno-writable-relocated-rdata |
34340 | @opindex fwritable-relocated-rdata | |
ddf6fe37 | 34341 | @item -fwritable-relocated-rdata |
d77de738 ML |
34342 | This option is available for MinGW and Cygwin targets. It specifies |
34343 | that relocated-data in read-only section is put into the @code{.data} | |
34344 | section. This is a necessary for older runtimes not supporting | |
34345 | modification of @code{.rdata} sections for pseudo-relocation. | |
34346 | ||
d77de738 | 34347 | @opindex mpe-aligned-commons |
ddf6fe37 | 34348 | @item -mpe-aligned-commons |
d77de738 ML |
34349 | This option is available for Cygwin and MinGW targets. It |
34350 | specifies that the GNU extension to the PE file format that | |
34351 | permits the correct alignment of COMMON variables should be | |
34352 | used when generating code. It is enabled by default if | |
34353 | GCC detects that the target assembler found during configuration | |
34354 | supports the feature. | |
34355 | @end table | |
34356 | ||
34357 | See also under @ref{x86 Options} for standard options. | |
34358 | ||
34359 | @node Xstormy16 Options | |
34360 | @subsection Xstormy16 Options | |
34361 | @cindex Xstormy16 Options | |
34362 | ||
34363 | These options are defined for Xstormy16: | |
34364 | ||
34365 | @table @gcctabopt | |
d77de738 | 34366 | @opindex msim |
ddf6fe37 | 34367 | @item -msim |
d77de738 ML |
34368 | Choose startup files and linker script suitable for the simulator. |
34369 | @end table | |
34370 | ||
34371 | @node Xtensa Options | |
34372 | @subsection Xtensa Options | |
34373 | @cindex Xtensa Options | |
34374 | ||
34375 | These options are supported for Xtensa targets: | |
34376 | ||
34377 | @table @gcctabopt | |
d77de738 ML |
34378 | @opindex mconst16 |
34379 | @opindex mno-const16 | |
ddf6fe37 AA |
34380 | @item -mconst16 |
34381 | @itemx -mno-const16 | |
d77de738 ML |
34382 | Enable or disable use of @code{CONST16} instructions for loading |
34383 | constant values. The @code{CONST16} instruction is currently not a | |
34384 | standard option from Tensilica. When enabled, @code{CONST16} | |
34385 | instructions are always used in place of the standard @code{L32R} | |
34386 | instructions. The use of @code{CONST16} is enabled by default only if | |
34387 | the @code{L32R} instruction is not available. | |
34388 | ||
d77de738 ML |
34389 | @opindex mfused-madd |
34390 | @opindex mno-fused-madd | |
ddf6fe37 AA |
34391 | @item -mfused-madd |
34392 | @itemx -mno-fused-madd | |
d77de738 ML |
34393 | Enable or disable use of fused multiply/add and multiply/subtract |
34394 | instructions in the floating-point option. This has no effect if the | |
34395 | floating-point option is not also enabled. Disabling fused multiply/add | |
34396 | and multiply/subtract instructions forces the compiler to use separate | |
34397 | instructions for the multiply and add/subtract operations. This may be | |
34398 | desirable in some cases where strict IEEE 754-compliant results are | |
34399 | required: the fused multiply add/subtract instructions do not round the | |
34400 | intermediate result, thereby producing results with @emph{more} bits of | |
34401 | precision than specified by the IEEE standard. Disabling fused multiply | |
34402 | add/subtract instructions also ensures that the program output is not | |
34403 | sensitive to the compiler's ability to combine multiply and add/subtract | |
34404 | operations. | |
34405 | ||
d77de738 ML |
34406 | @opindex mserialize-volatile |
34407 | @opindex mno-serialize-volatile | |
ddf6fe37 AA |
34408 | @item -mserialize-volatile |
34409 | @itemx -mno-serialize-volatile | |
d77de738 ML |
34410 | When this option is enabled, GCC inserts @code{MEMW} instructions before |
34411 | @code{volatile} memory references to guarantee sequential consistency. | |
34412 | The default is @option{-mserialize-volatile}. Use | |
34413 | @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions. | |
34414 | ||
d77de738 | 34415 | @opindex mforce-no-pic |
ddf6fe37 | 34416 | @item -mforce-no-pic |
d77de738 ML |
34417 | For targets, like GNU/Linux, where all user-mode Xtensa code must be |
34418 | position-independent code (PIC), this option disables PIC for compiling | |
34419 | kernel code. | |
34420 | ||
d77de738 ML |
34421 | @opindex mtext-section-literals |
34422 | @opindex mno-text-section-literals | |
ddf6fe37 AA |
34423 | @item -mtext-section-literals |
34424 | @itemx -mno-text-section-literals | |
d77de738 ML |
34425 | These options control the treatment of literal pools. The default is |
34426 | @option{-mno-text-section-literals}, which places literals in a separate | |
34427 | section in the output file. This allows the literal pool to be placed | |
34428 | in a data RAM/ROM, and it also allows the linker to combine literal | |
34429 | pools from separate object files to remove redundant literals and | |
34430 | improve code size. With @option{-mtext-section-literals}, the literals | |
34431 | are interspersed in the text section in order to keep them as close as | |
34432 | possible to their references. This may be necessary for large assembly | |
34433 | files. Literals for each function are placed right before that function. | |
34434 | ||
d77de738 ML |
34435 | @opindex mauto-litpools |
34436 | @opindex mno-auto-litpools | |
ddf6fe37 AA |
34437 | @item -mauto-litpools |
34438 | @itemx -mno-auto-litpools | |
d77de738 ML |
34439 | These options control the treatment of literal pools. The default is |
34440 | @option{-mno-auto-litpools}, which places literals in a separate | |
34441 | section in the output file unless @option{-mtext-section-literals} is | |
34442 | used. With @option{-mauto-litpools} the literals are interspersed in | |
34443 | the text section by the assembler. Compiler does not produce explicit | |
34444 | @code{.literal} directives and loads literals into registers with | |
34445 | @code{MOVI} instructions instead of @code{L32R} to let the assembler | |
34446 | do relaxation and place literals as necessary. This option allows | |
34447 | assembler to create several literal pools per function and assemble | |
34448 | very big functions, which may not be possible with | |
34449 | @option{-mtext-section-literals}. | |
34450 | ||
d77de738 ML |
34451 | @opindex mtarget-align |
34452 | @opindex mno-target-align | |
ddf6fe37 AA |
34453 | @item -mtarget-align |
34454 | @itemx -mno-target-align | |
d77de738 ML |
34455 | When this option is enabled, GCC instructs the assembler to |
34456 | automatically align instructions to reduce branch penalties at the | |
34457 | expense of some code density. The assembler attempts to widen density | |
34458 | instructions to align branch targets and the instructions following call | |
34459 | instructions. If there are not enough preceding safe density | |
34460 | instructions to align a target, no widening is performed. The | |
34461 | default is @option{-mtarget-align}. These options do not affect the | |
34462 | treatment of auto-aligned instructions like @code{LOOP}, which the | |
34463 | assembler always aligns, either by widening density instructions or | |
34464 | by inserting NOP instructions. | |
34465 | ||
d77de738 ML |
34466 | @opindex mlongcalls |
34467 | @opindex mno-longcalls | |
ddf6fe37 AA |
34468 | @item -mlongcalls |
34469 | @itemx -mno-longcalls | |
d77de738 ML |
34470 | When this option is enabled, GCC instructs the assembler to translate |
34471 | direct calls to indirect calls unless it can determine that the target | |
34472 | of a direct call is in the range allowed by the call instruction. This | |
34473 | translation typically occurs for calls to functions in other source | |
34474 | files. Specifically, the assembler translates a direct @code{CALL} | |
34475 | instruction into an @code{L32R} followed by a @code{CALLX} instruction. | |
34476 | The default is @option{-mno-longcalls}. This option should be used in | |
34477 | programs where the call target can potentially be out of range. This | |
34478 | option is implemented in the assembler, not the compiler, so the | |
34479 | assembly code generated by GCC still shows direct call | |
34480 | instructions---look at the disassembled object code to see the actual | |
34481 | instructions. Note that the assembler uses an indirect call for | |
34482 | every cross-file call, not just those that really are out of range. | |
34483 | ||
d77de738 | 34484 | @opindex mabi |
ddf6fe37 | 34485 | @item -mabi=@var{name} |
d77de738 ML |
34486 | Generate code for the specified ABI@. Permissible values are: @samp{call0}, |
34487 | @samp{windowed}. Default ABI is chosen by the Xtensa core configuration. | |
34488 | ||
d77de738 | 34489 | @opindex mabi=call0 |
ddf6fe37 | 34490 | @item -mabi=call0 |
d77de738 ML |
34491 | When this option is enabled function parameters are passed in registers |
34492 | @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are | |
34493 | caller-saved, and register @code{a15} may be used as a frame pointer. | |
34494 | When this version of the ABI is enabled the C preprocessor symbol | |
34495 | @code{__XTENSA_CALL0_ABI__} is defined. | |
34496 | ||
d77de738 | 34497 | @opindex mabi=windowed |
ddf6fe37 | 34498 | @item -mabi=windowed |
d77de738 ML |
34499 | When this option is enabled function parameters are passed in registers |
34500 | @code{a10} through @code{a15}, and called function rotates register window | |
34501 | by 8 registers on entry so that its arguments are found in registers | |
34502 | @code{a2} through @code{a7}. Register @code{a7} may be used as a frame | |
34503 | pointer. Register window is rotated 8 registers back upon return. | |
34504 | When this version of the ABI is enabled the C preprocessor symbol | |
34505 | @code{__XTENSA_WINDOWED_ABI__} is defined. | |
34506 | ||
d77de738 | 34507 | @opindex mextra-l32r-costs |
ddf6fe37 | 34508 | @item -mextra-l32r-costs=@var{n} |
d77de738 ML |
34509 | Specify an extra cost of instruction RAM/ROM access for @code{L32R} |
34510 | instructions, in clock cycles. This affects, when optimizing for speed, | |
34511 | whether loading a constant from literal pool using @code{L32R} or | |
34512 | synthesizing the constant from a small one with a couple of arithmetic | |
34513 | instructions. The default value is 0. | |
675b390e MF |
34514 | |
34515 | @opindex mstrict-align | |
34516 | @opindex mno-strict-align | |
34517 | @item -mstrict-align | |
34518 | @itemx -mno-strict-align | |
34519 | Avoid or allow generating memory accesses that may not be aligned on a natural | |
34520 | object boundary as described in the architecture specification. | |
34521 | The default is @option{-mno-strict-align} for cores that support both | |
34522 | unaligned loads and stores in hardware and @option{-mstrict-align} for all | |
34523 | other cores. | |
34524 | ||
d77de738 ML |
34525 | @end table |
34526 | ||
34527 | @node zSeries Options | |
34528 | @subsection zSeries Options | |
34529 | @cindex zSeries options | |
34530 | ||
34531 | These are listed under @xref{S/390 and zSeries Options}. | |
34532 | ||
34533 | ||
34534 | @c man end | |
34535 | ||
34536 | @node Spec Files | |
34537 | @section Specifying Subprocesses and the Switches to Pass to Them | |
34538 | @cindex Spec Files | |
34539 | ||
34540 | @command{gcc} is a driver program. It performs its job by invoking a | |
34541 | sequence of other programs to do the work of compiling, assembling and | |
34542 | linking. GCC interprets its command-line parameters and uses these to | |
34543 | deduce which programs it should invoke, and which command-line options | |
34544 | it ought to place on their command lines. This behavior is controlled | |
34545 | by @dfn{spec strings}. In most cases there is one spec string for each | |
34546 | program that GCC can invoke, but a few programs have multiple spec | |
34547 | strings to control their behavior. The spec strings built into GCC can | |
34548 | be overridden by using the @option{-specs=} command-line switch to specify | |
34549 | a spec file. | |
34550 | ||
34551 | @dfn{Spec files} are plain-text files that are used to construct spec | |
34552 | strings. They consist of a sequence of directives separated by blank | |
34553 | lines. The type of directive is determined by the first non-whitespace | |
34554 | character on the line, which can be one of the following: | |
34555 | ||
34556 | @table @code | |
34557 | @item %@var{command} | |
34558 | Issues a @var{command} to the spec file processor. The commands that can | |
34559 | appear here are: | |
34560 | ||
34561 | @table @code | |
d77de738 | 34562 | @cindex @code{%include} |
f33d7a88 | 34563 | @item %include <@var{file}> |
d77de738 ML |
34564 | Search for @var{file} and insert its text at the current point in the |
34565 | specs file. | |
34566 | ||
d77de738 | 34567 | @cindex @code{%include_noerr} |
f33d7a88 | 34568 | @item %include_noerr <@var{file}> |
d77de738 ML |
34569 | Just like @samp{%include}, but do not generate an error message if the include |
34570 | file cannot be found. | |
34571 | ||
d77de738 | 34572 | @cindex @code{%rename} |
f33d7a88 | 34573 | @item %rename @var{old_name} @var{new_name} |
d77de738 ML |
34574 | Rename the spec string @var{old_name} to @var{new_name}. |
34575 | ||
34576 | @end table | |
34577 | ||
34578 | @item *[@var{spec_name}]: | |
34579 | This tells the compiler to create, override or delete the named spec | |
34580 | string. All lines after this directive up to the next directive or | |
34581 | blank line are considered to be the text for the spec string. If this | |
34582 | results in an empty string then the spec is deleted. (Or, if the | |
34583 | spec did not exist, then nothing happens.) Otherwise, if the spec | |
34584 | does not currently exist a new spec is created. If the spec does | |
34585 | exist then its contents are overridden by the text of this | |
34586 | directive, unless the first character of that text is the @samp{+} | |
34587 | character, in which case the text is appended to the spec. | |
34588 | ||
34589 | @item [@var{suffix}]: | |
34590 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
34591 | and up to the next directive or blank line are considered to make up the | |
34592 | spec string for the indicated suffix. When the compiler encounters an | |
34593 | input file with the named suffix, it processes the spec string in | |
34594 | order to work out how to compile that file. For example: | |
34595 | ||
34596 | @smallexample | |
34597 | .ZZ: | |
34598 | z-compile -input %i | |
34599 | @end smallexample | |
34600 | ||
34601 | This says that any input file whose name ends in @samp{.ZZ} should be | |
34602 | passed to the program @samp{z-compile}, which should be invoked with the | |
34603 | command-line switch @option{-input} and with the result of performing the | |
34604 | @samp{%i} substitution. (See below.) | |
34605 | ||
34606 | As an alternative to providing a spec string, the text following a | |
34607 | suffix directive can be one of the following: | |
34608 | ||
34609 | @table @code | |
34610 | @item @@@var{language} | |
34611 | This says that the suffix is an alias for a known @var{language}. This is | |
34612 | similar to using the @option{-x} command-line switch to GCC to specify a | |
34613 | language explicitly. For example: | |
34614 | ||
34615 | @smallexample | |
34616 | .ZZ: | |
34617 | @@c++ | |
34618 | @end smallexample | |
34619 | ||
34620 | Says that .ZZ files are, in fact, C++ source files. | |
34621 | ||
34622 | @item #@var{name} | |
34623 | This causes an error messages saying: | |
34624 | ||
34625 | @smallexample | |
34626 | @var{name} compiler not installed on this system. | |
34627 | @end smallexample | |
34628 | @end table | |
34629 | ||
34630 | GCC already has an extensive list of suffixes built into it. | |
34631 | This directive adds an entry to the end of the list of suffixes, but | |
34632 | since the list is searched from the end backwards, it is effectively | |
34633 | possible to override earlier entries using this technique. | |
34634 | ||
34635 | @end table | |
34636 | ||
34637 | GCC has the following spec strings built into it. Spec files can | |
34638 | override these strings or create their own. Note that individual | |
34639 | targets can also add their own spec strings to this list. | |
34640 | ||
34641 | @smallexample | |
34642 | asm Options to pass to the assembler | |
34643 | asm_final Options to pass to the assembler post-processor | |
34644 | cpp Options to pass to the C preprocessor | |
34645 | cc1 Options to pass to the C compiler | |
34646 | cc1plus Options to pass to the C++ compiler | |
34647 | endfile Object files to include at the end of the link | |
34648 | link Options to pass to the linker | |
34649 | lib Libraries to include on the command line to the linker | |
34650 | libgcc Decides which GCC support library to pass to the linker | |
34651 | linker Sets the name of the linker | |
34652 | predefines Defines to be passed to the C preprocessor | |
34653 | signed_char Defines to pass to CPP to say whether @code{char} is signed | |
34654 | by default | |
34655 | startfile Object files to include at the start of the link | |
34656 | @end smallexample | |
34657 | ||
34658 | Here is a small example of a spec file: | |
34659 | ||
34660 | @smallexample | |
34661 | %rename lib old_lib | |
34662 | ||
34663 | *lib: | |
34664 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
34665 | @end smallexample | |
34666 | ||
34667 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
34668 | then overrides the previous definition of @samp{lib} with a new one. | |
34669 | The new definition adds in some extra command-line options before | |
34670 | including the text of the old definition. | |
34671 | ||
34672 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
34673 | corresponding program. In addition, the spec strings can contain | |
34674 | @samp{%}-prefixed sequences to substitute variable text or to | |
34675 | conditionally insert text into the command line. Using these constructs | |
34676 | it is possible to generate quite complex command lines. | |
34677 | ||
34678 | Here is a table of all defined @samp{%}-sequences for spec | |
34679 | strings. Note that spaces are not generated automatically around the | |
34680 | results of expanding these sequences. Therefore you can concatenate them | |
34681 | together or combine them with constant text in a single argument. | |
34682 | ||
34683 | @table @code | |
34684 | @item %% | |
34685 | Substitute one @samp{%} into the program name or argument. | |
34686 | ||
34687 | @item %" | |
34688 | Substitute an empty argument. | |
34689 | ||
34690 | @item %i | |
34691 | Substitute the name of the input file being processed. | |
34692 | ||
34693 | @item %b | |
34694 | Substitute the basename for outputs related with the input file being | |
34695 | processed. This is often the substring up to (and not including) the | |
34696 | last period and not including the directory but, unless %w is active, it | |
34697 | expands to the basename for auxiliary outputs, which may be influenced | |
34698 | by an explicit output name, and by various other options that control | |
34699 | how auxiliary outputs are named. | |
34700 | ||
34701 | @item %B | |
34702 | This is the same as @samp{%b}, but include the file suffix (text after | |
34703 | the last period). Without %w, it expands to the basename for dump | |
34704 | outputs. | |
34705 | ||
34706 | @item %d | |
34707 | Marks the argument containing or following the @samp{%d} as a | |
34708 | temporary file name, so that that file is deleted if GCC exits | |
34709 | successfully. Unlike @samp{%g}, this contributes no text to the | |
34710 | argument. | |
34711 | ||
34712 | @item %g@var{suffix} | |
34713 | Substitute a file name that has suffix @var{suffix} and is chosen | |
34714 | once per compilation, and mark the argument in the same way as | |
34715 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
34716 | name is now chosen in a way that is hard to predict even when previously | |
34717 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} | |
34718 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches | |
34719 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
34720 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
34721 | was simply substituted with a file name chosen once per compilation, | |
34722 | without regard to any appended suffix (which was therefore treated | |
34723 | just like ordinary text), making such attacks more likely to succeed. | |
34724 | ||
34725 | @item %u@var{suffix} | |
34726 | Like @samp{%g}, but generates a new temporary file name | |
34727 | each time it appears instead of once per compilation. | |
34728 | ||
34729 | @item %U@var{suffix} | |
34730 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
34731 | new one if there is no such last file name. In the absence of any | |
34732 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
34733 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} | |
34734 | involves the generation of two distinct file names, one | |
34735 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
34736 | simply substituted with a file name chosen for the previous @samp{%u}, | |
34737 | without regard to any appended suffix. | |
34738 | ||
34739 | @item %j@var{suffix} | |
34740 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is | |
34741 | writable, and if @option{-save-temps} is not used; | |
34742 | otherwise, substitute the name | |
34743 | of a temporary file, just like @samp{%u}. This temporary file is not | |
34744 | meant for communication between processes, but rather as a junk | |
34745 | disposal mechanism. | |
34746 | ||
34747 | @item %|@var{suffix} | |
34748 | @itemx %m@var{suffix} | |
34749 | Like @samp{%g}, except if @option{-pipe} is in effect. In that case | |
34750 | @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at | |
34751 | all. These are the two most common ways to instruct a program that it | |
34752 | should read from standard input or write to standard output. If you | |
34753 | need something more elaborate you can use an @samp{%@{pipe:@code{X}@}} | |
34754 | construct: see for example @file{gcc/fortran/lang-specs.h}. | |
34755 | ||
34756 | @item %.@var{SUFFIX} | |
34757 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
34758 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is | |
34759 | terminated by the next space or %. | |
34760 | ||
34761 | @item %w | |
34762 | Marks the argument containing or following the @samp{%w} as the | |
34763 | designated output file of this compilation. This puts the argument | |
34764 | into the sequence of arguments that @samp{%o} substitutes. | |
34765 | ||
34766 | @item %V | |
34767 | Indicates that this compilation produces no output file. | |
34768 | ||
34769 | @item %o | |
34770 | Substitutes the names of all the output files, with spaces | |
34771 | automatically placed around them. You should write spaces | |
34772 | around the @samp{%o} as well or the results are undefined. | |
34773 | @samp{%o} is for use in the specs for running the linker. | |
34774 | Input files whose names have no recognized suffix are not compiled | |
34775 | at all, but they are included among the output files, so they are | |
34776 | linked. | |
34777 | ||
34778 | @item %O | |
34779 | Substitutes the suffix for object files. Note that this is | |
34780 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
34781 | because of the need for those to form complete file names. The | |
34782 | handling is such that @samp{%O} is treated exactly as if it had already | |
34783 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
34784 | support additional @var{suffix} characters following @samp{%O} as they do | |
34785 | following, for example, @samp{.o}. | |
34786 | ||
34787 | @item %I | |
34788 | Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}), | |
34789 | @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), | |
34790 | @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options) | |
34791 | and @option{-imultilib} as necessary. | |
34792 | ||
34793 | @item %s | |
34794 | Current argument is the name of a library or startup file of some sort. | |
34795 | Search for that file in a standard list of directories and substitute | |
34796 | the full name found. The current working directory is included in the | |
34797 | list of directories scanned. | |
34798 | ||
34799 | @item %T | |
34800 | Current argument is the name of a linker script. Search for that file | |
34801 | in the current list of directories to scan for libraries. If the file | |
34802 | is located insert a @option{--script} option into the command line | |
34803 | followed by the full path name found. If the file is not found then | |
34804 | generate an error message. Note: the current working directory is not | |
34805 | searched. | |
34806 | ||
34807 | @item %e@var{str} | |
34808 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
34809 | Use this when inconsistent options are detected. | |
34810 | ||
34811 | @item %n@var{str} | |
34812 | Print @var{str} as a notice. @var{str} is terminated by a newline. | |
34813 | ||
34814 | @item %(@var{name}) | |
34815 | Substitute the contents of spec string @var{name} at this point. | |
34816 | ||
34817 | @item %x@{@var{option}@} | |
34818 | Accumulate an option for @samp{%X}. | |
34819 | ||
34820 | @item %X | |
34821 | Output the accumulated linker options specified by a @samp{%x} spec string. | |
34822 | ||
34823 | @item %Y | |
34824 | Output the accumulated assembler options specified by @option{-Wa}. | |
34825 | ||
34826 | @item %Z | |
34827 | Output the accumulated preprocessor options specified by @option{-Wp}. | |
34828 | ||
34829 | @item %M | |
34830 | Output @code{multilib_os_dir}. | |
34831 | ||
34832 | @item %R | |
34833 | Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}. | |
34834 | ||
34835 | @item %a | |
34836 | Process the @code{asm} spec. This is used to compute the | |
34837 | switches to be passed to the assembler. | |
34838 | ||
34839 | @item %A | |
34840 | Process the @code{asm_final} spec. This is a spec string for | |
34841 | passing switches to an assembler post-processor, if such a program is | |
34842 | needed. | |
34843 | ||
34844 | @item %l | |
34845 | Process the @code{link} spec. This is the spec for computing the | |
34846 | command line passed to the linker. Typically it makes use of the | |
34847 | @samp{%L %G %S %D and %E} sequences. | |
34848 | ||
34849 | @item %D | |
34850 | Dump out a @option{-L} option for each directory that GCC believes might | |
34851 | contain startup files. If the target supports multilibs then the | |
34852 | current multilib directory is prepended to each of these paths. | |
34853 | ||
34854 | @item %L | |
34855 | Process the @code{lib} spec. This is a spec string for deciding which | |
34856 | libraries are included on the command line to the linker. | |
34857 | ||
34858 | @item %G | |
34859 | Process the @code{libgcc} spec. This is a spec string for deciding | |
34860 | which GCC support library is included on the command line to the linker. | |
34861 | ||
34862 | @item %S | |
34863 | Process the @code{startfile} spec. This is a spec for deciding which | |
34864 | object files are the first ones passed to the linker. Typically | |
34865 | this might be a file named @file{crt0.o}. | |
34866 | ||
34867 | @item %E | |
34868 | Process the @code{endfile} spec. This is a spec string that specifies | |
34869 | the last object files that are passed to the linker. | |
34870 | ||
34871 | @item %C | |
34872 | Process the @code{cpp} spec. This is used to construct the arguments | |
34873 | to be passed to the C preprocessor. | |
34874 | ||
34875 | @item %1 | |
34876 | Process the @code{cc1} spec. This is used to construct the options to be | |
34877 | passed to the actual C compiler (@command{cc1}). | |
34878 | ||
34879 | @item %2 | |
34880 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
34881 | passed to the actual C++ compiler (@command{cc1plus}). | |
34882 | ||
34883 | @item %* | |
34884 | Substitute the variable part of a matched option. See below. | |
34885 | Note that each comma in the substituted string is replaced by | |
34886 | a single space. | |
34887 | ||
34888 | @item %<S | |
34889 | Remove all occurrences of @code{-S} from the command line. Note---this | |
34890 | command is position dependent. @samp{%} commands in the spec string | |
34891 | before this one see @code{-S}, @samp{%} commands in the spec string | |
34892 | after this one do not. | |
34893 | ||
34894 | @item %<S* | |
34895 | Similar to @samp{%<S}, but match all switches beginning with @code{-S}. | |
34896 | ||
34897 | @item %>S | |
34898 | Similar to @samp{%<S}, but keep @code{-S} in the GCC command line. | |
34899 | ||
34900 | @item %:@var{function}(@var{args}) | |
34901 | Call the named function @var{function}, passing it @var{args}. | |
34902 | @var{args} is first processed as a nested spec string, then split | |
34903 | into an argument vector in the usual fashion. The function returns | |
34904 | a string which is processed as if it had appeared literally as part | |
34905 | of the current spec. | |
34906 | ||
34907 | The following built-in spec functions are provided: | |
34908 | ||
34909 | @table @code | |
34910 | @item @code{getenv} | |
34911 | The @code{getenv} spec function takes two arguments: an environment | |
34912 | variable name and a string. If the environment variable is not | |
34913 | defined, a fatal error is issued. Otherwise, the return value is the | |
34914 | value of the environment variable concatenated with the string. For | |
34915 | example, if @env{TOPDIR} is defined as @file{/path/to/top}, then: | |
34916 | ||
34917 | @smallexample | |
34918 | %:getenv(TOPDIR /include) | |
34919 | @end smallexample | |
34920 | ||
34921 | expands to @file{/path/to/top/include}. | |
34922 | ||
34923 | @item @code{if-exists} | |
34924 | The @code{if-exists} spec function takes one argument, an absolute | |
34925 | pathname to a file. If the file exists, @code{if-exists} returns the | |
34926 | pathname. Here is a small example of its usage: | |
34927 | ||
34928 | @smallexample | |
34929 | *startfile: | |
34930 | crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s | |
34931 | @end smallexample | |
34932 | ||
34933 | @item @code{if-exists-else} | |
34934 | The @code{if-exists-else} spec function is similar to the @code{if-exists} | |
34935 | spec function, except that it takes two arguments. The first argument is | |
34936 | an absolute pathname to a file. If the file exists, @code{if-exists-else} | |
34937 | returns the pathname. If it does not exist, it returns the second argument. | |
34938 | This way, @code{if-exists-else} can be used to select one file or another, | |
34939 | based on the existence of the first. Here is a small example of its usage: | |
34940 | ||
34941 | @smallexample | |
34942 | *startfile: | |
34943 | crt0%O%s %:if-exists(crti%O%s) \ | |
34944 | %:if-exists-else(crtbeginT%O%s crtbegin%O%s) | |
34945 | @end smallexample | |
34946 | ||
34947 | @item @code{if-exists-then-else} | |
34948 | The @code{if-exists-then-else} spec function takes at least two arguments | |
34949 | and an optional third one. The first argument is an absolute pathname to a | |
34950 | file. If the file exists, the function returns the second argument. | |
34951 | If the file does not exist, the function returns the third argument if there | |
34952 | is one, or NULL otherwise. This can be used to expand one text, or optionally | |
34953 | another, based on the existence of a file. Here is a small example of its | |
34954 | usage: | |
34955 | ||
34956 | @smallexample | |
34957 | -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net) | |
34958 | @end smallexample | |
34959 | ||
34960 | @item @code{sanitize} | |
34961 | The @code{sanitize} spec function takes no arguments. It returns non-NULL if | |
34962 | any address, thread or undefined behavior sanitizers are active. | |
34963 | ||
34964 | @smallexample | |
34965 | %@{%:sanitize(address):-funwind-tables@} | |
34966 | @end smallexample | |
34967 | ||
34968 | @item @code{replace-outfile} | |
34969 | The @code{replace-outfile} spec function takes two arguments. It looks for the | |
34970 | first argument in the outfiles array and replaces it with the second argument. Here | |
34971 | is a small example of its usage: | |
34972 | ||
34973 | @smallexample | |
34974 | %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@} | |
34975 | @end smallexample | |
34976 | ||
34977 | @item @code{remove-outfile} | |
34978 | The @code{remove-outfile} spec function takes one argument. It looks for the | |
34979 | first argument in the outfiles array and removes it. Here is a small example | |
34980 | its usage: | |
34981 | ||
34982 | @smallexample | |
34983 | %:remove-outfile(-lm) | |
34984 | @end smallexample | |
34985 | ||
34986 | @item @code{version-compare} | |
34987 | The @code{version-compare} spec function takes four or five arguments of the following | |
34988 | form: | |
34989 | ||
34990 | @smallexample | |
34991 | <comparison-op> <arg1> [<arg2>] <switch> <result> | |
34992 | @end smallexample | |
34993 | ||
34994 | It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't. | |
34995 | The supported @code{comparison-op} values are: | |
34996 | ||
34997 | @table @code | |
34998 | @item >= | |
34999 | True if @code{switch} is a later (or same) version than @code{arg1} | |
35000 | ||
35001 | @item !> | |
35002 | Opposite of @code{>=} | |
35003 | ||
35004 | @item < | |
35005 | True if @code{switch} is an earlier version than @code{arg1} | |
35006 | ||
35007 | @item !< | |
35008 | Opposite of @code{<} | |
35009 | ||
35010 | @item >< | |
35011 | True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2} | |
35012 | ||
35013 | @item <> | |
35014 | True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later | |
35015 | @end table | |
35016 | ||
35017 | If the @code{switch} is not present at all, the condition is false unless the first character | |
35018 | of the @code{comparison-op} is @code{!}. | |
35019 | ||
35020 | @smallexample | |
35021 | %:version-compare(>= 10.3 mmacosx-version-min= -lmx) | |
35022 | @end smallexample | |
35023 | ||
35024 | The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was | |
35025 | passed. | |
35026 | ||
35027 | @item @code{include} | |
35028 | The @code{include} spec function behaves much like @code{%include}, with the advantage | |
35029 | that it can be nested inside a spec and thus be conditionalized. It takes one argument, | |
35030 | the filename, and looks for it in the startfile path. It always returns NULL. | |
35031 | ||
35032 | @smallexample | |
35033 | %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@} | |
35034 | @end smallexample | |
35035 | ||
35036 | @item @code{pass-through-libs} | |
35037 | The @code{pass-through-libs} spec function takes any number of arguments. It | |
35038 | finds any @option{-l} options and any non-options ending in @file{.a} (which it | |
35039 | assumes are the names of linker input library archive files) and returns a | |
35040 | result containing all the found arguments each prepended by | |
35041 | @option{-plugin-opt=-pass-through=} and joined by spaces. This list is | |
35042 | intended to be passed to the LTO linker plugin. | |
35043 | ||
35044 | @smallexample | |
35045 | %:pass-through-libs(%G %L %G) | |
35046 | @end smallexample | |
35047 | ||
35048 | @item @code{print-asm-header} | |
35049 | The @code{print-asm-header} function takes no arguments and simply | |
35050 | prints a banner like: | |
35051 | ||
35052 | @smallexample | |
35053 | Assembler options | |
35054 | ================= | |
35055 | ||
35056 | Use "-Wa,OPTION" to pass "OPTION" to the assembler. | |
35057 | @end smallexample | |
35058 | ||
35059 | It is used to separate compiler options from assembler options | |
35060 | in the @option{--target-help} output. | |
35061 | ||
35062 | @item @code{gt} | |
35063 | The @code{gt} spec function takes two or more arguments. It returns @code{""} (the | |
35064 | empty string) if the second-to-last argument is greater than the last argument, and NULL | |
35065 | otherwise. The following example inserts the @code{link_gomp} spec if the last | |
35066 | @option{-ftree-parallelize-loops=} option given on the command line is greater than 1: | |
35067 | ||
35068 | @smallexample | |
35069 | %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@} | |
35070 | @end smallexample | |
35071 | ||
35072 | @item @code{debug-level-gt} | |
35073 | The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the | |
35074 | empty string) if @code{debug_info_level} is greater than the specified number, and NULL | |
35075 | otherwise. | |
35076 | ||
35077 | @smallexample | |
35078 | %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@} | |
35079 | @end smallexample | |
35080 | @end table | |
35081 | ||
35082 | @item %@{S@} | |
35083 | Substitutes the @code{-S} switch, if that switch is given to GCC@. | |
35084 | If that switch is not specified, this substitutes nothing. Note that | |
35085 | the leading dash is omitted when specifying this option, and it is | |
35086 | automatically inserted if the substitution is performed. Thus the spec | |
35087 | string @samp{%@{foo@}} matches the command-line option @option{-foo} | |
35088 | and outputs the command-line option @option{-foo}. | |
35089 | ||
35090 | @item %W@{S@} | |
35091 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
35092 | deleted on failure. | |
35093 | ||
35094 | @item %@@@{S@} | |
35095 | Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes | |
35096 | @code{@@FILE} if an @code{@@file} argument has been supplied. | |
35097 | ||
35098 | @item %@{S*@} | |
35099 | Substitutes all the switches specified to GCC whose names start | |
35100 | with @code{-S}, but which also take an argument. This is used for | |
35101 | switches like @option{-o}, @option{-D}, @option{-I}, etc. | |
35102 | GCC considers @option{-o foo} as being | |
35103 | one switch whose name starts with @samp{o}. %@{o*@} substitutes this | |
35104 | text, including the space. Thus two arguments are generated. | |
35105 | ||
35106 | @item %@{S*&T*@} | |
35107 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
35108 | (the order of @code{S} and @code{T} in the spec is not significant). | |
35109 | There can be any number of ampersand-separated variables; for each the | |
35110 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
35111 | ||
35112 | @item %@{S:X@} | |
35113 | Substitutes @code{X}, if the @option{-S} switch is given to GCC@. | |
35114 | ||
35115 | @item %@{!S:X@} | |
35116 | Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@. | |
35117 | ||
35118 | @item %@{S*:X@} | |
35119 | Substitutes @code{X} if one or more switches whose names start with | |
35120 | @code{-S} are specified to GCC@. Normally @code{X} is substituted only | |
35121 | once, no matter how many such switches appeared. However, if @code{%*} | |
35122 | appears somewhere in @code{X}, then @code{X} is substituted once | |
35123 | for each matching switch, with the @code{%*} replaced by the part of | |
35124 | that switch matching the @code{*}. | |
35125 | ||
35126 | If @code{%*} appears as the last part of a spec sequence then a space | |
35127 | is added after the end of the last substitution. If there is more | |
35128 | text in the sequence, however, then a space is not generated. This | |
35129 | allows the @code{%*} substitution to be used as part of a larger | |
35130 | string. For example, a spec string like this: | |
35131 | ||
35132 | @smallexample | |
35133 | %@{mcu=*:--script=%*/memory.ld@} | |
35134 | @end smallexample | |
35135 | ||
35136 | @noindent | |
35137 | when matching an option like @option{-mcu=newchip} produces: | |
35138 | ||
35139 | @smallexample | |
35140 | --script=newchip/memory.ld | |
35141 | @end smallexample | |
35142 | ||
35143 | @item %@{.S:X@} | |
35144 | Substitutes @code{X}, if processing a file with suffix @code{S}. | |
35145 | ||
35146 | @item %@{!.S:X@} | |
35147 | Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}. | |
35148 | ||
35149 | @item %@{,S:X@} | |
35150 | Substitutes @code{X}, if processing a file for language @code{S}. | |
35151 | ||
35152 | @item %@{!,S:X@} | |
35153 | Substitutes @code{X}, if not processing a file for language @code{S}. | |
35154 | ||
35155 | @item %@{S|P:X@} | |
35156 | Substitutes @code{X} if either @code{-S} or @code{-P} is given to | |
35157 | GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and | |
35158 | @code{*} sequences as well, although they have a stronger binding than | |
35159 | the @samp{|}. If @code{%*} appears in @code{X}, all of the | |
35160 | alternatives must be starred, and only the first matching alternative | |
35161 | is substituted. | |
35162 | ||
35163 | For example, a spec string like this: | |
35164 | ||
35165 | @smallexample | |
35166 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
35167 | @end smallexample | |
35168 | ||
35169 | @noindent | |
35170 | outputs the following command-line options from the following input | |
35171 | command-line options: | |
35172 | ||
35173 | @smallexample | |
35174 | fred.c -foo -baz | |
35175 | jim.d -bar -boggle | |
35176 | -d fred.c -foo -baz -boggle | |
35177 | -d jim.d -bar -baz -boggle | |
35178 | @end smallexample | |
35179 | ||
35180 | @item %@{%:@var{function}(@var{args}):X@} | |
35181 | ||
35182 | Call function named @var{function} with args @var{args}. If the | |
35183 | function returns non-NULL, then @code{X} is substituted, if it returns | |
35184 | NULL, it isn't substituted. | |
35185 | ||
35186 | @item %@{S:X; T:Y; :D@} | |
35187 | ||
35188 | If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is | |
35189 | given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can | |
35190 | be as many clauses as you need. This may be combined with @code{.}, | |
35191 | @code{,}, @code{!}, @code{|}, and @code{*} as needed. | |
35192 | ||
35193 | ||
35194 | @end table | |
35195 | ||
35196 | The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}} | |
35197 | or similar construct can use a backslash to ignore the special meaning | |
35198 | of the character following it, thus allowing literal matching of a | |
35199 | character that is otherwise specially treated. For example, | |
35200 | @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the | |
35201 | @option{-std=iso9899:1999} option is given. | |
35202 | ||
35203 | The conditional text @code{X} in a @samp{%@{S:X@}} or similar | |
35204 | construct may contain other nested @samp{%} constructs or spaces, or | |
35205 | even newlines. They are processed as usual, as described above. | |
35206 | Trailing white space in @code{X} is ignored. White space may also | |
35207 | appear anywhere on the left side of the colon in these constructs, | |
35208 | except between @code{.} or @code{*} and the corresponding word. | |
35209 | ||
35210 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are | |
35211 | handled specifically in these constructs. If another value of | |
35212 | @option{-O} or the negated form of a @option{-f}, @option{-m}, or | |
35213 | @option{-W} switch is found later in the command line, the earlier | |
35214 | switch value is ignored, except with @{@code{S}*@} where @code{S} is | |
35215 | just one letter, which passes all matching options. | |
35216 | ||
35217 | The character @samp{|} at the beginning of the predicate text is used to | |
35218 | indicate that a command should be piped to the following command, but | |
35219 | only if @option{-pipe} is specified. | |
35220 | ||
35221 | It is built into GCC which switches take arguments and which do not. | |
35222 | (You might think it would be useful to generalize this to allow each | |
35223 | compiler's spec to say which switches take arguments. But this cannot | |
35224 | be done in a consistent fashion. GCC cannot even decide which input | |
35225 | files have been specified without knowing which switches take arguments, | |
35226 | and it must know which input files to compile in order to tell which | |
35227 | compilers to run). | |
35228 | ||
35229 | GCC also knows implicitly that arguments starting in @option{-l} are to be | |
35230 | treated as compiler output files, and passed to the linker in their | |
35231 | proper position among the other output files. | |
35232 | ||
35233 | @node Environment Variables | |
35234 | @section Environment Variables Affecting GCC | |
35235 | @cindex environment variables | |
35236 | ||
35237 | @c man begin ENVIRONMENT | |
35238 | This section describes several environment variables that affect how GCC | |
35239 | operates. Some of them work by specifying directories or prefixes to use | |
35240 | when searching for various kinds of files. Some are used to specify other | |
35241 | aspects of the compilation environment. | |
35242 | ||
35243 | Note that you can also specify places to search using options such as | |
35244 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These | |
35245 | take precedence over places specified using environment variables, which | |
35246 | in turn take precedence over those specified by the configuration of GCC@. | |
35247 | @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, | |
35248 | GNU Compiler Collection (GCC) Internals}. | |
35249 | ||
35250 | @table @env | |
f33d7a88 AA |
35251 | @vindex LANG |
35252 | @vindex LC_CTYPE | |
35253 | @c @vindex LC_COLLATE | |
35254 | @vindex LC_MESSAGES | |
35255 | @c @vindex LC_MONETARY | |
35256 | @c @vindex LC_NUMERIC | |
35257 | @c @vindex LC_TIME | |
35258 | @vindex LC_ALL | |
35259 | @cindex locale | |
d77de738 ML |
35260 | @item LANG |
35261 | @itemx LC_CTYPE | |
35262 | @c @itemx LC_COLLATE | |
35263 | @itemx LC_MESSAGES | |
35264 | @c @itemx LC_MONETARY | |
35265 | @c @itemx LC_NUMERIC | |
35266 | @c @itemx LC_TIME | |
35267 | @itemx LC_ALL | |
d77de738 ML |
35268 | These environment variables control the way that GCC uses |
35269 | localization information which allows GCC to work with different | |
35270 | national conventions. GCC inspects the locale categories | |
35271 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do | |
35272 | so. These locale categories can be set to any value supported by your | |
35273 | installation. A typical value is @samp{en_GB.UTF-8} for English in the United | |
35274 | Kingdom encoded in UTF-8. | |
35275 | ||
35276 | The @env{LC_CTYPE} environment variable specifies character | |
35277 | classification. GCC uses it to determine the character boundaries in | |
35278 | a string; this is needed for some multibyte encodings that contain quote | |
35279 | and escape characters that are otherwise interpreted as a string | |
35280 | end or escape. | |
35281 | ||
35282 | The @env{LC_MESSAGES} environment variable specifies the language to | |
35283 | use in diagnostic messages. | |
35284 | ||
35285 | If the @env{LC_ALL} environment variable is set, it overrides the value | |
35286 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
35287 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
35288 | environment variable. If none of these variables are set, GCC | |
35289 | defaults to traditional C English behavior. | |
35290 | ||
f33d7a88 | 35291 | @vindex TMPDIR |
d77de738 | 35292 | @item TMPDIR |
d77de738 ML |
35293 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
35294 | files. GCC uses temporary files to hold the output of one stage of | |
35295 | compilation which is to be used as input to the next stage: for example, | |
35296 | the output of the preprocessor, which is the input to the compiler | |
35297 | proper. | |
35298 | ||
f33d7a88 | 35299 | @vindex GCC_COMPARE_DEBUG |
d77de738 | 35300 | @item GCC_COMPARE_DEBUG |
d77de738 ML |
35301 | Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing |
35302 | @option{-fcompare-debug} to the compiler driver. See the documentation | |
35303 | of this option for more details. | |
35304 | ||
f33d7a88 | 35305 | @vindex GCC_EXEC_PREFIX |
d77de738 | 35306 | @item GCC_EXEC_PREFIX |
d77de738 ML |
35307 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
35308 | names of the subprograms executed by the compiler. No slash is added | |
35309 | when this prefix is combined with the name of a subprogram, but you can | |
35310 | specify a prefix that ends with a slash if you wish. | |
35311 | ||
35312 | If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out | |
35313 | an appropriate prefix to use based on the pathname it is invoked with. | |
35314 | ||
35315 | If GCC cannot find the subprogram using the specified prefix, it | |
35316 | tries looking in the usual places for the subprogram. | |
35317 | ||
35318 | The default value of @env{GCC_EXEC_PREFIX} is | |
35319 | @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to | |
35320 | the installed compiler. In many cases @var{prefix} is the value | |
35321 | of @code{prefix} when you ran the @file{configure} script. | |
35322 | ||
35323 | Other prefixes specified with @option{-B} take precedence over this prefix. | |
35324 | ||
35325 | This prefix is also used for finding files such as @file{crt0.o} that are | |
35326 | used for linking. | |
35327 | ||
35328 | In addition, the prefix is used in an unusual way in finding the | |
35329 | directories to search for header files. For each of the standard | |
35330 | directories whose name normally begins with @samp{/usr/local/lib/gcc} | |
35331 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries | |
35332 | replacing that beginning with the specified prefix to produce an | |
35333 | alternate directory name. Thus, with @option{-Bfoo/}, GCC searches | |
35334 | @file{foo/bar} just before it searches the standard directory | |
35335 | @file{/usr/local/lib/bar}. | |
35336 | If a standard directory begins with the configured | |
35337 | @var{prefix} then the value of @var{prefix} is replaced by | |
35338 | @env{GCC_EXEC_PREFIX} when looking for header files. | |
35339 | ||
f33d7a88 | 35340 | @vindex COMPILER_PATH |
d77de738 | 35341 | @item COMPILER_PATH |
d77de738 ML |
35342 | The value of @env{COMPILER_PATH} is a colon-separated list of |
35343 | directories, much like @env{PATH}. GCC tries the directories thus | |
35344 | specified when searching for subprograms, if it cannot find the | |
35345 | subprograms using @env{GCC_EXEC_PREFIX}. | |
35346 | ||
f33d7a88 | 35347 | @vindex LIBRARY_PATH |
d77de738 | 35348 | @item LIBRARY_PATH |
d77de738 ML |
35349 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
35350 | directories, much like @env{PATH}. When configured as a native compiler, | |
35351 | GCC tries the directories thus specified when searching for special | |
35352 | linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking | |
35353 | using GCC also uses these directories when searching for ordinary | |
35354 | libraries for the @option{-l} option (but directories specified with | |
35355 | @option{-L} come first). | |
35356 | ||
f33d7a88 | 35357 | @vindex LANG |
d77de738 | 35358 | @cindex locale definition |
f33d7a88 | 35359 | @item LANG |
d77de738 ML |
35360 | This variable is used to pass locale information to the compiler. One way in |
35361 | which this information is used is to determine the character set to be used | |
35362 | when character literals, string literals and comments are parsed in C and C++. | |
35363 | When the compiler is configured to allow multibyte characters, | |
35364 | the following values for @env{LANG} are recognized: | |
35365 | ||
35366 | @table @samp | |
35367 | @item C-JIS | |
35368 | Recognize JIS characters. | |
35369 | @item C-SJIS | |
35370 | Recognize SJIS characters. | |
35371 | @item C-EUCJP | |
35372 | Recognize EUCJP characters. | |
35373 | @end table | |
35374 | ||
35375 | If @env{LANG} is not defined, or if it has some other value, then the | |
35376 | compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to | |
35377 | recognize and translate multibyte characters. | |
35378 | ||
f33d7a88 | 35379 | @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 | 35380 | @item GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 ML |
35381 | If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values, |
35382 | then additional text will be emitted to stderr when fix-it hints are | |
35383 | emitted. @option{-fdiagnostics-parseable-fixits} and | |
35384 | @option{-fno-diagnostics-parseable-fixits} take precedence over this | |
35385 | environment variable. | |
35386 | ||
35387 | @table @samp | |
35388 | @item fixits-v1 | |
35389 | Emit parseable fix-it hints, equivalent to | |
35390 | @option{-fdiagnostics-parseable-fixits}. In particular, columns are | |
35391 | expressed as a count of bytes, starting at byte 1 for the initial column. | |
35392 | ||
35393 | @item fixits-v2 | |
35394 | As @code{fixits-v1}, but columns are expressed as display columns, | |
35395 | as per @option{-fdiagnostics-column-unit=display}. | |
35396 | @end table | |
35397 | ||
35398 | @end table | |
35399 | ||
35400 | @noindent | |
35401 | Some additional environment variables affect the behavior of the | |
35402 | preprocessor. | |
35403 | ||
35404 | @include cppenv.texi | |
35405 | ||
35406 | @c man end | |
35407 | ||
35408 | @node Precompiled Headers | |
35409 | @section Using Precompiled Headers | |
35410 | @cindex precompiled headers | |
35411 | @cindex speed of compilation | |
35412 | ||
35413 | Often large projects have many header files that are included in every | |
35414 | source file. The time the compiler takes to process these header files | |
35415 | over and over again can account for nearly all of the time required to | |
35416 | build the project. To make builds faster, GCC allows you to | |
35417 | @dfn{precompile} a header file. | |
35418 | ||
35419 | To create a precompiled header file, simply compile it as you would any | |
35420 | other file, if necessary using the @option{-x} option to make the driver | |
35421 | treat it as a C or C++ header file. You may want to use a | |
35422 | tool like @command{make} to keep the precompiled header up-to-date when | |
35423 | the headers it contains change. | |
35424 | ||
35425 | A precompiled header file is searched for when @code{#include} is | |
35426 | seen in the compilation. As it searches for the included file | |
35427 | (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the | |
35428 | compiler looks for a precompiled header in each directory just before it | |
35429 | looks for the include file in that directory. The name searched for is | |
35430 | the name specified in the @code{#include} with @samp{.gch} appended. If | |
35431 | the precompiled header file cannot be used, it is ignored. | |
35432 | ||
35433 | For instance, if you have @code{#include "all.h"}, and you have | |
35434 | @file{all.h.gch} in the same directory as @file{all.h}, then the | |
35435 | precompiled header file is used if possible, and the original | |
35436 | header is used otherwise. | |
35437 | ||
35438 | Alternatively, you might decide to put the precompiled header file in a | |
35439 | directory and use @option{-I} to ensure that directory is searched | |
35440 | before (or instead of) the directory containing the original header. | |
35441 | Then, if you want to check that the precompiled header file is always | |
35442 | used, you can put a file of the same name as the original header in this | |
35443 | directory containing an @code{#error} command. | |
35444 | ||
35445 | This also works with @option{-include}. So yet another way to use | |
35446 | precompiled headers, good for projects not designed with precompiled | |
35447 | header files in mind, is to simply take most of the header files used by | |
35448 | a project, include them from another header file, precompile that header | |
35449 | file, and @option{-include} the precompiled header. If the header files | |
35450 | have guards against multiple inclusion, they are skipped because | |
35451 | they've already been included (in the precompiled header). | |
35452 | ||
35453 | If you need to precompile the same header file for different | |
35454 | languages, targets, or compiler options, you can instead make a | |
35455 | @emph{directory} named like @file{all.h.gch}, and put each precompiled | |
35456 | header in the directory, perhaps using @option{-o}. It doesn't matter | |
35457 | what you call the files in the directory; every precompiled header in | |
35458 | the directory is considered. The first precompiled header | |
35459 | encountered in the directory that is valid for this compilation is | |
35460 | used; they're searched in no particular order. | |
35461 | ||
35462 | There are many other possibilities, limited only by your imagination, | |
35463 | good sense, and the constraints of your build system. | |
35464 | ||
35465 | A precompiled header file can be used only when these conditions apply: | |
35466 | ||
35467 | @itemize | |
35468 | @item | |
35469 | Only one precompiled header can be used in a particular compilation. | |
35470 | ||
35471 | @item | |
35472 | A precompiled header cannot be used once the first C token is seen. You | |
35473 | can have preprocessor directives before a precompiled header; you cannot | |
35474 | include a precompiled header from inside another header. | |
35475 | ||
35476 | @item | |
35477 | The precompiled header file must be produced for the same language as | |
35478 | the current compilation. You cannot use a C precompiled header for a C++ | |
35479 | compilation. | |
35480 | ||
35481 | @item | |
35482 | The precompiled header file must have been produced by the same compiler | |
35483 | binary as the current compilation is using. | |
35484 | ||
35485 | @item | |
35486 | Any macros defined before the precompiled header is included must | |
35487 | either be defined in the same way as when the precompiled header was | |
35488 | generated, or must not affect the precompiled header, which usually | |
35489 | means that they don't appear in the precompiled header at all. | |
35490 | ||
35491 | The @option{-D} option is one way to define a macro before a | |
35492 | precompiled header is included; using a @code{#define} can also do it. | |
35493 | There are also some options that define macros implicitly, like | |
35494 | @option{-O} and @option{-Wdeprecated}; the same rule applies to macros | |
35495 | defined this way. | |
35496 | ||
35497 | @item If debugging information is output when using the precompiled | |
35498 | header, using @option{-g} or similar, the same kind of debugging information | |
35499 | must have been output when building the precompiled header. However, | |
35500 | a precompiled header built using @option{-g} can be used in a compilation | |
35501 | when no debugging information is being output. | |
35502 | ||
35503 | @item The same @option{-m} options must generally be used when building | |
35504 | and using the precompiled header. @xref{Submodel Options}, | |
35505 | for any cases where this rule is relaxed. | |
35506 | ||
35507 | @item Each of the following options must be the same when building and using | |
35508 | the precompiled header: | |
35509 | ||
35510 | @gccoptlist{-fexceptions} | |
35511 | ||
35512 | @item | |
35513 | Some other command-line options starting with @option{-f}, | |
35514 | @option{-p}, or @option{-O} must be defined in the same way as when | |
35515 | the precompiled header was generated. At present, it's not clear | |
35516 | which options are safe to change and which are not; the safest choice | |
35517 | is to use exactly the same options when generating and using the | |
35518 | precompiled header. The following are known to be safe: | |
35519 | ||
43b72ede AA |
35520 | @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock |
35521 | -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous | |
35522 | -fsched-verbose=@var{number} -fschedule-insns -fvisibility= | |
d77de738 ML |
35523 | -pedantic-errors} |
35524 | ||
35525 | @item Address space layout randomization (ASLR) can lead to not binary identical | |
35526 | PCH files. If you rely on stable PCH file contents disable ASLR when generating | |
35527 | PCH files. | |
35528 | ||
35529 | @end itemize | |
35530 | ||
35531 | For all of these except the last, the compiler automatically | |
35532 | ignores the precompiled header if the conditions aren't met. If you | |
35533 | find an option combination that doesn't work and doesn't cause the | |
35534 | precompiled header to be ignored, please consider filing a bug report, | |
35535 | see @ref{Bugs}. | |
35536 | ||
35537 | If you do use differing options when generating and using the | |
35538 | precompiled header, the actual behavior is a mixture of the | |
35539 | behavior for the options. For instance, if you use @option{-g} to | |
35540 | generate the precompiled header but not when using it, you may or may | |
35541 | not get debugging information for routines in the precompiled header. | |
35542 | ||
35543 | @node C++ Modules | |
35544 | @section C++ Modules | |
35545 | @cindex speed of compilation | |
35546 | ||
35547 | Modules are a C++20 language feature. As the name suggests, they | |
35548 | provides a modular compilation system, intending to provide both | |
35549 | faster builds and better library isolation. The ``Merging Modules'' | |
35550 | paper @uref{https://wg21.link/p1103}, provides the easiest to read set | |
35551 | of changes to the standard, although it does not capture later | |
35552 | changes. | |
35553 | ||
35554 | @emph{G++'s modules support is not complete.} Other than bugs, the | |
35555 | known missing pieces are: | |
35556 | ||
35557 | @table @emph | |
35558 | ||
35559 | @item Private Module Fragment | |
35560 | The Private Module Fragment is recognized, but an error is emitted. | |
35561 | ||
35562 | @item Partition definition visibility rules | |
35563 | Entities may be defined in implementation partitions, and those | |
35564 | definitions are not available outside of the module. This is not | |
35565 | implemented, and the definitions are available to extra-module use. | |
35566 | ||
35567 | @item Textual merging of reachable GM entities | |
35568 | Entities may be multiply defined across different header-units. | |
35569 | These must be de-duplicated, and this is implemented across imports, | |
35570 | or when an import redefines a textually-defined entity. However the | |
35571 | reverse is not implemented---textually redefining an entity that has | |
35572 | been defined in an imported header-unit. A redefinition error is | |
35573 | emitted. | |
35574 | ||
35575 | @item Translation-Unit local referencing rules | |
35576 | Papers p1815 (@uref{https://wg21.link/p1815}) and p2003 | |
35577 | (@uref{https://wg21.link/p2003}) add limitations on which entities an | |
35578 | exported region may reference (for instance, the entities an exported | |
35579 | template definition may reference). These are not fully implemented. | |
35580 | ||
35581 | @item Standard Library Header Units | |
35582 | The Standard Library is not provided as importable header units. If | |
35583 | you want to import such units, you must explicitly build them first. | |
35584 | If you do not do this with care, you may have multiple declarations, | |
35585 | which the module machinery must merge---compiler resource usage can be | |
35586 | affected by how you partition header files into header units. | |
35587 | ||
35588 | @end table | |
35589 | ||
35590 | Modular compilation is @emph{not} enabled with just the | |
35591 | @option{-std=c++20} option. You must explicitly enable it with the | |
35592 | @option{-fmodules-ts} option. It is independent of the language | |
35593 | version selected, although in pre-C++20 versions, it is of course an | |
35594 | extension. | |
35595 | ||
35596 | No new source file suffixes are required or supported. If you wish to | |
35597 | use a non-standard suffix (@pxref{Overall Options}), you also need | |
35598 | to provide a @option{-x c++} option too.@footnote{Some users like to | |
35599 | distinguish module interface files with a new suffix, such as naming | |
35600 | the source @code{module.cppm}, which involves | |
35601 | teaching all tools about the new suffix. A different scheme, such as | |
35602 | naming @code{module-m.cpp} would be less invasive.} | |
35603 | ||
35604 | Compiling a module interface unit produces an additional output (to | |
35605 | the assembly or object file), called a Compiled Module Interface | |
35606 | (CMI). This encodes the exported declarations of the module. | |
35607 | Importing a module reads in the CMI. The import graph is a Directed | |
35608 | Acyclic Graph (DAG). You must build imports before the importer. | |
35609 | ||
35610 | Header files may themselves be compiled to header units, which are a | |
35611 | transitional ability aiming at faster compilation. The | |
35612 | @option{-fmodule-header} option is used to enable this, and implies | |
35613 | the @option{-fmodules-ts} option. These CMIs are named by the fully | |
35614 | resolved underlying header file, and thus may be a complete pathname | |
35615 | containing subdirectories. If the header file is found at an absolute | |
35616 | pathname, the CMI location is still relative to a CMI root directory. | |
35617 | ||
35618 | As header files often have no suffix, you commonly have to specify a | |
35619 | @option{-x} option to tell the compiler the source is a header file. | |
35620 | You may use @option{-x c++-header}, @option{-x c++-user-header} or | |
35621 | @option{-x c++-system-header}. When used in conjunction with | |
35622 | @option{-fmodules-ts}, these all imply an appropriate | |
35623 | @option{-fmodule-header} option. The latter two variants use the | |
35624 | user or system include path to search for the file specified. This | |
35625 | allows you to, for instance, compile standard library header files as | |
35626 | header units, without needing to know exactly where they are | |
35627 | installed. Specifying the language as one of these variants also | |
35628 | inhibits output of the object file, as header files have no associated | |
35629 | object file. | |
35630 | ||
35631 | The @option{-fmodule-only} option disables generation of the | |
35632 | associated object file for compiling a module interface. Only the CMI | |
35633 | is generated. This option is implied when using the | |
35634 | @option{-fmodule-header} option. | |
35635 | ||
35636 | The @option{-flang-info-include-translate} and | |
35637 | @option{-flang-info-include-translate-not} options notes whether | |
35638 | include translation occurs or not. With no argument, the first will | |
35639 | note all include translation. The second will note all | |
35640 | non-translations of include files not known to intentionally be | |
35641 | textual. With an argument, queries about include translation of a | |
35642 | header files with that particular trailing pathname are noted. You | |
35643 | may repeat this form to cover several different header files. This | |
35644 | option may be helpful in determining whether include translation is | |
35645 | happening---if it is working correctly, it behaves as if it isn't | |
35646 | there at all. | |
35647 | ||
35648 | The @option{-flang-info-module-cmi} option can be used to determine | |
35649 | where the compiler is reading a CMI from. Without the option, the | |
35650 | compiler is silent when such a read is successful. This option has an | |
35651 | optional argument, which will restrict the notification to just the | |
35652 | set of named modules or header units specified. | |
35653 | ||
35654 | The @option{-Winvalid-imported-macros} option causes all imported macros | |
35655 | to be resolved at the end of compilation. Without this, imported | |
35656 | macros are only resolved when expanded or (re)defined. This option | |
35657 | detects conflicting import definitions for all macros. | |
35658 | ||
35659 | For details of the @option{-fmodule-mapper} family of options, | |
35660 | @pxref{C++ Module Mapper}. | |
35661 | ||
35662 | @menu | |
35663 | * C++ Module Mapper:: Module Mapper | |
35664 | * C++ Module Preprocessing:: Module Preprocessing | |
35665 | * C++ Compiled Module Interface:: Compiled Module Interface | |
35666 | @end menu | |
35667 | ||
35668 | @node C++ Module Mapper | |
35669 | @subsection Module Mapper | |
35670 | @cindex C++ Module Mapper | |
35671 | ||
35672 | A module mapper provides a server or file that the compiler queries to | |
35673 | determine the mapping between module names and CMI files. It is also | |
35674 | used to build CMIs on demand. @emph{Mapper functionality is in its | |
35675 | infancy and is intended for experimentation with build system | |
35676 | interactions.} | |
35677 | ||
35678 | You can specify a mapper with the @option{-fmodule-mapper=@var{val}} | |
35679 | option or @env{CXX_MODULE_MAPPER} environment variable. The value may | |
35680 | have one of the following forms: | |
35681 | ||
35682 | @table @gcctabopt | |
35683 | ||
35684 | @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} | |
35685 | An optional hostname and a numeric port number to connect to. If the | |
35686 | hostname is omitted, the loopback address is used. If the hostname | |
35687 | corresponds to multiple IPV6 addresses, these are tried in turn, until | |
35688 | one is successful. If your host lacks IPv6, this form is | |
35689 | non-functional. If you must use IPv4 use | |
35690 | @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}. | |
35691 | ||
35692 | @item =@var{socket}@r{[}?@var{ident}@r{]} | |
35693 | A local domain socket. If your host lacks local domain sockets, this | |
35694 | form is non-functional. | |
35695 | ||
35696 | @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]} | |
35697 | A program to spawn, and communicate with on its stdin/stdout streams. | |
35698 | Your @var{PATH} environment variable is searched for the program. | |
35699 | Arguments are separated by space characters, (it is not possible for | |
35700 | one of the arguments delivered to the program to contain a space). An | |
35701 | exception is if @var{program} begins with @@. In that case | |
35702 | @var{program} (sans @@) is looked for in the compiler's internal | |
35703 | binary directory. Thus the sample mapper-server can be specified | |
35704 | with @code{@@g++-mapper-server}. | |
35705 | ||
35706 | @item <>@r{[}?@var{ident}@r{]} | |
35707 | @item <>@var{inout}@r{[}?@var{ident}@r{]} | |
35708 | @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
35709 | Named pipes or file descriptors to communicate over. The first form, | |
35710 | @option{<>}, communicates over stdin and stdout. The other forms | |
35711 | allow you to specify a file descriptor or name a pipe. A numeric value | |
35712 | is interpreted as a file descriptor, otherwise named pipe is opened. | |
35713 | The second form specifies a bidirectional pipe and the last form | |
35714 | allows specifying two independent pipes. Using file descriptors | |
35715 | directly in this manner is fragile in general, as it can require the | |
35716 | cooperation of intermediate processes. In particular using stdin & | |
35717 | stdout is fraught with danger as other compiler options might also | |
35718 | cause the compiler to read stdin or write stdout, and it can have | |
35719 | unfortunate interactions with signal delivery from the terminal. | |
35720 | ||
35721 | @item @var{file}@r{[}?@var{ident}@r{]} | |
35722 | A mapping file consisting of space-separated module-name, filename | |
35723 | pairs, one per line. Only the mappings for the direct imports and any | |
35724 | module export name need be provided. If other mappings are provided, | |
35725 | they override those stored in any imported CMI files. A repository | |
35726 | root may be specified in the mapping file by using @samp{$root} as the | |
35727 | module name in the first active line. Use of this option will disable | |
35728 | any default module->CMI name mapping. | |
35729 | ||
35730 | @end table | |
35731 | ||
35732 | As shown, an optional @var{ident} may suffix the first word of the | |
35733 | option, indicated by a @samp{?} prefix. The value is used in the | |
35734 | initial handshake with the module server, or to specify a prefix on | |
35735 | mapping file lines. In the server case, the main source file name is | |
35736 | used if no @var{ident} is specified. In the file case, all non-blank | |
35737 | lines are significant, unless a value is specified, in which case only | |
35738 | lines beginning with @var{ident} are significant. The @var{ident} | |
35739 | must be separated by whitespace from the module name. Be aware that | |
35740 | @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often | |
35741 | significant to the shell, and therefore may need quoting. | |
35742 | ||
35743 | The mapper is connected to or loaded lazily, when the first module | |
35744 | mapping is required. The networking protocols are only supported on | |
35745 | hosts that provide networking. If no mapper is specified a default is | |
35746 | provided. | |
35747 | ||
35748 | A project-specific mapper is expected to be provided by the build | |
35749 | system that invokes the compiler. It is not expected that a | |
35750 | general-purpose server is provided for all compilations. As such, the | |
35751 | server will know the build configuration, the compiler it invoked, and | |
35752 | the environment (such as working directory) in which that is | |
35753 | operating. As it may parallelize builds, several compilations may | |
35754 | connect to the same socket. | |
35755 | ||
35756 | The default mapper generates CMI files in a @samp{gcm.cache} | |
35757 | directory. CMI files have a @samp{.gcm} suffix. The module unit name | |
35758 | is used directly to provide the basename. Header units construct a | |
35759 | relative path using the underlying header file name. If the path is | |
35760 | already relative, a @samp{,} directory is prepended. Internal | |
35761 | @samp{..} components are translated to @samp{,,}. No attempt is made | |
35762 | to canonicalize these filenames beyond that done by the preprocessor's | |
35763 | include search algorithm, as in general it is ambiguous when symbolic | |
35764 | links are present. | |
35765 | ||
35766 | The mapper protocol was published as ``A Module Mapper'' | |
35767 | @uref{https://wg21.link/p1184}. The implementation is provided by | |
35768 | @command{libcody}, @uref{https://github.com/urnathan/libcody}, | |
35769 | which specifies the canonical protocol definition. A proof of concept | |
35770 | server implementation embedded in @command{make} was described in | |
35771 | ''Make Me A Module'', @uref{https://wg21.link/p1602}. | |
35772 | ||
35773 | @node C++ Module Preprocessing | |
35774 | @subsection Module Preprocessing | |
35775 | @cindex C++ Module Preprocessing | |
35776 | ||
35777 | Modules affect preprocessing because of header units and include | |
35778 | translation. Some uses of the preprocessor as a separate step either | |
35779 | do not produce a correct output, or require CMIs to be available. | |
35780 | ||
35781 | Header units import macros. These macros can affect later conditional | |
35782 | inclusion, which therefore can cascade to differing import sets. When | |
35783 | preprocessing, it is necessary to load the CMI. If a header unit is | |
35784 | unavailable, the preprocessor issues a warning and continue (when | |
35785 | not just preprocessing, an error is emitted). Detecting such imports | |
35786 | requires preprocessor tokenization of the input stream to phase 4 | |
35787 | (macro expansion). | |
35788 | ||
35789 | Include translation converts @code{#include}, @code{#include_next} and | |
35790 | @code{#import} directives to internal @code{import} declarations. | |
35791 | Whether a particular directive is translated is controlled by the | |
35792 | module mapper. Header unit names are canonicalized during | |
35793 | preprocessing. | |
35794 | ||
35795 | Dependency information can be emitted for macro import, extending the | |
35796 | functionality of @option{-MD} and @option{-MMD} options. Detection of | |
35797 | import declarations also requires phase 4 preprocessing, and thus | |
35798 | requires full preprocessing (or compilation). | |
35799 | ||
35800 | The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt | |
35801 | preprocessing before phase 4. | |
35802 | ||
35803 | The @option{-save-temps} option uses @option{-fdirectives-only} for | |
35804 | preprocessing, and preserve the macro definitions in the preprocessed | |
35805 | output. Usually you also want to use this option when explicitly | |
35806 | preprocessing a header-unit, or consuming such preprocessed output: | |
35807 | ||
35808 | @smallexample | |
35809 | g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii | |
35810 | g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii | |
35811 | @end smallexample | |
35812 | ||
35813 | @node C++ Compiled Module Interface | |
35814 | @subsection Compiled Module Interface | |
35815 | @cindex C++ Compiled Module Interface | |
35816 | ||
35817 | CMIs are an additional artifact when compiling named module | |
35818 | interfaces, partitions or header units. These are read when | |
35819 | importing. CMI contents are implementation-specific, and in GCC's | |
35820 | case tied to the compiler version. Consider them a rebuildable cache | |
35821 | artifact, not a distributable object. | |
35822 | ||
35823 | When creating an output CMI, any missing directory components are | |
35824 | created in a manner that is safe for concurrent builds creating | |
35825 | multiple, different, CMIs within a common subdirectory tree. | |
35826 | ||
35827 | CMI contents are written to a temporary file, which is then atomically | |
35828 | renamed. Observers either see old contents (if there is an | |
35829 | existing file), or complete new contents. They do not observe the | |
35830 | CMI during its creation. This is unlike object file writing, which | |
35831 | may be observed by an external process. | |
35832 | ||
35833 | CMIs are read in lazily, if the host OS provides @code{mmap} | |
35834 | functionality. Generally blocks are read when name lookup or template | |
35835 | instantiation occurs. To inhibit this, the @option{-fno-module-lazy} | |
35836 | option may be used. | |
35837 | ||
35838 | The @option{--param lazy-modules=@var{n}} parameter controls the limit | |
35839 | on the number of concurrently open module files during lazy loading. | |
35840 | Should more modules be imported, an LRU algorithm is used to determine | |
35841 | which files to close---until that file is needed again. This limit | |
35842 | may be exceeded with deep module dependency hierarchies. With large | |
35843 | code bases there may be more imports than the process limit of file | |
35844 | descriptors. By default, the limit is a few less than the per-process | |
35845 | file descriptor hard limit, if that is determinable.@footnote{Where | |
35846 | applicable the soft limit is incremented as needed towards the hard limit.} | |
35847 | ||
35848 | GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism. | |
35849 | You may use @command{readelf} to inspect them, although section | |
35850 | contents are largely undecipherable. There is a section named | |
35851 | @code{.gnu.c++.README}, which contains human-readable text. Other | |
35852 | than the first line, each line consists of @code{@var{tag}: @code{value}} | |
35853 | tuples. | |
35854 | ||
35855 | @smallexample | |
35856 | > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm} | |
35857 | ||
35858 | String dump of section '.gnu.c++.README': | |
35859 | [ 0] GNU C++ primary module interface | |
35860 | [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454] | |
35861 | [ 6f] version: 2020/11/16-04:54 | |
35862 | [ 89] module: foo | |
35863 | [ 95] source: c_b.ii | |
35864 | [ a4] dialect: C++20/coroutines | |
35865 | [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc | |
35866 | [ ee] repository: gcm.cache | |
35867 | [ 104] buildtime: 2020/11/16 15:03:21 UTC | |
35868 | [ 127] localtime: 2020/11/16 07:03:21 PST | |
35869 | [ 14a] export: foo:part1 foo-part1.gcm | |
35870 | @end smallexample | |
35871 | ||
35872 | Amongst other things, this lists the source that was built, C++ | |
35873 | dialect used and imports of the module.@footnote{The precise contents | |
35874 | of this output may change.} The timestamp is the same value as that | |
35875 | provided by the @code{__DATE__} & @code{__TIME__} macros, and may be | |
35876 | explicitly specified with the environment variable | |
35877 | @code{SOURCE_DATE_EPOCH}. For further details | |
35878 | @pxref{Environment Variables}. | |
35879 | ||
35880 | A set of related CMIs may be copied, provided the relative pathnames | |
35881 | are preserved. | |
35882 | ||
35883 | The @code{.gnu.c++.README} contents do not affect CMI integrity, and | |
35884 | it may be removed or altered. The section numbering of the sections | |
35885 | whose names do not begin with @code{.gnu.c++.}, or are not the string | |
35886 | section is significant and must not be altered. |