]>
Commit | Line | Data |
---|---|---|
d0a5eb32 | 1 | @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
b684a3df | 2 | @c 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
74291a4b MM |
3 | @c This is part of the GCC manual. |
4 | @c For copying conditions, see the file gcc.texi. | |
5 | ||
9d86bffc JM |
6 | @ignore |
7 | @c man begin COPYRIGHT | |
8 | Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, | |
daef8bbd | 9 | 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
9d86bffc | 10 | |
77bd67cb | 11 | Permission is granted to copy, distribute and/or modify this document |
b3a8389d | 12 | under the terms of the GNU Free Documentation License, Version 1.2 or |
77bd67cb JM |
13 | any later version published by the Free Software Foundation; with the |
14 | Invariant Sections being ``GNU General Public License'' and ``Funding | |
15 | Free Software'', the Front-Cover texts being (a) (see below), and with | |
16 | the Back-Cover Texts being (b) (see below). A copy of the license is | |
17 | included in the gfdl(7) man page. | |
9d86bffc | 18 | |
77bd67cb | 19 | (a) The FSF's Front-Cover Text is: |
9d86bffc | 20 | |
77bd67cb JM |
21 | A GNU Manual |
22 | ||
23 | (b) The FSF's Back-Cover Text is: | |
24 | ||
25 | You have freedom to copy and modify this GNU Manual, like GNU | |
26 | software. Copies published by the Free Software Foundation raise | |
27 | funds for GNU development. | |
9d86bffc JM |
28 | @c man end |
29 | @c Set file name and title for the man page. | |
30 | @setfilename gcc | |
31 | @settitle GNU project C and C++ compiler | |
32 | @c man begin SYNOPSIS | |
630d3d5a JM |
33 | gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}] |
34 | [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] | |
35 | [@option{-W}@var{warn}@dots{}] [@option{-pedantic}] | |
36 | [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] | |
37 | [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] | |
38 | [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}] | |
39 | [@option{-o} @var{outfile}] @var{infile}@dots{} | |
9d86bffc JM |
40 | |
41 | Only the most useful options are listed here; see below for the | |
42 | remainder. @samp{g++} accepts mostly the same options as @samp{gcc}. | |
43 | @c man end | |
44 | @c man begin SEEALSO | |
77bd67cb | 45 | gpl(7), gfdl(7), fsf-funding(7), |
b4117c30 ZW |
46 | cpp(1), gcov(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1) |
47 | and the Info entries for @file{gcc}, @file{cpp}, @file{as}, | |
9d86bffc JM |
48 | @file{ld}, @file{binutils} and @file{gdb}. |
49 | @c man end | |
2642624b JM |
50 | @c man begin BUGS |
51 | For instructions on reporting bugs, see | |
bedc7537 | 52 | @w{@uref{http://gcc.gnu.org/bugs.html}}. Use of the @command{gccbug} |
2642624b JM |
53 | script to report bugs is recommended. |
54 | @c man end | |
55 | @c man begin AUTHOR | |
24dbb440 GP |
56 | See the Info entry for @command{gcc}, or |
57 | @w{@uref{http://gcc.gnu.org/onlinedocs/gcc/Contributors.html}}, | |
58 | for contributors to GCC@. | |
2642624b | 59 | @c man end |
9d86bffc JM |
60 | @end ignore |
61 | ||
74291a4b | 62 | @node Invoking GCC |
0c2d1a2a JB |
63 | @chapter GCC Command Options |
64 | @cindex GCC command options | |
74291a4b | 65 | @cindex command options |
0c2d1a2a | 66 | @cindex options, GCC command |
74291a4b | 67 | |
9d86bffc | 68 | @c man begin DESCRIPTION |
0c2d1a2a | 69 | When you invoke GCC, it normally does preprocessing, compilation, |
74291a4b | 70 | assembly and linking. The ``overall options'' allow you to stop this |
630d3d5a | 71 | process at an intermediate stage. For example, the @option{-c} option |
74291a4b MM |
72 | says not to run the linker. Then the output consists of object files |
73 | output by the assembler. | |
74 | ||
75 | Other options are passed on to one stage of processing. Some options | |
76 | control the preprocessor and others the compiler itself. Yet other | |
77 | options control the assembler and linker; most of these are not | |
78 | documented here, since you rarely need to use any of them. | |
79 | ||
80 | @cindex C compilation options | |
0c2d1a2a | 81 | Most of the command line options that you can use with GCC are useful |
74291a4b MM |
82 | for C programs; when an option is only useful with another language |
83 | (usually C++), the explanation says so explicitly. If the description | |
84 | for a particular option does not mention a source language, you can use | |
85 | that option with all supported languages. | |
86 | ||
87 | @cindex C++ compilation options | |
88 | @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special | |
89 | options for compiling C++ programs. | |
90 | ||
91 | @cindex grouping options | |
92 | @cindex options, grouping | |
bedc7537 | 93 | The @command{gcc} program accepts options and file names as operands. Many |
b192711e | 94 | options have multi-letter names; therefore multiple single-letter options |
630d3d5a | 95 | may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d |
74291a4b MM |
96 | -r}}. |
97 | ||
98 | @cindex order of options | |
99 | @cindex options, order | |
100 | You can mix options and other arguments. For the most part, the order | |
101 | you use doesn't matter. Order does matter when you use several options | |
630d3d5a | 102 | of the same kind; for example, if you specify @option{-L} more than once, |
74291a4b MM |
103 | the directories are searched in the order specified. |
104 | ||
105 | Many options have long names starting with @samp{-f} or with | |
630d3d5a JM |
106 | @samp{-W}---for example, @option{-fforce-mem}, |
107 | @option{-fstrength-reduce}, @option{-Wformat} and so on. Most of | |
74291a4b | 108 | these have both positive and negative forms; the negative form of |
630d3d5a | 109 | @option{-ffoo} would be @option{-fno-foo}. This manual documents |
74291a4b MM |
110 | only one of these two forms, whichever one is not the default. |
111 | ||
9d86bffc JM |
112 | @c man end |
113 | ||
cd3bb277 JM |
114 | @xref{Option Index}, for an index to GCC's options. |
115 | ||
74291a4b MM |
116 | @menu |
117 | * Option Summary:: Brief list of all options, without explanations. | |
118 | * Overall Options:: Controlling the kind of output: | |
119 | an executable, object files, assembler files, | |
120 | or preprocessed source. | |
121 | * Invoking G++:: Compiling C++ programs. | |
122 | * C Dialect Options:: Controlling the variant of C language compiled. | |
123 | * C++ Dialect Options:: Variations on C++. | |
46e34f96 ZL |
124 | * Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C |
125 | and Objective-C++. | |
764dbbf2 | 126 | * Language Independent Options:: Controlling how diagnostics should be |
02f52e19 | 127 | formatted. |
74291a4b MM |
128 | * Warning Options:: How picky should the compiler be? |
129 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
130 | * Optimize Options:: How much optimization? | |
131 | * Preprocessor Options:: Controlling header files and macro definitions. | |
132 | Also, getting dependency information for Make. | |
133 | * Assembler Options:: Passing options to the assembler. | |
134 | * Link Options:: Specifying libraries and so on. | |
135 | * Directory Options:: Where to find header files and libraries. | |
136 | Where to find the compiler executable files. | |
a743d340 | 137 | * Spec Files:: How to pass switches to sub-processes. |
0c2d1a2a | 138 | * Target Options:: Running a cross-compiler, or an old version of GCC. |
74291a4b MM |
139 | * Submodel Options:: Specifying minor hardware or convention variations, |
140 | such as 68010 vs 68020. | |
141 | * Code Gen Options:: Specifying conventions for function calls, data layout | |
142 | and register usage. | |
0c2d1a2a | 143 | * Environment Variables:: Env vars that affect GCC. |
17211ab5 | 144 | * Precompiled Headers:: Compiling a header once, and using it many times. |
74291a4b MM |
145 | * Running Protoize:: Automatically adding or removing function prototypes. |
146 | @end menu | |
147 | ||
4bc1997b JM |
148 | @c man begin OPTIONS |
149 | ||
74291a4b MM |
150 | @node Option Summary |
151 | @section Option Summary | |
152 | ||
153 | Here is a summary of all the options, grouped by type. Explanations are | |
154 | in the following sections. | |
155 | ||
156 | @table @emph | |
157 | @item Overall Options | |
158 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
0855eab7 | 159 | @gccoptlist{-c -S -E -o @var{file} -combine -pipe -pass-exit-codes @gol |
9a94f7f3 | 160 | -x @var{language} -v -### --help --target-help --version} |
74291a4b MM |
161 | |
162 | @item C Language Options | |
163 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
9a94f7f3 JM |
164 | @gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol |
165 | -fno-asm -fno-builtin -fno-builtin-@var{function} @gol | |
750491fc | 166 | -fhosted -ffreestanding -fms-extensions @gol |
8a035a6b | 167 | -trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol |
4bc1997b JM |
168 | -fallow-single-precision -fcond-mismatch @gol |
169 | -fsigned-bitfields -fsigned-char @gol | |
3521b33c | 170 | -funsigned-bitfields -funsigned-char} |
74291a4b MM |
171 | |
172 | @item C++ Language Options | |
173 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. | |
9a94f7f3 | 174 | @gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol |
b1822ccc | 175 | -fconserve-space -fno-const-strings @gol |
aa0cc562 | 176 | -fno-elide-constructors @gol |
7813d14c | 177 | -fno-enforce-eh-specs @gol |
1dbb6023 | 178 | -ffor-scope -fno-for-scope -fno-gnu-keywords @gol |
90ecce3e | 179 | -fno-implicit-templates @gol |
4bc1997b JM |
180 | -fno-implicit-inline-templates @gol |
181 | -fno-implement-inlines -fms-extensions @gol | |
aa0cc562 | 182 | -fno-nonansi-builtins -fno-operator-names @gol |
4bc1997b | 183 | -fno-optional-diags -fpermissive @gol |
aa0cc562 | 184 | -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol |
40aac948 | 185 | -fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol |
d7afec4b ND |
186 | -fno-default-inline -fvisibility-inlines-hidden @gol |
187 | -Wabi -Wctor-dtor-privacy @gol | |
4bc1997b JM |
188 | -Wnon-virtual-dtor -Wreorder @gol |
189 | -Weffc++ -Wno-deprecated @gol | |
190 | -Wno-non-template-friend -Wold-style-cast @gol | |
191 | -Woverloaded-virtual -Wno-pmf-conversions @gol | |
192 | -Wsign-promo -Wsynth} | |
74291a4b | 193 | |
46e34f96 ZL |
194 | @item Objective-C and Objective-C++ Language Options |
195 | @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling | |
196 | Objective-C and Objective-C++ Dialects}. | |
264fa2db ZL |
197 | @gccoptlist{ |
198 | -fconstant-string-class=@var{class-name} @gol | |
199 | -fgnu-runtime -fnext-runtime @gol | |
200 | -fno-nil-receivers @gol | |
201 | -fobjc-exceptions @gol | |
202 | -freplace-objc-classes @gol | |
203 | -fzero-link @gol | |
204 | -gen-decls @gol | |
1f676100 | 205 | -Wno-protocol -Wselector -Wundeclared-selector} |
60de6385 | 206 | |
764dbbf2 GDR |
207 | @item Language Independent Options |
208 | @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}. | |
9a94f7f3 | 209 | @gccoptlist{-fmessage-length=@var{n} @gol |
4bc1997b | 210 | -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}} |
764dbbf2 | 211 | |
74291a4b MM |
212 | @item Warning Options |
213 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
9a94f7f3 | 214 | @gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol |
65ca2d60 | 215 | -w -Wextra -Wall -Waggregate-return @gol |
4bc1997b | 216 | -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol |
e23bd218 | 217 | -Wconversion -Wno-deprecated-declarations @gol |
fb0317c6 VR |
218 | -Wdisabled-optimization -Wno-div-by-zero -Wendif-labels @gol |
219 | -Werror -Werror-implicit-function-declaration @gol | |
c65a01af | 220 | -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol |
fb0317c6 | 221 | -Wno-format-extra-args -Wformat-nonliteral @gol |
c76f4e8e | 222 | -Wformat-security -Wformat-y2k @gol |
fb0317c6 VR |
223 | -Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol |
224 | -Wimport -Wno-import -Winit-self -Winline @gol | |
225 | -Wno-invalid-offsetof -Winvalid-pch @gol | |
4bc1997b | 226 | -Wlarger-than-@var{len} -Wlong-long @gol |
eaac4679 | 227 | -Wmain -Wmissing-braces -Wmissing-field-initializers @gol |
b02398bd BE |
228 | -Wmissing-format-attribute -Wmissing-include-dirs @gol |
229 | -Wmissing-noreturn @gol | |
fb0317c6 | 230 | -Wno-multichar -Wnonnull -Wpacked -Wpadded @gol |
310668e8 | 231 | -Wparentheses -Wpointer-arith -Wredundant-decls @gol |
4bc1997b | 232 | -Wreturn-type -Wsequence-point -Wshadow @gol |
5399d643 | 233 | -Wsign-compare -Wstrict-aliasing -Wstrict-aliasing=2 @gol |
9a94f7f3 JM |
234 | -Wswitch -Wswitch-default -Wswitch-enum @gol |
235 | -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol | |
4bc1997b JM |
236 | -Wunknown-pragmas -Wunreachable-code @gol |
237 | -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol | |
7c4d376d RH |
238 | -Wunused-value -Wunused-variable -Wwrite-strings @gol |
239 | -Wvariadic-macros} | |
74291a4b | 240 | |
fe50c0eb | 241 | @item C-only Warning Options |
9a94f7f3 | 242 | @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol |
fb0317c6 | 243 | -Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol |
85617eba HPN |
244 | -Wstrict-prototypes -Wtraditional @gol |
245 | -Wdeclaration-after-statement} | |
fe50c0eb | 246 | |
74291a4b MM |
247 | @item Debugging Options |
248 | @xref{Debugging Options,,Options for Debugging Your Program or GCC}. | |
9a94f7f3 JM |
249 | @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol |
250 | -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol | |
aee96fe9 | 251 | -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol |
6de9cd9a | 252 | -fdump-tree-all @gol |
9a94f7f3 JM |
253 | -fdump-tree-original@r{[}-@var{n}@r{]} @gol |
254 | -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol | |
22367161 | 255 | -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol |
6de9cd9a DN |
256 | -fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias @gol |
257 | -fdump-tree-ch @gol | |
258 | -fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol | |
259 | -fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol | |
260 | -fdump-tree-gimple@r{[}-raw@r{]} -fdump-tree-mudflap@r{[}-@var{n}@r{]} @gol | |
261 | -fdump-tree-dom@r{[}-@var{n}@r{]} @gol | |
262 | -fdump-tree-dse@r{[}-@var{n}@r{]} @gol | |
263 | -fdump-tree-phiopt@r{[}-@var{n}@r{]} @gol | |
264 | -fdump-tree-forwprop@r{[}-@var{n}@r{]} @gol | |
265 | -fdump-tree-copyrename@r{[}-@var{n}@r{]} @gol | |
79fe1b3b | 266 | -fdump-tree-nrv -fdump-tree-vect @gol |
6de9cd9a | 267 | -fdump-tree-sra@r{[}-@var{n}@r{]} @gol |
ff2ad0f7 | 268 | -fdump-tree-fre@r{[}-@var{n}@r{]} @gol |
a37db56b | 269 | -feliminate-dwarf2-dups -feliminate-unused-debug-types @gol |
6de9cd9a | 270 | -feliminate-unused-debug-symbols -fmem-report -fprofile-arcs -ftree-based-profiling @gol |
a37db56b | 271 | -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol |
014a1138 | 272 | -ftest-coverage -ftime-report -fvar-tracking @gol |
def66b10 | 273 | -g -g@var{level} -gcoff -gdwarf-2 @gol |
5f98259a | 274 | -ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol |
4bc1997b | 275 | -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol |
b1018de6 | 276 | -print-multi-directory -print-multi-lib @gol |
4bc1997b JM |
277 | -print-prog-name=@var{program} -print-search-dirs -Q @gol |
278 | -save-temps -time} | |
74291a4b MM |
279 | |
280 | @item Optimization Options | |
281 | @xref{Optimize Options,,Options that Control Optimization}. | |
9a94f7f3 | 282 | @gccoptlist{-falign-functions=@var{n} -falign-jumps=@var{n} @gol |
4bc1997b | 283 | -falign-labels=@var{n} -falign-loops=@var{n} @gol |
6de9cd9a | 284 | -fbounds-check -fmudflap -fmudflapth -fmudflapir @gol |
fca9dc00 | 285 | -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol |
1194fc79 R |
286 | -fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol |
287 | -fcaller-saves -fcprop-registers @gol | |
62d285ff | 288 | -fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol |
4bc1997b JM |
289 | -fdelayed-branch -fdelete-null-pointer-checks @gol |
290 | -fexpensive-optimizations -ffast-math -ffloat-store @gol | |
feb48bde | 291 | -fforce-addr -fforce-mem -ffunction-sections @gol |
db643b91 SH |
292 | -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload @gol |
293 | -floop-optimize -fcrossjumping -fif-conversion -fif-conversion2 @gol | |
4bc1997b | 294 | -finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol |
201556f0 | 295 | -fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol |
e5626198 | 296 | -fmodulo-sched -fmove-all-movables -fnew-ra -fno-branch-count-reg @gol |
5e962776 | 297 | -fno-default-inline -fno-defer-pop -floop-optimize2 -fmove-loop-invariants @gol |
feb48bde | 298 | -fno-function-cse -fno-guess-branch-probability @gol |
6cfc0341 | 299 | -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol |
9a94f7f3 JM |
300 | -funsafe-math-optimizations -ffinite-math-only @gol |
301 | -fno-trapping-math -fno-zero-initialized-in-bss @gol | |
4bc1997b | 302 | -fomit-frame-pointer -foptimize-register-move @gol |
5d22c1a5 | 303 | -foptimize-sibling-calls -fprefetch-loop-arrays @gol |
a8a5f53a | 304 | -fprofile-generate -fprofile-use @gol |
9a94f7f3 | 305 | -freduce-all-givs -fregmove -frename-registers @gol |
750054a2 | 306 | -freorder-blocks -freorder-blocks-and-partition -freorder-functions @gol |
4bc1997b | 307 | -frerun-cse-after-loop -frerun-loop-opt @gol |
039c3d42 | 308 | -frounding-math -fschedule-insns -fschedule-insns2 @gol |
e03b7153 | 309 | -fno-sched-interblock -fno-sched-spec -fsched-spec-load @gol |
569fa502 DN |
310 | -fsched-spec-load-dangerous @gol |
311 | -fsched-stalled-insns=@var{n} -sched-stalled-insns-dep=@var{n} @gol | |
312 | -fsched2-use-superblocks @gol | |
d72372e4 MH |
313 | -fsched2-use-traces -freschedule-modulo-scheduled-loops @gol |
314 | -fsignaling-nans -fsingle-precision-constant @gol | |
9a94f7f3 JM |
315 | -fstrength-reduce -fstrict-aliasing -ftracer -fthread-jumps @gol |
316 | -funroll-all-loops -funroll-loops -fpeel-loops @gol | |
317 | -funswitch-loops -fold-unroll-loops -fold-unroll-all-loops @gol | |
c66b6c66 | 318 | -ftree-pre -ftree-ccp -ftree-dce -ftree-loop-optimize @gol |
82b85a85 | 319 | -ftree-lim -fivcanon @gol |
6de9cd9a | 320 | -ftree-dominator-opts -ftree-dse -ftree-copyrename @gol |
79fe1b3b | 321 | -ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre -ftree-vectorize @gol |
3af64fd6 | 322 | --param @var{name}=@var{value} |
4bc1997b | 323 | -O -O0 -O1 -O2 -O3 -Os} |
74291a4b MM |
324 | |
325 | @item Preprocessor Options | |
326 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
c2d635bc | 327 | @gccoptlist{-A@var{question}=@var{answer} @gol |
9a94f7f3 | 328 | -A-@var{question}@r{[}=@var{answer}@r{]} @gol |
4bc1997b JM |
329 | -C -dD -dI -dM -dN @gol |
330 | -D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol | |
331 | -idirafter @var{dir} @gol | |
332 | -include @var{file} -imacros @var{file} @gol | |
333 | -iprefix @var{file} -iwithprefix @var{dir} @gol | |
bdd42dd9 | 334 | -iwithprefixbefore @var{dir} -isystem @var{dir} @gol |
b20d9f0c AO |
335 | -M -MM -MF -MG -MP -MQ -MT -nostdinc @gol |
336 | -P -fworking-directory -remap @gol | |
9a94f7f3 JM |
337 | -trigraphs -undef -U@var{macro} -Wp,@var{option} @gol |
338 | -Xpreprocessor @var{option}} | |
74291a4b MM |
339 | |
340 | @item Assembler Option | |
341 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
9a94f7f3 | 342 | @gccoptlist{-Wa,@var{option} -Xassembler @var{option}} |
74291a4b MM |
343 | |
344 | @item Linker Options | |
345 | @xref{Link Options,,Options for Linking}. | |
9a94f7f3 | 346 | @gccoptlist{@var{object-file-name} -l@var{library} @gol |
24a4dd31 | 347 | -nostartfiles -nodefaultlibs -nostdlib -pie @gol |
4bc1997b | 348 | -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol |
aee96fe9 | 349 | -Wl,@var{option} -Xlinker @var{option} @gol |
4bc1997b | 350 | -u @var{symbol}} |
74291a4b MM |
351 | |
352 | @item Directory Options | |
353 | @xref{Directory Options,,Options for Directory Search}. | |
4bed3787 | 354 | @gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir} -specs=@var{file} -I-} |
74291a4b MM |
355 | |
356 | @item Target Options | |
357 | @c I wrote this xref this way to avoid overfull hbox. -- rms | |
358 | @xref{Target Options}. | |
9a94f7f3 | 359 | @gccoptlist{-V @var{version} -b @var{machine}} |
74291a4b MM |
360 | |
361 | @item Machine Dependent Options | |
362 | @xref{Submodel Options,,Hardware Models and Configurations}. | |
39bc1876 NS |
363 | @c This list is ordered alphanumerically by subsection name. |
364 | @c Try and put the significant identifier (CPU or system) first, | |
365 | @c so users have a clue at guessing where the ones they want will be. | |
5d22c1a5 | 366 | |
39bc1876 NS |
367 | @emph{ARC Options} |
368 | @gccoptlist{-EB -EL @gol | |
369 | -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol | |
370 | -mdata=@var{data-section} -mrodata=@var{readonly-data-section}} | |
74291a4b | 371 | |
74291a4b | 372 | @emph{ARM Options} |
9a94f7f3 | 373 | @gccoptlist{-mapcs-frame -mno-apcs-frame @gol |
5848830f | 374 | -mabi=@var{name} @gol |
310668e8 JM |
375 | -mapcs-stack-check -mno-apcs-stack-check @gol |
376 | -mapcs-float -mno-apcs-float @gol | |
377 | -mapcs-reentrant -mno-apcs-reentrant @gol | |
378 | -msched-prolog -mno-sched-prolog @gol | |
379 | -mlittle-endian -mbig-endian -mwords-little-endian @gol | |
34a86306 | 380 | -mfloat-abi=@var{name} -msoft-float -mhard-float -mfpe @gol |
310668e8 | 381 | -mthumb-interwork -mno-thumb-interwork @gol |
9b66ebb1 | 382 | -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol |
247f8561 | 383 | -mstructure-size-boundary=@var{n} @gol |
4bc1997b | 384 | -mabort-on-noreturn @gol |
310668e8 JM |
385 | -mlong-calls -mno-long-calls @gol |
386 | -msingle-pic-base -mno-single-pic-base @gol | |
247f8561 PB |
387 | -mpic-register=@var{reg} @gol |
388 | -mnop-fun-dllimport @gol | |
9b6b54e2 | 389 | -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns @gol |
247f8561 | 390 | -mpoke-function-name @gol |
310668e8 JM |
391 | -mthumb -marm @gol |
392 | -mtpcs-frame -mtpcs-leaf-frame @gol | |
9a94f7f3 | 393 | -mcaller-super-interworking -mcallee-super-interworking} |
74291a4b | 394 | |
39bc1876 NS |
395 | @emph{AVR Options} |
396 | @gccoptlist{-mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol | |
397 | -mcall-prologues -mno-tablejump -mtiny-stack -mint8} | |
861bb6c1 | 398 | |
39bc1876 NS |
399 | @emph{CRIS Options} |
400 | @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} -mtune=@var{cpu} @gol | |
401 | -mmax-stack-frame=@var{n} -melinux-stacksize=@var{n} @gol | |
402 | -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol | |
403 | -mstack-align -mdata-align -mconst-align @gol | |
404 | -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt @gol | |
405 | -melf -maout -melinux -mlinux -sim -sim2 @gol | |
406 | -mmul-bug-workaround -mno-mul-bug-workaround} | |
74291a4b | 407 | |
48aec0bc | 408 | @emph{Darwin Options} |
6d2f9dd3 JM |
409 | @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol |
410 | -arch_only -bind_at_load -bundle -bundle_loader @gol | |
411 | -client_name -compatibility_version -current_version @gol | |
5079843a | 412 | -dead_strip @gol |
6d2f9dd3 JM |
413 | -dependency-file -dylib_file -dylinker_install_name @gol |
414 | -dynamic -dynamiclib -exported_symbols_list @gol | |
415 | -filelist -flat_namespace -force_cpusubtype_ALL @gol | |
416 | -force_flat_namespace -headerpad_max_install_names @gol | |
417 | -image_base -init -install_name -keep_private_externs @gol | |
418 | -multi_module -multiply_defined -multiply_defined_unused @gol | |
5079843a DP |
419 | -noall_load -no_dead_strip_inits_and_terms @gol |
420 | -nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol | |
6d2f9dd3 JM |
421 | -pagezero_size -prebind -prebind_all_twolevel_modules @gol |
422 | -private_bundle -read_only_relocs -sectalign @gol | |
423 | -sectobjectsymbols -whyload -seg1addr @gol | |
424 | -sectcreate -sectobjectsymbols -sectorder @gol | |
425 | -seg_addr_table -seg_addr_table_filename -seglinkedit @gol | |
426 | -segprot -segs_read_only_addr -segs_read_write_addr @gol | |
427 | -single_module -static -sub_library -sub_umbrella @gol | |
428 | -twolevel_namespace -umbrella -undefined @gol | |
429 | -unexported_symbols_list -weak_reference_mismatches @gol | |
8f4220dc | 430 | -whatsloaded -F -gused -gfull -mone-byte-bool} |
48aec0bc | 431 | |
74291a4b | 432 | @emph{DEC Alpha Options} |
9a94f7f3 | 433 | @gccoptlist{-mno-fp-regs -msoft-float -malpha-as -mgas @gol |
4bc1997b JM |
434 | -mieee -mieee-with-inexact -mieee-conformant @gol |
435 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol | |
436 | -mtrap-precision=@var{mode} -mbuild-constants @gol | |
58605ba0 RH |
437 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol |
438 | -mbwx -mmax -mfix -mcix @gol | |
439 | -mfloat-vax -mfloat-ieee @gol | |
9a94f7f3 JM |
440 | -mexplicit-relocs -msmall-data -mlarge-data @gol |
441 | -msmall-text -mlarge-text @gol | |
4bc1997b | 442 | -mmemory-latency=@var{time}} |
74291a4b | 443 | |
d7c23cdc | 444 | @emph{DEC Alpha/VMS Options} |
9a94f7f3 | 445 | @gccoptlist{-mvms-return-codes} |
d7c23cdc | 446 | |
39bc1876 NS |
447 | @emph{FRV Options} |
448 | @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol | |
449 | -mhard-float -msoft-float @gol | |
450 | -malloc-cc -mfixed-cc -mdword -mno-dword @gol | |
451 | -mdouble -mno-double @gol | |
452 | -mmedia -mno-media -mmuladd -mno-muladd @gol | |
453 | -mfdpic -minline-plt -mgprel-ro -multilib-library-pic -mlinked-fp @gol | |
454 | -mlibrary-pic -macc-4 -macc-8 @gol | |
455 | -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol | |
456 | -mscc -mno-scc -mcond-exec -mno-cond-exec @gol | |
457 | -mvliw-branch -mno-vliw-branch @gol | |
458 | -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol | |
459 | -mno-nested-cond-exec -mtomcat-stats @gol | |
460 | -mcpu=@var{cpu}} | |
461 | ||
74291a4b | 462 | @emph{H8/300 Options} |
9a94f7f3 | 463 | @gccoptlist{-mrelax -mh -ms -mn -mint32 -malign-300} |
74291a4b | 464 | |
39bc1876 NS |
465 | @emph{HPPA Options} |
466 | @gccoptlist{-march=@var{architecture-type} @gol | |
467 | -mbig-switch -mdisable-fpregs -mdisable-indexing @gol | |
468 | -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol | |
a2017852 | 469 | -mfixed-range=@var{register-range} @gol |
39bc1876 NS |
470 | -mjump-in-delay -mlinker-opt -mlong-calls @gol |
471 | -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol | |
472 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol | |
473 | -mno-jump-in-delay -mno-long-load-store @gol | |
474 | -mno-portable-runtime -mno-soft-float @gol | |
475 | -mno-space-regs -msoft-float -mpa-risc-1-0 @gol | |
476 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol | |
477 | -mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol | |
d711cf67 | 478 | -munix=@var{unix-std} -nolibdld -static -threads} |
74291a4b | 479 | |
39bc1876 NS |
480 | @emph{i386 and x86-64 Options} |
481 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol | |
482 | -mfpmath=@var{unit} @gol | |
483 | -masm=@var{dialect} -mno-fancy-math-387 @gol | |
484 | -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol | |
485 | -mno-wide-multiply -mrtd -malign-double @gol | |
486 | -mpreferred-stack-boundary=@var{num} @gol | |
487 | -mmmx -msse -msse2 -msse3 -m3dnow @gol | |
488 | -mthreads -mno-align-stringops -minline-all-stringops @gol | |
489 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol | |
490 | -m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer @gol | |
491 | -mno-red-zone -mno-tls-direct-seg-refs @gol | |
492 | -mcmodel=@var{code-model} @gol | |
493 | -m32 -m64} | |
56b2d7a7 | 494 | |
39bc1876 NS |
495 | @emph{IA-64 Options} |
496 | @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol | |
497 | -mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol | |
498 | -mconstant-gp -mauto-pic -minline-float-divide-min-latency @gol | |
499 | -minline-float-divide-max-throughput @gol | |
500 | -minline-int-divide-min-latency @gol | |
501 | -minline-int-divide-max-throughput -mno-dwarf2-asm @gol | |
502 | -mfixed-range=@var{register-range}} | |
282a61e6 | 503 | |
39bc1876 NS |
504 | @emph{M32R/D Options} |
505 | @gccoptlist{-m32r2 -m32rx -m32r @gol | |
506 | -mdebug @gol | |
507 | -malign-loops -mno-align-loops @gol | |
508 | -missue-rate=@var{number} @gol | |
509 | -mbranch-cost=@var{number} @gol | |
510 | -mmodel=@var{code-size-model-type} @gol | |
511 | -msdata=@var{sdata-type} @gol | |
512 | -mno-flush-func -mflush-func=@var{name} @gol | |
513 | -mno-flush-trap -mflush-trap=@var{number} @gol | |
514 | -G @var{num}} | |
83575957 | 515 | |
39bc1876 NS |
516 | @emph{M680x0 Options} |
517 | @gccoptlist{-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol | |
518 | -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol | |
519 | -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol | |
520 | -malign-int -mstrict-align -msep-data -mno-sep-data @gol | |
521 | -mshared-library-id=n -mid-shared-library -mno-id-shared-library} | |
789a3090 | 522 | |
39bc1876 NS |
523 | @emph{M68hc1x Options} |
524 | @gccoptlist{-m6811 -m6812 -m68hc11 -m68hc12 -m68hcs12 @gol | |
525 | -mauto-incdec -minmax -mlong-calls -mshort @gol | |
526 | -msoft-reg-count=@var{count}} | |
052a4b28 | 527 | |
789a3090 | 528 | @emph{MCore Options} |
9a94f7f3 | 529 | @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol |
310668e8 JM |
530 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol |
531 | -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol | |
532 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol | |
533 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} | |
f84271d9 | 534 | |
39bc1876 NS |
535 | @emph{MIPS Options} |
536 | @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol | |
537 | -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips64 @gol | |
538 | -mips16 -mno-mips16 -mabi=@var{abi} -mabicalls -mno-abicalls @gol | |
539 | -mxgot -mno-xgot -mgp32 -mgp64 -mfp32 -mfp64 @gol | |
540 | -mhard-float -msoft-float -msingle-float -mdouble-float @gol | |
541 | -mint64 -mlong64 -mlong32 @gol | |
542 | -G@var{num} -membedded-data -mno-embedded-data @gol | |
543 | -muninit-const-in-rodata -mno-uninit-const-in-rodata @gol | |
544 | -msplit-addresses -mno-split-addresses @gol | |
545 | -mexplicit-relocs -mno-explicit-relocs @gol | |
39bc1876 NS |
546 | -mcheck-zero-division -mno-check-zero-division @gol |
547 | -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol | |
548 | -mmad -mno-mad -mfused-madd -mno-fused-madd -nocpp @gol | |
549 | -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol | |
550 | -mfix-vr4120 -mno-fix-vr4120 -mfix-sb1 -mno-fix-sb1 @gol | |
551 | -mflush-func=@var{func} -mno-flush-func @gol | |
552 | -mbranch-likely -mno-branch-likely @gol | |
553 | -mfp-exceptions -mno-fp-exceptions @gol | |
554 | -mvr4130-align -mno-vr4130-align} | |
bcf684c7 | 555 | |
39bc1876 NS |
556 | @emph{MMIX Options} |
557 | @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol | |
558 | -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol | |
559 | -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol | |
560 | -mno-base-addresses -msingle-exit -mno-single-exit} | |
df6194d4 | 561 | |
39bc1876 NS |
562 | @emph{MN10300 Options} |
563 | @gccoptlist{-mmult-bug -mno-mult-bug @gol | |
564 | -mam33 -mno-am33 @gol | |
565 | -mam33-2 -mno-am33-2 @gol | |
566 | -mno-crt0 -mrelax} | |
91abf72d | 567 | |
39bc1876 NS |
568 | @emph{NS32K Options} |
569 | @gccoptlist{-m32032 -m32332 -m32532 -m32081 -m32381 @gol | |
570 | -mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol | |
571 | -mregparam -mnoregparam -msb -mnosb @gol | |
572 | -mbitfield -mnobitfield -mhimem -mnohimem} | |
0b85d816 | 573 | |
9f85bca7 | 574 | @emph{PDP-11 Options} |
9a94f7f3 | 575 | @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol |
9f85bca7 JM |
576 | -mbcopy -mbcopy-builtin -mint32 -mno-int16 @gol |
577 | -mint16 -mno-int32 -mfloat32 -mno-float64 @gol | |
578 | -mfloat64 -mno-float32 -mabshi -mno-abshi @gol | |
579 | -mbranch-expensive -mbranch-cheap @gol | |
580 | -msplit -mno-split -munix-asm -mdec-asm} | |
581 | ||
39bc1876 NS |
582 | @emph{PowerPC Options} |
583 | See RS/6000 and PowerPC Options. | |
584 | ||
585 | @emph{RS/6000 and PowerPC Options} | |
586 | @gccoptlist{-mcpu=@var{cpu-type} @gol | |
587 | -mtune=@var{cpu-type} @gol | |
588 | -mpower -mno-power -mpower2 -mno-power2 @gol | |
589 | -mpowerpc -mpowerpc64 -mno-powerpc @gol | |
590 | -maltivec -mno-altivec @gol | |
591 | -mpowerpc-gpopt -mno-powerpc-gpopt @gol | |
592 | -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol | |
593 | -mnew-mnemonics -mold-mnemonics @gol | |
594 | -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol | |
595 | -m64 -m32 -mxl-call -mno-xl-call -mpe @gol | |
596 | -malign-power -malign-natural @gol | |
597 | -msoft-float -mhard-float -mmultiple -mno-multiple @gol | |
598 | -mstring -mno-string -mupdate -mno-update @gol | |
599 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol | |
600 | -mstrict-align -mno-strict-align -mrelocatable @gol | |
601 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol | |
602 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol | |
603 | -mdynamic-no-pic @gol | |
604 | -mprioritize-restricted-insns=@var{priority} @gol | |
605 | -msched-costly-dep=@var{dependence_type} @gol | |
606 | -minsert-sched-nops=@var{scheme} @gol | |
607 | -mcall-sysv -mcall-netbsd @gol | |
608 | -maix-struct-return -msvr4-struct-return @gol | |
609 | -mabi=altivec -mabi=no-altivec @gol | |
610 | -mabi=spe -mabi=no-spe @gol | |
611 | -misel=yes -misel=no @gol | |
612 | -mspe=yes -mspe=no @gol | |
613 | -mfloat-gprs=yes -mfloat-gprs=no @gol | |
614 | -mprototype -mno-prototype @gol | |
615 | -msim -mmvme -mads -myellowknife -memb -msdata @gol | |
616 | -msdata=@var{opt} -mvxworks -mwindiss -G @var{num} -pthread} | |
617 | ||
618 | @emph{S/390 and zSeries Options} | |
619 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol | |
adf39f8f | 620 | -mhard-float -msoft-float -mbackchain -mno-backchain -mkernel-backchain @gol |
39bc1876 NS |
621 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol |
622 | -m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol | |
d75f90f1 AK |
623 | -mtpf-trace -mno-tpf-trace -mfused-madd -mno-fused-madd @gol |
624 | -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard} | |
39bc1876 NS |
625 | |
626 | @emph{SH Options} | |
627 | @gccoptlist{-m1 -m2 -m2e -m3 -m3e @gol | |
628 | -m4-nofpu -m4-single-only -m4-single -m4 @gol | |
312209c6 | 629 | -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol |
39bc1876 NS |
630 | -m5-64media -m5-64media-nofpu @gol |
631 | -m5-32media -m5-32media-nofpu @gol | |
632 | -m5-compact -m5-compact-nofpu @gol | |
633 | -mb -ml -mdalign -mrelax @gol | |
2acc29bd | 634 | -mbigtable -mfmovd -mhitachi -mrenesas -mno-renesas -mnomacsave @gol |
39bc1876 NS |
635 | -mieee -misize -mpadstruct -mspace @gol |
636 | -mprefergot -musermode} | |
637 | ||
638 | @emph{SPARC Options} | |
639 | @gccoptlist{-mcpu=@var{cpu-type} @gol | |
640 | -mtune=@var{cpu-type} @gol | |
641 | -mcmodel=@var{code-model} @gol | |
642 | -m32 -m64 -mapp-regs -mno-app-regs @gol | |
643 | -mfaster-structs -mno-faster-structs @gol | |
644 | -mfpu -mno-fpu -mhard-float -msoft-float @gol | |
645 | -mhard-quad-float -msoft-quad-float @gol | |
646 | -mimpure-text -mno-impure-text -mlittle-endian @gol | |
647 | -mstack-bias -mno-stack-bias @gol | |
648 | -munaligned-doubles -mno-unaligned-doubles @gol | |
6bfb2f93 EB |
649 | -mv8plus -mno-v8plus -mvis -mno-vis |
650 | -threads -pthreads} | |
39bc1876 NS |
651 | |
652 | @emph{System V Options} | |
653 | @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}} | |
654 | ||
655 | @emph{TMS320C3x/C4x Options} | |
656 | @gccoptlist{-mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol | |
657 | -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol | |
658 | -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol | |
659 | -mparallel-insns -mparallel-mpy -mpreserve-float} | |
660 | ||
661 | @emph{V850 Options} | |
662 | @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol | |
663 | -mprolog-function -mno-prolog-function -mspace @gol | |
664 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol | |
665 | -mapp-regs -mno-app-regs @gol | |
666 | -mdisable-callt -mno-disable-callt @gol | |
667 | -mv850e1 @gol | |
668 | -mv850e @gol | |
669 | -mv850 -mbig-switch} | |
670 | ||
671 | @emph{VAX Options} | |
672 | @gccoptlist{-mg -mgnu -munix} | |
673 | ||
674 | @emph{x86-64 Options} | |
675 | See i386 and x86-64 Options. | |
676 | ||
69a0611f | 677 | @emph{Xstormy16 Options} |
9a94f7f3 | 678 | @gccoptlist{-msim} |
69a0611f | 679 | |
03984308 | 680 | @emph{Xtensa Options} |
6cedbe44 | 681 | @gccoptlist{-mconst16 -mno-const16 @gol |
9a94f7f3 | 682 | -mfused-madd -mno-fused-madd @gol |
9a94f7f3 JM |
683 | -mtext-section-literals -mno-text-section-literals @gol |
684 | -mtarget-align -mno-target-align @gol | |
685 | -mlongcalls -mno-longcalls} | |
03984308 | 686 | |
39bc1876 NS |
687 | @emph{zSeries Options} |
688 | See S/390 and zSeries Options. | |
70899148 | 689 | |
74291a4b MM |
690 | @item Code Generation Options |
691 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
9a94f7f3 JM |
692 | @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol |
693 | -ffixed-@var{reg} -fexceptions @gol | |
5d22c1a5 | 694 | -fnon-call-exceptions -funwind-tables @gol |
a944ceb9 | 695 | -fasynchronous-unwind-tables @gol |
4bc1997b | 696 | -finhibit-size-directive -finstrument-functions @gol |
dc170a87 | 697 | -fno-common -fno-ident @gol |
24a4dd31 | 698 | -fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol |
4bc1997b | 699 | -freg-struct-return -fshared-data -fshort-enums @gol |
271bd540 | 700 | -fshort-double -fshort-wchar @gol |
4bc1997b JM |
701 | -fverbose-asm -fpack-struct -fstack-check @gol |
702 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol | |
703 | -fargument-alias -fargument-noalias @gol | |
478c9e72 | 704 | -fargument-noalias-global -fleading-underscore @gol |
d4463dfc | 705 | -ftls-model=@var{model} @gol |
d7afec4b ND |
706 | -ftrapv -fwrapv -fbounds-check @gol |
707 | -fvisibility} | |
74291a4b MM |
708 | @end table |
709 | ||
710 | @menu | |
711 | * Overall Options:: Controlling the kind of output: | |
712 | an executable, object files, assembler files, | |
713 | or preprocessed source. | |
714 | * C Dialect Options:: Controlling the variant of C language compiled. | |
715 | * C++ Dialect Options:: Variations on C++. | |
46e34f96 ZL |
716 | * Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C |
717 | and Objective-C++. | |
764dbbf2 | 718 | * Language Independent Options:: Controlling how diagnostics should be |
02f52e19 | 719 | formatted. |
74291a4b MM |
720 | * Warning Options:: How picky should the compiler be? |
721 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
722 | * Optimize Options:: How much optimization? | |
723 | * Preprocessor Options:: Controlling header files and macro definitions. | |
724 | Also, getting dependency information for Make. | |
725 | * Assembler Options:: Passing options to the assembler. | |
726 | * Link Options:: Specifying libraries and so on. | |
727 | * Directory Options:: Where to find header files and libraries. | |
728 | Where to find the compiler executable files. | |
a743d340 | 729 | * Spec Files:: How to pass switches to sub-processes. |
0c2d1a2a | 730 | * Target Options:: Running a cross-compiler, or an old version of GCC. |
74291a4b MM |
731 | @end menu |
732 | ||
733 | @node Overall Options | |
734 | @section Options Controlling the Kind of Output | |
735 | ||
736 | Compilation can involve up to four stages: preprocessing, compilation | |
d1bd0ded GK |
737 | proper, assembly and linking, always in that order. GCC is capable of |
738 | preprocessing and compiling several files either into several | |
739 | assembler input files, or into one assembler input file; then each | |
740 | assembler input file produces an object file, and linking combines all | |
741 | the object files (those newly compiled, and those specified as input) | |
742 | into an executable file. | |
74291a4b MM |
743 | |
744 | @cindex file name suffix | |
745 | For any given input file, the file name suffix determines what kind of | |
746 | compilation is done: | |
747 | ||
2642624b | 748 | @table @gcctabopt |
74291a4b MM |
749 | @item @var{file}.c |
750 | C source code which must be preprocessed. | |
751 | ||
752 | @item @var{file}.i | |
753 | C source code which should not be preprocessed. | |
754 | ||
755 | @item @var{file}.ii | |
756 | C++ source code which should not be preprocessed. | |
757 | ||
758 | @item @var{file}.m | |
46e34f96 ZL |
759 | Objective-C source code. Note that you must link with the @file{libobjc} |
760 | library to make an Objective-C program work. | |
74291a4b | 761 | |
b9265ec1 JM |
762 | @item @var{file}.mi |
763 | Objective-C source code which should not be preprocessed. | |
764 | ||
46e34f96 ZL |
765 | @item @var{file}.mm |
766 | @itemx @var{file}.M | |
767 | Objective-C++ source code. Note that you must link with the @file{libobjc} | |
768 | library to make an Objective-C++ program work. Note that @samp{.M} refers | |
769 | to a literal capital M@. | |
770 | ||
771 | @item @var{file}.mii | |
772 | Objective-C++ source code which should not be preprocessed. | |
773 | ||
74291a4b | 774 | @item @var{file}.h |
46e34f96 ZL |
775 | C, C++, Objective-C or Objective-C++ header file to be turned into a |
776 | precompiled header. | |
74291a4b MM |
777 | |
778 | @item @var{file}.cc | |
b9265ec1 | 779 | @itemx @var{file}.cp |
74291a4b MM |
780 | @itemx @var{file}.cxx |
781 | @itemx @var{file}.cpp | |
ee8acf89 | 782 | @itemx @var{file}.CPP |
b9265ec1 | 783 | @itemx @var{file}.c++ |
74291a4b MM |
784 | @itemx @var{file}.C |
785 | C++ source code which must be preprocessed. Note that in @samp{.cxx}, | |
786 | the last two letters must both be literally @samp{x}. Likewise, | |
161d7b59 | 787 | @samp{.C} refers to a literal capital C@. |
74291a4b | 788 | |
17211ab5 GK |
789 | @item @var{file}.hh |
790 | @itemx @var{file}.H | |
791 | C++ header file to be turned into a precompiled header. | |
792 | ||
b9265ec1 JM |
793 | @item @var{file}.f |
794 | @itemx @var{file}.for | |
795 | @itemx @var{file}.FOR | |
796 | Fortran source code which should not be preprocessed. | |
797 | ||
798 | @item @var{file}.F | |
799 | @itemx @var{file}.fpp | |
800 | @itemx @var{file}.FPP | |
801 | Fortran source code which must be preprocessed (with the traditional | |
802 | preprocessor). | |
803 | ||
804 | @item @var{file}.r | |
805 | Fortran source code which must be preprocessed with a RATFOR | |
161d7b59 | 806 | preprocessor (not included with GCC)@. |
b9265ec1 | 807 | |
6de9cd9a DN |
808 | @item @var{file}.f90 |
809 | @itemx @var{file}.f95 | |
810 | Fortran 90/95 source code which should not be preprocessed. | |
811 | ||
b9265ec1 JM |
812 | @c FIXME: Descriptions of Java file types. |
813 | @c @var{file}.java | |
814 | @c @var{file}.class | |
815 | @c @var{file}.zip | |
816 | @c @var{file}.jar | |
817 | ||
e23381df GB |
818 | @item @var{file}.ads |
819 | Ada source code file which contains a library unit declaration (a | |
820 | declaration of a package, subprogram, or generic, or a generic | |
821 | instantiation), or a library unit renaming declaration (a package, | |
822 | generic, or subprogram renaming declaration). Such files are also | |
823 | called @dfn{specs}. | |
824 | ||
825 | @itemx @var{file}.adb | |
826 | Ada source code file containing a library unit body (a subprogram or | |
827 | package body). Such files are also called @dfn{bodies}. | |
828 | ||
b9265ec1 | 829 | @c GCC also knows about some suffixes for languages not yet included: |
b9265ec1 JM |
830 | @c Pascal: |
831 | @c @var{file}.p | |
832 | @c @var{file}.pas | |
833 | ||
74291a4b MM |
834 | @item @var{file}.s |
835 | Assembler code. | |
836 | ||
837 | @item @var{file}.S | |
838 | Assembler code which must be preprocessed. | |
839 | ||
840 | @item @var{other} | |
841 | An object file to be fed straight into linking. | |
842 | Any file name with no recognized suffix is treated this way. | |
843 | @end table | |
844 | ||
cd3bb277 | 845 | @opindex x |
630d3d5a | 846 | You can specify the input language explicitly with the @option{-x} option: |
74291a4b | 847 | |
2642624b | 848 | @table @gcctabopt |
74291a4b MM |
849 | @item -x @var{language} |
850 | Specify explicitly the @var{language} for the following input files | |
851 | (rather than letting the compiler choose a default based on the file | |
852 | name suffix). This option applies to all following input files until | |
630d3d5a | 853 | the next @option{-x} option. Possible values for @var{language} are: |
3ab51846 | 854 | @smallexample |
46e34f96 | 855 | c c-header c-cpp-output |
17211ab5 | 856 | c++ c++-header c++-cpp-output |
46e34f96 ZL |
857 | objective-c objective-c-header objective-c-cpp-output |
858 | objective-c++ objective-c++-header objective-c++-cpp-output | |
74291a4b | 859 | assembler assembler-with-cpp |
e23381df | 860 | ada |
b9265ec1 | 861 | f77 f77-cpp-input ratfor |
6de9cd9a | 862 | f95 |
e23381df | 863 | java |
b38b97c4 | 864 | treelang |
3ab51846 | 865 | @end smallexample |
74291a4b MM |
866 | |
867 | @item -x none | |
868 | Turn off any specification of a language, so that subsequent files are | |
630d3d5a | 869 | handled according to their file name suffixes (as they are if @option{-x} |
74291a4b | 870 | has not been used at all). |
14a774a9 RK |
871 | |
872 | @item -pass-exit-codes | |
cd3bb277 | 873 | @opindex pass-exit-codes |
bedc7537 | 874 | Normally the @command{gcc} program will exit with the code of 1 if any |
14a774a9 | 875 | phase of the compiler returns a non-success return code. If you specify |
630d3d5a | 876 | @option{-pass-exit-codes}, the @command{gcc} program will instead return with |
14a774a9 RK |
877 | numerically highest error produced by any phase that returned an error |
878 | indication. | |
74291a4b MM |
879 | @end table |
880 | ||
881 | If you only want some of the stages of compilation, you can use | |
630d3d5a JM |
882 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and |
883 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
bedc7537 NC |
884 | @command{gcc} is to stop. Note that some combinations (for example, |
885 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
74291a4b | 886 | |
2642624b | 887 | @table @gcctabopt |
74291a4b | 888 | @item -c |
cd3bb277 | 889 | @opindex c |
74291a4b MM |
890 | Compile or assemble the source files, but do not link. The linking |
891 | stage simply is not done. The ultimate output is in the form of an | |
892 | object file for each source file. | |
893 | ||
894 | By default, the object file name for a source file is made by replacing | |
895 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
896 | ||
897 | Unrecognized input files, not requiring compilation or assembly, are | |
898 | ignored. | |
899 | ||
900 | @item -S | |
cd3bb277 | 901 | @opindex S |
74291a4b MM |
902 | Stop after the stage of compilation proper; do not assemble. The output |
903 | is in the form of an assembler code file for each non-assembler input | |
904 | file specified. | |
905 | ||
906 | By default, the assembler file name for a source file is made by | |
907 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
908 | ||
909 | Input files that don't require compilation are ignored. | |
910 | ||
911 | @item -E | |
cd3bb277 | 912 | @opindex E |
74291a4b MM |
913 | Stop after the preprocessing stage; do not run the compiler proper. The |
914 | output is in the form of preprocessed source code, which is sent to the | |
915 | standard output. | |
916 | ||
917 | Input files which don't require preprocessing are ignored. | |
918 | ||
919 | @cindex output file option | |
920 | @item -o @var{file} | |
cd3bb277 | 921 | @opindex o |
74291a4b MM |
922 | Place output in file @var{file}. This applies regardless to whatever |
923 | sort of output is being produced, whether it be an executable file, | |
924 | an object file, an assembler file or preprocessed C code. | |
925 | ||
488061c8 GK |
926 | If @option{-o} is not specified, the default is to put an executable |
927 | file in @file{a.out}, the object file for | |
928 | @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its | |
929 | assembler file in @file{@var{source}.s}, a precompiled header file in | |
930 | @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on | |
931 | standard output. | |
74291a4b MM |
932 | |
933 | @item -v | |
cd3bb277 | 934 | @opindex v |
74291a4b MM |
935 | Print (on standard error output) the commands executed to run the stages |
936 | of compilation. Also print the version number of the compiler driver | |
937 | program and of the preprocessor and the compiler proper. | |
938 | ||
e8b3c8ac IR |
939 | @item -### |
940 | @opindex ### | |
941 | Like @option{-v} except the commands are not executed and all command | |
942 | arguments are quoted. This is useful for shell scripts to capture the | |
943 | driver-generated command lines. | |
944 | ||
74291a4b | 945 | @item -pipe |
cd3bb277 | 946 | @opindex pipe |
74291a4b MM |
947 | Use pipes rather than temporary files for communication between the |
948 | various stages of compilation. This fails to work on some systems where | |
949 | the assembler is unable to read from a pipe; but the GNU assembler has | |
950 | no trouble. | |
844642e6 | 951 | |
0855eab7 CT |
952 | @item -combine |
953 | @opindex combine | |
954 | If you are compiling multiple source files, this option tells the driver | |
f26c1794 | 955 | to pass all the source files to the compiler at once (for those |
0855eab7 CT |
956 | languages for which the compiler can handle this). This will allow |
957 | intermodule analysis (IMA) to be performed by the compiler. Currently the only | |
958 | language for which this is supported is C. If you pass source files for | |
959 | multiple languages to the driver, using this option, the driver will invoke | |
960 | the compiler(s) that support IMA once each, passing each compiler all the | |
961 | source files appropriate for it. For those languages that do not support | |
962 | IMA this option will be ignored, and the compiler will be invoked once for | |
963 | each source file in that language. If you use this option in conjunction | |
964 | with -save-temps, the compiler will generate multiple pre-processed files | |
f26c1794 | 965 | (one for each source file), but only one (combined) .o or .s file. |
0855eab7 | 966 | |
844642e6 | 967 | @item --help |
cd3bb277 | 968 | @opindex help |
844642e6 | 969 | Print (on the standard output) a description of the command line options |
bedc7537 NC |
970 | understood by @command{gcc}. If the @option{-v} option is also specified |
971 | then @option{--help} will also be passed on to the various processes | |
972 | invoked by @command{gcc}, so that they can display the command line options | |
65ca2d60 | 973 | they accept. If the @option{-Wextra} option is also specified then command |
844642e6 NC |
974 | line options which have no documentation associated with them will also |
975 | be displayed. | |
10501d8f CC |
976 | |
977 | @item --target-help | |
cd3bb277 | 978 | @opindex target-help |
10501d8f CC |
979 | Print (on the standard output) a description of target specific command |
980 | line options for each tool. | |
e03b7153 RS |
981 | |
982 | @item --version | |
983 | @opindex version | |
984 | Display the version number and copyrights of the invoked GCC. | |
74291a4b MM |
985 | @end table |
986 | ||
987 | @node Invoking G++ | |
988 | @section Compiling C++ Programs | |
989 | ||
990 | @cindex suffixes for C++ source | |
991 | @cindex C++ source file suffixes | |
992 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
17211ab5 GK |
993 | @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or |
994 | @samp{.cxx}; C++ header files often use @samp{.hh} or @samp{.H}; and | |
0c2d1a2a | 995 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes |
bba975d4 | 996 | files with these names and compiles them as C++ programs even if you |
17211ab5 GK |
997 | call the compiler the same way as for compiling C programs (usually |
998 | with the name @command{gcc}). | |
74291a4b MM |
999 | |
1000 | @findex g++ | |
1001 | @findex c++ | |
1002 | However, C++ programs often require class libraries as well as a | |
1003 | compiler that understands the C++ language---and under some | |
17211ab5 GK |
1004 | circumstances, you might want to compile programs or header files from |
1005 | standard input, or otherwise without a suffix that flags them as C++ | |
1006 | programs. You might also like to precompile a C header file with a | |
1007 | @samp{.h} extension to be used in C++ compilations. @command{g++} is a | |
1008 | program that calls GCC with the default language set to C++, and | |
1009 | automatically specifies linking against the C++ library. On many | |
1010 | systems, @command{g++} is also installed with the name @command{c++}. | |
74291a4b | 1011 | |
bedc7537 | 1012 | @cindex invoking @command{g++} |
74291a4b MM |
1013 | When you compile C++ programs, you may specify many of the same |
1014 | command-line options that you use for compiling programs in any | |
1015 | language; or command-line options meaningful for C and related | |
1016 | languages; or options that are meaningful only for C++ programs. | |
1017 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
161d7b59 | 1018 | explanations of options for languages related to C@. |
74291a4b MM |
1019 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for |
1020 | explanations of options that are meaningful only for C++ programs. | |
1021 | ||
1022 | @node C Dialect Options | |
1023 | @section Options Controlling C Dialect | |
1024 | @cindex dialect options | |
1025 | @cindex language dialect options | |
1026 | @cindex options, dialect | |
1027 | ||
1028 | The following options control the dialect of C (or languages derived | |
46e34f96 ZL |
1029 | from C, such as C++, Objective-C and Objective-C++) that the compiler |
1030 | accepts: | |
74291a4b | 1031 | |
2642624b | 1032 | @table @gcctabopt |
74291a4b | 1033 | @cindex ANSI support |
c1030c7c | 1034 | @cindex ISO support |
74291a4b | 1035 | @item -ansi |
cd3bb277 | 1036 | @opindex ansi |
3764f879 | 1037 | In C mode, support all ISO C90 programs. In C++ mode, |
775afb25 | 1038 | remove GNU extensions that conflict with ISO C++. |
74291a4b | 1039 | |
c1030c7c | 1040 | This turns off certain features of GCC that are incompatible with ISO |
3764f879 | 1041 | C90 (when compiling C code), or of standard C++ (when compiling C++ code), |
0c2d1a2a | 1042 | such as the @code{asm} and @code{typeof} keywords, and |
74291a4b MM |
1043 | predefined macros such as @code{unix} and @code{vax} that identify the |
1044 | type of system you are using. It also enables the undesirable and | |
02f52e19 | 1045 | rarely used ISO trigraph feature. For the C compiler, |
0c2d1a2a | 1046 | it disables recognition of C++ style @samp{//} comments as well as |
775afb25 | 1047 | the @code{inline} keyword. |
74291a4b MM |
1048 | |
1049 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
1050 | @code{__inline__} and @code{__typeof__} continue to work despite | |
630d3d5a | 1051 | @option{-ansi}. You would not want to use them in an ISO C program, of |
74291a4b | 1052 | course, but it is useful to put them in header files that might be included |
630d3d5a | 1053 | in compilations done with @option{-ansi}. Alternate predefined macros |
74291a4b | 1054 | such as @code{__unix__} and @code{__vax__} are also available, with or |
630d3d5a | 1055 | without @option{-ansi}. |
74291a4b | 1056 | |
630d3d5a JM |
1057 | The @option{-ansi} option does not cause non-ISO programs to be |
1058 | rejected gratuitously. For that, @option{-pedantic} is required in | |
1059 | addition to @option{-ansi}. @xref{Warning Options}. | |
74291a4b | 1060 | |
630d3d5a | 1061 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} |
74291a4b MM |
1062 | option is used. Some header files may notice this macro and refrain |
1063 | from declaring certain functions or defining certain macros that the | |
c1030c7c | 1064 | ISO standard doesn't call for; this is to avoid interfering with any |
74291a4b MM |
1065 | programs that might use these names for other things. |
1066 | ||
c771326b JM |
1067 | Functions which would normally be built in but do not have semantics |
1068 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
630d3d5a | 1069 | functions with @option{-ansi} is used. @xref{Other Builtins,,Other |
f0523f02 | 1070 | built-in functions provided by GCC}, for details of the functions |
01702459 | 1071 | affected. |
74291a4b | 1072 | |
49419c8f | 1073 | @item -std= |
cd3bb277 | 1074 | @opindex std |
aee96fe9 | 1075 | Determine the language standard. This option is currently only |
f749a36b NB |
1076 | supported when compiling C or C++. A value for this option must be |
1077 | provided; possible values are | |
3932261a | 1078 | |
ee457005 | 1079 | @table @samp |
aee96fe9 JM |
1080 | @item c89 |
1081 | @itemx iso9899:1990 | |
3764f879 | 1082 | ISO C90 (same as @option{-ansi}). |
3043b30e ML |
1083 | |
1084 | @item iso9899:199409 | |
3764f879 | 1085 | ISO C90 as modified in amendment 1. |
3043b30e | 1086 | |
49419c8f | 1087 | @item c99 |
aee96fe9 JM |
1088 | @itemx c9x |
1089 | @itemx iso9899:1999 | |
1090 | @itemx iso9899:199x | |
1091 | ISO C99. Note that this standard is not yet fully supported; see | |
1092 | @w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The | |
1093 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
3043b30e ML |
1094 | |
1095 | @item gnu89 | |
3764f879 | 1096 | Default, ISO C90 plus GNU extensions (including some C99 features). |
3043b30e | 1097 | |
49419c8f | 1098 | @item gnu99 |
31775d31 | 1099 | @itemx gnu9x |
d15a05b3 EC |
1100 | ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC, |
1101 | this will become the default. The name @samp{gnu9x} is deprecated. | |
49419c8f | 1102 | |
f749a36b NB |
1103 | @item c++98 |
1104 | The 1998 ISO C++ standard plus amendments. | |
1105 | ||
1106 | @item gnu++98 | |
1107 | The same as @option{-std=c++98} plus GNU extensions. This is the | |
1108 | default for C++ code. | |
ee457005 | 1109 | @end table |
3043b30e ML |
1110 | |
1111 | Even when this option is not specified, you can still use some of the | |
1112 | features of newer standards in so far as they do not conflict with | |
1113 | previous C standards. For example, you may use @code{__restrict__} even | |
bedc7537 | 1114 | when @option{-std=c99} is not specified. |
3932261a | 1115 | |
5490d604 | 1116 | The @option{-std} options specifying some version of ISO C have the same |
3764f879 | 1117 | effects as @option{-ansi}, except that features that were not in ISO C90 |
5490d604 JM |
1118 | but are in the specified version (for example, @samp{//} comments and |
1119 | the @code{inline} keyword in ISO C99) are not disabled. | |
1120 | ||
c1030c7c JM |
1121 | @xref{Standards,,Language Standards Supported by GCC}, for details of |
1122 | these standard versions. | |
1123 | ||
b1018de6 AO |
1124 | @item -aux-info @var{filename} |
1125 | @opindex aux-info | |
1126 | Output to the given filename prototyped declarations for all functions | |
1127 | declared and/or defined in a translation unit, including those in header | |
161d7b59 | 1128 | files. This option is silently ignored in any language other than C@. |
b1018de6 AO |
1129 | |
1130 | Besides declarations, the file indicates, in comments, the origin of | |
1131 | each declaration (source file and line), whether the declaration was | |
1132 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
1133 | @samp{O} for old, respectively, in the first character after the line | |
1134 | number and the colon), and whether it came from a declaration or a | |
1135 | definition (@samp{C} or @samp{F}, respectively, in the following | |
1136 | character). In the case of function definitions, a K&R-style list of | |
1137 | arguments followed by their declarations is also provided, inside | |
1138 | comments, after the declaration. | |
1139 | ||
74291a4b | 1140 | @item -fno-asm |
cd3bb277 | 1141 | @opindex fno-asm |
74291a4b MM |
1142 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
1143 | keyword, so that code can use these words as identifiers. You can use | |
1144 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
630d3d5a | 1145 | instead. @option{-ansi} implies @option{-fno-asm}. |
74291a4b MM |
1146 | |
1147 | In C++, this switch only affects the @code{typeof} keyword, since | |
1148 | @code{asm} and @code{inline} are standard keywords. You may want to | |
630d3d5a | 1149 | use the @option{-fno-gnu-keywords} flag instead, which has the same |
5490d604 JM |
1150 | effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this |
1151 | switch only affects the @code{asm} and @code{typeof} keywords, since | |
1152 | @code{inline} is a standard keyword in ISO C99. | |
74291a4b MM |
1153 | |
1154 | @item -fno-builtin | |
a3926fe1 | 1155 | @itemx -fno-builtin-@var{function} |
cd3bb277 | 1156 | @opindex fno-builtin |
c771326b JM |
1157 | @cindex built-in functions |
1158 | Don't recognize built-in functions that do not begin with | |
01702459 | 1159 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in |
f0523f02 | 1160 | functions provided by GCC}, for details of the functions affected, |
c771326b | 1161 | including those which are not built-in functions when @option{-ansi} or |
5490d604 JM |
1162 | @option{-std} options for strict ISO C conformance are used because they |
1163 | do not have an ISO standard meaning. | |
74291a4b | 1164 | |
c771326b | 1165 | GCC normally generates special code to handle certain built-in functions |
74291a4b MM |
1166 | more efficiently; for instance, calls to @code{alloca} may become single |
1167 | instructions that adjust the stack directly, and calls to @code{memcpy} | |
1168 | may become inline copy loops. The resulting code is often both smaller | |
1169 | and faster, but since the function calls no longer appear as such, you | |
1170 | cannot set a breakpoint on those calls, nor can you change the behavior | |
1171 | of the functions by linking with a different library. | |
1172 | ||
a3926fe1 RS |
1173 | With the @option{-fno-builtin-@var{function}} option |
1174 | only the built-in function @var{function} is | |
7d14c755 JM |
1175 | disabled. @var{function} must not begin with @samp{__builtin_}. If a |
1176 | function is named this is not built-in in this version of GCC, this | |
1177 | option is ignored. There is no corresponding | |
1178 | @option{-fbuiltin-@var{function}} option; if you wish to enable | |
1179 | built-in functions selectively when using @option{-fno-builtin} or | |
1180 | @option{-ffreestanding}, you may define macros such as: | |
1181 | ||
1182 | @smallexample | |
1183 | #define abs(n) __builtin_abs ((n)) | |
1184 | #define strcpy(d, s) __builtin_strcpy ((d), (s)) | |
1185 | @end smallexample | |
1186 | ||
861bb6c1 | 1187 | @item -fhosted |
cd3bb277 | 1188 | @opindex fhosted |
861bb6c1 JL |
1189 | @cindex hosted environment |
1190 | ||
1191 | Assert that compilation takes place in a hosted environment. This implies | |
630d3d5a | 1192 | @option{-fbuiltin}. A hosted environment is one in which the |
861bb6c1 JL |
1193 | entire standard library is available, and in which @code{main} has a return |
1194 | type of @code{int}. Examples are nearly everything except a kernel. | |
630d3d5a | 1195 | This is equivalent to @option{-fno-freestanding}. |
861bb6c1 JL |
1196 | |
1197 | @item -ffreestanding | |
cd3bb277 | 1198 | @opindex ffreestanding |
861bb6c1 JL |
1199 | @cindex hosted environment |
1200 | ||
1201 | Assert that compilation takes place in a freestanding environment. This | |
630d3d5a | 1202 | implies @option{-fno-builtin}. A freestanding environment |
861bb6c1 JL |
1203 | is one in which the standard library may not exist, and program startup may |
1204 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
630d3d5a | 1205 | This is equivalent to @option{-fno-hosted}. |
861bb6c1 | 1206 | |
c1030c7c JM |
1207 | @xref{Standards,,Language Standards Supported by GCC}, for details of |
1208 | freestanding and hosted environments. | |
1209 | ||
750491fc RH |
1210 | @item -fms-extensions |
1211 | @opindex fms-extensions | |
1212 | Accept some non-standard constructs used in Microsoft header files. | |
1213 | ||
74291a4b | 1214 | @item -trigraphs |
cd3bb277 | 1215 | @opindex trigraphs |
3bce8a01 NB |
1216 | Support ISO C trigraphs. The @option{-ansi} option (and @option{-std} |
1217 | options for strict ISO C conformance) implies @option{-trigraphs}. | |
74291a4b | 1218 | |
8a035a6b AH |
1219 | @item -no-integrated-cpp |
1220 | @opindex no-integrated-cpp | |
1221 | Performs a compilation in two passes: preprocessing and compiling. This | |
1222 | option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the | |
1223 | @option{-B} option. The user supplied compilation step can then add in | |
1224 | an additional preprocessing step after normal preprocessing but before | |
1225 | compiling. The default is to use the integrated cpp (internal cpp) | |
1226 | ||
1227 | The semantics of this option will change if "cc1", "cc1plus", and | |
1228 | "cc1obj" are merged. | |
1229 | ||
74291a4b MM |
1230 | @cindex traditional C language |
1231 | @cindex C language, traditional | |
1232 | @item -traditional | |
f458d1d5 | 1233 | @itemx -traditional-cpp |
cd3bb277 | 1234 | @opindex traditional-cpp |
f458d1d5 ZW |
1235 | @opindex traditional |
1236 | Formerly, these options caused GCC to attempt to emulate a pre-standard | |
1237 | C compiler. They are now only supported with the @option{-E} switch. | |
1238 | The preprocessor continues to support a pre-standard mode. See the GNU | |
1239 | CPP manual for details. | |
74291a4b MM |
1240 | |
1241 | @item -fcond-mismatch | |
cd3bb277 | 1242 | @opindex fcond-mismatch |
74291a4b | 1243 | Allow conditional expressions with mismatched types in the second and |
a7537031 JM |
1244 | third arguments. The value of such an expression is void. This option |
1245 | is not supported for C++. | |
74291a4b MM |
1246 | |
1247 | @item -funsigned-char | |
cd3bb277 | 1248 | @opindex funsigned-char |
74291a4b MM |
1249 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
1250 | ||
1251 | Each kind of machine has a default for what @code{char} should | |
1252 | be. It is either like @code{unsigned char} by default or like | |
1253 | @code{signed char} by default. | |
1254 | ||
1255 | Ideally, a portable program should always use @code{signed char} or | |
1256 | @code{unsigned char} when it depends on the signedness of an object. | |
1257 | But many programs have been written to use plain @code{char} and | |
1258 | expect it to be signed, or expect it to be unsigned, depending on the | |
1259 | machines they were written for. This option, and its inverse, let you | |
1260 | make such a program work with the opposite default. | |
1261 | ||
1262 | The type @code{char} is always a distinct type from each of | |
1263 | @code{signed char} or @code{unsigned char}, even though its behavior | |
1264 | is always just like one of those two. | |
1265 | ||
1266 | @item -fsigned-char | |
cd3bb277 | 1267 | @opindex fsigned-char |
74291a4b MM |
1268 | Let the type @code{char} be signed, like @code{signed char}. |
1269 | ||
630d3d5a JM |
1270 | Note that this is equivalent to @option{-fno-unsigned-char}, which is |
1271 | the negative form of @option{-funsigned-char}. Likewise, the option | |
1272 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
74291a4b | 1273 | |
74291a4b MM |
1274 | @item -fsigned-bitfields |
1275 | @itemx -funsigned-bitfields | |
1276 | @itemx -fno-signed-bitfields | |
1277 | @itemx -fno-unsigned-bitfields | |
cd3bb277 JM |
1278 | @opindex fsigned-bitfields |
1279 | @opindex funsigned-bitfields | |
1280 | @opindex fno-signed-bitfields | |
1281 | @opindex fno-unsigned-bitfields | |
c771326b | 1282 | These options control whether a bit-field is signed or unsigned, when the |
74291a4b | 1283 | declaration does not use either @code{signed} or @code{unsigned}. By |
c771326b | 1284 | default, such a bit-field is signed, because this is consistent: the |
74291a4b | 1285 | basic integer types such as @code{int} are signed types. |
74291a4b MM |
1286 | @end table |
1287 | ||
1288 | @node C++ Dialect Options | |
1289 | @section Options Controlling C++ Dialect | |
1290 | ||
1291 | @cindex compiler options, C++ | |
1292 | @cindex C++ options, command line | |
1293 | @cindex options, C++ | |
1294 | This section describes the command-line options that are only meaningful | |
1295 | for C++ programs; but you can also use most of the GNU compiler options | |
1296 | regardless of what language your program is in. For example, you | |
1297 | might compile a file @code{firstClass.C} like this: | |
1298 | ||
3ab51846 | 1299 | @smallexample |
1dc5fc4b | 1300 | g++ -g -frepo -O -c firstClass.C |
3ab51846 | 1301 | @end smallexample |
74291a4b MM |
1302 | |
1303 | @noindent | |
630d3d5a | 1304 | In this example, only @option{-frepo} is an option meant |
74291a4b | 1305 | only for C++ programs; you can use the other options with any |
161d7b59 | 1306 | language supported by GCC@. |
74291a4b MM |
1307 | |
1308 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
1309 | ||
2642624b | 1310 | @table @gcctabopt |
2d3e278d MM |
1311 | |
1312 | @item -fabi-version=@var{n} | |
1313 | @opindex fabi-version | |
57702a80 MM |
1314 | Use version @var{n} of the C++ ABI. Version 2 is the version of the |
1315 | C++ ABI that first appeared in G++ 3.4. Version 1 is the version of | |
1316 | the C++ ABI that first appeared in G++ 3.2. Version 0 will always be | |
1317 | the version that conforms most closely to the C++ ABI specification. | |
1318 | Therefore, the ABI obtained using version 0 will change as ABI bugs | |
1319 | are fixed. | |
2d3e278d | 1320 | |
d150ccef | 1321 | The default is version 2. |
46c83bce | 1322 | |
74291a4b | 1323 | @item -fno-access-control |
cd3bb277 | 1324 | @opindex fno-access-control |
74291a4b MM |
1325 | Turn off all access checking. This switch is mainly useful for working |
1326 | around bugs in the access control code. | |
1327 | ||
74291a4b | 1328 | @item -fcheck-new |
cd3bb277 | 1329 | @opindex fcheck-new |
74291a4b | 1330 | Check that the pointer returned by @code{operator new} is non-null |
6d9c4c83 JW |
1331 | before attempting to modify the storage allocated. This check is |
1332 | normally unnecessary because the C++ standard specifies that | |
1333 | @code{operator new} will only return @code{0} if it is declared | |
1334 | @samp{throw()}, in which case the compiler will always check the | |
1335 | return value even without this option. In all other cases, when | |
1336 | @code{operator new} has a non-empty exception specification, memory | |
1337 | exhaustion is signalled by throwing @code{std::bad_alloc}. See also | |
1338 | @samp{new (nothrow)}. | |
1dc5fc4b | 1339 | |
74291a4b | 1340 | @item -fconserve-space |
cd3bb277 | 1341 | @opindex fconserve-space |
74291a4b MM |
1342 | Put uninitialized or runtime-initialized global variables into the |
1343 | common segment, as C does. This saves space in the executable at the | |
1344 | cost of not diagnosing duplicate definitions. If you compile with this | |
1345 | flag and your program mysteriously crashes after @code{main()} has | |
1346 | completed, you may have an object that is being destroyed twice because | |
1347 | two definitions were merged. | |
1348 | ||
1dc5fc4b JM |
1349 | This option is no longer useful on most targets, now that support has |
1350 | been added for putting variables into BSS without making them common. | |
1351 | ||
02f52e19 | 1352 | @item -fno-const-strings |
cd3bb277 | 1353 | @opindex fno-const-strings |
fcca588c MM |
1354 | Give string constants type @code{char *} instead of type @code{const |
1355 | char *}. By default, G++ uses type @code{const char *} as required by | |
630d3d5a | 1356 | the standard. Even if you use @option{-fno-const-strings}, you cannot |
3521b33c | 1357 | actually modify the value of a string constant. |
fcca588c MM |
1358 | |
1359 | This option might be removed in a future release of G++. For maximum | |
1360 | portability, you should structure your code so that it works with | |
1361 | string constants that have type @code{const char *}. | |
1362 | ||
1dc5fc4b | 1363 | @item -fno-elide-constructors |
cd3bb277 | 1364 | @opindex fno-elide-constructors |
1dc5fc4b JM |
1365 | The C++ standard allows an implementation to omit creating a temporary |
1366 | which is only used to initialize another object of the same type. | |
aee96fe9 | 1367 | Specifying this option disables that optimization, and forces G++ to |
1dc5fc4b | 1368 | call the copy constructor in all cases. |
74291a4b | 1369 | |
dd1ba632 | 1370 | @item -fno-enforce-eh-specs |
cd3bb277 | 1371 | @opindex fno-enforce-eh-specs |
dd1ba632 JM |
1372 | Don't check for violation of exception specifications at runtime. This |
1373 | option violates the C++ standard, but may be useful for reducing code | |
1374 | size in production builds, much like defining @samp{NDEBUG}. The compiler | |
1375 | will still optimize based on the exception specifications. | |
1376 | ||
74291a4b | 1377 | @item -ffor-scope |
8c81598d | 1378 | @itemx -fno-for-scope |
cd3bb277 JM |
1379 | @opindex ffor-scope |
1380 | @opindex fno-for-scope | |
695ac33f | 1381 | If @option{-ffor-scope} is specified, the scope of variables declared in |
74291a4b | 1382 | a @i{for-init-statement} is limited to the @samp{for} loop itself, |
34527c47 | 1383 | as specified by the C++ standard. |
695ac33f | 1384 | If @option{-fno-for-scope} is specified, the scope of variables declared in |
74291a4b | 1385 | a @i{for-init-statement} extends to the end of the enclosing scope, |
aee96fe9 | 1386 | as was the case in old versions of G++, and other (traditional) |
74291a4b MM |
1387 | implementations of C++. |
1388 | ||
1389 | The default if neither flag is given to follow the standard, | |
1390 | but to allow and give a warning for old-style code that would | |
1391 | otherwise be invalid, or have different behavior. | |
1392 | ||
1393 | @item -fno-gnu-keywords | |
cd3bb277 | 1394 | @opindex fno-gnu-keywords |
9762e8a4 | 1395 | Do not recognize @code{typeof} as a keyword, so that code can use this |
767094dd | 1396 | word as an identifier. You can use the keyword @code{__typeof__} instead. |
630d3d5a | 1397 | @option{-ansi} implies @option{-fno-gnu-keywords}. |
74291a4b | 1398 | |
1dc5fc4b | 1399 | @item -fno-implicit-templates |
cd3bb277 | 1400 | @opindex fno-implicit-templates |
bba975d4 | 1401 | Never emit code for non-inline templates which are instantiated |
e979f9e8 | 1402 | implicitly (i.e.@: by use); only emit code for explicit instantiations. |
bba975d4 JM |
1403 | @xref{Template Instantiation}, for more information. |
1404 | ||
1405 | @item -fno-implicit-inline-templates | |
cd3bb277 | 1406 | @opindex fno-implicit-inline-templates |
bba975d4 JM |
1407 | Don't emit code for implicit instantiations of inline templates, either. |
1408 | The default is to handle inlines differently so that compiles with and | |
1409 | without optimization will need the same set of explicit instantiations. | |
1dc5fc4b | 1410 | |
74291a4b | 1411 | @item -fno-implement-inlines |
cd3bb277 | 1412 | @opindex fno-implement-inlines |
74291a4b MM |
1413 | To save space, do not emit out-of-line copies of inline functions |
1414 | controlled by @samp{#pragma implementation}. This will cause linker | |
1415 | errors if these functions are not inlined everywhere they are called. | |
1416 | ||
631cf95d | 1417 | @item -fms-extensions |
cd3bb277 | 1418 | @opindex fms-extensions |
32fb1fb2 PE |
1419 | Disable pedantic warnings about constructs used in MFC, such as implicit |
1420 | int and getting a pointer to member function via non-standard syntax. | |
631cf95d | 1421 | |
fcca588c | 1422 | @item -fno-nonansi-builtins |
cd3bb277 | 1423 | @opindex fno-nonansi-builtins |
c771326b | 1424 | Disable built-in declarations of functions that are not mandated by |
161d7b59 | 1425 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, |
fcca588c MM |
1426 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. |
1427 | ||
775afb25 | 1428 | @item -fno-operator-names |
cd3bb277 | 1429 | @opindex fno-operator-names |
775afb25 | 1430 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
74291a4b | 1431 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as |
775afb25 | 1432 | synonyms as keywords. |
74291a4b | 1433 | |
4f8b4fd9 | 1434 | @item -fno-optional-diags |
cd3bb277 | 1435 | @opindex fno-optional-diags |
4f8b4fd9 | 1436 | Disable diagnostics that the standard says a compiler does not need to |
aee96fe9 | 1437 | issue. Currently, the only such diagnostic issued by G++ is the one for |
bba975d4 | 1438 | a name having multiple meanings within a class. |
4f8b4fd9 | 1439 | |
8c7707b0 | 1440 | @item -fpermissive |
cd3bb277 | 1441 | @opindex fpermissive |
4a386498 MM |
1442 | Downgrade some diagnostics about nonconformant code from errors to |
1443 | warnings. Thus, using @option{-fpermissive} will allow some | |
1444 | nonconforming code to compile. | |
8c7707b0 | 1445 | |
8c81598d | 1446 | @item -frepo |
cd3bb277 | 1447 | @opindex frepo |
9c34dbbf ZW |
1448 | Enable automatic template instantiation at link time. This option also |
1449 | implies @option{-fno-implicit-templates}. @xref{Template | |
1450 | Instantiation}, for more information. | |
8c81598d | 1451 | |
8c7707b0 | 1452 | @item -fno-rtti |
cd3bb277 | 1453 | @opindex fno-rtti |
a7fbfcf9 JM |
1454 | Disable generation of information about every class with virtual |
1455 | functions for use by the C++ runtime type identification features | |
1456 | (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts | |
1457 | of the language, you can save some space by using this flag. Note that | |
1458 | exception handling uses the same information, but it will generate it as | |
1459 | needed. | |
8c7707b0 | 1460 | |
fcca588c | 1461 | @item -fstats |
cd3bb277 | 1462 | @opindex fstats |
fcca588c MM |
1463 | Emit statistics about front-end processing at the end of the compilation. |
1464 | This information is generally only useful to the G++ development team. | |
1465 | ||
1dc5fc4b | 1466 | @item -ftemplate-depth-@var{n} |
cd3bb277 | 1467 | @opindex ftemplate-depth |
1dc5fc4b JM |
1468 | Set the maximum instantiation depth for template classes to @var{n}. |
1469 | A limit on the template instantiation depth is needed to detect | |
767094dd | 1470 | endless recursions during template class instantiation. ANSI/ISO C++ |
1dc5fc4b JM |
1471 | conforming programs must not rely on a maximum depth greater than 17. |
1472 | ||
40aac948 JM |
1473 | @item -fno-threadsafe-statics |
1474 | @opindex fno-threadsafe-statics | |
1475 | Do not emit the extra code to use the routines specified in the C++ | |
1476 | ABI for thread-safe initialization of local statics. You can use this | |
1477 | option to reduce code size slightly in code that doesn't need to be | |
1478 | thread-safe. | |
1479 | ||
fc693822 | 1480 | @item -fuse-cxa-atexit |
cd3bb277 | 1481 | @opindex fuse-cxa-atexit |
fc693822 MM |
1482 | Register destructors for objects with static storage duration with the |
1483 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
1484 | This option is required for fully standards-compliant handling of static | |
1485 | destructors, but will only work if your C library supports | |
1486 | @code{__cxa_atexit}. | |
1487 | ||
d7afec4b ND |
1488 | @item -fvisibility-inlines-hidden |
1489 | @opindex fvisibility-inlines-hidden | |
1490 | Causes all inlined methods to be marked with | |
1491 | @code{__attribute__ ((visibility ("hidden")))} so that they do not | |
1492 | appear in the export table of a DSO and do not require a PLT indirection | |
1493 | when used within the DSO. Enabling this option can have a dramatic effect | |
1494 | on load and link times of a DSO as it massively reduces the size of the | |
1495 | dynamic export table when the library makes heavy use of templates. While | |
1496 | it can cause bloating through duplication of code within each DSO where | |
1497 | it is used, often the wastage is less than the considerable space occupied | |
1498 | by a long symbol name in the export table which is typical when using | |
1499 | templates and namespaces. For even more savings, combine with the | |
1500 | @code{-fvisibility=hidden} switch. | |
1501 | ||
02f52e19 | 1502 | @item -fno-weak |
cd3bb277 | 1503 | @opindex fno-weak |
90ecce3e | 1504 | Do not use weak symbol support, even if it is provided by the linker. |
fcca588c MM |
1505 | By default, G++ will use weak symbols if they are available. This |
1506 | option exists only for testing, and should not be used by end-users; | |
1507 | it will result in inferior code and has no benefits. This option may | |
1508 | be removed in a future release of G++. | |
1509 | ||
74291a4b | 1510 | @item -nostdinc++ |
cd3bb277 | 1511 | @opindex nostdinc++ |
74291a4b MM |
1512 | Do not search for header files in the standard directories specific to |
1513 | C++, but do still search the other standard directories. (This option | |
e5e809f4 | 1514 | is used when building the C++ library.) |
74291a4b MM |
1515 | @end table |
1516 | ||
1517 | In addition, these optimization, warning, and code generation options | |
1518 | have meanings only for C++ programs: | |
1519 | ||
2642624b | 1520 | @table @gcctabopt |
74291a4b | 1521 | @item -fno-default-inline |
cd3bb277 | 1522 | @opindex fno-default-inline |
74291a4b | 1523 | Do not assume @samp{inline} for functions defined inside a class scope. |
1dc5fc4b JM |
1524 | @xref{Optimize Options,,Options That Control Optimization}. Note that these |
1525 | functions will have linkage like inline functions; they just won't be | |
1526 | inlined by default. | |
74291a4b | 1527 | |
eca7f13c MM |
1528 | @item -Wabi @r{(C++ only)} |
1529 | @opindex Wabi | |
1530 | Warn when G++ generates code that is probably not compatible with the | |
1531 | vendor-neutral C++ ABI. Although an effort has been made to warn about | |
daf2f129 | 1532 | all such cases, there are probably some cases that are not warned about, |
eca7f13c MM |
1533 | even though G++ is generating incompatible code. There may also be |
1534 | cases where warnings are emitted even though the code that is generated | |
1535 | will be compatible. | |
1536 | ||
1537 | You should rewrite your code to avoid these warnings if you are | |
1538 | concerned about the fact that code generated by G++ may not be binary | |
1539 | compatible with code generated by other compilers. | |
1540 | ||
3364c33b | 1541 | The known incompatibilities at this point include: |
eca7f13c MM |
1542 | |
1543 | @itemize @bullet | |
1544 | ||
1545 | @item | |
1546 | Incorrect handling of tail-padding for bit-fields. G++ may attempt to | |
1547 | pack data into the same byte as a base class. For example: | |
1548 | ||
1549 | @smallexample | |
1550 | struct A @{ virtual void f(); int f1 : 1; @}; | |
1551 | struct B : public A @{ int f2 : 1; @}; | |
1552 | @end smallexample | |
1553 | ||
1554 | @noindent | |
1555 | In this case, G++ will place @code{B::f2} into the same byte | |
daf2f129 | 1556 | as@code{A::f1}; other compilers will not. You can avoid this problem |
eca7f13c MM |
1557 | by explicitly padding @code{A} so that its size is a multiple of the |
1558 | byte size on your platform; that will cause G++ and other compilers to | |
1559 | layout @code{B} identically. | |
1560 | ||
1561 | @item | |
1562 | Incorrect handling of tail-padding for virtual bases. G++ does not use | |
1563 | tail padding when laying out virtual bases. For example: | |
1564 | ||
1565 | @smallexample | |
1566 | struct A @{ virtual void f(); char c1; @}; | |
1567 | struct B @{ B(); char c2; @}; | |
1568 | struct C : public A, public virtual B @{@}; | |
1569 | @end smallexample | |
1570 | ||
1571 | @noindent | |
1572 | In this case, G++ will not place @code{B} into the tail-padding for | |
1573 | @code{A}; other compilers will. You can avoid this problem by | |
1574 | explicitly padding @code{A} so that its size is a multiple of its | |
1575 | alignment (ignoring virtual base classes); that will cause G++ and other | |
1576 | compilers to layout @code{C} identically. | |
1577 | ||
2d3e278d MM |
1578 | @item |
1579 | Incorrect handling of bit-fields with declared widths greater than that | |
1580 | of their underlying types, when the bit-fields appear in a union. For | |
1581 | example: | |
1582 | ||
1583 | @smallexample | |
1584 | union U @{ int i : 4096; @}; | |
1585 | @end smallexample | |
1586 | ||
1587 | @noindent | |
1588 | Assuming that an @code{int} does not have 4096 bits, G++ will make the | |
1589 | union too small by the number of bits in an @code{int}. | |
1590 | ||
956d9305 MM |
1591 | @item |
1592 | Empty classes can be placed at incorrect offsets. For example: | |
daf2f129 | 1593 | |
956d9305 MM |
1594 | @smallexample |
1595 | struct A @{@}; | |
1596 | ||
1597 | struct B @{ | |
1598 | A a; | |
1599 | virtual void f (); | |
1600 | @}; | |
1601 | ||
1602 | struct C : public B, public A @{@}; | |
1603 | @end smallexample | |
1604 | ||
1605 | @noindent | |
c0478a66 | 1606 | G++ will place the @code{A} base class of @code{C} at a nonzero offset; |
956d9305 MM |
1607 | it should be placed at offset zero. G++ mistakenly believes that the |
1608 | @code{A} data member of @code{B} is already at offset zero. | |
1609 | ||
6397d80b MM |
1610 | @item |
1611 | Names of template functions whose types involve @code{typename} or | |
1612 | template template parameters can be mangled incorrectly. | |
1613 | ||
1614 | @smallexample | |
1615 | template <typename Q> | |
1616 | void f(typename Q::X) @{@} | |
1617 | ||
1618 | template <template <typename> class Q> | |
1619 | void f(typename Q<int>::X) @{@} | |
1620 | @end smallexample | |
1621 | ||
1622 | @noindent | |
3364c33b | 1623 | Instantiations of these templates may be mangled incorrectly. |
6397d80b | 1624 | |
eca7f13c MM |
1625 | @end itemize |
1626 | ||
aee96fe9 | 1627 | @item -Wctor-dtor-privacy @r{(C++ only)} |
cd3bb277 | 1628 | @opindex Wctor-dtor-privacy |
9eff22bc LG |
1629 | Warn when a class seems unusable because all the constructors or |
1630 | destructors in that class are private, and it has neither friends nor | |
78d0a54d | 1631 | public static member functions. |
bba975d4 | 1632 | |
aee96fe9 | 1633 | @item -Wnon-virtual-dtor @r{(C++ only)} |
cd3bb277 | 1634 | @opindex Wnon-virtual-dtor |
9eff22bc LG |
1635 | Warn when a class appears to be polymorphic, thereby requiring a virtual |
1636 | destructor, yet it declares a non-virtual one. | |
bd8f9aec | 1637 | This warning is enabled by @option{-Wall}. |
bba975d4 | 1638 | |
aee96fe9 | 1639 | @item -Wreorder @r{(C++ only)} |
cd3bb277 | 1640 | @opindex Wreorder |
bba975d4 JM |
1641 | @cindex reordering, warning |
1642 | @cindex warning for reordering of member initializers | |
1643 | Warn when the order of member initializers given in the code does not | |
1644 | match the order in which they must be executed. For instance: | |
1645 | ||
1646 | @smallexample | |
1647 | struct A @{ | |
1648 | int i; | |
1649 | int j; | |
1650 | A(): j (0), i (1) @{ @} | |
1651 | @}; | |
1652 | @end smallexample | |
1653 | ||
9eff22bc LG |
1654 | The compiler will rearrange the member initializers for @samp{i} |
1655 | and @samp{j} to match the declaration order of the members, emitting | |
1656 | a warning to that effect. This warning is enabled by @option{-Wall}. | |
bba975d4 JM |
1657 | @end table |
1658 | ||
630d3d5a | 1659 | The following @option{-W@dots{}} options are not affected by @option{-Wall}. |
bba975d4 | 1660 | |
2642624b | 1661 | @table @gcctabopt |
aee96fe9 | 1662 | @item -Weffc++ @r{(C++ only)} |
cd3bb277 | 1663 | @opindex Weffc++ |
77f6c1eb RS |
1664 | Warn about violations of the following style guidelines from Scott Meyers' |
1665 | @cite{Effective C++} book: | |
1666 | ||
1667 | @itemize @bullet | |
1668 | @item | |
1669 | Item 11: Define a copy constructor and an assignment operator for classes | |
1670 | with dynamically allocated memory. | |
1671 | ||
1672 | @item | |
1673 | Item 12: Prefer initialization to assignment in constructors. | |
1674 | ||
1675 | @item | |
1676 | Item 14: Make destructors virtual in base classes. | |
1677 | ||
1678 | @item | |
1679 | Item 15: Have @code{operator=} return a reference to @code{*this}. | |
1680 | ||
1681 | @item | |
1682 | Item 23: Don't try to return a reference when you must return an object. | |
1683 | ||
1684 | @end itemize | |
1685 | ||
daf2f129 | 1686 | Also warn about violations of the following style guidelines from |
9eff22bc | 1687 | Scott Meyers' @cite{More Effective C++} book: |
77f6c1eb RS |
1688 | |
1689 | @itemize @bullet | |
1690 | @item | |
1691 | Item 6: Distinguish between prefix and postfix forms of increment and | |
1692 | decrement operators. | |
1693 | ||
1694 | @item | |
1695 | Item 7: Never overload @code{&&}, @code{||}, or @code{,}. | |
1696 | ||
1697 | @end itemize | |
1698 | ||
9eff22bc LG |
1699 | When selecting this option, be aware that the standard library |
1700 | headers do not obey all of these guidelines; use @samp{grep -v} | |
77f6c1eb | 1701 | to filter out those warnings. |
bba975d4 | 1702 | |
aee96fe9 | 1703 | @item -Wno-deprecated @r{(C++ only)} |
cd3bb277 | 1704 | @opindex Wno-deprecated |
767094dd | 1705 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
2de45c06 | 1706 | |
aee96fe9 | 1707 | @item -Wno-non-template-friend @r{(C++ only)} |
cd3bb277 | 1708 | @opindex Wno-non-template-friend |
bba975d4 | 1709 | Disable warnings when non-templatized friend functions are declared |
9eff22bc | 1710 | within a template. Since the advent of explicit template specification |
aee96fe9 | 1711 | support in G++, if the name of the friend is an unqualified-id (i.e., |
bba975d4 | 1712 | @samp{friend foo(int)}), the C++ language specification demands that the |
767094dd | 1713 | friend declare or define an ordinary, nontemplate function. (Section |
aee96fe9 | 1714 | 14.5.3). Before G++ implemented explicit specification, unqualified-ids |
bba975d4 | 1715 | could be interpreted as a particular specialization of a templatized |
767094dd | 1716 | function. Because this non-conforming behavior is no longer the default |
aee96fe9 | 1717 | behavior for G++, @option{-Wnon-template-friend} allows the compiler to |
9eff22bc | 1718 | check existing code for potential trouble spots and is on by default. |
2228d450 | 1719 | This new compiler behavior can be turned off with |
630d3d5a | 1720 | @option{-Wno-non-template-friend} which keeps the conformant compiler code |
2228d450 | 1721 | but disables the helpful warning. |
bba975d4 | 1722 | |
aee96fe9 | 1723 | @item -Wold-style-cast @r{(C++ only)} |
cd3bb277 | 1724 | @opindex Wold-style-cast |
323728aa NS |
1725 | Warn if an old-style (C-style) cast to a non-void type is used within |
1726 | a C++ program. The new-style casts (@samp{static_cast}, | |
1727 | @samp{reinterpret_cast}, and @samp{const_cast}) are less vulnerable to | |
9eff22bc | 1728 | unintended effects and much easier to search for. |
bba975d4 | 1729 | |
aee96fe9 | 1730 | @item -Woverloaded-virtual @r{(C++ only)} |
cd3bb277 | 1731 | @opindex Woverloaded-virtual |
bba975d4 JM |
1732 | @cindex overloaded virtual fn, warning |
1733 | @cindex warning for overloaded virtual fn | |
3747f3dc MM |
1734 | Warn when a function declaration hides virtual functions from a |
1735 | base class. For example, in: | |
1736 | ||
1737 | @smallexample | |
1738 | struct A @{ | |
1739 | virtual void f(); | |
1740 | @}; | |
1741 | ||
1742 | struct B: public A @{ | |
1743 | void f(int); | |
1744 | @}; | |
1745 | @end smallexample | |
1746 | ||
1747 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
9eff22bc | 1748 | like: |
3747f3dc MM |
1749 | |
1750 | @smallexample | |
1751 | B* b; | |
1752 | b->f(); | |
1753 | @end smallexample | |
1754 | ||
1755 | will fail to compile. | |
bba975d4 | 1756 | |
aee96fe9 | 1757 | @item -Wno-pmf-conversions @r{(C++ only)} |
cd3bb277 | 1758 | @opindex Wno-pmf-conversions |
bba975d4 JM |
1759 | Disable the diagnostic for converting a bound pointer to member function |
1760 | to a plain pointer. | |
1761 | ||
aee96fe9 | 1762 | @item -Wsign-promo @r{(C++ only)} |
cd3bb277 | 1763 | @opindex Wsign-promo |
bba975d4 | 1764 | Warn when overload resolution chooses a promotion from unsigned or |
2eac577f | 1765 | enumerated type to a signed type, over a conversion to an unsigned type of |
aee96fe9 | 1766 | the same size. Previous versions of G++ would try to preserve |
bba975d4 JM |
1767 | unsignedness, but the standard mandates the current behavior. |
1768 | ||
aee96fe9 | 1769 | @item -Wsynth @r{(C++ only)} |
cd3bb277 | 1770 | @opindex Wsynth |
bba975d4 JM |
1771 | @cindex warning for synthesized methods |
1772 | @cindex synthesized methods, warning | |
aee96fe9 | 1773 | Warn when G++'s synthesis behavior does not match that of cfront. For |
bba975d4 JM |
1774 | instance: |
1775 | ||
1776 | @smallexample | |
1777 | struct A @{ | |
1778 | operator int (); | |
1779 | A& operator = (int); | |
1780 | @}; | |
1781 | ||
1782 | main () | |
1783 | @{ | |
1784 | A a,b; | |
1785 | a = b; | |
1786 | @} | |
1787 | @end smallexample | |
74291a4b | 1788 | |
aee96fe9 | 1789 | In this example, G++ will synthesize a default @samp{A& operator = |
bba975d4 | 1790 | (const A&);}, while cfront will use the user-defined @samp{operator =}. |
74291a4b MM |
1791 | @end table |
1792 | ||
46e34f96 ZL |
1793 | @node Objective-C and Objective-C++ Dialect Options |
1794 | @section Options Controlling Objective-C and Objective-C++ Dialects | |
60de6385 | 1795 | |
46e34f96 ZL |
1796 | @cindex compiler options, Objective-C and Objective-C++ |
1797 | @cindex Objective-C and Objective-C++ options, command line | |
1798 | @cindex options, Objective-C and Objective-C++ | |
1799 | (NOTE: This manual does not describe the Objective-C and Objective-C++ | |
1800 | languages themselves. See @xref{Standards,,Language Standards | |
1801 | Supported by GCC}, for references.) | |
264fa2db | 1802 | |
60de6385 | 1803 | This section describes the command-line options that are only meaningful |
46e34f96 ZL |
1804 | for Objective-C and Objective-C++ programs, but you can also use most of |
1805 | the language-independent GNU compiler options. | |
1806 | For example, you might compile a file @code{some_class.m} like this: | |
60de6385 | 1807 | |
3ab51846 | 1808 | @smallexample |
60de6385 | 1809 | gcc -g -fgnu-runtime -O -c some_class.m |
3ab51846 | 1810 | @end smallexample |
60de6385 SS |
1811 | |
1812 | @noindent | |
9eff22bc | 1813 | In this example, @option{-fgnu-runtime} is an option meant only for |
46e34f96 ZL |
1814 | Objective-C and Objective-C++ programs; you can use the other options with |
1815 | any language supported by GCC@. | |
1816 | ||
1817 | Note that since Objective-C is an extension of the C language, Objective-C | |
1818 | compilations may also use options specific to the C front-end (e.g., | |
1819 | @option{-Wtraditional}). Similarly, Objective-C++ compilations may use | |
1820 | C++-specific options (e.g., @option{-Wabi}). | |
60de6385 SS |
1821 | |
1822 | Here is a list of options that are @emph{only} for compiling Objective-C | |
46e34f96 | 1823 | and Objective-C++ programs: |
60de6385 SS |
1824 | |
1825 | @table @gcctabopt | |
630d3d5a | 1826 | @item -fconstant-string-class=@var{class-name} |
cd3bb277 | 1827 | @opindex fconstant-string-class |
630d3d5a | 1828 | Use @var{class-name} as the name of the class to instantiate for each |
695ac33f | 1829 | literal string specified with the syntax @code{@@"@dots{}"}. The default |
264fa2db ZL |
1830 | class name is @code{NXConstantString} if the GNU runtime is being used, and |
1831 | @code{NSConstantString} if the NeXT runtime is being used (see below). The | |
1832 | @option{-fconstant-cfstrings} option, if also present, will override the | |
1833 | @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals | |
1834 | to be laid out as constant CoreFoundation strings. | |
60de6385 SS |
1835 | |
1836 | @item -fgnu-runtime | |
cd3bb277 | 1837 | @opindex fgnu-runtime |
60de6385 SS |
1838 | Generate object code compatible with the standard GNU Objective-C |
1839 | runtime. This is the default for most types of systems. | |
1840 | ||
1841 | @item -fnext-runtime | |
cd3bb277 | 1842 | @opindex fnext-runtime |
60de6385 | 1843 | Generate output compatible with the NeXT runtime. This is the default |
1f676100 NP |
1844 | for NeXT-based systems, including Darwin and Mac OS X@. The macro |
1845 | @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is | |
1846 | used. | |
60de6385 | 1847 | |
264fa2db | 1848 | @item -fno-nil-receivers |
5ad7ae7f | 1849 | @opindex fno-nil-receivers |
daf2f129 JM |
1850 | Assume that all Objective-C message dispatches (e.g., |
1851 | @code{[receiver message:arg]}) in this translation unit ensure that the receiver | |
46e34f96 ZL |
1852 | is not @code{nil}. This allows for more efficient entry points in the runtime |
1853 | to be used. Currently, this option is only available in conjunction with | |
264fa2db ZL |
1854 | the NeXT runtime on Mac OS X 10.3 and later. |
1855 | ||
1856 | @item -fobjc-exceptions | |
5ad7ae7f | 1857 | @opindex fobjc-exceptions |
daf2f129 JM |
1858 | Enable syntactic support for structured exception handling in Objective-C, |
1859 | similar to what is offered by C++ and Java. Currently, this option is only | |
1860 | available in conjunction with the NeXT runtime on Mac OS X 10.3 and later. | |
264fa2db ZL |
1861 | |
1862 | @smallexample | |
1863 | @@try @{ | |
1864 | @dots{} | |
1865 | @@throw expr; | |
1866 | @dots{} | |
1867 | @} | |
1868 | @@catch (AnObjCClass *exc) @{ | |
1869 | @dots{} | |
1870 | @@throw expr; | |
1871 | @dots{} | |
1872 | @@throw; | |
1873 | @dots{} | |
1874 | @} | |
1875 | @@catch (AnotherClass *exc) @{ | |
1876 | @dots{} | |
1877 | @} | |
1878 | @@catch (id allOthers) @{ | |
1879 | @dots{} | |
1880 | @} | |
1881 | @@finally @{ | |
1882 | @dots{} | |
1883 | @@throw expr; | |
1884 | @dots{} | |
1885 | @} | |
1886 | @end smallexample | |
1887 | ||
1888 | The @code{@@throw} statement may appear anywhere in an Objective-C or | |
daf2f129 JM |
1889 | Objective-C++ program; when used inside of a @code{@@catch} block, the |
1890 | @code{@@throw} may appear without an argument (as shown above), in which case | |
264fa2db ZL |
1891 | the object caught by the @code{@@catch} will be rethrown. |
1892 | ||
1893 | Note that only (pointers to) Objective-C objects may be thrown and | |
1894 | caught using this scheme. When an object is thrown, it will be caught | |
1895 | by the nearest @code{@@catch} clause capable of handling objects of that type, | |
daf2f129 JM |
1896 | analogously to how @code{catch} blocks work in C++ and Java. A |
1897 | @code{@@catch(id @dots{})} clause (as shown above) may also be provided to catch | |
264fa2db ZL |
1898 | any and all Objective-C exceptions not caught by previous @code{@@catch} |
1899 | clauses (if any). | |
1900 | ||
1901 | The @code{@@finally} clause, if present, will be executed upon exit from the | |
1902 | immediately preceding @code{@@try @dots{} @@catch} section. This will happen | |
1903 | regardless of whether any exceptions are thrown, caught or rethrown | |
1904 | inside the @code{@@try @dots{} @@catch} section, analogously to the behavior | |
1905 | of the @code{finally} clause in Java. | |
1906 | ||
1907 | There are several caveats to using the new exception mechanism: | |
1908 | ||
1909 | @itemize @bullet | |
1910 | @item | |
daf2f129 | 1911 | Although currently designed to be binary compatible with @code{NS_HANDLER}-style |
264fa2db ZL |
1912 | idioms provided by the @code{NSException} class, the new |
1913 | exceptions can only be used on Mac OS X 10.3 (Panther) and later | |
1914 | systems, due to additional functionality needed in the (NeXT) Objective-C | |
1915 | runtime. | |
1916 | ||
1917 | @item | |
1918 | As mentioned above, the new exceptions do not support handling | |
daf2f129 | 1919 | types other than Objective-C objects. Furthermore, when used from |
264fa2db ZL |
1920 | Objective-C++, the Objective-C exception model does not interoperate with C++ |
1921 | exceptions at this time. This means you cannot @code{@@throw} an exception | |
daf2f129 | 1922 | from Objective-C and @code{catch} it in C++, or vice versa |
264fa2db ZL |
1923 | (i.e., @code{throw @dots{} @@catch}). |
1924 | @end itemize | |
daf2f129 | 1925 | |
264fa2db ZL |
1926 | The @option{-fobjc-exceptions} switch also enables the use of synchronization |
1927 | blocks for thread-safe execution: | |
1928 | ||
1929 | @smallexample | |
1930 | @@synchronized (ObjCClass *guard) @{ | |
1931 | @dots{} | |
1932 | @} | |
1933 | @end smallexample | |
1934 | ||
1935 | Upon entering the @code{@@synchronized} block, a thread of execution shall | |
1936 | first check whether a lock has been placed on the corresponding @code{guard} | |
1937 | object by another thread. If it has, the current thread shall wait until | |
daf2f129 | 1938 | the other thread relinquishes its lock. Once @code{guard} becomes available, |
264fa2db ZL |
1939 | the current thread will place its own lock on it, execute the code contained in |
1940 | the @code{@@synchronized} block, and finally relinquish the lock (thereby | |
1941 | making @code{guard} available to other threads). | |
1942 | ||
1943 | Unlike Java, Objective-C does not allow for entire methods to be marked | |
1944 | @code{@@synchronized}. Note that throwing exceptions out of | |
1945 | @code{@@synchronized} blocks is allowed, and will cause the guarding object | |
1946 | to be unlocked properly. | |
1947 | ||
1948 | @item -freplace-objc-classes | |
5ad7ae7f | 1949 | @opindex freplace-objc-classes |
264fa2db ZL |
1950 | Emit a special marker instructing @command{ld(1)} not to statically link in |
1951 | the resulting object file, and allow @command{dyld(1)} to load it in at | |
1952 | run time instead. This is used in conjunction with the Fix-and-Continue | |
daf2f129 | 1953 | debugging mode, where the object file in question may be recompiled and |
264fa2db ZL |
1954 | dynamically reloaded in the course of program execution, without the need |
1955 | to restart the program itself. Currently, Fix-and-Continue functionality | |
daf2f129 | 1956 | is only available in conjunction with the NeXT runtime on Mac OS X 10.3 |
264fa2db ZL |
1957 | and later. |
1958 | ||
1959 | @item -fzero-link | |
5ad7ae7f | 1960 | @opindex fzero-link |
264fa2db ZL |
1961 | When compiling for the NeXT runtime, the compiler ordinarily replaces calls |
1962 | to @code{objc_getClass("@dots{}")} (when the name of the class is known at | |
1963 | compile time) with static class references that get initialized at load time, | |
1964 | which improves run-time performance. Specifying the @option{-fzero-link} flag | |
1965 | suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")} | |
daf2f129 | 1966 | to be retained. This is useful in Zero-Link debugging mode, since it allows |
264fa2db ZL |
1967 | for individual class implementations to be modified during program execution. |
1968 | ||
60de6385 | 1969 | @item -gen-decls |
cd3bb277 | 1970 | @opindex gen-decls |
60de6385 SS |
1971 | Dump interface declarations for all classes seen in the source file to a |
1972 | file named @file{@var{sourcename}.decl}. | |
1973 | ||
1974 | @item -Wno-protocol | |
cd3bb277 | 1975 | @opindex Wno-protocol |
1f676100 NP |
1976 | If a class is declared to implement a protocol, a warning is issued for |
1977 | every method in the protocol that is not implemented by the class. The | |
6335b0aa | 1978 | default behavior is to issue a warning for every method not explicitly |
1f676100 NP |
1979 | implemented in the class, even if a method implementation is inherited |
1980 | from the superclass. If you use the @code{-Wno-protocol} option, then | |
1981 | methods inherited from the superclass are considered to be implemented, | |
1982 | and no warning is issued for them. | |
60de6385 SS |
1983 | |
1984 | @item -Wselector | |
cd3bb277 | 1985 | @opindex Wselector |
1f676100 NP |
1986 | Warn if multiple methods of different types for the same selector are |
1987 | found during compilation. The check is performed on the list of methods | |
1988 | in the final stage of compilation. Additionally, a check is performed | |
9eff22bc LG |
1989 | for each selector appearing in a @code{@@selector(@dots{})} |
1990 | expression, and a corresponding method for that selector has been found | |
1f676100 NP |
1991 | during compilation. Because these checks scan the method table only at |
1992 | the end of compilation, these warnings are not produced if the final | |
1993 | stage of compilation is not reached, for example because an error is | |
1994 | found during compilation, or because the @code{-fsyntax-only} option is | |
1995 | being used. | |
1996 | ||
1997 | @item -Wundeclared-selector | |
1998 | @opindex Wundeclared-selector | |
1999 | Warn if a @code{@@selector(@dots{})} expression referring to an | |
2000 | undeclared selector is found. A selector is considered undeclared if no | |
daf2f129 | 2001 | method with that name has been declared before the |
9eff22bc LG |
2002 | @code{@@selector(@dots{})} expression, either explicitly in an |
2003 | @code{@@interface} or @code{@@protocol} declaration, or implicitly in | |
2004 | an @code{@@implementation} section. This option always performs its | |
2005 | checks as soon as a @code{@@selector(@dots{})} expression is found, | |
2006 | while @code{-Wselector} only performs its checks in the final stage of | |
2007 | compilation. This also enforces the coding style convention | |
1f676100 | 2008 | that methods and selectors must be declared before being used. |
60de6385 | 2009 | |
7989e4dc | 2010 | @item -print-objc-runtime-info |
5ad7ae7f | 2011 | @opindex print-objc-runtime-info |
7989e4dc RO |
2012 | Generate C header describing the largest structure that is passed by |
2013 | value, if any. | |
60de6385 SS |
2014 | |
2015 | @end table | |
2016 | ||
764dbbf2 GDR |
2017 | @node Language Independent Options |
2018 | @section Options to Control Diagnostic Messages Formatting | |
2019 | @cindex options to control diagnostics formatting | |
2020 | @cindex diagnostic messages | |
2021 | @cindex message formatting | |
2022 | ||
b192711e | 2023 | Traditionally, diagnostic messages have been formatted irrespective of |
e979f9e8 | 2024 | the output device's aspect (e.g.@: its width, @dots{}). The options described |
764dbbf2 | 2025 | below can be used to control the diagnostic messages formatting |
e979f9e8 | 2026 | algorithm, e.g.@: how many characters per line, how often source location |
6c0a4eab | 2027 | information should be reported. Right now, only the C++ front end can |
764dbbf2 | 2028 | honor these options. However it is expected, in the near future, that |
6c0a4eab | 2029 | the remaining front ends would be able to digest them correctly. |
764dbbf2 | 2030 | |
2642624b | 2031 | @table @gcctabopt |
764dbbf2 | 2032 | @item -fmessage-length=@var{n} |
cd3bb277 | 2033 | @opindex fmessage-length |
764dbbf2 | 2034 | Try to format error messages so that they fit on lines of about @var{n} |
aee96fe9 | 2035 | characters. The default is 72 characters for @command{g++} and 0 for the rest of |
161d7b59 | 2036 | the front ends supported by GCC@. If @var{n} is zero, then no |
02f52e19 | 2037 | line-wrapping will be done; each error message will appear on a single |
764dbbf2 GDR |
2038 | line. |
2039 | ||
cd3bb277 | 2040 | @opindex fdiagnostics-show-location |
764dbbf2 | 2041 | @item -fdiagnostics-show-location=once |
b192711e | 2042 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
764dbbf2 GDR |
2043 | reporter to emit @emph{once} source location information; that is, in |
2044 | case the message is too long to fit on a single physical line and has to | |
2045 | be wrapped, the source location won't be emitted (as prefix) again, | |
2046 | over and over, in subsequent continuation lines. This is the default | |
c21cd8b1 | 2047 | behavior. |
764dbbf2 GDR |
2048 | |
2049 | @item -fdiagnostics-show-location=every-line | |
2050 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
2051 | messages reporter to emit the same source location information (as | |
4fe9b91c | 2052 | prefix) for physical lines that result from the process of breaking |
b192711e | 2053 | a message which is too long to fit on a single line. |
764dbbf2 GDR |
2054 | |
2055 | @end table | |
2056 | ||
74291a4b MM |
2057 | @node Warning Options |
2058 | @section Options to Request or Suppress Warnings | |
2059 | @cindex options to control warnings | |
2060 | @cindex warning messages | |
2061 | @cindex messages, warning | |
2062 | @cindex suppressing warnings | |
2063 | ||
2064 | Warnings are diagnostic messages that report constructions which | |
2065 | are not inherently erroneous but which are risky or suggest there | |
2066 | may have been an error. | |
2067 | ||
2068 | You can request many specific warnings with options beginning @samp{-W}, | |
630d3d5a | 2069 | for example @option{-Wimplicit} to request warnings on implicit |
74291a4b MM |
2070 | declarations. Each of these specific warning options also has a |
2071 | negative form beginning @samp{-Wno-} to turn off warnings; | |
630d3d5a | 2072 | for example, @option{-Wno-implicit}. This manual lists only one of the |
74291a4b MM |
2073 | two forms, whichever is not the default. |
2074 | ||
62aaa62c GP |
2075 | The following options control the amount and kinds of warnings produced |
2076 | by GCC; for further, language-specific options also refer to | |
46e34f96 ZL |
2077 | @ref{C++ Dialect Options} and @ref{Objective-C and Objective-C++ Dialect |
2078 | Options}. | |
74291a4b | 2079 | |
2642624b | 2080 | @table @gcctabopt |
74291a4b MM |
2081 | @cindex syntax checking |
2082 | @item -fsyntax-only | |
cd3bb277 | 2083 | @opindex fsyntax-only |
74291a4b MM |
2084 | Check the code for syntax errors, but don't do anything beyond that. |
2085 | ||
2086 | @item -pedantic | |
cd3bb277 | 2087 | @opindex pedantic |
074e95e3 JM |
2088 | Issue all the warnings demanded by strict ISO C and ISO C++; |
2089 | reject all programs that use forbidden extensions, and some other | |
2090 | programs that do not follow ISO C and ISO C++. For ISO C, follows the | |
630d3d5a | 2091 | version of the ISO C standard specified by any @option{-std} option used. |
74291a4b | 2092 | |
074e95e3 | 2093 | Valid ISO C and ISO C++ programs should compile properly with or without |
5490d604 | 2094 | this option (though a rare few will require @option{-ansi} or a |
161d7b59 | 2095 | @option{-std} option specifying the required version of ISO C)@. However, |
b1d16193 JL |
2096 | without this option, certain GNU extensions and traditional C and C++ |
2097 | features are supported as well. With this option, they are rejected. | |
74291a4b | 2098 | |
630d3d5a | 2099 | @option{-pedantic} does not cause warning messages for use of the |
74291a4b MM |
2100 | alternate keywords whose names begin and end with @samp{__}. Pedantic |
2101 | warnings are also disabled in the expression that follows | |
2102 | @code{__extension__}. However, only system header files should use | |
2103 | these escape routes; application programs should avoid them. | |
2104 | @xref{Alternate Keywords}. | |
2105 | ||
630d3d5a | 2106 | Some users try to use @option{-pedantic} to check programs for strict ISO |
74291a4b | 2107 | C conformance. They soon find that it does not do quite what they want: |
c1030c7c | 2108 | it finds some non-ISO practices, but not all---only those for which |
074e95e3 JM |
2109 | ISO C @emph{requires} a diagnostic, and some others for which |
2110 | diagnostics have been added. | |
74291a4b | 2111 | |
074e95e3 | 2112 | A feature to report any failure to conform to ISO C might be useful in |
74291a4b | 2113 | some instances, but would require considerable additional work and would |
630d3d5a | 2114 | be quite different from @option{-pedantic}. We don't have plans to |
892d0a6d | 2115 | support such a feature in the near future. |
74291a4b | 2116 | |
91ea548a JM |
2117 | Where the standard specified with @option{-std} represents a GNU |
2118 | extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a | |
2119 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
2120 | extended dialect is based. Warnings from @option{-pedantic} are given | |
2121 | where they are required by the base standard. (It would not make sense | |
2122 | for such warnings to be given only for features not in the specified GNU | |
2123 | C dialect, since by definition the GNU dialects of C include all | |
2124 | features the compiler supports with the given option, and there would be | |
2125 | nothing to warn about.) | |
2126 | ||
74291a4b | 2127 | @item -pedantic-errors |
cd3bb277 | 2128 | @opindex pedantic-errors |
630d3d5a | 2129 | Like @option{-pedantic}, except that errors are produced rather than |
74291a4b MM |
2130 | warnings. |
2131 | ||
2132 | @item -w | |
cd3bb277 | 2133 | @opindex w |
74291a4b MM |
2134 | Inhibit all warning messages. |
2135 | ||
2136 | @item -Wno-import | |
cd3bb277 | 2137 | @opindex Wno-import |
74291a4b MM |
2138 | Inhibit warning messages about the use of @samp{#import}. |
2139 | ||
2140 | @item -Wchar-subscripts | |
cd3bb277 | 2141 | @opindex Wchar-subscripts |
74291a4b MM |
2142 | Warn if an array subscript has type @code{char}. This is a common cause |
2143 | of error, as programmers often forget that this type is signed on some | |
2144 | machines. | |
2145 | ||
2146 | @item -Wcomment | |
cd3bb277 | 2147 | @opindex Wcomment |
74291a4b MM |
2148 | Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*} |
2149 | comment, or whenever a Backslash-Newline appears in a @samp{//} comment. | |
2150 | ||
c65a01af RG |
2151 | @item -Wfatal-errors |
2152 | @opindex Wfatal-errors | |
2153 | This option causes the compiler to abort compilation on the first error | |
2154 | occurred rather than trying to keep going and printing further error | |
2155 | messages. | |
2156 | ||
74291a4b | 2157 | @item -Wformat |
cd3bb277 | 2158 | @opindex Wformat |
74291a4b MM |
2159 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
2160 | the arguments supplied have types appropriate to the format string | |
26f6672d JM |
2161 | specified, and that the conversions specified in the format string make |
2162 | sense. This includes standard functions, and others specified by format | |
2163 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
2164 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
a2bec818 | 2165 | not in the C standard) families (or other target-specific families). |
74291a4b | 2166 | |
8308e0b7 | 2167 | The formats are checked against the format features supported by GNU |
3764f879 | 2168 | libc version 2.2. These include all ISO C90 and C99 features, as well |
8308e0b7 JM |
2169 | as features from the Single Unix Specification and some BSD and GNU |
2170 | extensions. Other library implementations may not support all these | |
2171 | features; GCC does not support warning about features that go beyond a | |
630d3d5a JM |
2172 | particular library's limitations. However, if @option{-pedantic} is used |
2173 | with @option{-Wformat}, warnings will be given about format features not | |
26f6672d JM |
2174 | in the selected standard version (but not for @code{strfmon} formats, |
2175 | since those are not in any version of the C standard). @xref{C Dialect | |
2176 | Options,,Options Controlling C Dialect}. | |
8308e0b7 | 2177 | |
b34c7881 JT |
2178 | Since @option{-Wformat} also checks for null format arguments for |
2179 | several functions, @option{-Wformat} also implies @option{-Wnonnull}. | |
2180 | ||
630d3d5a | 2181 | @option{-Wformat} is included in @option{-Wall}. For more control over some |
c76f4e8e | 2182 | aspects of format checking, the options @option{-Wformat-y2k}, |
e964a556 JT |
2183 | @option{-Wno-format-extra-args}, @option{-Wno-format-zero-length}, |
2184 | @option{-Wformat-nonliteral}, @option{-Wformat-security}, and | |
2185 | @option{-Wformat=2} are available, but are not included in @option{-Wall}. | |
4d808927 | 2186 | |
c76f4e8e JM |
2187 | @item -Wformat-y2k |
2188 | @opindex Wformat-y2k | |
2189 | If @option{-Wformat} is specified, also warn about @code{strftime} | |
4d808927 JM |
2190 | formats which may yield only a two-digit year. |
2191 | ||
2192 | @item -Wno-format-extra-args | |
cd3bb277 | 2193 | @opindex Wno-format-extra-args |
630d3d5a | 2194 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
4d808927 JM |
2195 | @code{printf} or @code{scanf} format function. The C standard specifies |
2196 | that such arguments are ignored. | |
2197 | ||
7e5fb12f JM |
2198 | Where the unused arguments lie between used arguments that are |
2199 | specified with @samp{$} operand number specifications, normally | |
2200 | warnings are still given, since the implementation could not know what | |
2201 | type to pass to @code{va_arg} to skip the unused arguments. However, | |
2202 | in the case of @code{scanf} formats, this option will suppress the | |
2203 | warning if the unused arguments are all pointers, since the Single | |
2204 | Unix Specification says that such unused arguments are allowed. | |
2205 | ||
e964a556 JT |
2206 | @item -Wno-format-zero-length |
2207 | @opindex Wno-format-zero-length | |
2208 | If @option{-Wformat} is specified, do not warn about zero-length formats. | |
2209 | The C standard specifies that zero-length formats are allowed. | |
2210 | ||
4d808927 | 2211 | @item -Wformat-nonliteral |
cd3bb277 | 2212 | @opindex Wformat-nonliteral |
630d3d5a | 2213 | If @option{-Wformat} is specified, also warn if the format string is not a |
4d808927 JM |
2214 | string literal and so cannot be checked, unless the format function |
2215 | takes its format arguments as a @code{va_list}. | |
2216 | ||
c907e684 | 2217 | @item -Wformat-security |
cd3bb277 | 2218 | @opindex Wformat-security |
630d3d5a | 2219 | If @option{-Wformat} is specified, also warn about uses of format |
c907e684 JM |
2220 | functions that represent possible security problems. At present, this |
2221 | warns about calls to @code{printf} and @code{scanf} functions where the | |
2222 | format string is not a string literal and there are no format arguments, | |
2223 | as in @code{printf (foo);}. This may be a security hole if the format | |
2224 | string came from untrusted input and contains @samp{%n}. (This is | |
630d3d5a JM |
2225 | currently a subset of what @option{-Wformat-nonliteral} warns about, but |
2226 | in future warnings may be added to @option{-Wformat-security} that are not | |
2227 | included in @option{-Wformat-nonliteral}.) | |
c907e684 | 2228 | |
4d808927 | 2229 | @item -Wformat=2 |
cd3bb277 | 2230 | @opindex Wformat=2 |
630d3d5a JM |
2231 | Enable @option{-Wformat} plus format checks not included in |
2232 | @option{-Wformat}. Currently equivalent to @samp{-Wformat | |
c76f4e8e | 2233 | -Wformat-nonliteral -Wformat-security -Wformat-y2k}. |
4d808927 | 2234 | |
b34c7881 JT |
2235 | @item -Wnonnull |
2236 | @opindex Wnonnull | |
f6d9224f | 2237 | Warn about passing a null pointer for arguments marked as |
b34c7881 JT |
2238 | requiring a non-null value by the @code{nonnull} function attribute. |
2239 | ||
2240 | @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It | |
2241 | can be disabled with the @option{-Wno-nonnull} option. | |
2242 | ||
46e34f96 | 2243 | @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)} |
3390f9c9 | 2244 | @opindex Winit-self |
f6d9224f GP |
2245 | Warn about uninitialized variables which are initialized with themselves. |
2246 | Note this option can only be used with the @option{-Wuninitialized} option, | |
2247 | which in turn only works with @option{-O1} and above. | |
3390f9c9 | 2248 | |
f6d9224f GP |
2249 | For example, GCC will warn about @code{i} being uninitialized in the |
2250 | following snippet only when @option{-Winit-self} has been specified: | |
3390f9c9 AP |
2251 | @smallexample |
2252 | @group | |
2253 | int f() | |
2254 | @{ | |
2255 | int i = i; | |
2256 | return i; | |
2257 | @} | |
2258 | @end group | |
2259 | @end smallexample | |
2260 | ||
e9a25f70 | 2261 | @item -Wimplicit-int |
cd3bb277 | 2262 | @opindex Wimplicit-int |
e9a25f70 JL |
2263 | Warn when a declaration does not specify a type. |
2264 | ||
f5963e61 JL |
2265 | @item -Wimplicit-function-declaration |
2266 | @itemx -Werror-implicit-function-declaration | |
cd3bb277 JM |
2267 | @opindex Wimplicit-function-declaration |
2268 | @opindex Werror-implicit-function-declaration | |
f5963e61 JL |
2269 | Give a warning (or error) whenever a function is used before being |
2270 | declared. | |
e9a25f70 | 2271 | |
74291a4b | 2272 | @item -Wimplicit |
cd3bb277 | 2273 | @opindex Wimplicit |
630d3d5a | 2274 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
861bb6c1 JL |
2275 | |
2276 | @item -Wmain | |
cd3bb277 | 2277 | @opindex Wmain |
861bb6c1 JL |
2278 | Warn if the type of @samp{main} is suspicious. @samp{main} should be a |
2279 | function with external linkage, returning int, taking either zero | |
2280 | arguments, two, or three arguments of appropriate types. | |
4a870dba | 2281 | |
1f0c3120 | 2282 | @item -Wmissing-braces |
cd3bb277 | 2283 | @opindex Wmissing-braces |
1f0c3120 JM |
2284 | Warn if an aggregate or union initializer is not fully bracketed. In |
2285 | the following example, the initializer for @samp{a} is not fully | |
2286 | bracketed, but that for @samp{b} is fully bracketed. | |
2287 | ||
2288 | @smallexample | |
2289 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
2290 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
2291 | @end smallexample | |
2292 | ||
46e34f96 | 2293 | @item -Wmissing-include-dirs @r{(C, C++, Objective-C and Objective-C++ only)} |
b02398bd BE |
2294 | @opindex Wmissing-include-dirs |
2295 | Warn if a user-supplied include directory does not exist. | |
2296 | ||
74291a4b | 2297 | @item -Wparentheses |
cd3bb277 | 2298 | @opindex Wparentheses |
74291a4b MM |
2299 | Warn if parentheses are omitted in certain contexts, such |
2300 | as when there is an assignment in a context where a truth value | |
2301 | is expected, or when operators are nested whose precedence people | |
3e3970a2 JM |
2302 | often get confused about. Only the warning for an assignment used as |
2303 | a truth value is supported when compiling C++; the other warnings are | |
2304 | only supported when compiling C@. | |
2305 | ||
2306 | Also warn if a comparison like @samp{x<=y<=z} appears; this is | |
2307 | equivalent to @samp{(x<=y ? 1 : 0) <= z}, which is a different | |
2308 | interpretation from that of ordinary mathematical notation. | |
74291a4b | 2309 | |
e9a25f70 JL |
2310 | Also warn about constructions where there may be confusion to which |
2311 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
2312 | such a case: | |
2313 | ||
2314 | @smallexample | |
aee96fe9 | 2315 | @group |
e9a25f70 JL |
2316 | @{ |
2317 | if (a) | |
2318 | if (b) | |
2319 | foo (); | |
2320 | else | |
2321 | bar (); | |
2322 | @} | |
aee96fe9 | 2323 | @end group |
e9a25f70 JL |
2324 | @end smallexample |
2325 | ||
2326 | In C, every @code{else} branch belongs to the innermost possible @code{if} | |
2327 | statement, which in this example is @code{if (b)}. This is often not | |
2328 | what the programmer expected, as illustrated in the above example by | |
2329 | indentation the programmer chose. When there is the potential for this | |
f0523f02 | 2330 | confusion, GCC will issue a warning when this flag is specified. |
e9a25f70 JL |
2331 | To eliminate the warning, add explicit braces around the innermost |
2332 | @code{if} statement so there is no way the @code{else} could belong to | |
2333 | the enclosing @code{if}. The resulting code would look like this: | |
2334 | ||
2335 | @smallexample | |
aee96fe9 | 2336 | @group |
e9a25f70 JL |
2337 | @{ |
2338 | if (a) | |
2339 | @{ | |
2340 | if (b) | |
2341 | foo (); | |
2342 | else | |
2343 | bar (); | |
2344 | @} | |
2345 | @} | |
aee96fe9 | 2346 | @end group |
e9a25f70 JL |
2347 | @end smallexample |
2348 | ||
bb58bec5 | 2349 | @item -Wsequence-point |
cd3bb277 | 2350 | @opindex Wsequence-point |
bb58bec5 JM |
2351 | Warn about code that may have undefined semantics because of violations |
2352 | of sequence point rules in the C standard. | |
2353 | ||
2354 | The C standard defines the order in which expressions in a C program are | |
2355 | evaluated in terms of @dfn{sequence points}, which represent a partial | |
2356 | ordering between the execution of parts of the program: those executed | |
2357 | before the sequence point, and those executed after it. These occur | |
2358 | after the evaluation of a full expression (one which is not part of a | |
2359 | larger expression), after the evaluation of the first operand of a | |
2360 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
2361 | function is called (but after the evaluation of its arguments and the | |
2362 | expression denoting the called function), and in certain other places. | |
2363 | Other than as expressed by the sequence point rules, the order of | |
2364 | evaluation of subexpressions of an expression is not specified. All | |
2365 | these rules describe only a partial order rather than a total order, | |
2366 | since, for example, if two functions are called within one expression | |
2367 | with no sequence point between them, the order in which the functions | |
2368 | are called is not specified. However, the standards committee have | |
2369 | ruled that function calls do not overlap. | |
2370 | ||
2371 | It is not specified when between sequence points modifications to the | |
2372 | values of objects take effect. Programs whose behavior depends on this | |
2373 | have undefined behavior; the C standard specifies that ``Between the | |
2374 | previous and next sequence point an object shall have its stored value | |
2375 | modified at most once by the evaluation of an expression. Furthermore, | |
2376 | the prior value shall be read only to determine the value to be | |
2377 | stored.''. If a program breaks these rules, the results on any | |
2378 | particular implementation are entirely unpredictable. | |
2379 | ||
2380 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
2381 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
2382 | diagnosed by this option, and it may give an occasional false positive | |
2383 | result, but in general it has been found fairly effective at detecting | |
2384 | this sort of problem in programs. | |
2385 | ||
2386 | The present implementation of this option only works for C programs. A | |
2387 | future implementation may also work for C++ programs. | |
2388 | ||
9c34dbbf ZW |
2389 | The C standard is worded confusingly, therefore there is some debate |
2390 | over the precise meaning of the sequence point rules in subtle cases. | |
2391 | Links to discussions of the problem, including proposed formal | |
962e6e00 | 2392 | definitions, may be found on the GCC readings page, at |
c5122d75 | 2393 | @w{@uref{http://gcc.gnu.org/readings.html}}. |
bb58bec5 | 2394 | |
74291a4b | 2395 | @item -Wreturn-type |
cd3bb277 | 2396 | @opindex Wreturn-type |
32c4c36c ML |
2397 | Warn whenever a function is defined with a return-type that defaults to |
2398 | @code{int}. Also warn about any @code{return} statement with no | |
02f52e19 | 2399 | return-value in a function whose return-type is not @code{void}. |
32c4c36c | 2400 | |
e508a019 JM |
2401 | For C, also warn if the return type of a function has a type qualifier |
2402 | such as @code{const}. Such a type qualifier has no effect, since the | |
2403 | value returned by a function is not an lvalue. ISO C prohibits | |
2404 | qualified @code{void} return types on function definitions, so such | |
2405 | return types always receive a warning even without this option. | |
2406 | ||
32c4c36c | 2407 | For C++, a function without return type always produces a diagnostic |
767094dd | 2408 | message, even when @option{-Wno-return-type} is specified. The only |
32c4c36c | 2409 | exceptions are @samp{main} and functions defined in system headers. |
74291a4b MM |
2410 | |
2411 | @item -Wswitch | |
cd3bb277 | 2412 | @opindex Wswitch |
2eac577f | 2413 | Warn whenever a @code{switch} statement has an index of enumerated type |
74291a4b MM |
2414 | and lacks a @code{case} for one or more of the named codes of that |
2415 | enumeration. (The presence of a @code{default} label prevents this | |
2416 | warning.) @code{case} labels outside the enumeration range also | |
2417 | provoke warnings when this option is used. | |
2418 | ||
d6961341 AC |
2419 | @item -Wswitch-default |
2420 | @opindex Wswitch-switch | |
2421 | Warn whenever a @code{switch} statement does not have a @code{default} | |
2422 | case. | |
2423 | ||
173028e5 AC |
2424 | @item -Wswitch-enum |
2425 | @opindex Wswitch-enum | |
2eac577f | 2426 | Warn whenever a @code{switch} statement has an index of enumerated type |
173028e5 AC |
2427 | and lacks a @code{case} for one or more of the named codes of that |
2428 | enumeration. @code{case} labels outside the enumeration range also | |
2429 | provoke warnings when this option is used. | |
2430 | ||
74291a4b | 2431 | @item -Wtrigraphs |
cd3bb277 | 2432 | @opindex Wtrigraphs |
f2ecb02d JM |
2433 | Warn if any trigraphs are encountered that might change the meaning of |
2434 | the program (trigraphs within comments are not warned about). | |
74291a4b | 2435 | |
078721e1 | 2436 | @item -Wunused-function |
cd3bb277 | 2437 | @opindex Wunused-function |
078721e1 AC |
2438 | Warn whenever a static function is declared but not defined or a |
2439 | non\-inline static function is unused. | |
74291a4b | 2440 | |
078721e1 | 2441 | @item -Wunused-label |
cd3bb277 | 2442 | @opindex Wunused-label |
078721e1 AC |
2443 | Warn whenever a label is declared but not used. |
2444 | ||
2445 | To suppress this warning use the @samp{unused} attribute | |
2446 | (@pxref{Variable Attributes}). | |
2447 | ||
2448 | @item -Wunused-parameter | |
cd3bb277 | 2449 | @opindex Wunused-parameter |
078721e1 AC |
2450 | Warn whenever a function parameter is unused aside from its declaration. |
2451 | ||
2452 | To suppress this warning use the @samp{unused} attribute | |
2453 | (@pxref{Variable Attributes}). | |
956d6950 | 2454 | |
078721e1 | 2455 | @item -Wunused-variable |
cd3bb277 | 2456 | @opindex Wunused-variable |
078721e1 AC |
2457 | Warn whenever a local variable or non-constant static variable is unused |
2458 | aside from its declaration | |
2459 | ||
2460 | To suppress this warning use the @samp{unused} attribute | |
74291a4b MM |
2461 | (@pxref{Variable Attributes}). |
2462 | ||
078721e1 | 2463 | @item -Wunused-value |
cd3bb277 | 2464 | @opindex Wunused-value |
078721e1 AC |
2465 | Warn whenever a statement computes a result that is explicitly not used. |
2466 | ||
2467 | To suppress this warning cast the expression to @samp{void}. | |
2468 | ||
2469 | @item -Wunused | |
cd3bb277 | 2470 | @opindex Wunused |
d3075b6c | 2471 | All the above @option{-Wunused} options combined. |
078721e1 AC |
2472 | |
2473 | In order to get a warning about an unused function parameter, you must | |
65ca2d60 PE |
2474 | either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies |
2475 | @samp{-Wunused}), or separately specify @option{-Wunused-parameter}. | |
078721e1 | 2476 | |
74291a4b | 2477 | @item -Wuninitialized |
cd3bb277 | 2478 | @opindex Wuninitialized |
c5c76735 JL |
2479 | Warn if an automatic variable is used without first being initialized or |
2480 | if a variable may be clobbered by a @code{setjmp} call. | |
74291a4b MM |
2481 | |
2482 | These warnings are possible only in optimizing compilation, | |
2483 | because they require data flow information that is computed only | |
630d3d5a | 2484 | when optimizing. If you don't specify @option{-O}, you simply won't |
74291a4b MM |
2485 | get these warnings. |
2486 | ||
3390f9c9 AP |
2487 | If you want to warn about code which uses the uninitialized value of the |
2488 | variable in its own initializer, use the @option{-Winit-self} option. | |
2489 | ||
74291a4b MM |
2490 | These warnings occur only for variables that are candidates for |
2491 | register allocation. Therefore, they do not occur for a variable that | |
2492 | is declared @code{volatile}, or whose address is taken, or whose size | |
2493 | is other than 1, 2, 4 or 8 bytes. Also, they do not occur for | |
2494 | structures, unions or arrays, even when they are in registers. | |
2495 | ||
2496 | Note that there may be no warning about a variable that is used only | |
2497 | to compute a value that itself is never used, because such | |
2498 | computations may be deleted by data flow analysis before the warnings | |
2499 | are printed. | |
2500 | ||
0c2d1a2a | 2501 | These warnings are made optional because GCC is not smart |
74291a4b MM |
2502 | enough to see all the reasons why the code might be correct |
2503 | despite appearing to have an error. Here is one example of how | |
2504 | this can happen: | |
2505 | ||
2506 | @smallexample | |
aee96fe9 | 2507 | @group |
74291a4b MM |
2508 | @{ |
2509 | int x; | |
2510 | switch (y) | |
2511 | @{ | |
2512 | case 1: x = 1; | |
2513 | break; | |
2514 | case 2: x = 4; | |
2515 | break; | |
2516 | case 3: x = 5; | |
2517 | @} | |
2518 | foo (x); | |
2519 | @} | |
aee96fe9 | 2520 | @end group |
74291a4b MM |
2521 | @end smallexample |
2522 | ||
2523 | @noindent | |
2524 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
0c2d1a2a | 2525 | always initialized, but GCC doesn't know this. Here is |
74291a4b MM |
2526 | another common case: |
2527 | ||
2528 | @smallexample | |
2529 | @{ | |
2530 | int save_y; | |
2531 | if (change_y) save_y = y, y = new_y; | |
2532 | @dots{} | |
2533 | if (change_y) y = save_y; | |
2534 | @} | |
2535 | @end smallexample | |
2536 | ||
2537 | @noindent | |
2538 | This has no bug because @code{save_y} is used only if it is set. | |
2539 | ||
20300b05 | 2540 | @cindex @code{longjmp} warnings |
b192711e | 2541 | This option also warns when a non-volatile automatic variable might be |
c5c76735 JL |
2542 | changed by a call to @code{longjmp}. These warnings as well are possible |
2543 | only in optimizing compilation. | |
20300b05 GK |
2544 | |
2545 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
2546 | where @code{longjmp} will be called; in fact, a signal handler could | |
2547 | call it at any point in the code. As a result, you may get a warning | |
2548 | even when there is in fact no problem because @code{longjmp} cannot | |
2549 | in fact be called at the place which would cause a problem. | |
2550 | ||
74291a4b MM |
2551 | Some spurious warnings can be avoided if you declare all the functions |
2552 | you use that never return as @code{noreturn}. @xref{Function | |
2553 | Attributes}. | |
2554 | ||
d300e551 | 2555 | @item -Wunknown-pragmas |
cd3bb277 | 2556 | @opindex Wunknown-pragmas |
d300e551 NC |
2557 | @cindex warning for unknown pragmas |
2558 | @cindex unknown pragmas, warning | |
2559 | @cindex pragmas, warning of unknown | |
2560 | Warn when a #pragma directive is encountered which is not understood by | |
161d7b59 | 2561 | GCC@. If this command line option is used, warnings will even be issued |
d300e551 | 2562 | for unknown pragmas in system header files. This is not the case if |
630d3d5a | 2563 | the warnings were only enabled by the @option{-Wall} command line option. |
d300e551 | 2564 | |
bf52f899 NS |
2565 | @item -Wstrict-aliasing |
2566 | @opindex Wstrict-aliasing | |
2567 | This option is only active when @option{-fstrict-aliasing} is active. | |
2568 | It warns about code which might break the strict aliasing rules that the | |
2569 | compiler is using for optimization. The warning does not catch all | |
2570 | cases, but does attempt to catch the more common pitfalls. It is | |
2571 | included in @option{-Wall}. | |
2572 | ||
5399d643 JW |
2573 | @item -Wstrict-aliasing=2 |
2574 | @opindex Wstrict-aliasing=2 | |
2575 | This option is only active when @option{-fstrict-aliasing} is active. | |
2576 | It warns about all code which might break the strict aliasing rules that the | |
2577 | compiler is using for optimization. This warning catches all cases, but | |
2578 | it will also give a warning for some ambiguous cases that are safe. | |
2579 | ||
74291a4b | 2580 | @item -Wall |
cd3bb277 | 2581 | @opindex Wall |
74291a4b MM |
2582 | All of the above @samp{-W} options combined. This enables all the |
2583 | warnings about constructions that some users consider questionable, and | |
2584 | that are easy to avoid (or modify to prevent the warning), even in | |
bd8f9aec SP |
2585 | conjunction with macros. This also enables some language-specific |
2586 | warnings described in @ref{C++ Dialect Options} and | |
46e34f96 | 2587 | @ref{Objective-C and Objective-C++ Dialect Options}. |
74291a4b MM |
2588 | @end table |
2589 | ||
630d3d5a | 2590 | The following @option{-W@dots{}} options are not implied by @option{-Wall}. |
74291a4b MM |
2591 | Some of them warn about constructions that users generally do not |
2592 | consider questionable, but which occasionally you might wish to check | |
2593 | for; others warn about constructions that are necessary or hard to avoid | |
2594 | in some cases, and there is no simple way to modify the code to suppress | |
2595 | the warning. | |
2596 | ||
2642624b | 2597 | @table @gcctabopt |
65ca2d60 | 2598 | @item -Wextra |
cd3bb277 | 2599 | @opindex W |
65ca2d60 PE |
2600 | @opindex Wextra |
2601 | (This option used to be called @option{-W}. The older name is still | |
2602 | supported, but the newer name is more descriptive.) Print extra warning | |
2603 | messages for these events: | |
74291a4b MM |
2604 | |
2605 | @itemize @bullet | |
74291a4b MM |
2606 | @item |
2607 | A function can return either with or without a value. (Falling | |
2608 | off the end of the function body is considered returning without | |
2609 | a value.) For example, this function would evoke such a | |
2610 | warning: | |
2611 | ||
2612 | @smallexample | |
2613 | @group | |
2614 | foo (a) | |
2615 | @{ | |
2616 | if (a > 0) | |
2617 | return a; | |
2618 | @} | |
2619 | @end group | |
2620 | @end smallexample | |
2621 | ||
2622 | @item | |
2623 | An expression-statement or the left-hand side of a comma expression | |
2624 | contains no side effects. | |
2625 | To suppress the warning, cast the unused expression to void. | |
2626 | For example, an expression such as @samp{x[i,j]} will cause a warning, | |
2627 | but @samp{x[(void)i,j]} will not. | |
2628 | ||
2629 | @item | |
65ca2d60 | 2630 | An unsigned value is compared against zero with @samp{<} or @samp{>=}. |
74291a4b | 2631 | |
74291a4b MM |
2632 | @item |
2633 | Storage-class specifiers like @code{static} are not the first things in | |
2634 | a declaration. According to the C Standard, this usage is obsolescent. | |
2635 | ||
2636 | @item | |
630d3d5a | 2637 | If @option{-Wall} or @option{-Wunused} is also specified, warn about unused |
74291a4b MM |
2638 | arguments. |
2639 | ||
e9a25f70 JL |
2640 | @item |
2641 | A comparison between signed and unsigned values could produce an | |
2642 | incorrect result when the signed value is converted to unsigned. | |
630d3d5a | 2643 | (But don't warn if @option{-Wno-sign-compare} is also specified.) |
e9a25f70 | 2644 | |
dbde0d5d BH |
2645 | @item |
2646 | An aggregate has an initializer which does not initialize all members. | |
eaac4679 RS |
2647 | This warning can be independently controlled by |
2648 | @option{-Wmissing-field-initializers}. | |
65ca2d60 PE |
2649 | |
2650 | @item | |
2651 | A function parameter is declared without a type specifier in K&R-style | |
2652 | functions: | |
2653 | ||
2654 | @smallexample | |
2655 | void foo(bar) @{ @} | |
2656 | @end smallexample | |
2657 | ||
2658 | @item | |
2659 | An empty body occurs in an @samp{if} or @samp{else} statement. | |
2660 | ||
2661 | @item | |
2662 | A pointer is compared against integer zero with @samp{<}, @samp{<=}, | |
2663 | @samp{>}, or @samp{>=}. | |
2664 | ||
2665 | @item | |
2666 | A variable might be changed by @samp{longjmp} or @samp{vfork}. | |
2667 | ||
2668 | @item | |
2669 | Any of several floating-point events that often indicate errors, such as | |
2670 | overflow, underflow, loss of precision, etc. | |
2671 | ||
2672 | @item @r{(C++ only)} | |
2673 | An enumerator and a non-enumerator both appear in a conditional expression. | |
2674 | ||
2675 | @item @r{(C++ only)} | |
2676 | A non-static reference or non-static @samp{const} member appears in a | |
2677 | class without constructors. | |
2678 | ||
2679 | @item @r{(C++ only)} | |
2680 | Ambiguous virtual bases. | |
2681 | ||
2682 | @item @r{(C++ only)} | |
2683 | Subscripting an array which has been declared @samp{register}. | |
2684 | ||
2685 | @item @r{(C++ only)} | |
2686 | Taking the address of a variable which has been declared @samp{register}. | |
2687 | ||
2688 | @item @r{(C++ only)} | |
62b9c42c | 2689 | A base class is not initialized in a derived class' copy constructor. |
74291a4b MM |
2690 | @end itemize |
2691 | ||
75227a33 GK |
2692 | @item -Wno-div-by-zero |
2693 | @opindex Wno-div-by-zero | |
2694 | @opindex Wdiv-by-zero | |
2695 | Do not warn about compile-time integer division by zero. Floating point | |
2696 | division by zero is not warned about, as it can be a legitimate way of | |
2697 | obtaining infinities and NaNs. | |
2698 | ||
2699 | @item -Wsystem-headers | |
2700 | @opindex Wsystem-headers | |
2701 | @cindex warnings from system headers | |
2702 | @cindex system headers, warnings from | |
2703 | Print warning messages for constructs found in system header files. | |
2704 | Warnings from system headers are normally suppressed, on the assumption | |
2705 | that they usually do not indicate real problems and would only make the | |
2706 | compiler output harder to read. Using this command line option tells | |
2707 | GCC to emit warnings from system headers as if they occurred in user | |
2708 | code. However, note that using @option{-Wall} in conjunction with this | |
2709 | option will @emph{not} warn about unknown pragmas in system | |
2710 | headers---for that, @option{-Wunknown-pragmas} must also be used. | |
2711 | ||
f793a95e | 2712 | @item -Wfloat-equal |
cd3bb277 | 2713 | @opindex Wfloat-equal |
f793a95e JL |
2714 | Warn if floating point values are used in equality comparisons. |
2715 | ||
488d3985 GK |
2716 | The idea behind this is that sometimes it is convenient (for the |
2717 | programmer) to consider floating-point values as approximations to | |
2718 | infinitely precise real numbers. If you are doing this, then you need | |
c0478a66 | 2719 | to compute (by analyzing the code, or in some other way) the maximum or |
488d3985 GK |
2720 | likely maximum error that the computation introduces, and allow for it |
2721 | when performing comparisons (and when producing output, but that's a | |
2722 | different problem). In particular, instead of testing for equality, you | |
2723 | would check to see whether the two values have ranges that overlap; and | |
2724 | this is done with the relational operators, so equality comparisons are | |
2725 | probably mistaken. | |
2726 | ||
aee96fe9 | 2727 | @item -Wtraditional @r{(C only)} |
cd3bb277 | 2728 | @opindex Wtraditional |
74291a4b | 2729 | Warn about certain constructs that behave differently in traditional and |
161d7b59 | 2730 | ISO C@. Also warn about ISO C constructs that have no traditional C |
c8abc684 | 2731 | equivalent, and/or problematic constructs which should be avoided. |
74291a4b MM |
2732 | |
2733 | @itemize @bullet | |
2734 | @item | |
da312b55 NB |
2735 | Macro parameters that appear within string literals in the macro body. |
2736 | In traditional C macro replacement takes place within string literals, | |
161d7b59 | 2737 | but does not in ISO C@. |
da312b55 NB |
2738 | |
2739 | @item | |
2740 | In traditional C, some preprocessor directives did not exist. | |
2741 | Traditional preprocessors would only consider a line to be a directive | |
2742 | if the @samp{#} appeared in column 1 on the line. Therefore | |
630d3d5a | 2743 | @option{-Wtraditional} warns about directives that traditional C |
da312b55 NB |
2744 | understands but would ignore because the @samp{#} does not appear as the |
2745 | first character on the line. It also suggests you hide directives like | |
2746 | @samp{#pragma} not understood by traditional C by indenting them. Some | |
c21cd8b1 | 2747 | traditional implementations would not recognize @samp{#elif}, so it |
da312b55 NB |
2748 | suggests avoiding it altogether. |
2749 | ||
2750 | @item | |
2751 | A function-like macro that appears without arguments. | |
2752 | ||
2753 | @item | |
2754 | The unary plus operator. | |
2755 | ||
2756 | @item | |
c771326b JM |
2757 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point |
2758 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
da312b55 | 2759 | constants.) Note, these suffixes appear in macros defined in the system |
e979f9e8 | 2760 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. |
c8abc684 | 2761 | Use of these macros in user code might normally lead to spurious |
2dd76960 | 2762 | warnings, however GCC's integrated preprocessor has enough context to |
c8abc684 | 2763 | avoid warning in these cases. |
74291a4b MM |
2764 | |
2765 | @item | |
2766 | A function declared external in one block and then used after the end of | |
2767 | the block. | |
2768 | ||
2769 | @item | |
2770 | A @code{switch} statement has an operand of type @code{long}. | |
db838bb8 KG |
2771 | |
2772 | @item | |
2773 | A non-@code{static} function declaration follows a @code{static} one. | |
2774 | This construct is not accepted by some traditional C compilers. | |
48776cde KG |
2775 | |
2776 | @item | |
c1030c7c | 2777 | The ISO type of an integer constant has a different width or |
48776cde | 2778 | signedness from its traditional type. This warning is only issued if |
e979f9e8 | 2779 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which |
48776cde | 2780 | typically represent bit patterns, are not warned about. |
bb66adca KG |
2781 | |
2782 | @item | |
c1030c7c | 2783 | Usage of ISO string concatenation is detected. |
7f094a94 | 2784 | |
895ea614 KG |
2785 | @item |
2786 | Initialization of automatic aggregates. | |
2787 | ||
2788 | @item | |
2789 | Identifier conflicts with labels. Traditional C lacks a separate | |
2790 | namespace for labels. | |
253b6b82 KG |
2791 | |
2792 | @item | |
2793 | Initialization of unions. If the initializer is zero, the warning is | |
2794 | omitted. This is done under the assumption that the zero initializer in | |
e979f9e8 | 2795 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing |
253b6b82 KG |
2796 | initializer warnings and relies on default initialization to zero in the |
2797 | traditional C case. | |
03829ad2 KG |
2798 | |
2799 | @item | |
3ed56f8a KG |
2800 | Conversions by prototypes between fixed/floating point values and vice |
2801 | versa. The absence of these prototypes when compiling with traditional | |
2802 | C would cause serious problems. This is a subset of the possible | |
630d3d5a | 2803 | conversion warnings, for the full set use @option{-Wconversion}. |
622d3731 KG |
2804 | |
2805 | @item | |
2806 | Use of ISO C style function definitions. This warning intentionally is | |
2807 | @emph{not} issued for prototype declarations or variadic functions | |
2808 | because these ISO C features will appear in your code when using | |
2809 | libiberty's traditional C compatibility macros, @code{PARAMS} and | |
2810 | @code{VPARAMS}. This warning is also bypassed for nested functions | |
2dd76960 | 2811 | because that feature is already a GCC extension and thus not relevant to |
622d3731 | 2812 | traditional C compatibility. |
74291a4b MM |
2813 | @end itemize |
2814 | ||
85617eba HPN |
2815 | @item -Wdeclaration-after-statement @r{(C only)} |
2816 | @opindex Wdeclaration-after-statement | |
2817 | Warn when a declaration is found after a statement in a block. This | |
2818 | construct, known from C++, was introduced with ISO C99 and is by default | |
2819 | allowed in GCC@. It is not supported by ISO C90 and was not supported by | |
2820 | GCC versions before GCC 3.0. @xref{Mixed Declarations}. | |
2821 | ||
861bb6c1 | 2822 | @item -Wundef |
cd3bb277 | 2823 | @opindex Wundef |
861bb6c1 JL |
2824 | Warn if an undefined identifier is evaluated in an @samp{#if} directive. |
2825 | ||
909de5da PE |
2826 | @item -Wendif-labels |
2827 | @opindex Wendif-labels | |
2828 | Warn whenever an @samp{#else} or an @samp{#endif} are followed by text. | |
2829 | ||
74291a4b | 2830 | @item -Wshadow |
cd3bb277 | 2831 | @opindex Wshadow |
d773df5a DB |
2832 | Warn whenever a local variable shadows another local variable, parameter or |
2833 | global variable or whenever a built-in function is shadowed. | |
74291a4b | 2834 | |
74291a4b | 2835 | @item -Wlarger-than-@var{len} |
cd3bb277 | 2836 | @opindex Wlarger-than |
74291a4b MM |
2837 | Warn whenever an object of larger than @var{len} bytes is defined. |
2838 | ||
2839 | @item -Wpointer-arith | |
cd3bb277 | 2840 | @opindex Wpointer-arith |
74291a4b MM |
2841 | Warn about anything that depends on the ``size of'' a function type or |
2842 | of @code{void}. GNU C assigns these types a size of 1, for | |
2843 | convenience in calculations with @code{void *} pointers and pointers | |
2844 | to functions. | |
2845 | ||
aee96fe9 | 2846 | @item -Wbad-function-cast @r{(C only)} |
cd3bb277 | 2847 | @opindex Wbad-function-cast |
74291a4b MM |
2848 | Warn whenever a function call is cast to a non-matching type. |
2849 | For example, warn if @code{int malloc()} is cast to @code{anything *}. | |
2850 | ||
2851 | @item -Wcast-qual | |
cd3bb277 | 2852 | @opindex Wcast-qual |
74291a4b MM |
2853 | Warn whenever a pointer is cast so as to remove a type qualifier from |
2854 | the target type. For example, warn if a @code{const char *} is cast | |
2855 | to an ordinary @code{char *}. | |
2856 | ||
2857 | @item -Wcast-align | |
cd3bb277 | 2858 | @opindex Wcast-align |
74291a4b MM |
2859 | Warn whenever a pointer is cast such that the required alignment of the |
2860 | target is increased. For example, warn if a @code{char *} is cast to | |
2861 | an @code{int *} on machines where integers can only be accessed at | |
2862 | two- or four-byte boundaries. | |
2863 | ||
2864 | @item -Wwrite-strings | |
cd3bb277 | 2865 | @opindex Wwrite-strings |
aee96fe9 JM |
2866 | When compiling C, give string constants the type @code{const |
2867 | char[@var{length}]} so that | |
74291a4b | 2868 | copying the address of one into a non-@code{const} @code{char *} |
aee96fe9 JM |
2869 | pointer will get a warning; when compiling C++, warn about the |
2870 | deprecated conversion from string constants to @code{char *}. | |
2871 | These warnings will help you find at | |
74291a4b MM |
2872 | compile time code that can try to write into a string constant, but |
2873 | only if you have been very careful about using @code{const} in | |
2874 | declarations and prototypes. Otherwise, it will just be a nuisance; | |
630d3d5a | 2875 | this is why we did not make @option{-Wall} request these warnings. |
74291a4b MM |
2876 | |
2877 | @item -Wconversion | |
cd3bb277 | 2878 | @opindex Wconversion |
74291a4b MM |
2879 | Warn if a prototype causes a type conversion that is different from what |
2880 | would happen to the same argument in the absence of a prototype. This | |
2881 | includes conversions of fixed point to floating and vice versa, and | |
2882 | conversions changing the width or signedness of a fixed point argument | |
2883 | except when the same as the default promotion. | |
2884 | ||
2885 | Also, warn if a negative integer constant expression is implicitly | |
2886 | converted to an unsigned type. For example, warn about the assignment | |
2887 | @code{x = -1} if @code{x} is unsigned. But do not warn about explicit | |
2888 | casts like @code{(unsigned) -1}. | |
2889 | ||
e9a25f70 | 2890 | @item -Wsign-compare |
cd3bb277 | 2891 | @opindex Wsign-compare |
e9a25f70 JL |
2892 | @cindex warning for comparison of signed and unsigned values |
2893 | @cindex comparison of signed and unsigned values, warning | |
2894 | @cindex signed and unsigned values, comparison warning | |
2895 | Warn when a comparison between signed and unsigned values could produce | |
2896 | an incorrect result when the signed value is converted to unsigned. | |
65ca2d60 PE |
2897 | This warning is also enabled by @option{-Wextra}; to get the other warnings |
2898 | of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}. | |
e9a25f70 | 2899 | |
74291a4b | 2900 | @item -Waggregate-return |
cd3bb277 | 2901 | @opindex Waggregate-return |
74291a4b MM |
2902 | Warn if any functions that return structures or unions are defined or |
2903 | called. (In languages where you can return an array, this also elicits | |
2904 | a warning.) | |
2905 | ||
aee96fe9 | 2906 | @item -Wstrict-prototypes @r{(C only)} |
cd3bb277 | 2907 | @opindex Wstrict-prototypes |
74291a4b MM |
2908 | Warn if a function is declared or defined without specifying the |
2909 | argument types. (An old-style function definition is permitted without | |
2910 | a warning if preceded by a declaration which specifies the argument | |
2911 | types.) | |
2912 | ||
c034f121 AJ |
2913 | @item -Wold-style-definition @r{(C only)} |
2914 | @opindex Wold-style-definition | |
2915 | Warn if an old-style function definition is used. A warning is given | |
2916 | even if there is a previous prototype. | |
2917 | ||
aee96fe9 | 2918 | @item -Wmissing-prototypes @r{(C only)} |
cd3bb277 | 2919 | @opindex Wmissing-prototypes |
74291a4b MM |
2920 | Warn if a global function is defined without a previous prototype |
2921 | declaration. This warning is issued even if the definition itself | |
2922 | provides a prototype. The aim is to detect global functions that fail | |
2923 | to be declared in header files. | |
2924 | ||
da635858 | 2925 | @item -Wmissing-declarations @r{(C only)} |
cd3bb277 | 2926 | @opindex Wmissing-declarations |
74291a4b MM |
2927 | Warn if a global function is defined without a previous declaration. |
2928 | Do so even if the definition itself provides a prototype. | |
2929 | Use this option to detect global functions that are not declared in | |
2930 | header files. | |
2931 | ||
eaac4679 RS |
2932 | @item -Wmissing-field-initializers |
2933 | @opindex Wmissing-field-initializers | |
2934 | @opindex W | |
2935 | @opindex Wextra | |
2936 | Warn if a structure's initializer has some fields missing. For | |
2937 | example, the following code would cause such a warning, because | |
2938 | @code{x.h} is implicitly zero: | |
2939 | ||
2940 | @smallexample | |
2941 | struct s @{ int f, g, h; @}; | |
2942 | struct s x = @{ 3, 4 @}; | |
2943 | @end smallexample | |
2944 | ||
2945 | This option does not warn about designated initializers, so the following | |
2946 | modification would not trigger a warning: | |
2947 | ||
2948 | @smallexample | |
2949 | struct s @{ int f, g, h; @}; | |
2950 | struct s x = @{ .f = 3, .g = 4 @}; | |
2951 | @end smallexample | |
2952 | ||
2953 | This warning is included in @option{-Wextra}. To get other @option{-Wextra} | |
2954 | warnings without this one, use @samp{-Wextra -Wno-missing-field-initializers}. | |
2955 | ||
0ca3fb0a | 2956 | @item -Wmissing-noreturn |
cd3bb277 | 2957 | @opindex Wmissing-noreturn |
0ca3fb0a KG |
2958 | Warn about functions which might be candidates for attribute @code{noreturn}. |
2959 | Note these are only possible candidates, not absolute ones. Care should | |
2960 | be taken to manually verify functions actually do not ever return before | |
2961 | adding the @code{noreturn} attribute, otherwise subtle code generation | |
21c7361e AJ |
2962 | bugs could be introduced. You will not get a warning for @code{main} in |
2963 | hosted C environments. | |
0ca3fb0a | 2964 | |
74ff4629 | 2965 | @item -Wmissing-format-attribute |
cd3bb277 JM |
2966 | @opindex Wmissing-format-attribute |
2967 | @opindex Wformat | |
630d3d5a | 2968 | If @option{-Wformat} is enabled, also warn about functions which might be |
74ff4629 JM |
2969 | candidates for @code{format} attributes. Note these are only possible |
2970 | candidates, not absolute ones. GCC will guess that @code{format} | |
2971 | attributes might be appropriate for any function that calls a function | |
2972 | like @code{vprintf} or @code{vscanf}, but this might not always be the | |
2973 | case, and some functions for which @code{format} attributes are | |
2974 | appropriate may not be detected. This option has no effect unless | |
630d3d5a | 2975 | @option{-Wformat} is enabled (possibly by @option{-Wall}). |
74ff4629 | 2976 | |
75227a33 GK |
2977 | @item -Wno-multichar |
2978 | @opindex Wno-multichar | |
2979 | @opindex Wmultichar | |
2980 | Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. | |
2981 | Usually they indicate a typo in the user's code, as they have | |
2982 | implementation-defined values, and should not be used in portable code. | |
2983 | ||
e23bd218 IR |
2984 | @item -Wno-deprecated-declarations |
2985 | @opindex Wno-deprecated-declarations | |
2986 | Do not warn about uses of functions, variables, and types marked as | |
f282ffb3 | 2987 | deprecated by using the @code{deprecated} attribute. |
e23bd218 IR |
2988 | (@pxref{Function Attributes}, @pxref{Variable Attributes}, |
2989 | @pxref{Type Attributes}.) | |
2990 | ||
3c12fcc2 | 2991 | @item -Wpacked |
cd3bb277 | 2992 | @opindex Wpacked |
3c12fcc2 | 2993 | Warn if a structure is given the packed attribute, but the packed |
02f52e19 | 2994 | attribute has no effect on the layout or size of the structure. |
3c12fcc2 GM |
2995 | Such structures may be mis-aligned for little benefit. For |
2996 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
2997 | will be misaligned even though @code{struct bar} does not itself | |
2998 | have the packed attribute: | |
2999 | ||
3000 | @smallexample | |
3001 | @group | |
3002 | struct foo @{ | |
3003 | int x; | |
3004 | char a, b, c, d; | |
3005 | @} __attribute__((packed)); | |
3006 | struct bar @{ | |
3007 | char z; | |
3008 | struct foo f; | |
3009 | @}; | |
3010 | @end group | |
3011 | @end smallexample | |
3012 | ||
3013 | @item -Wpadded | |
cd3bb277 | 3014 | @opindex Wpadded |
3c12fcc2 GM |
3015 | Warn if padding is included in a structure, either to align an element |
3016 | of the structure or to align the whole structure. Sometimes when this | |
3017 | happens it is possible to rearrange the fields of the structure to | |
3018 | reduce the padding and so make the structure smaller. | |
3019 | ||
74291a4b | 3020 | @item -Wredundant-decls |
cd3bb277 | 3021 | @opindex Wredundant-decls |
74291a4b MM |
3022 | Warn if anything is declared more than once in the same scope, even in |
3023 | cases where multiple declaration is valid and changes nothing. | |
3024 | ||
aee96fe9 | 3025 | @item -Wnested-externs @r{(C only)} |
cd3bb277 | 3026 | @opindex Wnested-externs |
252215a7 | 3027 | Warn if an @code{extern} declaration is encountered within a function. |
74291a4b | 3028 | |
312f6255 | 3029 | @item -Wunreachable-code |
cd3bb277 | 3030 | @opindex Wunreachable-code |
312f6255 GK |
3031 | Warn if the compiler detects that code will never be executed. |
3032 | ||
3033 | This option is intended to warn when the compiler detects that at | |
3034 | least a whole line of source code will never be executed, because | |
3035 | some condition is never satisfied or because it is after a | |
3036 | procedure that never returns. | |
3037 | ||
3038 | It is possible for this option to produce a warning even though there | |
3039 | are circumstances under which part of the affected line can be executed, | |
3040 | so care should be taken when removing apparently-unreachable code. | |
3041 | ||
3042 | For instance, when a function is inlined, a warning may mean that the | |
02f52e19 | 3043 | line is unreachable in only one inlined copy of the function. |
312f6255 | 3044 | |
630d3d5a | 3045 | This option is not made part of @option{-Wall} because in a debugging |
312f6255 GK |
3046 | version of a program there is often substantial code which checks |
3047 | correct functioning of the program and is, hopefully, unreachable | |
3048 | because the program does work. Another common use of unreachable | |
c21cd8b1 | 3049 | code is to provide behavior which is selectable at compile-time. |
312f6255 | 3050 | |
74291a4b | 3051 | @item -Winline |
cd3bb277 | 3052 | @opindex Winline |
c5c76735 | 3053 | Warn if a function can not be inlined and it was declared as inline. |
ae4a7155 | 3054 | Even with this option, the compiler will not warn about failures to |
daf2f129 | 3055 | inline functions declared in system headers. |
ae4a7155 MM |
3056 | |
3057 | The compiler uses a variety of heuristics to determine whether or not | |
3058 | to inline a function. For example, the compiler takes into account | |
3059 | the size of the function being inlined and the the amount of inlining | |
3060 | that has already been done in the current function. Therefore, | |
3061 | seemingly insignificant changes in the source program can cause the | |
3062 | warnings produced by @option{-Winline} to appear or disappear. | |
74291a4b | 3063 | |
a01fff59 MA |
3064 | @item -Wno-invalid-offsetof @r{(C++ only)} |
3065 | @opindex Wno-invalid-offsetof | |
3066 | Suppress warnings from applying the @samp{offsetof} macro to a non-POD | |
3067 | type. According to the 1998 ISO C++ standard, applying @samp{offsetof} | |
3068 | to a non-POD type is undefined. In existing C++ implementations, | |
3069 | however, @samp{offsetof} typically gives meaningful results even when | |
3070 | applied to certain kinds of non-POD types. (Such as a simple | |
3071 | @samp{struct} that fails to be a POD type only by virtue of having a | |
3072 | constructor.) This flag is for users who are aware that they are | |
3073 | writing nonportable code and who have deliberately chosen to ignore the | |
3074 | warning about it. | |
3075 | ||
3076 | The restrictions on @samp{offsetof} may be relaxed in a future version | |
3077 | of the C++ standard. | |
3078 | ||
17211ab5 GK |
3079 | @item -Winvalid-pch |
3080 | @opindex Winvalid-pch | |
3081 | Warn if a precompiled header (@pxref{Precompiled Headers}) is found in | |
3082 | the search path but can't be used. | |
3083 | ||
795add94 | 3084 | @item -Wlong-long |
cd3bb277 JM |
3085 | @opindex Wlong-long |
3086 | @opindex Wno-long-long | |
795add94 | 3087 | Warn if @samp{long long} type is used. This is default. To inhibit |
630d3d5a JM |
3088 | the warning messages, use @option{-Wno-long-long}. Flags |
3089 | @option{-Wlong-long} and @option{-Wno-long-long} are taken into account | |
3090 | only when @option{-pedantic} flag is used. | |
795add94 | 3091 | |
7c4d376d RH |
3092 | @item -Wvariadic-macros |
3093 | @opindex Wvariadic-macros | |
3094 | @opindex Wno-variadic-macros | |
3095 | Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU | |
3096 | alternate syntax when in pedantic ISO C99 mode. This is default. | |
3097 | To inhibit the warning messages, use @option{-Wno-variadic-macros}. | |
3098 | ||
18424ae1 | 3099 | @item -Wdisabled-optimization |
cd3bb277 | 3100 | @opindex Wdisabled-optimization |
18424ae1 BL |
3101 | Warn if a requested optimization pass is disabled. This warning does |
3102 | not generally indicate that there is anything wrong with your code; it | |
3103 | merely indicates that GCC's optimizers were unable to handle the code | |
3104 | effectively. Often, the problem is that your code is too big or too | |
3105 | complex; GCC will refuse to optimize programs when the optimization | |
3106 | itself is likely to take inordinate amounts of time. | |
3107 | ||
74291a4b | 3108 | @item -Werror |
cd3bb277 | 3109 | @opindex Werror |
74291a4b MM |
3110 | Make all warnings into errors. |
3111 | @end table | |
3112 | ||
3113 | @node Debugging Options | |
0c2d1a2a | 3114 | @section Options for Debugging Your Program or GCC |
74291a4b MM |
3115 | @cindex options, debugging |
3116 | @cindex debugging information options | |
3117 | ||
0c2d1a2a | 3118 | GCC has various special options that are used for debugging |
74291a4b MM |
3119 | either your program or GCC: |
3120 | ||
2642624b | 3121 | @table @gcctabopt |
74291a4b | 3122 | @item -g |
cd3bb277 | 3123 | @opindex g |
74291a4b | 3124 | Produce debugging information in the operating system's native format |
f8ca7e49 | 3125 | (stabs, COFF, XCOFF, or DWARF 2)@. GDB can work with this debugging |
74291a4b MM |
3126 | information. |
3127 | ||
630d3d5a | 3128 | On most systems that use stabs format, @option{-g} enables use of extra |
74291a4b MM |
3129 | debugging information that only GDB can use; this extra information |
3130 | makes debugging work better in GDB but will probably make other debuggers | |
3131 | crash or | |
3132 | refuse to read the program. If you want to control for certain whether | |
630d3d5a | 3133 | to generate the extra information, use @option{-gstabs+}, @option{-gstabs}, |
def66b10 | 3134 | @option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below). |
74291a4b | 3135 | |
f8ca7e49 | 3136 | GCC allows you to use @option{-g} with |
630d3d5a | 3137 | @option{-O}. The shortcuts taken by optimized code may occasionally |
74291a4b MM |
3138 | produce surprising results: some variables you declared may not exist |
3139 | at all; flow of control may briefly move where you did not expect it; | |
3140 | some statements may not be executed because they compute constant | |
3141 | results or their values were already at hand; some statements may | |
3142 | execute in different places because they were moved out of loops. | |
3143 | ||
3144 | Nevertheless it proves possible to debug optimized output. This makes | |
3145 | it reasonable to use the optimizer for programs that might have bugs. | |
3146 | ||
0c2d1a2a | 3147 | The following options are useful when GCC is generated with the |
74291a4b MM |
3148 | capability for more than one debugging format. |
3149 | ||
3150 | @item -ggdb | |
cd3bb277 | 3151 | @opindex ggdb |
161d7b59 | 3152 | Produce debugging information for use by GDB@. This means to use the |
861bb6c1 JL |
3153 | most expressive format available (DWARF 2, stabs, or the native format |
3154 | if neither of those are supported), including GDB extensions if at all | |
3155 | possible. | |
74291a4b MM |
3156 | |
3157 | @item -gstabs | |
cd3bb277 | 3158 | @opindex gstabs |
74291a4b MM |
3159 | Produce debugging information in stabs format (if that is supported), |
3160 | without GDB extensions. This is the format used by DBX on most BSD | |
3161 | systems. On MIPS, Alpha and System V Release 4 systems this option | |
161d7b59 | 3162 | produces stabs debugging output which is not understood by DBX or SDB@. |
74291a4b MM |
3163 | On System V Release 4 systems this option requires the GNU assembler. |
3164 | ||
6a08f7b3 DP |
3165 | @item -feliminate-unused-debug-symbols |
3166 | @opindex feliminate-unused-debug-symbols | |
3167 | Produce debugging information in stabs format (if that is supported), | |
c0cbdbd9 | 3168 | for only symbols that are actually used. |
6a08f7b3 | 3169 | |
74291a4b | 3170 | @item -gstabs+ |
cd3bb277 | 3171 | @opindex gstabs+ |
74291a4b | 3172 | Produce debugging information in stabs format (if that is supported), |
161d7b59 | 3173 | using GNU extensions understood only by the GNU debugger (GDB)@. The |
74291a4b MM |
3174 | use of these extensions is likely to make other debuggers crash or |
3175 | refuse to read the program. | |
3176 | ||
3177 | @item -gcoff | |
cd3bb277 | 3178 | @opindex gcoff |
74291a4b MM |
3179 | Produce debugging information in COFF format (if that is supported). |
3180 | This is the format used by SDB on most System V systems prior to | |
3181 | System V Release 4. | |
3182 | ||
3183 | @item -gxcoff | |
cd3bb277 | 3184 | @opindex gxcoff |
74291a4b MM |
3185 | Produce debugging information in XCOFF format (if that is supported). |
3186 | This is the format used by the DBX debugger on IBM RS/6000 systems. | |
3187 | ||
3188 | @item -gxcoff+ | |
cd3bb277 | 3189 | @opindex gxcoff+ |
74291a4b | 3190 | Produce debugging information in XCOFF format (if that is supported), |
161d7b59 | 3191 | using GNU extensions understood only by the GNU debugger (GDB)@. The |
74291a4b MM |
3192 | use of these extensions is likely to make other debuggers crash or |
3193 | refuse to read the program, and may cause assemblers other than the GNU | |
3194 | assembler (GAS) to fail with an error. | |
3195 | ||
861bb6c1 | 3196 | @item -gdwarf-2 |
cd3bb277 | 3197 | @opindex gdwarf-2 |
861bb6c1 | 3198 | Produce debugging information in DWARF version 2 format (if that is |
f8ca7e49 ZW |
3199 | supported). This is the format used by DBX on IRIX 6. With this |
3200 | option, GCC uses features of DWARF version 3 when they are useful; | |
3201 | version 3 is upward compatible with version 2, but may still cause | |
3202 | problems for older debuggers. | |
74291a4b | 3203 | |
5f98259a RK |
3204 | @item -gvms |
3205 | @opindex gvms | |
3206 | Produce debugging information in VMS debug format (if that is | |
3207 | supported). This is the format used by DEBUG on VMS systems. | |
3208 | ||
74291a4b MM |
3209 | @item -g@var{level} |
3210 | @itemx -ggdb@var{level} | |
3211 | @itemx -gstabs@var{level} | |
3212 | @itemx -gcoff@var{level} | |
3213 | @itemx -gxcoff@var{level} | |
5f98259a | 3214 | @itemx -gvms@var{level} |
74291a4b MM |
3215 | Request debugging information and also use @var{level} to specify how |
3216 | much information. The default level is 2. | |
3217 | ||
3218 | Level 1 produces minimal information, enough for making backtraces in | |
3219 | parts of the program that you don't plan to debug. This includes | |
3220 | descriptions of functions and external variables, but no information | |
3221 | about local variables and no line numbers. | |
3222 | ||
3223 | Level 3 includes extra information, such as all the macro definitions | |
3224 | present in the program. Some debuggers support macro expansion when | |
630d3d5a | 3225 | you use @option{-g3}. |
74291a4b | 3226 | |
f8ca7e49 ZW |
3227 | @option{-gdwarf-2} does not accept a concatenated debug level, because |
3228 | GCC used to support an option @option{-gdwarf} that meant to generate | |
3229 | debug information in version 1 of the DWARF format (which is very | |
3230 | different from version 2), and it would have been too confusing. That | |
3231 | debug format is long obsolete, but the option cannot be changed now. | |
3232 | Instead use an additional @option{-g@var{level}} option to change the | |
3233 | debug level for DWARF2. | |
eb7715a4 | 3234 | |
e03b7153 RS |
3235 | @item -feliminate-dwarf2-dups |
3236 | @opindex feliminate-dwarf2-dups | |
3237 | Compress DWARF2 debugging information by eliminating duplicated | |
3238 | information about each symbol. This option only makes sense when | |
3239 | generating DWARF2 debugging information with @option{-gdwarf-2}. | |
3240 | ||
05739753 | 3241 | @cindex @command{prof} |
74291a4b | 3242 | @item -p |
cd3bb277 | 3243 | @opindex p |
74291a4b | 3244 | Generate extra code to write profile information suitable for the |
05739753 | 3245 | analysis program @command{prof}. You must use this option when compiling |
74291a4b MM |
3246 | the source files you want data about, and you must also use it when |
3247 | linking. | |
3248 | ||
05739753 | 3249 | @cindex @command{gprof} |
74291a4b | 3250 | @item -pg |
cd3bb277 | 3251 | @opindex pg |
74291a4b | 3252 | Generate extra code to write profile information suitable for the |
05739753 | 3253 | analysis program @command{gprof}. You must use this option when compiling |
74291a4b MM |
3254 | the source files you want data about, and you must also use it when |
3255 | linking. | |
3256 | ||
898f531b | 3257 | @item -Q |
cd3bb277 | 3258 | @opindex Q |
898f531b JL |
3259 | Makes the compiler print out each function name as it is compiled, and |
3260 | print some statistics about each pass when it finishes. | |
3261 | ||
1f0c3120 | 3262 | @item -ftime-report |
cd3bb277 | 3263 | @opindex ftime-report |
1f0c3120 JM |
3264 | Makes the compiler print some statistics about the time consumed by each |
3265 | pass when it finishes. | |
3266 | ||
3267 | @item -fmem-report | |
cd3bb277 | 3268 | @opindex fmem-report |
1f0c3120 JM |
3269 | Makes the compiler print some statistics about permanent memory |
3270 | allocation when it finishes. | |
3271 | ||
861bb6c1 | 3272 | @item -fprofile-arcs |
cd3bb277 | 3273 | @opindex fprofile-arcs |
23af32e6 NS |
3274 | Add code so that program flow @dfn{arcs} are instrumented. During |
3275 | execution the program records how many times each branch and call is | |
3276 | executed and how many times it is taken or returns. When the compiled | |
3277 | program exits it saves this data to a file called | |
a4878735 | 3278 | @file{@var{auxname}.gcda} for each source file. The data may be used for |
23af32e6 NS |
3279 | profile-directed optimizations (@option{-fbranch-probabilities}), or for |
3280 | test coverage analysis (@option{-ftest-coverage}). Each object file's | |
3281 | @var{auxname} is generated from the name of the output file, if | |
3282 | explicitly specified and it is not the final executable, otherwise it is | |
3283 | the basename of the source file. In both cases any suffix is removed | |
a4878735 NS |
3284 | (e.g. @file{foo.gcda} for input file @file{dir/foo.c}, or |
3285 | @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}). | |
23af32e6 NS |
3286 | |
3287 | @itemize | |
3288 | ||
3289 | @item | |
3290 | Compile the source files with @option{-fprofile-arcs} plus optimization | |
3291 | and code generation options. For test coverage analysis, use the | |
3292 | additional @option{-ftest-coverage} option. You do not need to profile | |
3293 | every source file in a program. | |
3294 | ||
3295 | @item | |
8555daff NS |
3296 | Link your object files with @option{-lgcov} or @option{-fprofile-arcs} |
3297 | (the latter implies the former). | |
23af32e6 NS |
3298 | |
3299 | @item | |
3300 | Run the program on a representative workload to generate the arc profile | |
8555daff NS |
3301 | information. This may be repeated any number of times. You can run |
3302 | concurrent instances of your program, and provided that the file system | |
3303 | supports locking, the data files will be correctly updated. Also | |
3304 | @code{fork} calls are detected and correctly handled (double counting | |
3305 | will not happen). | |
23af32e6 NS |
3306 | |
3307 | @item | |
3308 | For profile-directed optimizations, compile the source files again with | |
3309 | the same optimization and code generation options plus | |
630d3d5a | 3310 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that |
3de87bf2 JJ |
3311 | Control Optimization}). |
3312 | ||
23af32e6 NS |
3313 | @item |
3314 | For test coverage analysis, use @command{gcov} to produce human readable | |
a4878735 | 3315 | information from the @file{.gcno} and @file{.gcda} files. Refer to the |
23af32e6 NS |
3316 | @command{gcov} documentation for further information. |
3317 | ||
3318 | @end itemize | |
3de87bf2 JJ |
3319 | |
3320 | With @option{-fprofile-arcs}, for each function of your program GCC | |
3321 | creates a program flow graph, then finds a spanning tree for the graph. | |
3322 | Only arcs that are not on the spanning tree have to be instrumented: the | |
3323 | compiler adds code to count the number of times that these arcs are | |
3324 | executed. When an arc is the only exit or only entrance to a block, the | |
3325 | instrumentation code can be added to the block; otherwise, a new basic | |
3326 | block must be created to hold the instrumentation code. | |
3327 | ||
6de9cd9a DN |
3328 | @item -ftree-based-profiling |
3329 | @opindex ftree-based-profiling | |
3330 | This option is used in addition to @option{-fprofile-arcs} or | |
3331 | @option{-fbranch-probabilities} to control whether those optimizations | |
3332 | are performed on a tree-based or rtl-based internal representation. | |
3333 | If you use this option when compiling with @option{-fprofile-arcs}, | |
3334 | you must also use it when compiling later with @option{-fbranch-probabilities}. | |
3335 | Currently the tree-based optimization is in an early stage of | |
3336 | development, and this option is recommended only for those people | |
3337 | working on improving it. | |
3338 | ||
861bb6c1 JL |
3339 | @need 2000 |
3340 | @item -ftest-coverage | |
cd3bb277 | 3341 | @opindex ftest-coverage |
a4878735 | 3342 | Produce a notes file that the @command{gcov} code-coverage utility |
23af32e6 | 3343 | (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to |
a4878735 NS |
3344 | show program coverage. Each source file's note file is called |
3345 | @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option | |
23af32e6 NS |
3346 | above for a description of @var{auxname} and instructions on how to |
3347 | generate test coverage data. Coverage data will match the source files | |
3348 | more closely, if you do not optimize. | |
3de87bf2 | 3349 | |
74291a4b | 3350 | @item -d@var{letters} |
cd3bb277 | 3351 | @opindex d |
74291a4b MM |
3352 | Says to make debugging dumps during compilation at times specified by |
3353 | @var{letters}. This is used for debugging the compiler. The file names | |
375e2d5c | 3354 | for most of the dumps are made by appending a pass number and a word to |
ea67fe71 NS |
3355 | the @var{dumpname}. @var{dumpname} is generated from the name of the |
3356 | output file, if explicitly specified and it is not an executable, | |
3357 | otherwise it is the basename of the source file. In both cases any | |
98edbb7a | 3358 | suffix is removed (e.g. @file{foo.01.rtl} or @file{foo.02.sibling}). |
ea67fe71 NS |
3359 | Here are the possible letters for use in @var{letters}, and their |
3360 | meanings: | |
74291a4b MM |
3361 | |
3362 | @table @samp | |
375e2d5c | 3363 | @item A |
cd3bb277 | 3364 | @opindex dA |
375e2d5c | 3365 | Annotate the assembler output with miscellaneous debugging information. |
956d6950 | 3366 | @item b |
cd3bb277 | 3367 | @opindex db |
98edbb7a | 3368 | Dump after computing branch probabilities, to @file{@var{file}.12.bp}. |
48d9ade5 | 3369 | @item B |
cd3bb277 | 3370 | @opindex dB |
e5626198 | 3371 | Dump after block reordering, to @file{@var{file}.32.bbro}. |
032713aa | 3372 | @item c |
cd3bb277 | 3373 | @opindex dc |
98edbb7a | 3374 | Dump after instruction combination, to the file @file{@var{file}.20.combine}. |
470fc13d | 3375 | @item C |
cd3bb277 | 3376 | @opindex dC |
98edbb7a KH |
3377 | Dump after the first if conversion, to the file @file{@var{file}.14.ce1}. |
3378 | Also dump after the second if conversion, to the file @file{@var{file}.21.ce2}. | |
032713aa | 3379 | @item d |
cd3bb277 | 3380 | @opindex dd |
e5626198 AZ |
3381 | Dump after branch target load optimization, to to @file{@var{file}.33.btl}. |
3382 | Also dump after delayed branch scheduling, to @file{@var{file}.37.dbr}. | |
032713aa | 3383 | @item D |
cd3bb277 | 3384 | @opindex dD |
f5963e61 JL |
3385 | Dump all macro definitions, at the end of preprocessing, in addition to |
3386 | normal output. | |
470fc13d | 3387 | @item E |
cd3bb277 | 3388 | @opindex dE |
e5626198 | 3389 | Dump after the third if conversion, to @file{@var{file}.31.ce3}. |
74291a4b | 3390 | @item f |
cd3bb277 | 3391 | @opindex df |
98edbb7a KH |
3392 | Dump after control and data flow analysis, to @file{@var{file}.11.cfg}. |
3393 | Also dump after life analysis, to @file{@var{file}.19.life}. | |
74291a4b | 3394 | @item g |
cd3bb277 | 3395 | @opindex dg |
e5626198 | 3396 | Dump after global register allocation, to @file{@var{file}.26.greg}. |
02f52e19 | 3397 | @item G |
cd3bb277 | 3398 | @opindex dG |
98edbb7a | 3399 | Dump after GCSE, to @file{@var{file}.08.gcse}. |
34695841 | 3400 | Also dump after jump bypassing and control flow optimizations, to |
98edbb7a | 3401 | @file{@var{file}.10.bypass}. |
7fedea11 KH |
3402 | @item h |
3403 | @opindex dh | |
a194aa56 | 3404 | Dump after finalization of EH handling code, to @file{@var{file}.03.eh}. |
48d9ade5 | 3405 | @item i |
cd3bb277 | 3406 | @opindex di |
a194aa56 | 3407 | Dump after sibling call optimizations, to @file{@var{file}.02.sibling}. |
032713aa | 3408 | @item j |
cd3bb277 | 3409 | @opindex dj |
a194aa56 | 3410 | Dump after the first jump optimization, to @file{@var{file}.04.jump}. |
74291a4b | 3411 | @item k |
cd3bb277 | 3412 | @opindex dk |
e5626198 | 3413 | Dump after conversion from registers to stack, to @file{@var{file}.35.stack}. |
032713aa | 3414 | @item l |
cd3bb277 | 3415 | @opindex dl |
e5626198 | 3416 | Dump after local register allocation, to @file{@var{file}.25.lreg}. |
032713aa | 3417 | @item L |
cd3bb277 | 3418 | @opindex dL |
98edbb7a KH |
3419 | Dump after loop optimization passes, to @file{@var{file}.09.loop} and |
3420 | @file{@var{file}.16.loop2}. | |
e5626198 AZ |
3421 | @item m |
3422 | @opindex dm | |
f26c1794 | 3423 | Dump after modulo scheduling, to @file{@var{file}.23.sms}. |
032713aa | 3424 | @item M |
cd3bb277 | 3425 | @opindex dM |
c0478a66 | 3426 | Dump after performing the machine dependent reorganization pass, to |
e5626198 | 3427 | @file{@var{file}.36.mach}. |
48d9ade5 | 3428 | @item n |
cd3bb277 | 3429 | @opindex dn |
e5626198 | 3430 | Dump after register renumbering, to @file{@var{file}.30.rnreg}. |
032713aa | 3431 | @item N |
cd3bb277 | 3432 | @opindex dN |
98edbb7a | 3433 | Dump after the register move pass, to @file{@var{file}.22.regmove}. |
7fedea11 KH |
3434 | @item o |
3435 | @opindex do | |
e5626198 | 3436 | Dump after post-reload optimizations, to @file{@var{file}.27.postreload}. |
032713aa | 3437 | @item r |
cd3bb277 | 3438 | @opindex dr |
a194aa56 | 3439 | Dump after RTL generation, to @file{@var{file}.01.rtl}. |
032713aa | 3440 | @item R |
cd3bb277 | 3441 | @opindex dR |
e5626198 | 3442 | Dump after the second scheduling pass, to @file{@var{file}.34.sched2}. |
032713aa | 3443 | @item s |
cd3bb277 | 3444 | @opindex ds |
032713aa | 3445 | Dump after CSE (including the jump optimization that sometimes follows |
98edbb7a | 3446 | CSE), to @file{@var{file}.06.cse}. |
032713aa | 3447 | @item S |
cd3bb277 | 3448 | @opindex dS |
e5626198 | 3449 | Dump after the first scheduling pass, to @file{@var{file}.24.sched}. |
032713aa | 3450 | @item t |
cd3bb277 | 3451 | @opindex dt |
032713aa | 3452 | Dump after the second CSE pass (including the jump optimization that |
98edbb7a | 3453 | sometimes follows CSE), to @file{@var{file}.18.cse2}. |
4319ef2a KH |
3454 | @item T |
3455 | @opindex dT | |
98edbb7a | 3456 | Dump after running tracer, to @file{@var{file}.15.tracer}. |
38c1593d JH |
3457 | @item u |
3458 | @opindex du | |
98edbb7a | 3459 | Dump after null pointer elimination pass to @file{@var{file}.05.null}. |
a194aa56 JH |
3460 | @item U |
3461 | @opindex dU | |
3462 | Dump callgraph and unit-at-a-time optimization @file{@var{file}.00.unit}. | |
9313cfdd KH |
3463 | @item V |
3464 | @opindex dV | |
3465 | Dump after the value profile transformations, to @file{@var{file}.13.vpt}. | |
014a1138 | 3466 | Also dump after variable tracking, to @file{@var{file}.35.vartrack}. |
c80e4c17 | 3467 | @item w |
cd3bb277 | 3468 | @opindex dw |
e5626198 | 3469 | Dump after the second flow pass, to @file{@var{file}.28.flow2}. |
48d9ade5 | 3470 | @item z |
cd3bb277 | 3471 | @opindex dz |
e5626198 | 3472 | Dump after the peephole pass, to @file{@var{file}.29.peephole2}. |
9313cfdd KH |
3473 | @item Z |
3474 | @opindex dZ | |
3475 | Dump after constructing the web, to @file{@var{file}.17.web}. | |
74291a4b | 3476 | @item a |
cd3bb277 | 3477 | @opindex da |
74291a4b | 3478 | Produce all the dumps listed above. |
886e0865 GK |
3479 | @item H |
3480 | @opindex dH | |
3481 | Produce a core dump whenever an error occurs. | |
74291a4b | 3482 | @item m |
cd3bb277 | 3483 | @opindex dm |
74291a4b MM |
3484 | Print statistics on memory usage, at the end of the run, to |
3485 | standard error. | |
3486 | @item p | |
cd3bb277 | 3487 | @opindex dp |
74291a4b | 3488 | Annotate the assembler output with a comment indicating which |
f20b5577 MM |
3489 | pattern and alternative was used. The length of each instruction is |
3490 | also printed. | |
2856c3e3 | 3491 | @item P |
cd3bb277 | 3492 | @opindex dP |
2856c3e3 | 3493 | Dump the RTL in the assembler output as a comment before each instruction. |
630d3d5a | 3494 | Also turns on @option{-dp} annotation. |
375e2d5c | 3495 | @item v |
cd3bb277 | 3496 | @opindex dv |
375e2d5c | 3497 | For each of the other indicated dump files (except for |
a194aa56 | 3498 | @file{@var{file}.01.rtl}), dump a representation of the control flow graph |
b192711e | 3499 | suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}. |
62a1403d | 3500 | @item x |
cd3bb277 | 3501 | @opindex dx |
62a1403d AS |
3502 | Just generate RTL for a function instead of compiling it. Usually used |
3503 | with @samp{r}. | |
032713aa | 3504 | @item y |
cd3bb277 | 3505 | @opindex dy |
032713aa | 3506 | Dump debugging information during parsing, to standard error. |
74291a4b MM |
3507 | @end table |
3508 | ||
b707b450 | 3509 | @item -fdump-unnumbered |
cd3bb277 | 3510 | @opindex fdump-unnumbered |
695ac33f | 3511 | When doing debugging dumps (see @option{-d} option above), suppress instruction |
b707b450 | 3512 | numbers and line number note output. This makes it more feasible to |
b192711e | 3513 | use diff on debugging dumps for compiler invocations with different |
695ac33f | 3514 | options, in particular with and without @option{-g}. |
b707b450 | 3515 | |
f70a54cb CR |
3516 | @item -fdump-translation-unit @r{(C and C++ only)} |
3517 | @itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)} | |
3518 | @opindex fdump-translation-unit | |
3519 | Dump a representation of the tree structure for the entire translation | |
3520 | unit to a file. The file name is made by appending @file{.tu} to the | |
3521 | source file name. If the @samp{-@var{options}} form is used, @var{options} | |
3522 | controls the details of the dump as described for the | |
3523 | @option{-fdump-tree} options. | |
3524 | ||
aee96fe9 | 3525 | @item -fdump-class-hierarchy @r{(C++ only)} |
22367161 | 3526 | @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)} |
cd3bb277 | 3527 | @opindex fdump-class-hierarchy |
e76b4820 | 3528 | Dump a representation of each class's hierarchy and virtual function |
767094dd | 3529 | table layout to a file. The file name is made by appending @file{.class} |
22367161 NS |
3530 | to the source file name. If the @samp{-@var{options}} form is used, |
3531 | @var{options} controls the details of the dump as described for the | |
3532 | @option{-fdump-tree} options. | |
3533 | ||
6de9cd9a DN |
3534 | @item -fdump-tree-@var{switch} @r{(C and C++ only)} |
3535 | @itemx -fdump-tree-@var{switch}-@var{options} @r{(C and C++ only)} | |
22367161 NS |
3536 | @opindex fdump-tree |
3537 | Control the dumping at various stages of processing the intermediate | |
3538 | language tree to a file. The file name is generated by appending a switch | |
3539 | specific suffix to the source file name. If the @samp{-@var{options}} | |
3540 | form is used, @var{options} is a list of @samp{-} separated options that | |
3541 | control the details of the dump. Not all options are applicable to all | |
3542 | dumps, those which are not meaningful will be ignored. The following | |
3543 | options are available | |
f71f87f9 | 3544 | |
e76b4820 | 3545 | @table @samp |
22367161 | 3546 | @item address |
767094dd | 3547 | Print the address of each node. Usually this is not meaningful as it |
22367161 NS |
3548 | changes according to the environment and source file. Its primary use |
3549 | is for tying up a dump file with a debug environment. | |
3550 | @item slim | |
3551 | Inhibit dumping of members of a scope or body of a function merely | |
6de9cd9a DN |
3552 | because that scope has been reached. Only dump such items when they |
3553 | are directly reachable by some other path. When dumping pretty-printed | |
3554 | trees, this option inhibits dumping the bodies of control structures. | |
3555 | @item raw | |
3556 | Print a raw representation of the tree. By default, trees are | |
3557 | pretty-printed into a C-like representation. | |
3558 | @item details | |
3559 | Enable more detailed dumps (not honored by every dump option). | |
3560 | @item stats | |
3561 | Enable dumping various statistics about the pass (not honored by every dump | |
3562 | option). | |
3563 | @item blocks | |
3564 | Enable showing basic block boundaries (disabled in raw dumps). | |
3565 | @item vops | |
3566 | Enable showing virtual operands for every statement. | |
3567 | @item lineno | |
3568 | Enable showing line numbers for statements. | |
3569 | @item uid | |
3570 | Enable showing the unique ID (@code{DECL_UID}) for each variable. | |
22367161 | 3571 | @item all |
6de9cd9a | 3572 | Turn on all options, except @option{raw}, @option{slim} and @option{lineno}. |
e76b4820 NS |
3573 | @end table |
3574 | ||
3575 | The following tree dumps are possible: | |
3576 | @table @samp | |
6de9cd9a | 3577 | |
e76b4820 NS |
3578 | @item original |
3579 | Dump before any tree based optimization, to @file{@var{file}.original}. | |
6de9cd9a | 3580 | |
e76b4820 NS |
3581 | @item optimized |
3582 | Dump after all tree based optimization, to @file{@var{file}.optimized}. | |
6de9cd9a | 3583 | |
6be77748 | 3584 | @item inlined |
9c34dbbf | 3585 | Dump after function inlining, to @file{@var{file}.inlined}. |
6de9cd9a DN |
3586 | |
3587 | @item gimple | |
3588 | @opindex fdump-tree-gimple | |
3589 | Dump each function before and after the gimplification pass to a file. The | |
3590 | file name is made by appending @file{.gimple} to the source file name. | |
3591 | ||
3592 | @item cfg | |
3593 | @opindex fdump-tree-cfg | |
3594 | Dump the control flow graph of each function to a file. The file name is | |
3595 | made by appending @file{.cfg} to the source file name. | |
3596 | ||
3597 | @item vcg | |
3598 | @opindex fdump-tree-vcg | |
3599 | Dump the control flow graph of each function to a file in VCG format. The | |
3600 | file name is made by appending @file{.vcg} to the source file name. Note | |
3601 | that if the file contains more than one function, the generated file cannot | |
3602 | be used directly by VCG. You will need to cut and paste each function's | |
3603 | graph into its own separate file first. | |
3604 | ||
3605 | @item ch | |
3606 | @opindex fdump-tree-ch | |
3607 | Dump each function after copying loop headers. The file name is made by | |
3608 | appending @file{.ch} to the source file name. | |
3609 | ||
3610 | @item ssa | |
3611 | @opindex fdump-tree-ssa | |
3612 | Dump SSA related information to a file. The file name is made by appending | |
3613 | @file{.ssa} to the source file name. | |
3614 | ||
3615 | @item alias | |
3616 | @opindex fdump-tree-alias | |
3617 | Dump aliasing information for each function. The file name is made by | |
3618 | appending @file{.alias} to the source file name. | |
3619 | ||
3620 | @item ccp | |
3621 | @opindex fdump-tree-ccp | |
3622 | Dump each function after CCP. The file name is made by appending | |
3623 | @file{.ccp} to the source file name. | |
3624 | ||
3625 | @item pre | |
3626 | @opindex fdump-tree-pre | |
3627 | Dump trees after partial redundancy elimination. The file name is made | |
3628 | by appending @file{.pre} to the source file name. | |
3629 | ||
ff2ad0f7 DN |
3630 | @item fre |
3631 | @opindex fdump-tree-fre | |
3632 | Dump trees after full redundancy elimination. The file name is made | |
3633 | by appending @file{.fre} to the source file name. | |
3634 | ||
6de9cd9a DN |
3635 | @item dce |
3636 | @opindex fdump-tree-dce | |
3637 | Dump each function after dead code elimination. The file name is made by | |
3638 | appending @file{.dce} to the source file name. | |
3639 | ||
3640 | @item mudflap | |
3641 | @opindex fdump-tree-mudflap | |
3642 | Dump each function after adding mudflap instrumentation. The file name is | |
3643 | made by appending @file{.mudflap} to the source file name. | |
3644 | ||
3645 | @item sra | |
3646 | @opindex fdump-tree-sra | |
3647 | Dump each function after performing scalar replacement of aggregates. The | |
3648 | file name is made by appending @file{.sra} to the source file name. | |
3649 | ||
3650 | @item dom | |
3651 | @opindex fdump-tree-dom | |
3652 | Dump each function after applying dominator tree optimizations. The file | |
3653 | name is made by appending @file{.dom} to the source file name. | |
3654 | ||
3655 | @item dse | |
3656 | @opindex fdump-tree-dse | |
3657 | Dump each function after applying dead store elimination. The file | |
3658 | name is made by appending @file{.dse} to the source file name. | |
3659 | ||
3660 | @item phiopt | |
3661 | @opindex fdump-tree-phiopt | |
3662 | Dump each function after optimizing PHI nodes into straightline code. The file | |
3663 | name is made by appending @file{.phiopt} to the source file name. | |
3664 | ||
3665 | @item forwprop | |
3666 | @opindex fdump-tree-forwprop | |
3667 | Dump each function after forward propagating single use variables. The file | |
3668 | name is made by appending @file{.forwprop} to the source file name. | |
3669 | ||
3670 | @item copyrename | |
3671 | @opindex fdump-tree-copyrename | |
3672 | Dump each function after applying the copy rename optimization. The file | |
3673 | name is made by appending @file{.copyrename} to the source file name. | |
3674 | ||
3675 | @item nrv | |
3676 | @opindex fdump-tree-nrv | |
3677 | Dump each function after applying the named return value optimization on | |
3678 | generic trees. The file name is made by appending @file{.nrv} to the source | |
3679 | file name. | |
3680 | ||
79fe1b3b DN |
3681 | @item vect |
3682 | @opindex fdump-tree-vect | |
3683 | Dump each function after applying vectorization of loops. The file name is | |
3684 | made by appending @file{.vect} to the source file name. | |
3685 | ||
6de9cd9a DN |
3686 | @item all |
3687 | @opindex fdump-tree-all | |
3688 | Enable all the available tree dumps with the flags provided in this option. | |
e76b4820 | 3689 | @end table |
9965d119 | 3690 | |
a37db56b GK |
3691 | @item -frandom-seed=@var{string} |
3692 | @opindex frandom-string | |
3693 | This option provides a seed that GCC uses when it would otherwise use | |
e61a2eb7 NS |
3694 | random numbers. It is used to generate certain symbol names |
3695 | that have to be different in every compiled file. It is also used to | |
3696 | place unique stamps in coverage data files and the object files that | |
3697 | produce them. You can use the @option{-frandom-seed} option to produce | |
3698 | reproducibly identical object files. | |
a37db56b GK |
3699 | |
3700 | The @var{string} should be different for every file you compile. | |
3701 | ||
e03b7153 RS |
3702 | @item -fsched-verbose=@var{n} |
3703 | @opindex fsched-verbose | |
3704 | On targets that use instruction scheduling, this option controls the | |
3705 | amount of debugging output the scheduler prints. This information is | |
3706 | written to standard error, unless @option{-dS} or @option{-dR} is | |
3707 | specified, in which case it is output to the usual dump | |
3708 | listing file, @file{.sched} or @file{.sched2} respectively. However | |
3709 | for @var{n} greater than nine, the output is always printed to standard | |
3710 | error. | |
3711 | ||
3712 | For @var{n} greater than zero, @option{-fsched-verbose} outputs the | |
3713 | same information as @option{-dRS}. For @var{n} greater than one, it | |
3714 | also output basic block probabilities, detailed ready list information | |
3715 | and unit/insn info. For @var{n} greater than two, it includes RTL | |
3716 | at abort point, control-flow and regions info. And for @var{n} over | |
3717 | four, @option{-fsched-verbose} also includes dependence info. | |
3718 | ||
74291a4b | 3719 | @item -save-temps |
cd3bb277 | 3720 | @opindex save-temps |
74291a4b MM |
3721 | Store the usual ``temporary'' intermediate files permanently; place them |
3722 | in the current directory and name them based on the source file. Thus, | |
3723 | compiling @file{foo.c} with @samp{-c -save-temps} would produce files | |
f2ecb02d JM |
3724 | @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a |
3725 | preprocessed @file{foo.i} output file even though the compiler now | |
3726 | normally uses an integrated preprocessor. | |
74291a4b | 3727 | |
03c41c05 | 3728 | @item -time |
cd3bb277 | 3729 | @opindex time |
03c41c05 | 3730 | Report the CPU time taken by each subprocess in the compilation |
f2ecb02d JM |
3731 | sequence. For C source files, this is the compiler proper and assembler |
3732 | (plus the linker if linking is done). The output looks like this: | |
03c41c05 ZW |
3733 | |
3734 | @smallexample | |
03c41c05 ZW |
3735 | # cc1 0.12 0.01 |
3736 | # as 0.00 0.01 | |
3737 | @end smallexample | |
3738 | ||
3739 | The first number on each line is the ``user time,'' that is time spent | |
3740 | executing the program itself. The second number is ``system time,'' | |
3741 | time spent executing operating system routines on behalf of the program. | |
3742 | Both numbers are in seconds. | |
3743 | ||
014a1138 JZ |
3744 | @item -fvar-tracking |
3745 | @opindex fvar-tracking | |
3746 | Run variable tracking pass. It computes where variables are stored at each | |
3747 | position in code. Better debugging information is then generated | |
3748 | (if the debugging information format supports this information). | |
3749 | ||
3750 | It is enabled by default when compiling with optimization (@option{-Os}, | |
3751 | @option{-O}, @option{-O2}, ...), debugging information (@option{-g}) and | |
3752 | the debug info format supports it. | |
3753 | ||
74291a4b | 3754 | @item -print-file-name=@var{library} |
cd3bb277 | 3755 | @opindex print-file-name |
74291a4b MM |
3756 | Print the full absolute name of the library file @var{library} that |
3757 | would be used when linking---and don't do anything else. With this | |
0c2d1a2a | 3758 | option, GCC does not compile or link anything; it just prints the |
74291a4b MM |
3759 | file name. |
3760 | ||
b1018de6 AO |
3761 | @item -print-multi-directory |
3762 | @opindex print-multi-directory | |
3763 | Print the directory name corresponding to the multilib selected by any | |
3764 | other switches present in the command line. This directory is supposed | |
3765 | to exist in @env{GCC_EXEC_PREFIX}. | |
3766 | ||
3767 | @item -print-multi-lib | |
3768 | @opindex print-multi-lib | |
3769 | Print the mapping from multilib directory names to compiler switches | |
3770 | that enable them. The directory name is separated from the switches by | |
3771 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
3772 | @samp{-}, without spaces between multiple switches. This is supposed to | |
3773 | ease shell-processing. | |
3774 | ||
74291a4b | 3775 | @item -print-prog-name=@var{program} |
cd3bb277 | 3776 | @opindex print-prog-name |
630d3d5a | 3777 | Like @option{-print-file-name}, but searches for a program such as @samp{cpp}. |
74291a4b MM |
3778 | |
3779 | @item -print-libgcc-file-name | |
cd3bb277 | 3780 | @opindex print-libgcc-file-name |
630d3d5a | 3781 | Same as @option{-print-file-name=libgcc.a}. |
74291a4b | 3782 | |
630d3d5a | 3783 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} |
74291a4b MM |
3784 | but you do want to link with @file{libgcc.a}. You can do |
3785 | ||
3ab51846 | 3786 | @smallexample |
74291a4b | 3787 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` |
3ab51846 | 3788 | @end smallexample |
74291a4b MM |
3789 | |
3790 | @item -print-search-dirs | |
cd3bb277 | 3791 | @opindex print-search-dirs |
74291a4b | 3792 | Print the name of the configured installation directory and a list of |
2dd76960 | 3793 | program and library directories @command{gcc} will search---and don't do anything else. |
74291a4b | 3794 | |
2dd76960 | 3795 | This is useful when @command{gcc} prints the error message |
3c0b7970 JM |
3796 | @samp{installation problem, cannot exec cpp0: No such file or directory}. |
3797 | To resolve this you either need to put @file{cpp0} and the other compiler | |
2dd76960 | 3798 | components where @command{gcc} expects to find them, or you can set the environment |
bedc7537 | 3799 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. |
74291a4b MM |
3800 | Don't forget the trailing '/'. |
3801 | @xref{Environment Variables}. | |
1f0c3120 JM |
3802 | |
3803 | @item -dumpmachine | |
cd3bb277 | 3804 | @opindex dumpmachine |
1f0c3120 JM |
3805 | Print the compiler's target machine (for example, |
3806 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
3807 | ||
3808 | @item -dumpversion | |
cd3bb277 | 3809 | @opindex dumpversion |
1f0c3120 JM |
3810 | Print the compiler version (for example, @samp{3.0})---and don't do |
3811 | anything else. | |
3812 | ||
3813 | @item -dumpspecs | |
cd3bb277 | 3814 | @opindex dumpspecs |
1f0c3120 JM |
3815 | Print the compiler's built-in specs---and don't do anything else. (This |
3816 | is used when GCC itself is being built.) @xref{Spec Files}. | |
73c68f61 SS |
3817 | |
3818 | @item -feliminate-unused-debug-types | |
3819 | @opindex feliminate-unused-debug-types | |
3820 | Normally, when producing DWARF2 output, GCC will emit debugging | |
3821 | information for all types declared in a compilation | |
3822 | unit, regardless of whether or not they are actually used | |
3823 | in that compilation unit. Sometimes this is useful, such as | |
3824 | if, in the debugger, you want to cast a value to a type that is | |
3825 | not actually used in your program (but is declared). More often, | |
3826 | however, this results in a significant amount of wasted space. | |
3827 | With this option, GCC will avoid producing debug symbol output | |
3828 | for types that are nowhere used in the source file being compiled. | |
74291a4b MM |
3829 | @end table |
3830 | ||
3831 | @node Optimize Options | |
3832 | @section Options That Control Optimization | |
3833 | @cindex optimize options | |
3834 | @cindex options, optimization | |
3835 | ||
147d1cd3 JQ |
3836 | These options control various sorts of optimizations. |
3837 | ||
3838 | Without any optimization option, the compiler's goal is to reduce the | |
3839 | cost of compilation and to make debugging produce the expected | |
3840 | results. Statements are independent: if you stop the program with a | |
3841 | breakpoint between statements, you can then assign a new value to any | |
3842 | variable or change the program counter to any other statement in the | |
3843 | function and get exactly the results you would expect from the source | |
3844 | code. | |
3845 | ||
3846 | Turning on optimization flags makes the compiler attempt to improve | |
3847 | the performance and/or code size at the expense of compilation time | |
3848 | and possibly the ability to debug the program. | |
3849 | ||
a451b0bd | 3850 | The compiler performs optimization based on the knowledge it has of |
7797ff53 PB |
3851 | the program. Optimization levels @option{-O2} and above, in |
3852 | particular, enable @emph{unit-at-a-time} mode, which allows the | |
3853 | compiler to consider information gained from later functions in | |
3854 | the file when compiling a function. Compiling multiple files at | |
3855 | once to a single output file in @emph{unit-at-a-time} mode allows | |
d1bd0ded GK |
3856 | the compiler to use information gained from all of the files when |
3857 | compiling each of them. | |
3858 | ||
147d1cd3 JQ |
3859 | Not all optimizations are controlled directly by a flag. Only |
3860 | optimizations that have a flag are listed. | |
74291a4b | 3861 | |
2642624b | 3862 | @table @gcctabopt |
74291a4b MM |
3863 | @item -O |
3864 | @itemx -O1 | |
cd3bb277 JM |
3865 | @opindex O |
3866 | @opindex O1 | |
74291a4b MM |
3867 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
3868 | more memory for a large function. | |
3869 | ||
630d3d5a | 3870 | With @option{-O}, the compiler tries to reduce code size and execution |
9c34dbbf ZW |
3871 | time, without performing any optimizations that take a great deal of |
3872 | compilation time. | |
74291a4b | 3873 | |
daf2f129 | 3874 | @option{-O} turns on the following optimization flags: |
9a94f7f3 JM |
3875 | @gccoptlist{-fdefer-pop @gol |
3876 | -fmerge-constants @gol | |
3877 | -fthread-jumps @gol | |
3878 | -floop-optimize @gol | |
9a94f7f3 JM |
3879 | -fif-conversion @gol |
3880 | -fif-conversion2 @gol | |
3881 | -fdelayed-branch @gol | |
3882 | -fguess-branch-probability @gol | |
fad893da JQ |
3883 | -fcprop-registers} |
3884 | ||
3885 | @option{-O} also turns on @option{-fomit-frame-pointer} on machines | |
3886 | where doing so does not interfere with debugging. | |
3887 | ||
74291a4b | 3888 | @item -O2 |
cd3bb277 | 3889 | @opindex O2 |
0c2d1a2a | 3890 | Optimize even more. GCC performs nearly all supported optimizations |
74291a4b | 3891 | that do not involve a space-speed tradeoff. The compiler does not |
630d3d5a JM |
3892 | perform loop unrolling or function inlining when you specify @option{-O2}. |
3893 | As compared to @option{-O}, this option increases both compilation time | |
74291a4b MM |
3894 | and the performance of the generated code. |
3895 | ||
fad893da JQ |
3896 | @option{-O2} turns on all optimization flags specified by @option{-O}. It |
3897 | also turns on the following optimization flags: | |
9a94f7f3 JM |
3898 | @gccoptlist{-fforce-mem @gol |
3899 | -foptimize-sibling-calls @gol | |
3900 | -fstrength-reduce @gol | |
3901 | -fcse-follow-jumps -fcse-skip-blocks @gol | |
3902 | -frerun-cse-after-loop -frerun-loop-opt @gol | |
f5f2e3cd | 3903 | -fgcse -fgcse-lm -fgcse-sm -fgcse-las @gol |
9a94f7f3 JM |
3904 | -fdelete-null-pointer-checks @gol |
3905 | -fexpensive-optimizations @gol | |
f5f2e3cd | 3906 | -fregmove @gol |
9a94f7f3 JM |
3907 | -fschedule-insns -fschedule-insns2 @gol |
3908 | -fsched-interblock -fsched-spec @gol | |
3909 | -fcaller-saves @gol | |
3910 | -fpeephole2 @gol | |
3911 | -freorder-blocks -freorder-functions @gol | |
3912 | -fstrict-aliasing @gol | |
23a44080 | 3913 | -funit-at-a-time @gol |
9a94f7f3 | 3914 | -falign-functions -falign-jumps @gol |
b684a3df JH |
3915 | -falign-loops -falign-labels @gol |
3916 | -fcrossjumping} | |
74291a4b | 3917 | |
081ca317 BL |
3918 | Please note the warning under @option{-fgcse} about |
3919 | invoking @option{-O2} on programs that use computed gotos. | |
3920 | ||
74291a4b | 3921 | @item -O3 |
cd3bb277 | 3922 | @opindex O3 |
630d3d5a | 3923 | Optimize yet more. @option{-O3} turns on all optimizations specified by |
dafc5b82 | 3924 | @option{-O2} and also turns on the @option{-finline-functions}, |
4c59781d | 3925 | @option{-fweb} and @option{-fgcse-after-reload} options. |
74291a4b MM |
3926 | |
3927 | @item -O0 | |
cd3bb277 | 3928 | @opindex O0 |
fad893da | 3929 | Do not optimize. This is the default. |
74291a4b | 3930 | |
c6aded7c | 3931 | @item -Os |
cd3bb277 | 3932 | @opindex Os |
630d3d5a | 3933 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations that |
c6aded7c AG |
3934 | do not typically increase code size. It also performs further |
3935 | optimizations designed to reduce code size. | |
3936 | ||
fad893da | 3937 | @option{-Os} disables the following optimization flags: |
9a94f7f3 | 3938 | @gccoptlist{-falign-functions -falign-jumps -falign-loops @gol |
750054a2 | 3939 | -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays} |
fad893da | 3940 | |
630d3d5a | 3941 | If you use multiple @option{-O} options, with or without level numbers, |
74291a4b MM |
3942 | the last such option is the one that is effective. |
3943 | @end table | |
3944 | ||
630d3d5a | 3945 | Options of the form @option{-f@var{flag}} specify machine-independent |
74291a4b | 3946 | flags. Most flags have both positive and negative forms; the negative |
147d1cd3 JQ |
3947 | form of @option{-ffoo} would be @option{-fno-foo}. In the table |
3948 | below, only one of the forms is listed---the one you typically will | |
3949 | use. You can figure out the other form by either removing @samp{no-} | |
3950 | or adding it. | |
3951 | ||
3952 | The following options control specific optimizations. They are either | |
3953 | activated by @option{-O} options or are related to ones that are. You | |
3954 | can use the following flags in the rare cases when ``fine-tuning'' of | |
3955 | optimizations to be performed is desired. | |
74291a4b | 3956 | |
2642624b | 3957 | @table @gcctabopt |
74291a4b | 3958 | @item -fno-default-inline |
cd3bb277 | 3959 | @opindex fno-default-inline |
74291a4b MM |
3960 | Do not make member functions inline by default merely because they are |
3961 | defined inside the class scope (C++ only). Otherwise, when you specify | |
630d3d5a | 3962 | @w{@option{-O}}, member functions defined inside class scope are compiled |
74291a4b MM |
3963 | inline by default; i.e., you don't need to add @samp{inline} in front of |
3964 | the member function name. | |
3965 | ||
3966 | @item -fno-defer-pop | |
cd3bb277 | 3967 | @opindex fno-defer-pop |
74291a4b MM |
3968 | Always pop the arguments to each function call as soon as that function |
3969 | returns. For machines which must pop arguments after a function call, | |
3970 | the compiler normally lets arguments accumulate on the stack for several | |
3971 | function calls and pops them all at once. | |
3972 | ||
38df970e JQ |
3973 | Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
3974 | ||
74291a4b | 3975 | @item -fforce-mem |
cd3bb277 | 3976 | @opindex fforce-mem |
74291a4b MM |
3977 | Force memory operands to be copied into registers before doing |
3978 | arithmetic on them. This produces better code by making all memory | |
3979 | references potential common subexpressions. When they are not common | |
3980 | subexpressions, instruction combination should eliminate the separate | |
38df970e JQ |
3981 | register-load. |
3982 | ||
3983 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
74291a4b MM |
3984 | |
3985 | @item -fforce-addr | |
cd3bb277 | 3986 | @opindex fforce-addr |
74291a4b MM |
3987 | Force memory address constants to be copied into registers before |
3988 | doing arithmetic on them. This may produce better code just as | |
630d3d5a | 3989 | @option{-fforce-mem} may. |
74291a4b MM |
3990 | |
3991 | @item -fomit-frame-pointer | |
cd3bb277 | 3992 | @opindex fomit-frame-pointer |
74291a4b MM |
3993 | Don't keep the frame pointer in a register for functions that |
3994 | don't need one. This avoids the instructions to save, set up and | |
3995 | restore frame pointers; it also makes an extra register available | |
3996 | in many functions. @strong{It also makes debugging impossible on | |
3997 | some machines.} | |
3998 | ||
8aeea6e6 | 3999 | On some machines, such as the VAX, this flag has no effect, because |
74291a4b MM |
4000 | the standard calling sequence automatically handles the frame pointer |
4001 | and nothing is saved by pretending it doesn't exist. The | |
4002 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
4003 | whether a target machine supports this flag. @xref{Registers,,Register | |
b11cc610 | 4004 | Usage, gccint, GNU Compiler Collection (GCC) Internals}. |
74291a4b | 4005 | |
38df970e JQ |
4006 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4007 | ||
1aaef9c1 | 4008 | @item -foptimize-sibling-calls |
cd3bb277 | 4009 | @opindex foptimize-sibling-calls |
1aaef9c1 JH |
4010 | Optimize sibling and tail recursive calls. |
4011 | ||
38df970e JQ |
4012 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4013 | ||
74291a4b | 4014 | @item -fno-inline |
cd3bb277 | 4015 | @opindex fno-inline |
74291a4b MM |
4016 | Don't pay attention to the @code{inline} keyword. Normally this option |
4017 | is used to keep the compiler from expanding any functions inline. | |
4018 | Note that if you are not optimizing, no functions can be expanded inline. | |
4019 | ||
4020 | @item -finline-functions | |
cd3bb277 | 4021 | @opindex finline-functions |
74291a4b MM |
4022 | Integrate all simple functions into their callers. The compiler |
4023 | heuristically decides which functions are simple enough to be worth | |
4024 | integrating in this way. | |
4025 | ||
4026 | If all calls to a given function are integrated, and the function is | |
4027 | declared @code{static}, then the function is normally not output as | |
4028 | assembler code in its own right. | |
4029 | ||
38df970e JQ |
4030 | Enabled at level @option{-O3}. |
4031 | ||
efa3896a | 4032 | @item -finline-limit=@var{n} |
cd3bb277 | 4033 | @opindex finline-limit |
2dd76960 | 4034 | By default, GCC limits the size of functions that can be inlined. This flag |
f9e814f1 | 4035 | allows the control of this limit for functions that are explicitly marked as |
3364c33b | 4036 | inline (i.e., marked with the inline keyword or defined within the class |
02f52e19 | 4037 | definition in c++). @var{n} is the size of functions that can be inlined in |
f9e814f1 | 4038 | number of pseudo instructions (not counting parameter handling). The default |
93ee12c4 GP |
4039 | value of @var{n} is 600. |
4040 | Increasing this value can result in more inlined code at | |
f9e814f1 | 4041 | the cost of compilation time and memory consumption. Decreasing usually makes |
02f52e19 AJ |
4042 | the compilation faster and less code will be inlined (which presumably |
4043 | means slower programs). This option is particularly useful for programs that | |
aee96fe9 | 4044 | use inlining heavily such as those based on recursive templates with C++. |
f9e814f1 | 4045 | |
bc522472 KG |
4046 | Inlining is actually controlled by a number of parameters, which may be |
4047 | specified individually by using @option{--param @var{name}=@var{value}}. | |
daf2f129 | 4048 | The @option{-finline-limit=@var{n}} option sets some of these parameters |
bc522472 KG |
4049 | as follows: |
4050 | ||
4051 | @table @gcctabopt | |
bc522472 KG |
4052 | @item max-inline-insns-single |
4053 | is set to @var{n}/2. | |
6d7fe8b3 | 4054 | @item max-inline-insns-auto |
bc522472 KG |
4055 | is set to @var{n}/2. |
4056 | @item min-inline-insns | |
4057 | is set to 130 or @var{n}/4, whichever is smaller. | |
4058 | @item max-inline-insns-rtl | |
4059 | is set to @var{n}. | |
4060 | @end table | |
4061 | ||
f7a01847 | 4062 | See below for a documentation of the individual |
bc522472 KG |
4063 | parameters controlling inlining. |
4064 | ||
f9e814f1 TP |
4065 | @emph{Note:} pseudo instruction represents, in this particular context, an |
4066 | abstract measurement of function's size. In no way, it represents a count | |
4067 | of assembly instructions and as such its exact meaning might change from one | |
4068 | release to an another. | |
4069 | ||
74291a4b | 4070 | @item -fkeep-inline-functions |
cd3bb277 | 4071 | @opindex fkeep-inline-functions |
1a10290c MM |
4072 | In C, emit @code{static} functions that are declared @code{inline} |
4073 | into the object file, even if the function has been inlined into all | |
4074 | of its callers. This switch does not affect functions using the | |
4075 | @code{extern inline} extension in GNU C. In C++, emit any and all | |
4076 | inline functions into the object file. | |
74291a4b MM |
4077 | |
4078 | @item -fkeep-static-consts | |
cd3bb277 | 4079 | @opindex fkeep-static-consts |
74291a4b MM |
4080 | Emit variables declared @code{static const} when optimization isn't turned |
4081 | on, even if the variables aren't referenced. | |
4082 | ||
0c2d1a2a | 4083 | GCC enables this option by default. If you want to force the compiler to |
74291a4b | 4084 | check if the variable was referenced, regardless of whether or not |
630d3d5a | 4085 | optimization is turned on, use the @option{-fno-keep-static-consts} option. |
74291a4b | 4086 | |
201556f0 JJ |
4087 | @item -fmerge-constants |
4088 | Attempt to merge identical constants (string constants and floating point | |
3364c33b | 4089 | constants) across compilation units. |
201556f0 | 4090 | |
3364c33b JQ |
4091 | This option is the default for optimized compilation if the assembler and |
4092 | linker support it. Use @option{-fno-merge-constants} to inhibit this | |
4093 | behavior. | |
201556f0 | 4094 | |
38df970e JQ |
4095 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4096 | ||
201556f0 JJ |
4097 | @item -fmerge-all-constants |
4098 | Attempt to merge identical constants and identical variables. | |
4099 | ||
4100 | This option implies @option{-fmerge-constants}. In addition to | |
4101 | @option{-fmerge-constants} this considers e.g. even constant initialized | |
4102 | arrays or initialized constant variables with integral or floating point | |
4103 | types. Languages like C or C++ require each non-automatic variable to | |
4104 | have distinct location, so using this option will result in non-conforming | |
c21cd8b1 | 4105 | behavior. |
201556f0 | 4106 | |
e5626198 AZ |
4107 | @item -fmodulo-sched |
4108 | @opindex fmodulo-sched | |
4109 | Perform swing modulo scheduling immediately before the first scheduling | |
4110 | pass. This pass looks at innermost loops and reorders their | |
4111 | instructions by overlapping different iterations. | |
4112 | ||
ed8d2920 MM |
4113 | @item -fnew-ra |
4114 | @opindex fnew-ra | |
4115 | Use a graph coloring register allocator. Currently this option is meant | |
7db956db DH |
4116 | only for testing. Users should not specify this option, since it is not |
4117 | yet ready for production use. | |
ed8d2920 | 4118 | |
e03b7153 RS |
4119 | @item -fno-branch-count-reg |
4120 | @opindex fno-branch-count-reg | |
4121 | Do not use ``decrement and branch'' instructions on a count register, | |
4122 | but instead generate a sequence of instructions that decrement a | |
4123 | register, compare it against zero, then branch based upon the result. | |
4124 | This option is only meaningful on architectures that support such | |
4125 | instructions, which include x86, PowerPC, IA-64 and S/390. | |
4126 | ||
38df970e JQ |
4127 | The default is @option{-fbranch-count-reg}, enabled when |
4128 | @option{-fstrength-reduce} is enabled. | |
4129 | ||
74291a4b | 4130 | @item -fno-function-cse |
cd3bb277 | 4131 | @opindex fno-function-cse |
74291a4b MM |
4132 | Do not put function addresses in registers; make each instruction that |
4133 | calls a constant function contain the function's address explicitly. | |
4134 | ||
4135 | This option results in less efficient code, but some strange hacks | |
4136 | that alter the assembler output may be confused by the optimizations | |
4137 | performed when this option is not used. | |
4138 | ||
38df970e JQ |
4139 | The default is @option{-ffunction-cse} |
4140 | ||
27b41650 KG |
4141 | @item -fno-zero-initialized-in-bss |
4142 | @opindex fno-zero-initialized-in-bss | |
4143 | If the target supports a BSS section, GCC by default puts variables that | |
4144 | are initialized to zero into BSS@. This can save space in the resulting | |
4145 | code. | |
4146 | ||
4147 | This option turns off this behavior because some programs explicitly | |
4148 | rely on variables going to the data section. E.g., so that the | |
4149 | resulting executable can find the beginning of that section and/or make | |
4150 | assumptions based on that. | |
4151 | ||
4152 | The default is @option{-fzero-initialized-in-bss}. | |
e03b7153 | 4153 | |
6de9cd9a DN |
4154 | @item -fbounds-check |
4155 | @opindex fbounds-check | |
4156 | For front-ends that support it, generate additional code to check that | |
4157 | indices used to access arrays are within the declared range. This is | |
4158 | currently only supported by the Java and Fortran front-ends, where | |
4159 | this option defaults to true and false respectively. | |
4160 | ||
4161 | @item -fmudflap -fmudflapth -fmudflapir | |
4162 | @opindex fmudflap | |
4163 | @opindex fmudflapth | |
4164 | @opindex fmudflapir | |
4165 | @cindex bounds checking | |
4166 | @cindex mudflap | |
4167 | For front-ends that support it (C and C++), instrument all risky | |
4168 | pointer/array dereferencing operations, some standard library | |
4169 | string/heap functions, and some other associated constructs with | |
4170 | range/validity tests. Modules so instrumented should be immune to | |
4171 | buffer overflows, invalid heap use, and some other classes of C/C++ | |
4172 | programming errors. The instrumentation relies on a separate runtime | |
4173 | library (@file{libmudflap}), which will be linked into a program if | |
4174 | @option{-fmudflap} is given at link time. Run-time behavior of the | |
4175 | instrumented program is controlled by the @env{MUDFLAP_OPTIONS} | |
4176 | environment variable. See @code{env MUDFLAP_OPTIONS=-help a.out} | |
4177 | for its options. | |
4178 | ||
4179 | Use @option{-fmudflapth} instead of @option{-fmudflap} to compile and to | |
4180 | link if your program is multi-threaded. Use @option{-fmudflapir}, in | |
4181 | addition to @option{-fmudflap} or @option{-fmudflapth}, if | |
4182 | instrumentation should ignore pointer reads. This produces less | |
4183 | instrumentation (and therefore faster execution) and still provides | |
4184 | some protection against outright memory corrupting writes, but allows | |
4185 | erroneously read data to propagate within a program. | |
4186 | ||
74291a4b | 4187 | @item -fstrength-reduce |
cd3bb277 | 4188 | @opindex fstrength-reduce |
74291a4b MM |
4189 | Perform the optimizations of loop strength reduction and |
4190 | elimination of iteration variables. | |
4191 | ||
38df970e JQ |
4192 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4193 | ||
74291a4b | 4194 | @item -fthread-jumps |
cd3bb277 | 4195 | @opindex fthread-jumps |
74291a4b MM |
4196 | Perform optimizations where we check to see if a jump branches to a |
4197 | location where another comparison subsumed by the first is found. If | |
4198 | so, the first branch is redirected to either the destination of the | |
4199 | second branch or a point immediately following it, depending on whether | |
4200 | the condition is known to be true or false. | |
4201 | ||
38df970e JQ |
4202 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4203 | ||
74291a4b | 4204 | @item -fcse-follow-jumps |
cd3bb277 | 4205 | @opindex fcse-follow-jumps |
74291a4b MM |
4206 | In common subexpression elimination, scan through jump instructions |
4207 | when the target of the jump is not reached by any other path. For | |
4208 | example, when CSE encounters an @code{if} statement with an | |
4209 | @code{else} clause, CSE will follow the jump when the condition | |
4210 | tested is false. | |
4211 | ||
38df970e JQ |
4212 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4213 | ||
74291a4b | 4214 | @item -fcse-skip-blocks |
cd3bb277 | 4215 | @opindex fcse-skip-blocks |
630d3d5a | 4216 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
74291a4b MM |
4217 | follow jumps which conditionally skip over blocks. When CSE |
4218 | encounters a simple @code{if} statement with no else clause, | |
630d3d5a | 4219 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the |
74291a4b MM |
4220 | body of the @code{if}. |
4221 | ||
38df970e JQ |
4222 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4223 | ||
74291a4b | 4224 | @item -frerun-cse-after-loop |
cd3bb277 | 4225 | @opindex frerun-cse-after-loop |
74291a4b MM |
4226 | Re-run common subexpression elimination after loop optimizations has been |
4227 | performed. | |
4228 | ||
38df970e JQ |
4229 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4230 | ||
6d6d0fa0 | 4231 | @item -frerun-loop-opt |
cd3bb277 | 4232 | @opindex frerun-loop-opt |
6d6d0fa0 JL |
4233 | Run the loop optimizer twice. |
4234 | ||
38df970e JQ |
4235 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4236 | ||
7506f491 | 4237 | @item -fgcse |
cd3bb277 | 4238 | @opindex fgcse |
7506f491 DE |
4239 | Perform a global common subexpression elimination pass. |
4240 | This pass also performs global constant and copy propagation. | |
4241 | ||
081ca317 BL |
4242 | @emph{Note:} When compiling a program using computed gotos, a GCC |
4243 | extension, you may get better runtime performance if you disable | |
3364c33b | 4244 | the global common subexpression elimination pass by adding |
081ca317 BL |
4245 | @option{-fno-gcse} to the command line. |
4246 | ||
38df970e JQ |
4247 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4248 | ||
a13d4ebf | 4249 | @item -fgcse-lm |
cd3bb277 | 4250 | @opindex fgcse-lm |
695ac33f | 4251 | When @option{-fgcse-lm} is enabled, global common subexpression elimination will |
767094dd | 4252 | attempt to move loads which are only killed by stores into themselves. This |
a13d4ebf | 4253 | allows a loop containing a load/store sequence to be changed to a load outside |
02f52e19 | 4254 | the loop, and a copy/store within the loop. |
a13d4ebf | 4255 | |
38df970e JQ |
4256 | Enabled by default when gcse is enabled. |
4257 | ||
a13d4ebf | 4258 | @item -fgcse-sm |
cd3bb277 | 4259 | @opindex fgcse-sm |
f5f2e3cd MH |
4260 | When @option{-fgcse-sm} is enabled, a store motion pass is run after |
4261 | global common subexpression elimination. This pass will attempt to move | |
4262 | stores out of loops. When used in conjunction with @option{-fgcse-lm}, | |
4263 | loops containing a load/store sequence can be changed to a load before | |
4264 | the loop and a store after the loop. | |
4265 | ||
4266 | Enabled by default when gcse is enabled. | |
4267 | ||
4268 | @item -fgcse-las | |
4269 | @opindex fgcse-las | |
4270 | When @option{-fgcse-las} is enabled, the global common subexpression | |
4271 | elimination pass eliminates redundant loads that come after stores to the | |
2206e783 | 4272 | same memory location (both partial and full redundancies). |
a13d4ebf | 4273 | |
38df970e JQ |
4274 | Enabled by default when gcse is enabled. |
4275 | ||
db643b91 SH |
4276 | @item -fgcse-after-reload |
4277 | @opindex fgcse-after-reload | |
4278 | When @option{-fgcse-after-reload} is enabled, a redundant load elimination | |
4279 | pass is performed after reload. The purpose of this pass is to cleanup | |
4280 | redundant spilling. | |
4281 | ||
96327cdc JH |
4282 | @item -floop-optimize |
4283 | @opindex floop-optimize | |
4284 | Perform loop optimizations: move constant expressions out of loops, simplify | |
4285 | exit test conditions and optionally do strength-reduction and loop unrolling as | |
4286 | well. | |
4287 | ||
38df970e JQ |
4288 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4289 | ||
5e962776 ZD |
4290 | @item -floop-optimize2 |
4291 | @opindex floop-optimize2 | |
4292 | Perform loop optimizations using the new loop optimizer. The optimizations | |
4293 | (loop unrolling, peeling and unswitching, loop invariant motion) are enabled | |
4294 | by separate flags. | |
4295 | ||
96327cdc JH |
4296 | @item -fcrossjumping |
4297 | @opindex crossjumping | |
4298 | Perform cross-jumping transformation. This transformation unifies equivalent code and save code size. The | |
4299 | resulting code may or may not perform better than without cross-jumping. | |
4300 | ||
38df970e JQ |
4301 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4302 | ||
2c4b77f3 JH |
4303 | @item -fif-conversion |
4304 | @opindex if-conversion | |
4305 | Attempt to transform conditional jumps into branch-less equivalents. This | |
4306 | include use of conditional moves, min, max, set flags and abs instructions, and | |
4307 | some tricks doable by standard arithmetics. The use of conditional execution | |
4308 | on chips where it is available is controlled by @code{if-conversion2}. | |
4309 | ||
38df970e JQ |
4310 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4311 | ||
2c4b77f3 JH |
4312 | @item -fif-conversion2 |
4313 | @opindex if-conversion2 | |
4314 | Use conditional execution (where available) to transform conditional jumps into | |
4315 | branch-less equivalents. | |
4316 | ||
38df970e JQ |
4317 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4318 | ||
b6d24183 | 4319 | @item -fdelete-null-pointer-checks |
cd3bb277 | 4320 | @opindex fdelete-null-pointer-checks |
9c34dbbf ZW |
4321 | Use global dataflow analysis to identify and eliminate useless checks |
4322 | for null pointers. The compiler assumes that dereferencing a null | |
4323 | pointer would have halted the program. If a pointer is checked after | |
4324 | it has already been dereferenced, it cannot be null. | |
4325 | ||
4326 | In some environments, this assumption is not true, and programs can | |
4327 | safely dereference null pointers. Use | |
4328 | @option{-fno-delete-null-pointer-checks} to disable this optimization | |
4329 | for programs which depend on that behavior. | |
b6d24183 | 4330 | |
38df970e JQ |
4331 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4332 | ||
74291a4b | 4333 | @item -fexpensive-optimizations |
cd3bb277 | 4334 | @opindex fexpensive-optimizations |
74291a4b MM |
4335 | Perform a number of minor optimizations that are relatively expensive. |
4336 | ||
38df970e JQ |
4337 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4338 | ||
639726ba | 4339 | @item -foptimize-register-move |
59d40964 | 4340 | @itemx -fregmove |
cd3bb277 JM |
4341 | @opindex foptimize-register-move |
4342 | @opindex fregmove | |
9ec36da5 JL |
4343 | Attempt to reassign register numbers in move instructions and as |
4344 | operands of other simple instructions in order to maximize the amount of | |
56159047 | 4345 | register tying. This is especially helpful on machines with two-operand |
38df970e | 4346 | instructions. |
9ec36da5 | 4347 | |
bedc7537 | 4348 | Note @option{-fregmove} and @option{-foptimize-register-move} are the same |
9ec36da5 JL |
4349 | optimization. |
4350 | ||
38df970e JQ |
4351 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4352 | ||
74291a4b | 4353 | @item -fdelayed-branch |
cd3bb277 | 4354 | @opindex fdelayed-branch |
74291a4b MM |
4355 | If supported for the target machine, attempt to reorder instructions |
4356 | to exploit instruction slots available after delayed branch | |
4357 | instructions. | |
4358 | ||
38df970e JQ |
4359 | Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. |
4360 | ||
74291a4b | 4361 | @item -fschedule-insns |
cd3bb277 | 4362 | @opindex fschedule-insns |
74291a4b MM |
4363 | If supported for the target machine, attempt to reorder instructions to |
4364 | eliminate execution stalls due to required data being unavailable. This | |
4365 | helps machines that have slow floating point or memory load instructions | |
4366 | by allowing other instructions to be issued until the result of the load | |
4367 | or floating point instruction is required. | |
4368 | ||
38df970e JQ |
4369 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4370 | ||
74291a4b | 4371 | @item -fschedule-insns2 |
cd3bb277 | 4372 | @opindex fschedule-insns2 |
630d3d5a | 4373 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
74291a4b MM |
4374 | instruction scheduling after register allocation has been done. This is |
4375 | especially useful on machines with a relatively small number of | |
4376 | registers and where memory load instructions take more than one cycle. | |
4377 | ||
38df970e JQ |
4378 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4379 | ||
e03b7153 RS |
4380 | @item -fno-sched-interblock |
4381 | @opindex fno-sched-interblock | |
4382 | Don't schedule instructions across basic blocks. This is normally | |
4383 | enabled by default when scheduling before register allocation, i.e.@: | |
4384 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
4385 | ||
4386 | @item -fno-sched-spec | |
4387 | @opindex fno-sched-spec | |
4388 | Don't allow speculative motion of non-load instructions. This is normally | |
4389 | enabled by default when scheduling before register allocation, i.e.@: | |
4390 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
4391 | ||
4392 | @item -fsched-spec-load | |
4393 | @opindex fsched-spec-load | |
4394 | Allow speculative motion of some load instructions. This only makes | |
4395 | sense when scheduling before register allocation, i.e.@: with | |
4396 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
4397 | ||
4398 | @item -fsched-spec-load-dangerous | |
4399 | @opindex fsched-spec-load-dangerous | |
4400 | Allow speculative motion of more load instructions. This only makes | |
4401 | sense when scheduling before register allocation, i.e.@: with | |
4402 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
4403 | ||
569fa502 DN |
4404 | @item -fsched-stalled-insns=@var{n} |
4405 | @opindex fsched-stalled-insns | |
4406 | Define how many insns (if any) can be moved prematurely from the queue | |
4407 | of stalled insns into the ready list, during the second scheduling pass. | |
4408 | ||
4409 | @item -fsched-stalled-insns-dep=@var{n} | |
4410 | @opindex fsched-stalled-insns-dep | |
daf2f129 JM |
4411 | Define how many insn groups (cycles) will be examined for a dependency |
4412 | on a stalled insn that is candidate for premature removal from the queue | |
4413 | of stalled insns. Has an effect only during the second scheduling pass, | |
569fa502 DN |
4414 | and only if @option{-fsched-stalled-insns} is used and its value is not zero. |
4415 | ||
b9422b69 JH |
4416 | @item -fsched2-use-superblocks |
4417 | @opindex fsched2-use-superblocks | |
61aeb06f | 4418 | When scheduling after register allocation, do use superblock scheduling |
62b9c42c | 4419 | algorithm. Superblock scheduling allows motion across basic block boundaries |
b9422b69 | 4420 | resulting on faster schedules. This option is experimental, as not all machine |
62b9c42c | 4421 | descriptions used by GCC model the CPU closely enough to avoid unreliable |
daf2f129 | 4422 | results from the algorithm. |
b9422b69 JH |
4423 | |
4424 | This only makes sense when scheduling after register allocation, i.e.@: with | |
4425 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
4426 | ||
4427 | @item -fsched2-use-traces | |
4428 | @opindex fsched2-use-traces | |
4429 | Use @option{-fsched2-use-superblocks} algorithm when scheduling after register | |
4430 | allocation and additionally perform code duplication in order to increase the | |
4431 | size of superblocks using tracer pass. See @option{-ftracer} for details on | |
4432 | trace formation. | |
4433 | ||
62b9c42c | 4434 | This mode should produce faster but significantly longer programs. Also |
b9422b69 JH |
4435 | without @code{-fbranch-probabilities} the traces constructed may not match the |
4436 | reality and hurt the performance. This only makes | |
4437 | sense when scheduling after register allocation, i.e.@: with | |
4438 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
4439 | ||
d72372e4 MH |
4440 | @item -freschedule-modulo-scheduled-loops |
4441 | @opindex fscheduling-in-modulo-scheduled-loops | |
4442 | The modulo scheduling comes before the traditional scheduling, if a loop was modulo scheduled | |
4443 | we may want to prevent the later scheduling passes from changing its schedule, we use this | |
4444 | option to control that. | |
4445 | ||
74291a4b | 4446 | @item -fcaller-saves |
cd3bb277 | 4447 | @opindex fcaller-saves |
74291a4b MM |
4448 | Enable values to be allocated in registers that will be clobbered by |
4449 | function calls, by emitting extra instructions to save and restore the | |
4450 | registers around such calls. Such allocation is done only when it | |
4451 | seems to result in better code than would otherwise be produced. | |
4452 | ||
81610a0d HPN |
4453 | This option is always enabled by default on certain machines, usually |
4454 | those which have no call-preserved registers to use instead. | |
4455 | ||
38df970e | 4456 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
74291a4b | 4457 | |
6de9cd9a DN |
4458 | @item -ftree-pre |
4459 | Perform Partial Redundancy Elimination (PRE) on trees. This flag is | |
4460 | enabled by default at -O and higher. | |
ff2ad0f7 DN |
4461 | |
4462 | @item -ftree-fre | |
4463 | Perform Full Redundancy Elimination (FRE) on trees. The difference | |
4464 | between FRE and PRE is that FRE only considers expressions | |
4465 | that are computed on all paths leading to the redundant computation. | |
4466 | This analysis faster than PRE, though it exposes fewer redundancies. | |
4467 | This flag is enabled by default at -O and higher. | |
6de9cd9a DN |
4468 | |
4469 | @item -ftree-ccp | |
4470 | Perform sparse conditional constant propagation (CCP) on trees. This flag | |
4471 | is enabled by default at -O and higher. | |
4472 | ||
4473 | @item -ftree-dce | |
4474 | Perform dead code elimination (DCE) on trees. This flag is enabled by | |
4475 | default at -O and higher. | |
4476 | ||
4477 | @item -ftree-dominator-opts | |
4478 | Perform dead code elimination (DCE) on trees. This flag is enabled by | |
4479 | default at -O and higher. | |
4480 | ||
4481 | @item -ftree-ch | |
4482 | Perform loop header copying on trees. This is beneficial since it increases | |
4483 | effectivity of code motion optimizations. It also saves one jump. This flag | |
4484 | is enabled by default at -O and higher. It is not enabled for -Os, since it | |
4485 | usually increases code size. | |
4486 | ||
c66b6c66 ZD |
4487 | @item -ftree-loop-optimize |
4488 | Perform loop optimizations on trees. This flag is enabled by default at -O | |
4489 | and higher. | |
4490 | ||
a7e5372d ZD |
4491 | @item -ftree-lim |
4492 | Perform loop invariant motion on trees. This pass moves only invartiants that | |
4493 | would be hard to handle on rtl level (function calls, operations that expand to | |
4494 | nontrivial sequences of insns). With @option{-funswitch-loops} it also moves | |
4495 | operands of conditions that are invariant out of the loop, so that we can use | |
4496 | just trivial invariantness analysis in loop unswitching. The pass also includes | |
4497 | store motion. | |
4498 | ||
82b85a85 ZD |
4499 | @item -fivcanon |
4500 | Create a canonical counter for number of iterations in the loop for that | |
4501 | determining number of iterations requires complicated analysis. Later | |
4502 | optimizations then may determine the number easily. Useful especially | |
4503 | in connection with unrolling. | |
4504 | ||
6de9cd9a DN |
4505 | @item -ftree-sra |
4506 | Perform scalar replacement of aggregates. This pass replaces structure | |
4507 | references with scalars to prevent committing structures to memory too | |
4508 | early. This flag is enabled by default at -O and higher. | |
4509 | ||
4510 | @item -ftree-copyrename | |
f26c1794 EC |
4511 | Perform copy renaming on trees. This pass attempts to rename compiler |
4512 | temporaries to other variables at copy locations, usually resulting in | |
4513 | variable names which more closely resemble the original variables. This flag | |
6de9cd9a DN |
4514 | is enabled by default at -O and higher. |
4515 | ||
4516 | @item -ftree-ter | |
4517 | Perform temporary expression replacement during the SSA->normal phase. Single | |
f26c1794 EC |
4518 | use/single def temporaries are replaced at their use location with their |
4519 | defining expression. This results in non-GIMPLE code, but gives the expanders | |
6de9cd9a DN |
4520 | much more complex trees to work on resulting in better RTL generation. This is |
4521 | enabled by default at -O and higher. | |
4522 | ||
4523 | @item -ftree-lrs | |
f26c1794 EC |
4524 | Perform live range splitting during the SSA->normal phase. Distinct live |
4525 | ranges of a variable are split into unique variables, allowing for better | |
6de9cd9a DN |
4526 | optimization later. This is enabled by default at -O and higher. |
4527 | ||
79fe1b3b DN |
4528 | @item -ftree-vectorize |
4529 | Perform loop vectorization on trees. | |
4530 | ||
6de9cd9a DN |
4531 | @item -ftracer |
4532 | @opindex ftracer | |
4533 | Perform tail duplication to enlarge superblock size. This transformation | |
4534 | simplifies the control flow of the function allowing other optimizations to do | |
4535 | better job. | |
4536 | ||
4537 | @item -funroll-loops | |
4538 | @opindex funroll-loops | |
4539 | Unroll loops whose number of iterations can be determined at compile | |
4540 | time or upon entry to the loop. @option{-funroll-loops} implies both | |
4541 | @option{-fstrength-reduce} and @option{-frerun-cse-after-loop}. This | |
4542 | option makes code larger, and may or may not make it run faster. | |
4543 | ||
4544 | @item -funroll-all-loops | |
4545 | @opindex funroll-all-loops | |
4546 | Unroll all loops, even if their number of iterations is uncertain when | |
4547 | the loop is entered. This usually makes programs run more slowly. | |
4548 | @option{-funroll-all-loops} implies the same options as | |
4549 | @option{-funroll-loops}, | |
4550 | ||
4551 | @item -fprefetch-loop-arrays | |
4552 | @opindex fprefetch-loop-arrays | |
4553 | If supported by the target machine, generate instructions to prefetch | |
4554 | memory to improve the performance of loops that access large arrays. | |
4555 | ||
e5eb27e5 | 4556 | @item -fmove-all-movables |
cd3bb277 | 4557 | @opindex fmove-all-movables |
e5eb27e5 JL |
4558 | Forces all invariant computations in loops to be moved |
4559 | outside the loop. | |
4560 | ||
4561 | @item -freduce-all-givs | |
cd3bb277 | 4562 | @opindex freduce-all-givs |
e5eb27e5 JL |
4563 | Forces all general-induction variables in loops to be |
4564 | strength-reduced. | |
4565 | ||
4566 | @emph{Note:} When compiling programs written in Fortran, | |
630d3d5a | 4567 | @option{-fmove-all-movables} and @option{-freduce-all-givs} are enabled |
e5eb27e5 JL |
4568 | by default when you use the optimizer. |
4569 | ||
4570 | These options may generate better or worse code; results are highly | |
4571 | dependent on the structure of loops within the source code. | |
4572 | ||
4573 | These two options are intended to be removed someday, once | |
4574 | they have helped determine the efficacy of various | |
4575 | approaches to improving loop optimizations. | |
4576 | ||
962e6e00 JM |
4577 | Please contact @w{@email{gcc@@gcc.gnu.org}}, and describe how use of |
4578 | these options affects the performance of your production code. | |
4579 | Examples of code that runs @emph{slower} when these options are | |
4580 | @emph{enabled} are very valuable. | |
e5eb27e5 | 4581 | |
74291a4b | 4582 | @item -fno-peephole |
6cfc0341 | 4583 | @itemx -fno-peephole2 |
cd3bb277 | 4584 | @opindex fno-peephole |
6cfc0341 RH |
4585 | @opindex fno-peephole2 |
4586 | Disable any machine-specific peephole optimizations. The difference | |
630d3d5a | 4587 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they |
6cfc0341 RH |
4588 | are implemented in the compiler; some targets use one, some use the |
4589 | other, a few use both. | |
861bb6c1 | 4590 | |
38df970e JQ |
4591 | @option{-fpeephole} is enabled by default. |
4592 | @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
4593 | ||
454d0cc7 | 4594 | @item -fno-guess-branch-probability |
cd3bb277 | 4595 | @opindex fno-guess-branch-probability |
9c34dbbf ZW |
4596 | Do not guess branch probabilities using a randomized model. |
4597 | ||
2dd76960 | 4598 | Sometimes GCC will opt to use a randomized model to guess branch |
9c34dbbf ZW |
4599 | probabilities, when none are available from either profiling feedback |
4600 | (@option{-fprofile-arcs}) or @samp{__builtin_expect}. This means that | |
4601 | different runs of the compiler on the same program may produce different | |
4602 | object code. | |
4603 | ||
4604 | In a hard real-time system, people don't want different runs of the | |
4605 | compiler to produce code that has different behavior; minimizing | |
4606 | non-determinism is of paramount import. This switch allows users to | |
4607 | reduce non-determinism, possibly at the expense of inferior | |
4608 | optimization. | |
454d0cc7 | 4609 | |
38df970e JQ |
4610 | The default is @option{-fguess-branch-probability} at levels |
4611 | @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
4612 | ||
194734e9 JH |
4613 | @item -freorder-blocks |
4614 | @opindex freorder-blocks | |
4615 | Reorder basic blocks in the compiled function in order to reduce number of | |
4616 | taken branches and improve code locality. | |
4617 | ||
3f8b659d | 4618 | Enabled at levels @option{-O2}, @option{-O3}. |
38df970e | 4619 | |
750054a2 CT |
4620 | @item -freorder-blocks-and-partition |
4621 | @opindex freorder-blocks-and-partition | |
4622 | In addition to reordering basic blocks in the compiled function, in order | |
4623 | to reduce number of taken branches, partitions hot and cold basic blocks | |
4624 | into separate sections of the assembly and .o files, to improve | |
4625 | paging and cache locality performance. | |
4626 | ||
8e8d5162 CT |
4627 | This optimization is automatically turned off in the presence of |
4628 | exception handling, for linkonce sections, for functions with a user-defined | |
4629 | section attribute and on any architecture that does not support named | |
4630 | sections. | |
4631 | ||
194734e9 JH |
4632 | @item -freorder-functions |
4633 | @opindex freorder-functions | |
4634 | Reorder basic blocks in the compiled function in order to reduce number of | |
4635 | taken branches and improve code locality. This is implemented by using special | |
3a4bdd05 RH |
4636 | subsections @code{.text.hot} for most frequently executed functions and |
4637 | @code{.text.unlikely} for unlikely executed functions. Reordering is done by | |
194734e9 | 4638 | the linker so object file format must support named sections and linker must |
3364c33b | 4639 | place them in a reasonable way. |
194734e9 JH |
4640 | |
4641 | Also profile feedback must be available in to make this option effective. See | |
4642 | @option{-fprofile-arcs} for details. | |
4643 | ||
38df970e JQ |
4644 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
4645 | ||
41472af8 | 4646 | @item -fstrict-aliasing |
cd3bb277 | 4647 | @opindex fstrict-aliasing |
41472af8 MM |
4648 | Allows the compiler to assume the strictest aliasing rules applicable to |
4649 | the language being compiled. For C (and C++), this activates | |
4650 | optimizations based on the type of expressions. In particular, an | |
4651 | object of one type is assumed never to reside at the same address as an | |
4652 | object of a different type, unless the types are almost the same. For | |
4653 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
4654 | @code{void*} or a @code{double}. A character type may alias any other | |
02f52e19 | 4655 | type. |
41472af8 MM |
4656 | |
4657 | Pay special attention to code like this: | |
3ab51846 | 4658 | @smallexample |
02f52e19 | 4659 | union a_union @{ |
41472af8 MM |
4660 | int i; |
4661 | double d; | |
4662 | @}; | |
4663 | ||
4664 | int f() @{ | |
4665 | a_union t; | |
4666 | t.d = 3.0; | |
4667 | return t.i; | |
4668 | @} | |
3ab51846 | 4669 | @end smallexample |
41472af8 MM |
4670 | The practice of reading from a different union member than the one most |
4671 | recently written to (called ``type-punning'') is common. Even with | |
630d3d5a | 4672 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory |
41472af8 MM |
4673 | is accessed through the union type. So, the code above will work as |
4674 | expected. However, this code might not: | |
3ab51846 | 4675 | @smallexample |
02f52e19 | 4676 | int f() @{ |
41472af8 MM |
4677 | a_union t; |
4678 | int* ip; | |
4679 | t.d = 3.0; | |
4680 | ip = &t.i; | |
4681 | return *ip; | |
4682 | @} | |
3ab51846 | 4683 | @end smallexample |
41472af8 | 4684 | |
41472af8 MM |
4685 | Every language that wishes to perform language-specific alias analysis |
4686 | should define a function that computes, given an @code{tree} | |
4687 | node, an alias set for the node. Nodes in different alias sets are not | |
4688 | allowed to alias. For an example, see the C front-end function | |
4689 | @code{c_get_alias_set}. | |
41472af8 | 4690 | |
38df970e | 4691 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. |
852b81bb | 4692 | |
efa3896a GK |
4693 | @item -falign-functions |
4694 | @itemx -falign-functions=@var{n} | |
cd3bb277 | 4695 | @opindex falign-functions |
efa3896a GK |
4696 | Align the start of functions to the next power-of-two greater than |
4697 | @var{n}, skipping up to @var{n} bytes. For instance, | |
630d3d5a JM |
4698 | @option{-falign-functions=32} aligns functions to the next 32-byte |
4699 | boundary, but @option{-falign-functions=24} would align to the next | |
efa3896a GK |
4700 | 32-byte boundary only if this can be done by skipping 23 bytes or less. |
4701 | ||
630d3d5a | 4702 | @option{-fno-align-functions} and @option{-falign-functions=1} are |
efa3896a GK |
4703 | equivalent and mean that functions will not be aligned. |
4704 | ||
4705 | Some assemblers only support this flag when @var{n} is a power of two; | |
4706 | in that case, it is rounded up. | |
4707 | ||
561913cb | 4708 | If @var{n} is not specified or is zero, use a machine-dependent default. |
efa3896a | 4709 | |
38df970e JQ |
4710 | Enabled at levels @option{-O2}, @option{-O3}. |
4711 | ||
efa3896a GK |
4712 | @item -falign-labels |
4713 | @itemx -falign-labels=@var{n} | |
cd3bb277 | 4714 | @opindex falign-labels |
efa3896a | 4715 | Align all branch targets to a power-of-two boundary, skipping up to |
630d3d5a | 4716 | @var{n} bytes like @option{-falign-functions}. This option can easily |
efa3896a GK |
4717 | make code slower, because it must insert dummy operations for when the |
4718 | branch target is reached in the usual flow of the code. | |
4719 | ||
561913cb AP |
4720 | @option{-fno-align-labels} and @option{-falign-labels=1} are |
4721 | equivalent and mean that labels will not be aligned. | |
4722 | ||
630d3d5a | 4723 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and |
efa3896a GK |
4724 | are greater than this value, then their values are used instead. |
4725 | ||
561913cb AP |
4726 | If @var{n} is not specified or is zero, use a machine-dependent default |
4727 | which is very likely to be @samp{1}, meaning no alignment. | |
efa3896a | 4728 | |
38df970e JQ |
4729 | Enabled at levels @option{-O2}, @option{-O3}. |
4730 | ||
efa3896a GK |
4731 | @item -falign-loops |
4732 | @itemx -falign-loops=@var{n} | |
cd3bb277 | 4733 | @opindex falign-loops |
efa3896a | 4734 | Align loops to a power-of-two boundary, skipping up to @var{n} bytes |
630d3d5a | 4735 | like @option{-falign-functions}. The hope is that the loop will be |
efa3896a GK |
4736 | executed many times, which will make up for any execution of the dummy |
4737 | operations. | |
4738 | ||
561913cb AP |
4739 | @option{-fno-align-loops} and @option{-falign-loops=1} are |
4740 | equivalent and mean that loops will not be aligned. | |
4741 | ||
4742 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
efa3896a | 4743 | |
38df970e JQ |
4744 | Enabled at levels @option{-O2}, @option{-O3}. |
4745 | ||
efa3896a GK |
4746 | @item -falign-jumps |
4747 | @itemx -falign-jumps=@var{n} | |
cd3bb277 | 4748 | @opindex falign-jumps |
efa3896a GK |
4749 | Align branch targets to a power-of-two boundary, for branch targets |
4750 | where the targets can only be reached by jumping, skipping up to @var{n} | |
630d3d5a | 4751 | bytes like @option{-falign-functions}. In this case, no dummy operations |
efa3896a GK |
4752 | need be executed. |
4753 | ||
561913cb AP |
4754 | @option{-fno-align-jumps} and @option{-falign-jumps=1} are |
4755 | equivalent and mean that loops will not be aligned. | |
4756 | ||
4757 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
efa3896a | 4758 | |
38df970e JQ |
4759 | Enabled at levels @option{-O2}, @option{-O3}. |
4760 | ||
7797ff53 PB |
4761 | @item -funit-at-a-time |
4762 | @opindex funit-at-a-time | |
4763 | Parse the whole compilation unit before starting to produce code. | |
4764 | This allows some extra optimizations to take place but consumes | |
4765 | more memory (in general). There are some compatibility issues | |
4766 | with @emph{unit-at-at-time} mode: | |
4767 | @itemize @bullet | |
4768 | @item | |
4769 | enabling @emph{unit-at-a-time} mode may change the order | |
4770 | in which functions, variables, and top-level @code{asm} statements | |
4771 | are emitted, and will likely break code relying on some particular | |
4772 | ordering. The majority of such top-level @code{asm} statements, | |
4773 | though, can be replaced by @code{section} attributes. | |
4774 | ||
4775 | @item | |
4776 | @emph{unit-at-a-time} mode removes unreferenced static variables | |
4777 | and functions are removed. This may result in undefined references | |
4778 | when an @code{asm} statement refers directly to variables or functions | |
4779 | that are otherwise unused. In that case either the variable/function | |
4780 | shall be listed as an operand of the @code{asm} statement operand or, | |
4781 | in the case of top-level @code{asm} statements the attribute @code{used} | |
4782 | shall be used on the declaration. | |
4783 | ||
4784 | @item | |
4785 | Static functions now can use non-standard passing conventions that | |
4786 | may break @code{asm} statements calling functions directly. Again, | |
4787 | attribute @code{used} will prevent this behavior. | |
4788 | @end itemize | |
4789 | ||
4790 | As a temporary workaround, @option{-fno-unit-at-a-time} can be used, | |
f26c1794 | 4791 | but this scheme may not be supported by future releases of GCC. |
7797ff53 PB |
4792 | |
4793 | Enabled at levels @option{-O2}, @option{-O3}. | |
4794 | ||
7260e9a0 JH |
4795 | @item -fweb |
4796 | @opindex fweb | |
4797 | Constructs webs as commonly used for register allocation purposes and assign | |
962e6e00 | 4798 | each web individual pseudo register. This allows the register allocation pass |
7260e9a0 JH |
4799 | to operate on pseudos directly, but also strengthens several other optimization |
4800 | passes, such as CSE, loop optimizer and trivial dead code remover. It can, | |
4801 | however, make debugging impossible, since variables will no longer stay in a | |
4802 | ``home register''. | |
4803 | ||
38d396e5 PB |
4804 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, |
4805 | on targets where the default format for debugging information supports | |
4806 | variable tracking. | |
d4463dfc JQ |
4807 | |
4808 | @item -fno-cprop-registers | |
4809 | @opindex fno-cprop-registers | |
4810 | After register allocation and post-register allocation instruction splitting, | |
4811 | we perform a copy-propagation pass to try to reduce scheduling dependencies | |
4812 | and occasionally eliminate the copy. | |
4813 | ||
4814 | Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
4815 | ||
a8a5f53a JH |
4816 | @item -fprofile-generate |
4817 | @opindex fprofile-generate | |
a8a5f53a | 4818 | |
33adcb6c MM |
4819 | Enable options usually used for instrumenting application to produce |
4820 | profile useful for later recompilation with profile feedback based | |
4821 | optimization. You must use @code{-fprofile-generate} both when | |
4822 | compiling and when linking your program. | |
4823 | ||
4824 | The following options are enabled: @code{-fprofile-arcs}, @code{-fprofile-values}, @code{-fvpt}. | |
a8a5f53a JH |
4825 | |
4826 | @item -fprofile-use | |
4827 | @opindex fprofile-use | |
4828 | Enable profile feedback directed optimizations, and optimizations | |
4829 | generally profitable only with profile feedback available. | |
4830 | ||
4831 | The following options are enabled: @code{-fbranch-probabilities}, | |
4832 | @code{-fvpt}, @code{-funroll-loops}, @code{-fpeel-loops}, @code{-ftracer}. | |
4833 | ||
d4463dfc JQ |
4834 | @end table |
4835 | ||
4836 | The following options control compiler behavior regarding floating | |
4837 | point arithmetic. These options trade off between speed and | |
4838 | correctness. All must be specifically enabled. | |
4839 | ||
4840 | @table @gcctabopt | |
4841 | @item -ffloat-store | |
4842 | @opindex ffloat-store | |
4843 | Do not store floating point variables in registers, and inhibit other | |
4844 | options that might change whether a floating point value is taken from a | |
4845 | register or memory. | |
4846 | ||
4847 | @cindex floating point precision | |
4848 | This option prevents undesirable excess precision on machines such as | |
4849 | the 68000 where the floating registers (of the 68881) keep more | |
4850 | precision than a @code{double} is supposed to have. Similarly for the | |
4851 | x86 architecture. For most programs, the excess precision does only | |
4852 | good, but a few programs rely on the precise definition of IEEE floating | |
4853 | point. Use @option{-ffloat-store} for such programs, after modifying | |
4854 | them to store all pertinent intermediate computations into variables. | |
4855 | ||
4856 | @item -ffast-math | |
4857 | @opindex ffast-math | |
4858 | Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @* | |
039c3d42 RS |
4859 | @option{-fno-trapping-math}, @option{-ffinite-math-only}, |
4860 | @option{-fno-rounding-math} and @option{-fno-signaling-nans}. | |
d4463dfc JQ |
4861 | |
4862 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. | |
4863 | ||
4864 | This option should never be turned on by any @option{-O} option since | |
4865 | it can result in incorrect output for programs which depend on | |
4866 | an exact implementation of IEEE or ISO rules/specifications for | |
4867 | math functions. | |
4868 | ||
4869 | @item -fno-math-errno | |
4870 | @opindex fno-math-errno | |
4871 | Do not set ERRNO after calling math functions that are executed | |
4872 | with a single instruction, e.g., sqrt. A program that relies on | |
4873 | IEEE exceptions for math error handling may want to use this flag | |
4874 | for speed while maintaining IEEE arithmetic compatibility. | |
4875 | ||
4876 | This option should never be turned on by any @option{-O} option since | |
4877 | it can result in incorrect output for programs which depend on | |
4878 | an exact implementation of IEEE or ISO rules/specifications for | |
4879 | math functions. | |
4880 | ||
4881 | The default is @option{-fmath-errno}. | |
4882 | ||
4883 | @item -funsafe-math-optimizations | |
4884 | @opindex funsafe-math-optimizations | |
4885 | Allow optimizations for floating-point arithmetic that (a) assume | |
4886 | that arguments and results are valid and (b) may violate IEEE or | |
4887 | ANSI standards. When used at link-time, it may include libraries | |
4888 | or startup files that change the default FPU control word or other | |
4889 | similar optimizations. | |
4890 | ||
4891 | This option should never be turned on by any @option{-O} option since | |
4892 | it can result in incorrect output for programs which depend on | |
4893 | an exact implementation of IEEE or ISO rules/specifications for | |
4894 | math functions. | |
4895 | ||
4896 | The default is @option{-fno-unsafe-math-optimizations}. | |
4897 | ||
4898 | @item -ffinite-math-only | |
4899 | @opindex ffinite-math-only | |
4900 | Allow optimizations for floating-point arithmetic that assume | |
4901 | that arguments and results are not NaNs or +-Infs. | |
4902 | ||
4903 | This option should never be turned on by any @option{-O} option since | |
4904 | it can result in incorrect output for programs which depend on | |
4905 | an exact implementation of IEEE or ISO rules/specifications. | |
4906 | ||
4907 | The default is @option{-fno-finite-math-only}. | |
4908 | ||
4909 | @item -fno-trapping-math | |
4910 | @opindex fno-trapping-math | |
4911 | Compile code assuming that floating-point operations cannot generate | |
4912 | user-visible traps. These traps include division by zero, overflow, | |
4913 | underflow, inexact result and invalid operation. This option implies | |
4914 | @option{-fno-signaling-nans}. Setting this option may allow faster | |
4915 | code if one relies on ``non-stop'' IEEE arithmetic, for example. | |
4916 | ||
4917 | This option should never be turned on by any @option{-O} option since | |
4918 | it can result in incorrect output for programs which depend on | |
4919 | an exact implementation of IEEE or ISO rules/specifications for | |
4920 | math functions. | |
4921 | ||
4922 | The default is @option{-ftrapping-math}. | |
4923 | ||
039c3d42 RS |
4924 | @item -frounding-math |
4925 | @opindex frounding-math | |
4926 | Disable transformations and optimizations that assume default floating | |
4927 | point rounding behavior. This is round-to-zero for all floating point | |
4928 | to integer conversions, and round-to-nearest for all other arithmetic | |
4929 | truncations. This option should be specified for programs that change | |
4930 | the FP rounding mode dynamically, or that may be executed with a | |
4931 | non-default rounding mode. This option disables constant folding of | |
4932 | floating point expressions at compile-time (which may be affected by | |
4933 | rounding mode) and arithmetic transformations that are unsafe in the | |
4934 | presence of sign-dependent rounding modes. | |
4935 | ||
4936 | The default is @option{-fno-rounding-math}. | |
4937 | ||
4938 | This option is experimental and does not currently guarantee to | |
4939 | disable all GCC optimizations that are affected by rounding mode. | |
2dd76960 | 4940 | Future versions of GCC may provide finer control of this setting |
039c3d42 RS |
4941 | using C99's @code{FENV_ACCESS} pragma. This command line option |
4942 | will be used to specify the default state for @code{FENV_ACCESS}. | |
4943 | ||
d4463dfc JQ |
4944 | @item -fsignaling-nans |
4945 | @opindex fsignaling-nans | |
4946 | Compile code assuming that IEEE signaling NaNs may generate user-visible | |
4947 | traps during floating-point operations. Setting this option disables | |
4948 | optimizations that may change the number of exceptions visible with | |
4949 | signaling NaNs. This option implies @option{-ftrapping-math}. | |
4950 | ||
4951 | This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to | |
4952 | be defined. | |
4953 | ||
4954 | The default is @option{-fno-signaling-nans}. | |
4955 | ||
4956 | This option is experimental and does not currently guarantee to | |
4957 | disable all GCC optimizations that affect signaling NaN behavior. | |
4958 | ||
4959 | @item -fsingle-precision-constant | |
4960 | @opindex fsingle-precision-constant | |
4961 | Treat floating point constant as single precision constant instead of | |
4962 | implicitly converting it to double precision constant. | |
4963 | ||
4964 | ||
4965 | @end table | |
4966 | ||
4967 | The following options control optimizations that may improve | |
4968 | performance, but are not enabled by any @option{-O} options. This | |
4969 | section includes experimental options that may produce broken code. | |
4970 | ||
4971 | @table @gcctabopt | |
4972 | @item -fbranch-probabilities | |
4973 | @opindex fbranch-probabilities | |
4974 | After running a program compiled with @option{-fprofile-arcs} | |
4975 | (@pxref{Debugging Options,, Options for Debugging Your Program or | |
4976 | @command{gcc}}), you can compile it a second time using | |
4977 | @option{-fbranch-probabilities}, to improve optimizations based on | |
4978 | the number of times each branch was taken. When the program | |
4979 | compiled with @option{-fprofile-arcs} exits it saves arc execution | |
a4878735 | 4980 | counts to a file called @file{@var{sourcename}.gcda} for each source |
d4463dfc JQ |
4981 | file The information in this data file is very dependent on the |
4982 | structure of the generated code, so you must use the same source code | |
4983 | and the same optimization options for both compilations. | |
4984 | ||
daf2f129 | 4985 | With @option{-fbranch-probabilities}, GCC puts a |
d4463dfc JQ |
4986 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. |
4987 | These can be used to improve optimization. Currently, they are only | |
4988 | used in one place: in @file{reorg.c}, instead of guessing which path a | |
4989 | branch is mostly to take, the @samp{REG_BR_PROB} values are used to | |
4990 | exactly determine which path is taken more often. | |
4991 | ||
fc5eb4a1 ZD |
4992 | @item -fprofile-values |
4993 | @opindex fprofile-values | |
4994 | If combined with @option{-fprofile-arcs}, it adds code so that some | |
4995 | data about values of expressions in the program is gathered. | |
4996 | ||
6e885ee3 ZD |
4997 | With @option{-fbranch-probabilities}, it reads back the data gathered |
4998 | from profiling values of expressions and adds @samp{REG_VALUE_PROFILE} | |
4999 | notes to instructions for their later usage in optimizations. | |
5000 | ||
7797ff53 | 5001 | Enabled with @option{-fprofile-generate} and @option{-fprofile-use}. |
8d3b3fb7 | 5002 | |
fca9dc00 ZD |
5003 | @item -fvpt |
5004 | @opindex fvpt | |
5005 | If combined with @option{-fprofile-arcs}, it instructs the compiler to add | |
5006 | a code to gather information about values of expressions. | |
5007 | ||
5008 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
5009 | and actually performs the optimizations based on them. | |
5010 | Currently the optimizations include specialization of division operation | |
5011 | using the knowledge about the value of the denominator. | |
5012 | ||
7797ff53 | 5013 | Enabled with @option{-fprofile-generate} and @option{-fprofile-use}. |
8d3b3fb7 | 5014 | |
a7b1dc36 PB |
5015 | @item -frename-registers |
5016 | @opindex frename-registers | |
5017 | Attempt to avoid false dependencies in scheduled code by making use | |
5018 | of registers left over after register allocation. This optimization | |
5019 | will most benefit processors with lots of registers. Depending on the | |
5020 | debug information format adopted by the target, however, it can | |
5021 | make debugging impossible, since variables will no longer stay in | |
5022 | a ``home register''. | |
5023 | ||
5024 | Not enabled by default at any level because it has known bugs. | |
5025 | ||
d4463dfc JQ |
5026 | @item -fnew-ra |
5027 | @opindex fnew-ra | |
5028 | Use a graph coloring register allocator. Currently this option is meant | |
5029 | for testing, so we are interested to hear about miscompilations with | |
5030 | @option{-fnew-ra}. | |
5031 | ||
5032 | @item -ftracer | |
5033 | @opindex ftracer | |
5034 | Perform tail duplication to enlarge superblock size. This transformation | |
5035 | simplifies the control flow of the function allowing other optimizations to do | |
5036 | better job. | |
5037 | ||
7797ff53 | 5038 | Enabled with @option{-fprofile-use}. |
8d3b3fb7 | 5039 | |
d4463dfc JQ |
5040 | @item -funroll-loops |
5041 | @opindex funroll-loops | |
b17d5d7c ZD |
5042 | Unroll loops whose number of iterations can be determined at compile time or |
5043 | upon entry to the loop. @option{-funroll-loops} implies | |
5044 | @option{-frerun-cse-after-loop}. It also turns on complete loop peeling | |
5045 | (i.e. complete removal of loops with small constant number of iterations). | |
5046 | This option makes code larger, and may or may not make it run faster. | |
d4463dfc | 5047 | |
7797ff53 | 5048 | Enabled with @option{-fprofile-use}. |
8d3b3fb7 | 5049 | |
d4463dfc JQ |
5050 | @item -funroll-all-loops |
5051 | @opindex funroll-all-loops | |
5052 | Unroll all loops, even if their number of iterations is uncertain when | |
5053 | the loop is entered. This usually makes programs run more slowly. | |
5054 | @option{-funroll-all-loops} implies the same options as | |
b17d5d7c ZD |
5055 | @option{-funroll-loops}. |
5056 | ||
5057 | @item -fpeel-loops | |
5058 | @opindex fpeel-loops | |
5059 | Peels the loops for that there is enough information that they do not | |
5060 | roll much (from profile feedback). It also turns on complete loop peeling | |
5061 | (i.e. complete removal of loops with small constant number of iterations). | |
5062 | ||
7797ff53 | 5063 | Enabled with @option{-fprofile-use}. |
8d3b3fb7 | 5064 | |
5e962776 ZD |
5065 | @item -fmove-loop-invariants |
5066 | @opindex fmove-loop-invariants | |
5067 | Enables the loop invariant motion pass in the new loop optimizer. Enabled | |
5068 | at level @option{-O1} | |
5069 | ||
b17d5d7c ZD |
5070 | @item -funswitch-loops |
5071 | @opindex funswitch-loops | |
5072 | Move branches with loop invariant conditions out of the loop, with duplicates | |
5073 | of the loop on both branches (modified according to result of the condition). | |
5074 | ||
5075 | @item -fold-unroll-loops | |
5076 | @opindex fold-unroll-loops | |
5077 | Unroll loops whose number of iterations can be determined at compile | |
5078 | time or upon entry to the loop, using the old loop unroller whose loop | |
5079 | recognition is based on notes from frontend. @option{-fold-unroll-loops} implies | |
5080 | both @option{-fstrength-reduce} and @option{-frerun-cse-after-loop}. This | |
5081 | option makes code larger, and may or may not make it run faster. | |
5082 | ||
5083 | @item -fold-unroll-all-loops | |
5084 | @opindex fold-unroll-all-loops | |
5085 | Unroll all loops, even if their number of iterations is uncertain when | |
5086 | the loop is entered. This is done using the old loop unroller whose loop | |
5087 | recognition is based on notes from frontend. This usually makes programs run more slowly. | |
5088 | @option{-fold-unroll-all-loops} implies the same options as | |
5089 | @option{-fold-unroll-loops}. | |
daf2f129 | 5090 | |
d4463dfc JQ |
5091 | @item -fprefetch-loop-arrays |
5092 | @opindex fprefetch-loop-arrays | |
5093 | If supported by the target machine, generate instructions to prefetch | |
5094 | memory to improve the performance of loops that access large arrays. | |
5095 | ||
5096 | Disabled at level @option{-Os}. | |
5097 | ||
5098 | @item -ffunction-sections | |
5099 | @itemx -fdata-sections | |
5100 | @opindex ffunction-sections | |
5101 | @opindex fdata-sections | |
5102 | Place each function or data item into its own section in the output | |
5103 | file if the target supports arbitrary sections. The name of the | |
5104 | function or the name of the data item determines the section's name | |
5105 | in the output file. | |
5106 | ||
5107 | Use these options on systems where the linker can perform optimizations | |
f401d0f5 JDA |
5108 | to improve locality of reference in the instruction space. Most systems |
5109 | using the ELF object format and SPARC processors running Solaris 2 have | |
5110 | linkers with such optimizations. AIX may have these optimizations in | |
5111 | the future. | |
d4463dfc JQ |
5112 | |
5113 | Only use these options when there are significant benefits from doing | |
5114 | so. When you specify these options, the assembler and linker will | |
5115 | create larger object and executable files and will also be slower. | |
5116 | You will not be able to use @code{gprof} on all systems if you | |
5117 | specify this option and you may have problems with debugging if | |
5118 | you specify both this option and @option{-g}. | |
5119 | ||
fe3ad572 SC |
5120 | @item -fbranch-target-load-optimize |
5121 | @opindex fbranch-target-load-optimize | |
5122 | Perform branch target register load optimization before prologue / epilogue | |
5123 | threading. | |
5124 | The use of target registers can typically be exposed only during reload, | |
5125 | thus hoisting loads out of loops and doing inter-block scheduling needs | |
5126 | a separate optimization pass. | |
5127 | ||
5128 | @item -fbranch-target-load-optimize2 | |
5129 | @opindex fbranch-target-load-optimize2 | |
5130 | Perform branch target register load optimization after prologue / epilogue | |
5131 | threading. | |
5132 | ||
1194fc79 R |
5133 | @item -fbtr-bb-exclusive |
5134 | @opindex fbtr-bb-exclusive | |
8d3b3fb7 | 5135 | When performing branch target register load optimization, don't reuse |
1194fc79 R |
5136 | branch target registers in within any basic block. |
5137 | ||
3af64fd6 | 5138 | @item --param @var{name}=@var{value} |
cd3bb277 | 5139 | @opindex param |
3af64fd6 MM |
5140 | In some places, GCC uses various constants to control the amount of |
5141 | optimization that is done. For example, GCC will not inline functions | |
5142 | that contain more that a certain number of instructions. You can | |
5143 | control some of these constants on the command-line using the | |
630d3d5a | 5144 | @option{--param} option. |
3af64fd6 | 5145 | |
b00567b0 ILT |
5146 | The names of specific parameters, and the meaning of the values, are |
5147 | tied to the internals of the compiler, and are subject to change | |
5148 | without notice in future releases. | |
5149 | ||
4fe9b91c | 5150 | In each case, the @var{value} is an integer. The allowable choices for |
3af64fd6 MM |
5151 | @var{name} are given in the following table: |
5152 | ||
5153 | @table @gcctabopt | |
5f24e0dc RH |
5154 | @item max-crossjump-edges |
5155 | The maximum number of incoming edges to consider for crossjumping. | |
d203738b | 5156 | The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in |
5f24e0dc RH |
5157 | the number of edges incoming to each block. Increasing values mean |
5158 | more aggressive optimization, making the compile time increase with | |
5159 | probably small improvement in executable size. | |
5160 | ||
12183e0f PH |
5161 | @item min-crossjump-insns |
5162 | The minimum number of instructions which must be matched at the end | |
5163 | of two blocks before crossjumping will be performed on them. This | |
5164 | value is ignored in the case where all instructions in the block being | |
5165 | crossjumped from are matched. The default value is 5. | |
5166 | ||
1c4c47db JO |
5167 | @item max-delay-slot-insn-search |
5168 | The maximum number of instructions to consider when looking for an | |
5169 | instruction to fill a delay slot. If more than this arbitrary number of | |
5170 | instructions is searched, the time savings from filling the delay slot | |
5171 | will be minimal so stop searching. Increasing values mean more | |
5172 | aggressive optimization, making the compile time increase with probably | |
5173 | small improvement in executable run time. | |
5174 | ||
5175 | @item max-delay-slot-live-search | |
5176 | When trying to fill delay slots, the maximum number of instructions to | |
5177 | consider when searching for a block with valid live register | |
5178 | information. Increasing this arbitrarily chosen value means more | |
5179 | aggressive optimization, increasing the compile time. This parameter | |
5180 | should be removed when the delay slot code is rewritten to maintain the | |
5181 | control-flow graph. | |
33d3b05b MM |
5182 | |
5183 | @item max-gcse-memory | |
5184 | The approximate maximum amount of memory that will be allocated in | |
5185 | order to perform the global common subexpression elimination | |
5186 | optimization. If more memory than specified is required, the | |
5187 | optimization will not be done. | |
3af64fd6 | 5188 | |
740f35a0 | 5189 | @item max-gcse-passes |
8d3b3fb7 | 5190 | The maximum number of passes of GCSE to run. The default is 1. |
740f35a0 | 5191 | |
4a121cc3 | 5192 | @item max-pending-list-length |
0c688a7d | 5193 | The maximum number of pending dependencies scheduling will allow |
4a121cc3 AM |
5194 | before flushing the current state and starting over. Large functions |
5195 | with few branches or calls can create excessively large lists which | |
5196 | needlessly consume memory and resources. | |
5197 | ||
bc522472 KG |
5198 | @item max-inline-insns-single |
5199 | Several parameters control the tree inliner used in gcc. | |
2dd76960 | 5200 | This number sets the maximum number of instructions (counted in GCC's |
daf2f129 | 5201 | internal representation) in a single function that the tree inliner |
bc522472 KG |
5202 | will consider for inlining. This only affects functions declared |
5203 | inline and methods implemented in a class declaration (C++). | |
1f95c733 | 5204 | The default value is 500. |
bc522472 KG |
5205 | |
5206 | @item max-inline-insns-auto | |
5207 | When you use @option{-finline-functions} (included in @option{-O3}), | |
5208 | a lot of functions that would otherwise not be considered for inlining | |
5209 | by the compiler will be investigated. To those functions, a different | |
5210 | (more restrictive) limit compared to functions declared inline can | |
5211 | be applied. | |
3b75d796 | 5212 | The default value is 120. |
bc522472 | 5213 | |
b58b1157 JH |
5214 | @item large-function-insns |
5215 | The limit specifying really large functions. For functions greater than this | |
5216 | limit inlining is constrained by @option{--param large-function-growth}. | |
a2b172fb | 5217 | This parameter is useful primarily to avoid extreme compilation time caused by non-linear |
b58b1157 JH |
5218 | algorithms used by the backend. |
5219 | This parameter is ignored when @option{-funit-at-a-time} is not used. | |
3b75d796 | 5220 | The default value is 3000. |
b58b1157 JH |
5221 | |
5222 | @item large-function-growth | |
e53e0c56 | 5223 | Specifies maximal growth of large function caused by inlining in percents. |
b58b1157 JH |
5224 | This parameter is ignored when @option{-funit-at-a-time} is not used. |
5225 | The default value is 200. | |
5226 | ||
5227 | @item inline-unit-growth | |
5228 | Specifies maximal overall growth of the compilation unit caused by inlining. | |
5229 | This parameter is ignored when @option{-funit-at-a-time} is not used. | |
5230 | The default value is 150. | |
5231 | ||
6de9cd9a DN |
5232 | @item max-inline-insns-recursive |
5233 | @itemx max-inline-insns-recursive-auto | |
5234 | Specifies maximum number of instructions out-of-line copy of self recursive inline | |
5235 | function can grow into by performing recursive inlining. | |
5236 | ||
5237 | For functions declared inline @option{--param max-inline-insns-recursive} is | |
5238 | taken into acount. For function not declared inline, recursive inlining | |
5239 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
5240 | enabled and @option{--param max-inline-insns-recursive-auto} is used. The | |
5241 | default value is 500. | |
5242 | ||
5243 | @item max-inline-recursive-depth | |
5244 | @itemx max-inline-recursive-depth-auto | |
5245 | Specifies maximum recursion depth used by the recursive inlining. | |
5246 | ||
5247 | For functions declared inline @option{--param max-inline-recursive-depth} is | |
5248 | taken into acount. For function not declared inline, recursive inlining | |
5249 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
5250 | enabled and @option{--param max-inline-recursive-depth-auto} is used. The | |
5251 | default value is 500. | |
5252 | ||
bc522472 KG |
5253 | @item max-inline-insns-rtl |
5254 | For languages that use the RTL inliner (this happens at a later stage | |
daf2f129 | 5255 | than tree inlining), you can set the maximum allowable size (counted |
bc522472 KG |
5256 | in RTL instructions) for the RTL inliner with this parameter. |
5257 | The default value is 600. | |
5258 | ||
03e9dbc9 MM |
5259 | @item max-unrolled-insns |
5260 | The maximum number of instructions that a loop should have if that loop | |
5261 | is unrolled, and if the loop is unrolled, it determines how many times | |
5262 | the loop code is unrolled. | |
5263 | ||
b17d5d7c ZD |
5264 | @item max-average-unrolled-insns |
5265 | The maximum number of instructions biased by probabilities of their execution | |
5266 | that a loop should have if that loop is unrolled, and if the loop is unrolled, | |
5267 | it determines how many times the loop code is unrolled. | |
5268 | ||
5269 | @item max-unroll-times | |
5270 | The maximum number of unrollings of a single loop. | |
5271 | ||
5272 | @item max-peeled-insns | |
5273 | The maximum number of instructions that a loop should have if that loop | |
5274 | is peeled, and if the loop is peeled, it determines how many times | |
5275 | the loop code is peeled. | |
5276 | ||
5277 | @item max-peel-times | |
5278 | The maximum number of peelings of a single loop. | |
5279 | ||
5280 | @item max-completely-peeled-insns | |
5281 | The maximum number of insns of a completely peeled loop. | |
5282 | ||
5283 | @item max-completely-peel-times | |
5284 | The maximum number of iterations of a loop to be suitable for complete peeling. | |
5285 | ||
01a132bb ZD |
5286 | @item max-unswitch-insns |
5287 | The maximum number of insns of an unswitched loop. | |
5288 | ||
5289 | @item max-unswitch-level | |
5290 | The maximum number of branches unswitched in a single loop. | |
5291 | ||
a7e5372d ZD |
5292 | @item lim-expensive |
5293 | The minimum cost of an expensive expression in the loop invariant motion. | |
5294 | ||
e9eb809d ZD |
5295 | @item max-iterations-to-track |
5296 | ||
5297 | The maximum number of iterations of a loop the brute force algorithm | |
5298 | for analysis of # of iterations of the loop tries to evaluate. | |
5299 | ||
194734e9 JH |
5300 | @item hot-bb-count-fraction |
5301 | Select fraction of the maximal count of repetitions of basic block in program | |
5302 | given basic block needs to have to be considered hot. | |
5303 | ||
5304 | @item hot-bb-frequency-fraction | |
5305 | Select fraction of the maximal frequency of executions of basic block in | |
5306 | function given basic block needs to have to be considered hot | |
5c856b23 JH |
5307 | |
5308 | @item tracer-dynamic-coverage | |
5309 | @itemx tracer-dynamic-coverage-feedback | |
5310 | ||
3364c33b JQ |
5311 | This value is used to limit superblock formation once the given percentage of |
5312 | executed instructions is covered. This limits unnecessary code size | |
5313 | expansion. | |
5c856b23 JH |
5314 | |
5315 | The @option{tracer-dynamic-coverage-feedback} is used only when profile | |
5316 | feedback is available. The real profiles (as opposed to statically estimated | |
5317 | ones) are much less balanced allowing the threshold to be larger value. | |
5318 | ||
5319 | @item tracer-max-code-growth | |
5320 | Stop tail duplication once code growth has reached given percentage. This is | |
3364c33b | 5321 | rather hokey argument, as most of the duplicates will be eliminated later in |
5c856b23 JH |
5322 | cross jumping, so it may be set to much higher values than is the desired code |
5323 | growth. | |
5324 | ||
5325 | @item tracer-min-branch-ratio | |
5326 | ||
5327 | Stop reverse growth when the reverse probability of best edge is less than this | |
5328 | threshold (in percent). | |
5329 | ||
5330 | @item tracer-min-branch-ratio | |
5331 | @itemx tracer-min-branch-ratio-feedback | |
5332 | ||
5333 | Stop forward growth if the best edge do have probability lower than this | |
5334 | threshold. | |
5335 | ||
3364c33b | 5336 | Similarly to @option{tracer-dynamic-coverage} two values are present, one for |
5c856b23 JH |
5337 | compilation for profile feedback and one for compilation without. The value |
5338 | for compilation with profile feedback needs to be more conservative (higher) in | |
5339 | order to make tracer effective. | |
5340 | ||
c48ec590 ZD |
5341 | @item max-cse-path-length |
5342 | ||
8d3b3fb7 | 5343 | Maximum number of basic blocks on path that cse considers. The default is 10. |
c48ec590 | 5344 | |
6de9cd9a DN |
5345 | @item global-var-threshold |
5346 | ||
5347 | Counts the number of function calls (N) and the number of | |
5348 | call-clobbered variables (V). If NxV is larger than this limit, a | |
5349 | single artificial variable will be created to represent all the | |
5350 | call-clobbered variables at function call sites. This artificial | |
5351 | variable will then be made to alias every call-clobbered variable. | |
5352 | (done as int * size_t on the host machine; beware overflow). | |
5353 | ||
5354 | @item max-aliased-vops | |
5355 | ||
5356 | Maxiumum number of virtual operands allowed to represent aliases | |
5357 | before triggering the alias grouping heuristic. Alias grouping | |
5358 | reduces compile times and memory consumption needed for aliasing at | |
5359 | the expense of precision loss in alias information. | |
5360 | ||
3788cc17 ZW |
5361 | @item ggc-min-expand |
5362 | ||
5363 | GCC uses a garbage collector to manage its own memory allocation. This | |
5364 | parameter specifies the minimum percentage by which the garbage | |
5365 | collector's heap should be allowed to expand between collections. | |
5366 | Tuning this may improve compilation speed; it has no effect on code | |
5367 | generation. | |
5368 | ||
9ac121af | 5369 | The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when |
16226f1e | 5370 | RAM >= 1GB. If @code{getrlimit} is available, the notion of "RAM" is |
d37e6b50 | 5371 | the smallest of actual RAM and RLIMIT_DATA or RLIMIT_AS. If |
16226f1e KG |
5372 | GCC is not able to calculate RAM on a particular platform, the lower |
5373 | bound of 30% is used. Setting this parameter and | |
737c38d1 GK |
5374 | @option{ggc-min-heapsize} to zero causes a full collection to occur at |
5375 | every opportunity. This is extremely slow, but can be useful for | |
5376 | debugging. | |
3788cc17 ZW |
5377 | |
5378 | @item ggc-min-heapsize | |
5379 | ||
5380 | Minimum size of the garbage collector's heap before it begins bothering | |
5381 | to collect garbage. The first collection occurs after the heap expands | |
5382 | by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, | |
5383 | tuning this may improve compilation speed, and has no effect on code | |
5384 | generation. | |
5385 | ||
d37e6b50 GK |
5386 | The default is the smaller of RAM/8, RLIMIT_RSS, or a limit which |
5387 | tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but | |
5388 | with a lower bound of 4096 (four megabytes) and an upper bound of | |
5389 | 131072 (128 megabytes). If GCC is not able to calculate RAM on a | |
5390 | particular platform, the lower bound is used. Setting this parameter | |
5391 | very large effectively disables garbage collection. Setting this | |
5392 | parameter and @option{ggc-min-expand} to zero causes a full collection | |
5393 | to occur at every opportunity. | |
3788cc17 | 5394 | |
0bcf8261 JH |
5395 | @item max-reload-search-insns |
5396 | The maximum number of instruction reload should look backward for equivalent | |
5397 | register. Increasing values mean more aggressive optimization, making the | |
5398 | compile time increase with probably slightly better performance. The default | |
5399 | value is 100. | |
5400 | ||
c65ecebc JH |
5401 | @item max-cselib-memory-location |
5402 | The maximum number of memory locations cselib should take into acount. | |
5403 | Increasing values mean more aggressive optimization, making the compile time | |
5404 | increase with probably slightly better performance. The default value is 500. | |
5405 | ||
26f74aa3 JH |
5406 | @item reorder-blocks-duplicate |
5407 | @itemx reorder-blocks-duplicate-feedback | |
5408 | ||
65d2d764 | 5409 | Used by basic block reordering pass to decide whether to use unconditional |
b222f49a | 5410 | branch or duplicate the code on its destination. Code is duplicated when its |
26f74aa3 | 5411 | estimated size is smaller than this value multiplied by the estimated size of |
65d2d764 | 5412 | unconditional jump in the hot spots of the program. |
26f74aa3 JH |
5413 | |
5414 | The @option{reorder-block-duplicate-feedback} is used only when profile | |
5415 | feedback is available and may be set to higher values than | |
5416 | @option{reorder-block-duplicate} since information about the hot spots is more | |
5417 | accurate. | |
f72c6b56 DE |
5418 | |
5419 | @item max-sched-region-blocks | |
5420 | The maximum number of blocks in a region to be considered for | |
5421 | interblock scheduling. The default value is 10. | |
5422 | ||
fbce7685 | 5423 | @item max-sched-region-insns |
f72c6b56 DE |
5424 | The maximum number of insns in a region to be considered for |
5425 | interblock scheduling. The default value is 100. | |
31ebd7c8 NS |
5426 | |
5427 | @item integer-share-limit | |
5428 | Small integer constants can use a shared data structure, reducing the | |
5429 | compiler's memory usage and increasing its speed. This sets the maximum | |
5430 | value of a shared integer constant's. The default value is 256. | |
5431 | ||
1c4c47db | 5432 | @end table |
74291a4b MM |
5433 | @end table |
5434 | ||
5435 | @node Preprocessor Options | |
5436 | @section Options Controlling the Preprocessor | |
5437 | @cindex preprocessor options | |
5438 | @cindex options, preprocessor | |
5439 | ||
5440 | These options control the C preprocessor, which is run on each C source | |
5441 | file before actual compilation. | |
5442 | ||
630d3d5a JM |
5443 | If you use the @option{-E} option, nothing is done except preprocessing. |
5444 | Some of these options make sense only together with @option{-E} because | |
74291a4b MM |
5445 | they cause the preprocessor output to be unsuitable for actual |
5446 | compilation. | |
5447 | ||
4977bab6 | 5448 | @table @gcctabopt |
cd3bb277 | 5449 | @opindex Wp |
40adaa27 NB |
5450 | You can use @option{-Wp,@var{option}} to bypass the compiler driver |
5451 | and pass @var{option} directly through to the preprocessor. If | |
5452 | @var{option} contains commas, it is split into multiple options at the | |
5453 | commas. However, many options are modified, translated or interpreted | |
5454 | by the compiler driver before being passed to the preprocessor, and | |
5455 | @option{-Wp} forcibly bypasses this phase. The preprocessor's direct | |
5456 | interface is undocumented and subject to change, so whenever possible | |
5457 | you should avoid using @option{-Wp} and let the driver handle the | |
5458 | options instead. | |
5459 | ||
4977bab6 ZW |
5460 | @item -Xpreprocessor @var{option} |
5461 | @opindex preprocessor | |
5462 | Pass @var{option} as an option to the preprocessor. You can use this to | |
5463 | supply system-specific preprocessor options which GCC does not know how to | |
5464 | recognize. | |
5465 | ||
5466 | If you want to pass an option that takes an argument, you must use | |
5467 | @option{-Xpreprocessor} twice, once for the option and once for the argument. | |
5468 | @end table | |
5469 | ||
40adaa27 | 5470 | @include cppopts.texi |
74291a4b MM |
5471 | |
5472 | @node Assembler Options | |
5473 | @section Passing Options to the Assembler | |
5474 | ||
5475 | @c prevent bad page break with this line | |
5476 | You can pass options to the assembler. | |
5477 | ||
2642624b | 5478 | @table @gcctabopt |
aee96fe9 | 5479 | @item -Wa,@var{option} |
cd3bb277 | 5480 | @opindex Wa |
74291a4b MM |
5481 | Pass @var{option} as an option to the assembler. If @var{option} |
5482 | contains commas, it is split into multiple options at the commas. | |
4977bab6 ZW |
5483 | |
5484 | @item -Xassembler @var{option} | |
5485 | @opindex Xassembler | |
5486 | Pass @var{option} as an option to the assembler. You can use this to | |
5487 | supply system-specific assembler options which GCC does not know how to | |
5488 | recognize. | |
5489 | ||
5490 | If you want to pass an option that takes an argument, you must use | |
5491 | @option{-Xassembler} twice, once for the option and once for the argument. | |
5492 | ||
74291a4b MM |
5493 | @end table |
5494 | ||
5495 | @node Link Options | |
5496 | @section Options for Linking | |
5497 | @cindex link options | |
5498 | @cindex options, linking | |
5499 | ||
5500 | These options come into play when the compiler links object files into | |
5501 | an executable output file. They are meaningless if the compiler is | |
5502 | not doing a link step. | |
5503 | ||
2642624b | 5504 | @table @gcctabopt |
74291a4b MM |
5505 | @cindex file names |
5506 | @item @var{object-file-name} | |
5507 | A file name that does not end in a special recognized suffix is | |
5508 | considered to name an object file or library. (Object files are | |
5509 | distinguished from libraries by the linker according to the file | |
5510 | contents.) If linking is done, these object files are used as input | |
5511 | to the linker. | |
5512 | ||
5513 | @item -c | |
5514 | @itemx -S | |
5515 | @itemx -E | |
cd3bb277 JM |
5516 | @opindex c |
5517 | @opindex S | |
5518 | @opindex E | |
74291a4b MM |
5519 | If any of these options is used, then the linker is not run, and |
5520 | object file names should not be used as arguments. @xref{Overall | |
5521 | Options}. | |
5522 | ||
5523 | @cindex Libraries | |
5524 | @item -l@var{library} | |
4275c4c4 | 5525 | @itemx -l @var{library} |
cd3bb277 | 5526 | @opindex l |
4275c4c4 JS |
5527 | Search the library named @var{library} when linking. (The second |
5528 | alternative with the library as a separate argument is only for | |
5529 | POSIX compliance and is not recommended.) | |
74291a4b MM |
5530 | |
5531 | It makes a difference where in the command you write this option; the | |
4275c4c4 | 5532 | linker searches and processes libraries and object files in the order they |
74291a4b MM |
5533 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} |
5534 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
5535 | to functions in @samp{z}, those functions may not be loaded. | |
5536 | ||
5537 | The linker searches a standard list of directories for the library, | |
5538 | which is actually a file named @file{lib@var{library}.a}. The linker | |
5539 | then uses this file as if it had been specified precisely by name. | |
5540 | ||
5541 | The directories searched include several standard system directories | |
630d3d5a | 5542 | plus any that you specify with @option{-L}. |
74291a4b MM |
5543 | |
5544 | Normally the files found this way are library files---archive files | |
5545 | whose members are object files. The linker handles an archive file by | |
5546 | scanning through it for members which define symbols that have so far | |
5547 | been referenced but not defined. But if the file that is found is an | |
5548 | ordinary object file, it is linked in the usual fashion. The only | |
630d3d5a JM |
5549 | difference between using an @option{-l} option and specifying a file name |
5550 | is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a} | |
74291a4b MM |
5551 | and searches several directories. |
5552 | ||
5553 | @item -lobjc | |
cd3bb277 | 5554 | @opindex lobjc |
630d3d5a | 5555 | You need this special case of the @option{-l} option in order to |
46e34f96 | 5556 | link an Objective-C or Objective-C++ program. |
74291a4b MM |
5557 | |
5558 | @item -nostartfiles | |
cd3bb277 | 5559 | @opindex nostartfiles |
74291a4b | 5560 | Do not use the standard system startup files when linking. |
bedc7537 NC |
5561 | The standard system libraries are used normally, unless @option{-nostdlib} |
5562 | or @option{-nodefaultlibs} is used. | |
74291a4b MM |
5563 | |
5564 | @item -nodefaultlibs | |
cd3bb277 | 5565 | @opindex nodefaultlibs |
74291a4b MM |
5566 | Do not use the standard system libraries when linking. |
5567 | Only the libraries you specify will be passed to the linker. | |
bedc7537 | 5568 | The standard startup files are used normally, unless @option{-nostartfiles} |
8f99553f JM |
5569 | is used. The compiler may generate calls to @code{memcmp}, |
5570 | @code{memset}, @code{memcpy} and @code{memmove}. | |
5571 | These entries are usually resolved by entries in | |
4754172c CM |
5572 | libc. These entry points should be supplied through some other |
5573 | mechanism when this option is specified. | |
74291a4b MM |
5574 | |
5575 | @item -nostdlib | |
cd3bb277 | 5576 | @opindex nostdlib |
74291a4b MM |
5577 | Do not use the standard system startup files or libraries when linking. |
5578 | No startup files and only the libraries you specify will be passed to | |
8f99553f JM |
5579 | the linker. The compiler may generate calls to @code{memcmp}, @code{memset}, |
5580 | @code{memcpy} and @code{memmove}. | |
5581 | These entries are usually resolved by entries in | |
4754172c CM |
5582 | libc. These entry points should be supplied through some other |
5583 | mechanism when this option is specified. | |
74291a4b | 5584 | |
630d3d5a JM |
5585 | @cindex @option{-lgcc}, use with @option{-nostdlib} |
5586 | @cindex @option{-nostdlib} and unresolved references | |
5587 | @cindex unresolved references and @option{-nostdlib} | |
5588 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
5589 | @cindex @option{-nodefaultlibs} and unresolved references | |
5590 | @cindex unresolved references and @option{-nodefaultlibs} | |
5591 | One of the standard libraries bypassed by @option{-nostdlib} and | |
5592 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
0c2d1a2a | 5593 | that GCC uses to overcome shortcomings of particular machines, or special |
74291a4b | 5594 | needs for some languages. |
b11cc610 JM |
5595 | (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler |
5596 | Collection (GCC) Internals}, | |
74291a4b | 5597 | for more discussion of @file{libgcc.a}.) |
74291a4b | 5598 | In most cases, you need @file{libgcc.a} even when you want to avoid |
630d3d5a JM |
5599 | other standard libraries. In other words, when you specify @option{-nostdlib} |
5600 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
0c2d1a2a | 5601 | This ensures that you have no unresolved references to internal GCC |
74291a4b | 5602 | library subroutines. (For example, @samp{__main}, used to ensure C++ |
b11cc610 JM |
5603 | constructors will be called; @pxref{Collect2,,@code{collect2}, gccint, |
5604 | GNU Compiler Collection (GCC) Internals}.) | |
74291a4b | 5605 | |
24a4dd31 JJ |
5606 | @item -pie |
5607 | @opindex pie | |
5608 | Produce a position independent executable on targets which support it. | |
5609 | For predictable results, you must also specify the same set of options | |
5610 | that were used to generate code (@option{-fpie}, @option{-fPIE}, | |
5611 | or model suboptions) when you specify this option. | |
5612 | ||
74291a4b | 5613 | @item -s |
cd3bb277 | 5614 | @opindex s |
74291a4b MM |
5615 | Remove all symbol table and relocation information from the executable. |
5616 | ||
5617 | @item -static | |
cd3bb277 | 5618 | @opindex static |
74291a4b MM |
5619 | On systems that support dynamic linking, this prevents linking with the shared |
5620 | libraries. On other systems, this option has no effect. | |
5621 | ||
5622 | @item -shared | |
cd3bb277 | 5623 | @opindex shared |
74291a4b | 5624 | Produce a shared object which can then be linked with other objects to |
1d3b0e2c | 5625 | form an executable. Not all systems support this option. For predictable |
02f52e19 | 5626 | results, you must also specify the same set of options that were used to |
630d3d5a | 5627 | generate code (@option{-fpic}, @option{-fPIC}, or model suboptions) |
2642624b | 5628 | when you specify this option.@footnote{On some systems, @samp{gcc -shared} |
767094dd | 5629 | needs to build supplementary stub code for constructors to work. On |
2642624b | 5630 | multi-libbed systems, @samp{gcc -shared} must select the correct support |
1d3b0e2c | 5631 | libraries to link against. Failing to supply the correct flags may lead |
767094dd | 5632 | to subtle defects. Supplying them in cases where they are not necessary |
1d3b0e2c | 5633 | is innocuous.} |
74291a4b | 5634 | |
9db0819e RH |
5635 | @item -shared-libgcc |
5636 | @itemx -static-libgcc | |
cd3bb277 JM |
5637 | @opindex shared-libgcc |
5638 | @opindex static-libgcc | |
9db0819e RH |
5639 | On systems that provide @file{libgcc} as a shared library, these options |
5640 | force the use of either the shared or static version respectively. | |
5641 | If no shared version of @file{libgcc} was built when the compiler was | |
5642 | configured, these options have no effect. | |
5643 | ||
5644 | There are several situations in which an application should use the | |
5645 | shared @file{libgcc} instead of the static version. The most common | |
5646 | of these is when the application wishes to throw and catch exceptions | |
5647 | across different shared libraries. In that case, each of the libraries | |
5648 | as well as the application itself should use the shared @file{libgcc}. | |
5649 | ||
5c181756 AO |
5650 | Therefore, the G++ and GCJ drivers automatically add |
5651 | @option{-shared-libgcc} whenever you build a shared library or a main | |
5652 | executable, because C++ and Java programs typically use exceptions, so | |
5653 | this is the right thing to do. | |
5654 | ||
5655 | If, instead, you use the GCC driver to create shared libraries, you may | |
5656 | find that they will not always be linked with the shared @file{libgcc}. | |
d3144423 EB |
5657 | If GCC finds, at its configuration time, that you have a non-GNU linker |
5658 | or a GNU linker that does not support option @option{--eh-frame-hdr}, | |
5659 | it will link the shared version of @file{libgcc} into shared libraries | |
5660 | by default. Otherwise, it will take advantage of the linker and optimize | |
5661 | away the linking with the shared version of @file{libgcc}, linking with | |
5662 | the static version of libgcc by default. This allows exceptions to | |
5663 | propagate through such shared libraries, without incurring relocation | |
5664 | costs at library load time. | |
5c181756 AO |
5665 | |
5666 | However, if a library or main executable is supposed to throw or catch | |
5667 | exceptions, you must link it using the G++ or GCJ driver, as appropriate | |
5668 | for the languages used in the program, or using the option | |
5669 | @option{-shared-libgcc}, such that it is linked with the shared | |
049f6ec9 | 5670 | @file{libgcc}. |
9db0819e | 5671 | |
74291a4b | 5672 | @item -symbolic |
cd3bb277 | 5673 | @opindex symbolic |
74291a4b MM |
5674 | Bind references to global symbols when building a shared object. Warn |
5675 | about any unresolved references (unless overridden by the link editor | |
5676 | option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support | |
5677 | this option. | |
5678 | ||
5679 | @item -Xlinker @var{option} | |
cd3bb277 | 5680 | @opindex Xlinker |
74291a4b | 5681 | Pass @var{option} as an option to the linker. You can use this to |
0c2d1a2a | 5682 | supply system-specific linker options which GCC does not know how to |
74291a4b MM |
5683 | recognize. |
5684 | ||
5685 | If you want to pass an option that takes an argument, you must use | |
630d3d5a JM |
5686 | @option{-Xlinker} twice, once for the option and once for the argument. |
5687 | For example, to pass @option{-assert definitions}, you must write | |
74291a4b | 5688 | @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write |
630d3d5a | 5689 | @option{-Xlinker "-assert definitions"}, because this passes the entire |
74291a4b MM |
5690 | string as a single argument, which is not what the linker expects. |
5691 | ||
aee96fe9 | 5692 | @item -Wl,@var{option} |
cd3bb277 | 5693 | @opindex Wl |
74291a4b MM |
5694 | Pass @var{option} as an option to the linker. If @var{option} contains |
5695 | commas, it is split into multiple options at the commas. | |
5696 | ||
5697 | @item -u @var{symbol} | |
cd3bb277 | 5698 | @opindex u |
74291a4b | 5699 | Pretend the symbol @var{symbol} is undefined, to force linking of |
630d3d5a | 5700 | library modules to define it. You can use @option{-u} multiple times with |
74291a4b MM |
5701 | different symbols to force loading of additional library modules. |
5702 | @end table | |
5703 | ||
5704 | @node Directory Options | |
5705 | @section Options for Directory Search | |
5706 | @cindex directory options | |
5707 | @cindex options, directory search | |
5708 | @cindex search path | |
5709 | ||
5710 | These options specify directories to search for header files, for | |
5711 | libraries and for parts of the compiler: | |
5712 | ||
2642624b | 5713 | @table @gcctabopt |
74291a4b | 5714 | @item -I@var{dir} |
cd3bb277 | 5715 | @opindex I |
861bb6c1 JL |
5716 | Add the directory @var{dir} to the head of the list of directories to be |
5717 | searched for header files. This can be used to override a system header | |
5718 | file, substituting your own version, since these directories are | |
d0a5eb32 RK |
5719 | searched before the system header file directories. However, you should |
5720 | not use this option to add directories that contain vendor-supplied | |
767094dd | 5721 | system header files (use @option{-isystem} for that). If you use more than |
630d3d5a | 5722 | one @option{-I} option, the directories are scanned in left-to-right |
74291a4b MM |
5723 | order; the standard system directories come after. |
5724 | ||
dbead49c | 5725 | If a standard system include directory, or a directory specified with |
48209ce5 JDA |
5726 | @option{-isystem}, is also specified with @option{-I}, the @option{-I} |
5727 | option will be ignored. The directory will still be searched but as a | |
5728 | system directory at its normal position in the system include chain. | |
5729 | This is to ensure that GCC's procedure to fix buggy system headers and | |
3364c33b | 5730 | the ordering for the include_next directive are not inadvertently changed. |
48209ce5 JDA |
5731 | If you really need to change the search order for system directories, |
5732 | use the @option{-nostdinc} and/or @option{-isystem} options. | |
dbead49c | 5733 | |
4bed3787 MS |
5734 | @item -iquote@var{dir} |
5735 | @opindex iquote | |
5736 | Add the directory @var{dir} to the head of the list of directories to | |
5737 | be searched for header files only for the case of @samp{#include | |
5738 | "@var{file}"}; they are not searched for @samp{#include <@var{file}>}, | |
5739 | otherwise just like @option{-I}. | |
74291a4b MM |
5740 | |
5741 | @item -L@var{dir} | |
cd3bb277 | 5742 | @opindex L |
74291a4b | 5743 | Add directory @var{dir} to the list of directories to be searched |
630d3d5a | 5744 | for @option{-l}. |
74291a4b MM |
5745 | |
5746 | @item -B@var{prefix} | |
cd3bb277 | 5747 | @opindex B |
74291a4b MM |
5748 | This option specifies where to find the executables, libraries, |
5749 | include files, and data files of the compiler itself. | |
5750 | ||
5751 | The compiler driver program runs one or more of the subprograms | |
5752 | @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries | |
5753 | @var{prefix} as a prefix for each program it tries to run, both with and | |
5754 | without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}). | |
5755 | ||
5756 | For each subprogram to be run, the compiler driver first tries the | |
630d3d5a | 5757 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} |
74291a4b | 5758 | was not specified, the driver tries two standard prefixes, which are |
8e5f33ff | 5759 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of |
74291a4b MM |
5760 | those results in a file name that is found, the unmodified program |
5761 | name is searched for using the directories specified in your | |
bedc7537 | 5762 | @env{PATH} environment variable. |
74291a4b | 5763 | |
07804c3b NC |
5764 | The compiler will check to see if the path provided by the @option{-B} |
5765 | refers to a directory, and if necessary it will add a directory | |
5766 | separator character at the end of the path. | |
5767 | ||
630d3d5a | 5768 | @option{-B} prefixes that effectively specify directory names also apply |
74291a4b | 5769 | to libraries in the linker, because the compiler translates these |
630d3d5a | 5770 | options into @option{-L} options for the linker. They also apply to |
74291a4b | 5771 | includes files in the preprocessor, because the compiler translates these |
630d3d5a | 5772 | options into @option{-isystem} options for the preprocessor. In this case, |
74291a4b MM |
5773 | the compiler appends @samp{include} to the prefix. |
5774 | ||
5775 | The run-time support file @file{libgcc.a} can also be searched for using | |
630d3d5a | 5776 | the @option{-B} prefix, if needed. If it is not found there, the two |
74291a4b MM |
5777 | standard prefixes above are tried, and that is all. The file is left |
5778 | out of the link if it is not found by those means. | |
5779 | ||
630d3d5a | 5780 | Another way to specify a prefix much like the @option{-B} prefix is to use |
bedc7537 | 5781 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment |
74291a4b | 5782 | Variables}. |
861bb6c1 | 5783 | |
07804c3b | 5784 | As a special kludge, if the path provided by @option{-B} is |
bf4eebe0 NC |
5785 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to |
5786 | 9, then it will be replaced by @file{[dir/]include}. This is to help | |
7dac2f89 | 5787 | with boot-strapping the compiler. |
07804c3b | 5788 | |
861bb6c1 | 5789 | @item -specs=@var{file} |
cd3bb277 | 5790 | @opindex specs |
861bb6c1 JL |
5791 | Process @var{file} after the compiler reads in the standard @file{specs} |
5792 | file, in order to override the defaults that the @file{gcc} driver | |
5793 | program uses when determining what switches to pass to @file{cc1}, | |
5794 | @file{cc1plus}, @file{as}, @file{ld}, etc. More than one | |
630d3d5a | 5795 | @option{-specs=@var{file}} can be specified on the command line, and they |
861bb6c1 | 5796 | are processed in order, from left to right. |
4bed3787 MS |
5797 | |
5798 | @item -I- | |
5799 | @opindex I- | |
5800 | This option has been deprecated. Please use @option{-iquote} instead for | |
5801 | @option{-I} directories before the @option{-I-} and remove the @option{-I-}. | |
5802 | Any directories you specify with @option{-I} options before the @option{-I-} | |
5803 | option are searched only for the case of @samp{#include "@var{file}"}; | |
5804 | they are not searched for @samp{#include <@var{file}>}. | |
5805 | ||
5806 | If additional directories are specified with @option{-I} options after | |
5807 | the @option{-I-}, these directories are searched for all @samp{#include} | |
5808 | directives. (Ordinarily @emph{all} @option{-I} directories are used | |
5809 | this way.) | |
5810 | ||
5811 | In addition, the @option{-I-} option inhibits the use of the current | |
5812 | directory (where the current input file came from) as the first search | |
5813 | directory for @samp{#include "@var{file}"}. There is no way to | |
5814 | override this effect of @option{-I-}. With @option{-I.} you can specify | |
5815 | searching the directory which was current when the compiler was | |
5816 | invoked. That is not exactly the same as what the preprocessor does | |
5817 | by default, but it is often satisfactory. | |
5818 | ||
5819 | @option{-I-} does not inhibit the use of the standard system directories | |
5820 | for header files. Thus, @option{-I-} and @option{-nostdinc} are | |
5821 | independent. | |
74291a4b MM |
5822 | @end table |
5823 | ||
ee457005 JM |
5824 | @c man end |
5825 | ||
a743d340 NC |
5826 | @node Spec Files |
5827 | @section Specifying subprocesses and the switches to pass to them | |
5828 | @cindex Spec Files | |
d2d42a91 | 5829 | |
bedc7537 | 5830 | @command{gcc} is a driver program. It performs its job by invoking a |
a743d340 NC |
5831 | sequence of other programs to do the work of compiling, assembling and |
5832 | linking. GCC interprets its command-line parameters and uses these to | |
5833 | deduce which programs it should invoke, and which command-line options | |
c21cd8b1 | 5834 | it ought to place on their command lines. This behavior is controlled |
a743d340 NC |
5835 | by @dfn{spec strings}. In most cases there is one spec string for each |
5836 | program that GCC can invoke, but a few programs have multiple spec | |
c21cd8b1 | 5837 | strings to control their behavior. The spec strings built into GCC can |
630d3d5a | 5838 | be overridden by using the @option{-specs=} command-line switch to specify |
a743d340 NC |
5839 | a spec file. |
5840 | ||
5841 | @dfn{Spec files} are plaintext files that are used to construct spec | |
5842 | strings. They consist of a sequence of directives separated by blank | |
5843 | lines. The type of directive is determined by the first non-whitespace | |
5844 | character on the line and it can be one of the following: | |
5845 | ||
5846 | @table @code | |
5847 | @item %@var{command} | |
5848 | Issues a @var{command} to the spec file processor. The commands that can | |
02f52e19 | 5849 | appear here are: |
a743d340 NC |
5850 | |
5851 | @table @code | |
5852 | @item %include <@var{file}> | |
5853 | @cindex %include | |
5854 | Search for @var{file} and insert its text at the current point in the | |
5855 | specs file. | |
5856 | ||
5857 | @item %include_noerr <@var{file}> | |
5858 | @cindex %include_noerr | |
5859 | Just like @samp{%include}, but do not generate an error message if the include | |
5860 | file cannot be found. | |
5861 | ||
5862 | @item %rename @var{old_name} @var{new_name} | |
5863 | @cindex %rename | |
5864 | Rename the spec string @var{old_name} to @var{new_name}. | |
5865 | ||
5866 | @end table | |
5867 | ||
5868 | @item *[@var{spec_name}]: | |
5869 | This tells the compiler to create, override or delete the named spec | |
5870 | string. All lines after this directive up to the next directive or | |
5871 | blank line are considered to be the text for the spec string. If this | |
5872 | results in an empty string then the spec will be deleted. (Or, if the | |
5873 | spec did not exist, then nothing will happened.) Otherwise, if the spec | |
5874 | does not currently exist a new spec will be created. If the spec does | |
5875 | exist then its contents will be overridden by the text of this | |
5876 | directive, unless the first character of that text is the @samp{+} | |
5877 | character, in which case the text will be appended to the spec. | |
5878 | ||
5879 | @item [@var{suffix}]: | |
5880 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
5881 | and up to the next directive or blank line are considered to make up the | |
02f52e19 | 5882 | spec string for the indicated suffix. When the compiler encounters an |
a743d340 NC |
5883 | input file with the named suffix, it will processes the spec string in |
5884 | order to work out how to compile that file. For example: | |
5885 | ||
5886 | @smallexample | |
5887 | .ZZ: | |
5888 | z-compile -input %i | |
5889 | @end smallexample | |
5890 | ||
5891 | This says that any input file whose name ends in @samp{.ZZ} should be | |
5892 | passed to the program @samp{z-compile}, which should be invoked with the | |
630d3d5a | 5893 | command-line switch @option{-input} and with the result of performing the |
a743d340 NC |
5894 | @samp{%i} substitution. (See below.) |
5895 | ||
5896 | As an alternative to providing a spec string, the text that follows a | |
5897 | suffix directive can be one of the following: | |
5898 | ||
5899 | @table @code | |
5900 | @item @@@var{language} | |
5901 | This says that the suffix is an alias for a known @var{language}. This is | |
bedc7537 | 5902 | similar to using the @option{-x} command-line switch to GCC to specify a |
a743d340 NC |
5903 | language explicitly. For example: |
5904 | ||
5905 | @smallexample | |
5906 | .ZZ: | |
5907 | @@c++ | |
5908 | @end smallexample | |
5909 | ||
5910 | Says that .ZZ files are, in fact, C++ source files. | |
5911 | ||
5912 | @item #@var{name} | |
5913 | This causes an error messages saying: | |
5914 | ||
5915 | @smallexample | |
5916 | @var{name} compiler not installed on this system. | |
5917 | @end smallexample | |
5918 | @end table | |
5919 | ||
5920 | GCC already has an extensive list of suffixes built into it. | |
5921 | This directive will add an entry to the end of the list of suffixes, but | |
5922 | since the list is searched from the end backwards, it is effectively | |
5923 | possible to override earlier entries using this technique. | |
5924 | ||
5925 | @end table | |
5926 | ||
5927 | GCC has the following spec strings built into it. Spec files can | |
5928 | override these strings or create their own. Note that individual | |
02f52e19 | 5929 | targets can also add their own spec strings to this list. |
a743d340 NC |
5930 | |
5931 | @smallexample | |
5932 | asm Options to pass to the assembler | |
5933 | asm_final Options to pass to the assembler post-processor | |
5934 | cpp Options to pass to the C preprocessor | |
5935 | cc1 Options to pass to the C compiler | |
5936 | cc1plus Options to pass to the C++ compiler | |
5937 | endfile Object files to include at the end of the link | |
5938 | link Options to pass to the linker | |
5939 | lib Libraries to include on the command line to the linker | |
5940 | libgcc Decides which GCC support library to pass to the linker | |
5941 | linker Sets the name of the linker | |
5942 | predefines Defines to be passed to the C preprocessor | |
310668e8 JM |
5943 | signed_char Defines to pass to CPP to say whether @code{char} is signed |
5944 | by default | |
a743d340 NC |
5945 | startfile Object files to include at the start of the link |
5946 | @end smallexample | |
5947 | ||
5948 | Here is a small example of a spec file: | |
5949 | ||
5950 | @smallexample | |
5951 | %rename lib old_lib | |
5952 | ||
5953 | *lib: | |
5954 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
5955 | @end smallexample | |
5956 | ||
5957 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
5958 | then overrides the previous definition of @samp{lib} with a new one. | |
5959 | The new definition adds in some extra command-line options before | |
5960 | including the text of the old definition. | |
5961 | ||
5962 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
5963 | corresponding program. In addition, the spec strings can contain | |
5964 | @samp{%}-prefixed sequences to substitute variable text or to | |
5965 | conditionally insert text into the command line. Using these constructs | |
5966 | it is possible to generate quite complex command lines. | |
5967 | ||
5968 | Here is a table of all defined @samp{%}-sequences for spec | |
5969 | strings. Note that spaces are not generated automatically around the | |
5970 | results of expanding these sequences. Therefore you can concatenate them | |
02f52e19 | 5971 | together or combine them with constant text in a single argument. |
a743d340 NC |
5972 | |
5973 | @table @code | |
5974 | @item %% | |
5975 | Substitute one @samp{%} into the program name or argument. | |
5976 | ||
5977 | @item %i | |
5978 | Substitute the name of the input file being processed. | |
5979 | ||
5980 | @item %b | |
5981 | Substitute the basename of the input file being processed. | |
5982 | This is the substring up to (and not including) the last period | |
5983 | and not including the directory. | |
5984 | ||
371e300b NC |
5985 | @item %B |
5986 | This is the same as @samp{%b}, but include the file suffix (text after | |
5987 | the last period). | |
5988 | ||
a743d340 NC |
5989 | @item %d |
5990 | Marks the argument containing or following the @samp{%d} as a | |
5991 | temporary file name, so that that file will be deleted if GCC exits | |
5992 | successfully. Unlike @samp{%g}, this contributes no text to the | |
02f52e19 | 5993 | argument. |
a743d340 NC |
5994 | |
5995 | @item %g@var{suffix} | |
5996 | Substitute a file name that has suffix @var{suffix} and is chosen | |
5997 | once per compilation, and mark the argument in the same way as | |
5998 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
02f52e19 | 5999 | name is now chosen in a way that is hard to predict even when previously |
695ac33f | 6000 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} |
a743d340 NC |
6001 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches |
6002 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
6003 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
6004 | was simply substituted with a file name chosen once per compilation, | |
6005 | without regard to any appended suffix (which was therefore treated | |
6006 | just like ordinary text), making such attacks more likely to succeed. | |
6007 | ||
6008 | @item %u@var{suffix} | |
6009 | Like @samp{%g}, but generates a new temporary file name even if | |
6010 | @samp{%u@var{suffix}} was already seen. | |
6011 | ||
6012 | @item %U@var{suffix} | |
6013 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
6014 | new one if there is no such last file name. In the absence of any | |
6015 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
695ac33f | 6016 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} |
a743d340 NC |
6017 | would involve the generation of two distinct file names, one |
6018 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
6019 | simply substituted with a file name chosen for the previous @samp{%u}, | |
6020 | without regard to any appended suffix. | |
6021 | ||
4977bab6 | 6022 | @item %j@var{suffix} |
aee96fe9 | 6023 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is |
371e300b NC |
6024 | writable, and if save-temps is off; otherwise, substitute the name |
6025 | of a temporary file, just like @samp{%u}. This temporary file is not | |
6026 | meant for communication between processes, but rather as a junk | |
6027 | disposal mechanism. | |
6028 | ||
4977bab6 ZW |
6029 | @item %|@var{suffix} |
6030 | @itemx %m@var{suffix} | |
6031 | Like @samp{%g}, except if @option{-pipe} is in effect. In that case | |
6032 | @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at | |
6033 | all. These are the two most common ways to instruct a program that it | |
6034 | should read from standard input or write to standard output. If you | |
6035 | need something more elaborate you can use an @samp{%@{pipe:@code{X}@}} | |
6036 | construct: see for example @file{f/lang-specs.h}. | |
6037 | ||
371e300b NC |
6038 | @item %.@var{SUFFIX} |
6039 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
767094dd | 6040 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is |
371e300b NC |
6041 | terminated by the next space or %. |
6042 | ||
a743d340 NC |
6043 | @item %w |
6044 | Marks the argument containing or following the @samp{%w} as the | |
6045 | designated output file of this compilation. This puts the argument | |
6046 | into the sequence of arguments that @samp{%o} will substitute later. | |
6047 | ||
6048 | @item %o | |
6049 | Substitutes the names of all the output files, with spaces | |
6050 | automatically placed around them. You should write spaces | |
6051 | around the @samp{%o} as well or the results are undefined. | |
6052 | @samp{%o} is for use in the specs for running the linker. | |
6053 | Input files whose names have no recognized suffix are not compiled | |
6054 | at all, but they are included among the output files, so they will | |
6055 | be linked. | |
6056 | ||
6057 | @item %O | |
6058 | Substitutes the suffix for object files. Note that this is | |
6059 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
6060 | because of the need for those to form complete file names. The | |
6061 | handling is such that @samp{%O} is treated exactly as if it had already | |
6062 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
6063 | support additional @var{suffix} characters following @samp{%O} as they would | |
6064 | following, for example, @samp{.o}. | |
6065 | ||
6066 | @item %p | |
6067 | Substitutes the standard macro predefinitions for the | |
6068 | current target machine. Use this when running @code{cpp}. | |
6069 | ||
6070 | @item %P | |
6071 | Like @samp{%p}, but puts @samp{__} before and after the name of each | |
6072 | predefined macro, except for macros that start with @samp{__} or with | |
c1030c7c | 6073 | @samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO |
161d7b59 | 6074 | C@. |
a743d340 NC |
6075 | |
6076 | @item %I | |
047d636f DJ |
6077 | Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}), |
6078 | @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), and | |
6079 | @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options) | |
6080 | as necessary. | |
a743d340 NC |
6081 | |
6082 | @item %s | |
6083 | Current argument is the name of a library or startup file of some sort. | |
6084 | Search for that file in a standard list of directories and substitute | |
02f52e19 | 6085 | the full name found. |
a743d340 NC |
6086 | |
6087 | @item %e@var{str} | |
6088 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
6089 | Use this when inconsistent options are detected. | |
6090 | ||
a743d340 NC |
6091 | @item %(@var{name}) |
6092 | Substitute the contents of spec string @var{name} at this point. | |
6093 | ||
6094 | @item %[@var{name}] | |
630d3d5a | 6095 | Like @samp{%(@dots{})} but put @samp{__} around @option{-D} arguments. |
a743d340 NC |
6096 | |
6097 | @item %x@{@var{option}@} | |
6098 | Accumulate an option for @samp{%X}. | |
6099 | ||
6100 | @item %X | |
630d3d5a | 6101 | Output the accumulated linker options specified by @option{-Wl} or a @samp{%x} |
a743d340 NC |
6102 | spec string. |
6103 | ||
6104 | @item %Y | |
630d3d5a | 6105 | Output the accumulated assembler options specified by @option{-Wa}. |
a743d340 NC |
6106 | |
6107 | @item %Z | |
630d3d5a | 6108 | Output the accumulated preprocessor options specified by @option{-Wp}. |
a743d340 | 6109 | |
a743d340 NC |
6110 | @item %a |
6111 | Process the @code{asm} spec. This is used to compute the | |
6112 | switches to be passed to the assembler. | |
6113 | ||
6114 | @item %A | |
6115 | Process the @code{asm_final} spec. This is a spec string for | |
6116 | passing switches to an assembler post-processor, if such a program is | |
6117 | needed. | |
6118 | ||
6119 | @item %l | |
6120 | Process the @code{link} spec. This is the spec for computing the | |
6121 | command line passed to the linker. Typically it will make use of the | |
6122 | @samp{%L %G %S %D and %E} sequences. | |
6123 | ||
6124 | @item %D | |
630d3d5a | 6125 | Dump out a @option{-L} option for each directory that GCC believes might |
a743d340 | 6126 | contain startup files. If the target supports multilibs then the |
02f52e19 | 6127 | current multilib directory will be prepended to each of these paths. |
a743d340 | 6128 | |
371e300b | 6129 | @item %M |
c771326b | 6130 | Output the multilib directory with directory separators replaced with |
695ac33f JM |
6131 | @samp{_}. If multilib directories are not set, or the multilib directory is |
6132 | @file{.} then this option emits nothing. | |
371e300b | 6133 | |
a743d340 NC |
6134 | @item %L |
6135 | Process the @code{lib} spec. This is a spec string for deciding which | |
02f52e19 | 6136 | libraries should be included on the command line to the linker. |
a743d340 NC |
6137 | |
6138 | @item %G | |
6139 | Process the @code{libgcc} spec. This is a spec string for deciding | |
02f52e19 | 6140 | which GCC support library should be included on the command line to the linker. |
a743d340 NC |
6141 | |
6142 | @item %S | |
6143 | Process the @code{startfile} spec. This is a spec for deciding which | |
6144 | object files should be the first ones passed to the linker. Typically | |
02f52e19 | 6145 | this might be a file named @file{crt0.o}. |
a743d340 NC |
6146 | |
6147 | @item %E | |
6148 | Process the @code{endfile} spec. This is a spec string that specifies | |
02f52e19 | 6149 | the last object files that will be passed to the linker. |
a743d340 NC |
6150 | |
6151 | @item %C | |
6152 | Process the @code{cpp} spec. This is used to construct the arguments | |
6153 | to be passed to the C preprocessor. | |
6154 | ||
a743d340 NC |
6155 | @item %1 |
6156 | Process the @code{cc1} spec. This is used to construct the options to be | |
6157 | passed to the actual C compiler (@samp{cc1}). | |
6158 | ||
6159 | @item %2 | |
6160 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
6161 | passed to the actual C++ compiler (@samp{cc1plus}). | |
6162 | ||
6163 | @item %* | |
6164 | Substitute the variable part of a matched option. See below. | |
6165 | Note that each comma in the substituted string is replaced by | |
6166 | a single space. | |
6167 | ||
4977bab6 ZW |
6168 | @item %<@code{S} |
6169 | Remove all occurrences of @code{-S} from the command line. Note---this | |
6170 | command is position dependent. @samp{%} commands in the spec string | |
6171 | before this one will see @code{-S}, @samp{%} commands in the spec string | |
6172 | after this one will not. | |
6173 | ||
f3226a90 JT |
6174 | @item %:@var{function}(@var{args}) |
6175 | Call the named function @var{function}, passing it @var{args}. | |
6176 | @var{args} is first processed as a nested spec string, then split | |
6177 | into an argument vector in the usual fashion. The function returns | |
6178 | a string which is processed as if it had appeared literally as part | |
6179 | of the current spec. | |
6180 | ||
6181 | The following built-in spec functions are provided: | |
6182 | ||
6183 | @table @code | |
6184 | @item @code{if-exists} | |
6185 | The @code{if-exists} spec function takes one argument, an absolute | |
6186 | pathname to a file. If the file exists, @code{if-exists} returns the | |
6187 | pathname. Here is a small example of its usage: | |
6188 | ||
6189 | @smallexample | |
6190 | *startfile: | |
6191 | crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s | |
6192 | @end smallexample | |
152a5a9c JT |
6193 | |
6194 | @item @code{if-exists-else} | |
6195 | The @code{if-exists-else} spec function is similar to the @code{if-exists} | |
6196 | spec function, except that it takes two arguments. The first argument is | |
6197 | an absolute pathname to a file. If the file exists, @code{if-exists-else} | |
6198 | returns the pathname. If it does not exist, it returns the second argument. | |
6199 | This way, @code{if-exists-else} can be used to select one file or another, | |
6200 | based on the existence of the first. Here is a small example of its usage: | |
6201 | ||
daf2f129 | 6202 | @smallexample |
152a5a9c | 6203 | *startfile: |
f5034c5e JM |
6204 | crt0%O%s %:if-exists(crti%O%s) \ |
6205 | %:if-exists-else(crtbeginT%O%s crtbegin%O%s) | |
152a5a9c | 6206 | @end smallexample |
daf2f129 | 6207 | @end table |
f3226a90 | 6208 | |
a743d340 | 6209 | @item %@{@code{S}@} |
161d7b59 | 6210 | Substitutes the @code{-S} switch, if that switch was given to GCC@. |
a743d340 NC |
6211 | If that switch was not specified, this substitutes nothing. Note that |
6212 | the leading dash is omitted when specifying this option, and it is | |
6213 | automatically inserted if the substitution is performed. Thus the spec | |
630d3d5a JM |
6214 | string @samp{%@{foo@}} would match the command-line option @option{-foo} |
6215 | and would output the command line option @option{-foo}. | |
a743d340 NC |
6216 | |
6217 | @item %W@{@code{S}@} | |
6218 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
02f52e19 | 6219 | deleted on failure. |
a743d340 NC |
6220 | |
6221 | @item %@{@code{S}*@} | |
6222 | Substitutes all the switches specified to GCC whose names start | |
6223 | with @code{-S}, but which also take an argument. This is used for | |
695ac33f | 6224 | switches like @option{-o}, @option{-D}, @option{-I}, etc. |
630d3d5a | 6225 | GCC considers @option{-o foo} as being |
a743d340 | 6226 | one switch whose names starts with @samp{o}. %@{o*@} would substitute this |
02f52e19 | 6227 | text, including the space. Thus two arguments would be generated. |
a743d340 | 6228 | |
371e300b NC |
6229 | @item %@{@code{S}*&@code{T}*@} |
6230 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
6231 | (the order of @code{S} and @code{T} in the spec is not significant). | |
6232 | There can be any number of ampersand-separated variables; for each the | |
6233 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
6234 | ||
a743d340 | 6235 | @item %@{@code{S}:@code{X}@} |
4977bab6 | 6236 | Substitutes @code{X}, if the @samp{-S} switch was given to GCC@. |
a743d340 NC |
6237 | |
6238 | @item %@{!@code{S}:@code{X}@} | |
4977bab6 | 6239 | Substitutes @code{X}, if the @samp{-S} switch was @emph{not} given to GCC@. |
a743d340 | 6240 | |
4977bab6 ZW |
6241 | @item %@{@code{S}*:@code{X}@} |
6242 | Substitutes @code{X} if one or more switches whose names start with | |
6243 | @code{-S} are specified to GCC@. Normally @code{X} is substituted only | |
6244 | once, no matter how many such switches appeared. However, if @code{%*} | |
6245 | appears somewhere in @code{X}, then @code{X} will be substituted once | |
6246 | for each matching switch, with the @code{%*} replaced by the part of | |
6247 | that switch that matched the @code{*}. | |
a743d340 NC |
6248 | |
6249 | @item %@{.@code{S}:@code{X}@} | |
4977bab6 | 6250 | Substitutes @code{X}, if processing a file with suffix @code{S}. |
a743d340 NC |
6251 | |
6252 | @item %@{!.@code{S}:@code{X}@} | |
4977bab6 | 6253 | Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}. |
a743d340 NC |
6254 | |
6255 | @item %@{@code{S}|@code{P}:@code{X}@} | |
4977bab6 ZW |
6256 | Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC@. |
6257 | This may be combined with @samp{!}, @samp{.}, and @code{*} sequences as well, | |
6258 | although they have a stronger binding than the @samp{|}. If @code{%*} | |
6259 | appears in @code{X}, all of the alternatives must be starred, and only | |
6260 | the first matching alternative is substituted. | |
6261 | ||
6262 | For example, a spec string like this: | |
a743d340 NC |
6263 | |
6264 | @smallexample | |
6265 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
6266 | @end smallexample | |
6267 | ||
6268 | will output the following command-line options from the following input | |
6269 | command-line options: | |
6270 | ||
6271 | @smallexample | |
6272 | fred.c -foo -baz | |
6273 | jim.d -bar -boggle | |
6274 | -d fred.c -foo -baz -boggle | |
6275 | -d jim.d -bar -baz -boggle | |
6276 | @end smallexample | |
6277 | ||
4977bab6 ZW |
6278 | @item %@{S:X; T:Y; :D@} |
6279 | ||
c0cbdbd9 KH |
6280 | If @code{S} was given to GCC, substitutes @code{X}; else if @code{T} was |
6281 | given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can | |
daf2f129 | 6282 | be as many clauses as you need. This may be combined with @code{.}, |
4977bab6 ZW |
6283 | @code{!}, @code{|}, and @code{*} as needed. |
6284 | ||
6285 | ||
a743d340 NC |
6286 | @end table |
6287 | ||
4977bab6 ZW |
6288 | The conditional text @code{X} in a %@{@code{S}:@code{X}@} or similar |
6289 | construct may contain other nested @samp{%} constructs or spaces, or | |
6290 | even newlines. They are processed as usual, as described above. | |
6291 | Trailing white space in @code{X} is ignored. White space may also | |
6292 | appear anywhere on the left side of the colon in these constructs, | |
6293 | except between @code{.} or @code{*} and the corresponding word. | |
a743d340 | 6294 | |
4977bab6 ZW |
6295 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are |
6296 | handled specifically in these constructs. If another value of | |
6297 | @option{-O} or the negated form of a @option{-f}, @option{-m}, or | |
6298 | @option{-W} switch is found later in the command line, the earlier | |
6299 | switch value is ignored, except with @{@code{S}*@} where @code{S} is | |
6300 | just one letter, which passes all matching options. | |
a743d340 | 6301 | |
4977bab6 ZW |
6302 | The character @samp{|} at the beginning of the predicate text is used to |
6303 | indicate that a command should be piped to the following command, but | |
6304 | only if @option{-pipe} is specified. | |
a743d340 NC |
6305 | |
6306 | It is built into GCC which switches take arguments and which do not. | |
6307 | (You might think it would be useful to generalize this to allow each | |
6308 | compiler's spec to say which switches take arguments. But this cannot | |
6309 | be done in a consistent fashion. GCC cannot even decide which input | |
6310 | files have been specified without knowing which switches take arguments, | |
6311 | and it must know which input files to compile in order to tell which | |
02f52e19 | 6312 | compilers to run). |
a743d340 | 6313 | |
630d3d5a | 6314 | GCC also knows implicitly that arguments starting in @option{-l} are to be |
a743d340 NC |
6315 | treated as compiler output files, and passed to the linker in their |
6316 | proper position among the other output files. | |
6317 | ||
ee457005 JM |
6318 | @c man begin OPTIONS |
6319 | ||
74291a4b MM |
6320 | @node Target Options |
6321 | @section Specifying Target Machine and Compiler Version | |
6322 | @cindex target options | |
6323 | @cindex cross compiling | |
6324 | @cindex specifying machine version | |
6325 | @cindex specifying compiler version and target machine | |
6326 | @cindex compiler version, specifying | |
6327 | @cindex target machine, specifying | |
6328 | ||
37a4aa31 GK |
6329 | The usual way to run GCC is to run the executable called @file{gcc}, or |
6330 | @file{<machine>-gcc} when cross-compiling, or | |
6331 | @file{<machine>-gcc-<version>} to run a version other than the one that | |
6332 | was installed last. Sometimes this is inconvenient, so GCC provides | |
6333 | options that will switch to another cross-compiler or version. | |
74291a4b | 6334 | |
2642624b | 6335 | @table @gcctabopt |
74291a4b | 6336 | @item -b @var{machine} |
cd3bb277 | 6337 | @opindex b |
74291a4b | 6338 | The argument @var{machine} specifies the target machine for compilation. |
74291a4b MM |
6339 | |
6340 | The value to use for @var{machine} is the same as was specified as the | |
0c2d1a2a | 6341 | machine type when configuring GCC as a cross-compiler. For |
74291a4b MM |
6342 | example, if a cross-compiler was configured with @samp{configure |
6343 | i386v}, meaning to compile for an 80386 running System V, then you | |
630d3d5a | 6344 | would specify @option{-b i386v} to run that cross compiler. |
74291a4b | 6345 | |
37a4aa31 GK |
6346 | @item -V @var{version} |
6347 | @opindex V | |
6348 | The argument @var{version} specifies which version of GCC to run. | |
6349 | This is useful when multiple versions are installed. For example, | |
6350 | @var{version} might be @samp{2.0}, meaning to run GCC version 2.0. | |
74291a4b MM |
6351 | @end table |
6352 | ||
37a4aa31 GK |
6353 | The @option{-V} and @option{-b} options work by running the |
6354 | @file{<machine>-gcc-<version>} executable, so there's no real reason to | |
6355 | use them if you can just run that directly. | |
74291a4b MM |
6356 | |
6357 | @node Submodel Options | |
6358 | @section Hardware Models and Configurations | |
6359 | @cindex submodel options | |
6360 | @cindex specifying hardware config | |
6361 | @cindex hardware models and configurations, specifying | |
6362 | @cindex machine dependent options | |
6363 | ||
630d3d5a | 6364 | Earlier we discussed the standard option @option{-b} which chooses among |
74291a4b | 6365 | different installed compilers for completely different target |
8aeea6e6 | 6366 | machines, such as VAX vs.@: 68000 vs.@: 80386. |
74291a4b MM |
6367 | |
6368 | In addition, each of these target machine types can have its own | |
6369 | special options, starting with @samp{-m}, to choose among various | |
6370 | hardware models or configurations---for example, 68010 vs 68020, | |
6371 | floating coprocessor or none. A single installed version of the | |
6372 | compiler can compile for any model or configuration, according to the | |
6373 | options specified. | |
6374 | ||
6375 | Some configurations of the compiler also support additional special | |
6376 | options, usually for compatibility with other compilers on the same | |
6377 | platform. | |
6378 | ||
74291a4b MM |
6379 | These options are defined by the macro @code{TARGET_SWITCHES} in the |
6380 | machine description. The default for the options is also defined by | |
6381 | that macro, which enables you to change the defaults. | |
74291a4b | 6382 | |
39bc1876 NS |
6383 | @c This list is ordered alphanumerically by subsection name. |
6384 | @c It should be the same order and spelling as these options are listed | |
6385 | @c in Machine Dependent Options | |
6386 | ||
74291a4b | 6387 | @menu |
39bc1876 | 6388 | * ARC Options:: |
74291a4b | 6389 | * ARM Options:: |
39bc1876 NS |
6390 | * AVR Options:: |
6391 | * CRIS Options:: | |
48aec0bc | 6392 | * Darwin Options:: |
74291a4b | 6393 | * DEC Alpha Options:: |
d7c23cdc | 6394 | * DEC Alpha/VMS Options:: |
39bc1876 | 6395 | * FRV Options:: |
74291a4b | 6396 | * H8/300 Options:: |
39bc1876 NS |
6397 | * HPPA Options:: |
6398 | * i386 and x86-64 Options:: | |
6399 | * IA-64 Options:: | |
6400 | * M32R/D Options:: | |
6401 | * M680x0 Options:: | |
6402 | * M68hc1x Options:: | |
6403 | * MCore Options:: | |
6404 | * MIPS Options:: | |
6405 | * MMIX Options:: | |
6406 | * MN10300 Options:: | |
6407 | * NS32K Options:: | |
6408 | * PDP-11 Options:: | |
6409 | * PowerPC Options:: | |
6410 | * RS/6000 and PowerPC Options:: | |
6411 | * S/390 and zSeries Options:: | |
74291a4b | 6412 | * SH Options:: |
39bc1876 | 6413 | * SPARC Options:: |
74291a4b | 6414 | * System V Options:: |
282a61e6 | 6415 | * TMS320C3x/C4x Options:: |
f84271d9 | 6416 | * V850 Options:: |
39bc1876 NS |
6417 | * VAX Options:: |
6418 | * x86-64 Options:: | |
69a0611f | 6419 | * Xstormy16 Options:: |
03984308 | 6420 | * Xtensa Options:: |
39bc1876 | 6421 | * zSeries Options:: |
74291a4b MM |
6422 | @end menu |
6423 | ||
39bc1876 NS |
6424 | @node ARC Options |
6425 | @subsection ARC Options | |
6426 | @cindex ARC Options | |
74291a4b | 6427 | |
39bc1876 | 6428 | These options are defined for ARC implementations: |
74291a4b | 6429 | |
2642624b | 6430 | @table @gcctabopt |
39bc1876 NS |
6431 | @item -EL |
6432 | @opindex EL | |
6433 | Compile code for little endian mode. This is the default. | |
74cf1c6d | 6434 | |
39bc1876 NS |
6435 | @item -EB |
6436 | @opindex EB | |
6437 | Compile code for big endian mode. | |
74291a4b | 6438 | |
39bc1876 NS |
6439 | @item -mmangle-cpu |
6440 | @opindex mmangle-cpu | |
6441 | Prepend the name of the cpu to all public symbol names. | |
6442 | In multiple-processor systems, there are many ARC variants with different | |
6443 | instruction and register set characteristics. This flag prevents code | |
6444 | compiled for one cpu to be linked with code compiled for another. | |
6445 | No facility exists for handling variants that are ``almost identical''. | |
6446 | This is an all or nothing option. | |
74291a4b | 6447 | |
39bc1876 NS |
6448 | @item -mcpu=@var{cpu} |
6449 | @opindex mcpu | |
6450 | Compile code for ARC variant @var{cpu}. | |
6451 | Which variants are supported depend on the configuration. | |
6452 | All variants support @option{-mcpu=base}, this is the default. | |
74291a4b | 6453 | |
39bc1876 NS |
6454 | @item -mtext=@var{text-section} |
6455 | @itemx -mdata=@var{data-section} | |
6456 | @itemx -mrodata=@var{readonly-data-section} | |
6457 | @opindex mtext | |
6458 | @opindex mdata | |
6459 | @opindex mrodata | |
6460 | Put functions, data, and readonly data in @var{text-section}, | |
6461 | @var{data-section}, and @var{readonly-data-section} respectively | |
6462 | by default. This can be overridden with the @code{section} attribute. | |
6463 | @xref{Variable Attributes}. | |
74291a4b | 6464 | |
39bc1876 | 6465 | @end table |
74291a4b | 6466 | |
39bc1876 NS |
6467 | @node ARM Options |
6468 | @subsection ARM Options | |
6469 | @cindex ARM options | |
74291a4b | 6470 | |
39bc1876 NS |
6471 | These @samp{-m} options are defined for Advanced RISC Machines (ARM) |
6472 | architectures: | |
74cf1c6d | 6473 | |
39bc1876 NS |
6474 | @table @gcctabopt |
6475 | @item -mabi=@var{name} | |
6476 | @opindex mabi | |
6477 | Generate code for the specified ABI. Permissible values are: @samp{apcs-gnu}, | |
6478 | @samp{atpcs}, @samp{aapcs} and @samp{iwmmxt}. | |
74cf1c6d | 6479 | |
39bc1876 NS |
6480 | @item -mapcs-frame |
6481 | @opindex mapcs-frame | |
6482 | Generate a stack frame that is compliant with the ARM Procedure Call | |
6483 | Standard for all functions, even if this is not strictly necessary for | |
6484 | correct execution of the code. Specifying @option{-fomit-frame-pointer} | |
6485 | with this option will cause the stack frames not to be generated for | |
6486 | leaf functions. The default is @option{-mno-apcs-frame}. | |
74291a4b | 6487 | |
39bc1876 NS |
6488 | @item -mapcs |
6489 | @opindex mapcs | |
6490 | This is a synonym for @option{-mapcs-frame}. | |
74291a4b | 6491 | |
39bc1876 NS |
6492 | @ignore |
6493 | @c not currently implemented | |
6494 | @item -mapcs-stack-check | |
6495 | @opindex mapcs-stack-check | |
6496 | Generate code to check the amount of stack space available upon entry to | |
6497 | every function (that actually uses some stack space). If there is | |
6498 | insufficient space available then either the function | |
6499 | @samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be | |
6500 | called, depending upon the amount of stack space required. The run time | |
6501 | system is required to provide these functions. The default is | |
6502 | @option{-mno-apcs-stack-check}, since this produces smaller code. | |
74cf1c6d | 6503 | |
39bc1876 NS |
6504 | @c not currently implemented |
6505 | @item -mapcs-float | |
6506 | @opindex mapcs-float | |
6507 | Pass floating point arguments using the float point registers. This is | |
6508 | one of the variants of the APCS@. This option is recommended if the | |
6509 | target hardware has a floating point unit or if a lot of floating point | |
6510 | arithmetic is going to be performed by the code. The default is | |
6511 | @option{-mno-apcs-float}, since integer only code is slightly increased in | |
6512 | size if @option{-mapcs-float} is used. | |
74291a4b | 6513 | |
39bc1876 NS |
6514 | @c not currently implemented |
6515 | @item -mapcs-reentrant | |
6516 | @opindex mapcs-reentrant | |
6517 | Generate reentrant, position independent code. The default is | |
6518 | @option{-mno-apcs-reentrant}. | |
6519 | @end ignore | |
74291a4b | 6520 | |
39bc1876 NS |
6521 | @item -mthumb-interwork |
6522 | @opindex mthumb-interwork | |
6523 | Generate code which supports calling between the ARM and Thumb | |
6524 | instruction sets. Without this option the two instruction sets cannot | |
6525 | be reliably used inside one program. The default is | |
6526 | @option{-mno-thumb-interwork}, since slightly larger code is generated | |
6527 | when @option{-mthumb-interwork} is specified. | |
6528 | ||
6529 | @item -mno-sched-prolog | |
6530 | @opindex mno-sched-prolog | |
6531 | Prevent the reordering of instructions in the function prolog, or the | |
6532 | merging of those instruction with the instructions in the function's | |
6533 | body. This means that all functions will start with a recognizable set | |
6534 | of instructions (or in fact one of a choice from a small set of | |
6535 | different function prologues), and this information can be used to | |
6536 | locate the start if functions inside an executable piece of code. The | |
6537 | default is @option{-msched-prolog}. | |
6538 | ||
6539 | @item -mhard-float | |
6540 | @opindex mhard-float | |
6541 | Generate output containing floating point instructions. This is the | |
6542 | default. | |
861bb6c1 | 6543 | |
74291a4b | 6544 | @item -msoft-float |
cd3bb277 | 6545 | @opindex msoft-float |
74291a4b | 6546 | Generate output containing library calls for floating point. |
39bc1876 | 6547 | @strong{Warning:} the requisite libraries are not available for all ARM |
74291a4b | 6548 | targets. Normally the facilities of the machine's usual C compiler are |
39bc1876 NS |
6549 | used, but this cannot be done directly in cross-compilation. You must make |
6550 | your own arrangements to provide suitable library functions for | |
6551 | cross-compilation. | |
74291a4b | 6552 | |
39bc1876 NS |
6553 | @option{-msoft-float} changes the calling convention in the output file; |
6554 | therefore, it is only useful if you compile @emph{all} of a program with | |
6555 | this option. In particular, you need to compile @file{libgcc.a}, the | |
6556 | library that comes with GCC, with @option{-msoft-float} in order for | |
6557 | this to work. | |
74291a4b | 6558 | |
39bc1876 NS |
6559 | @item -mfloat-abi=@var{name} |
6560 | @opindex mfloat-abi | |
6561 | Specifies which ABI to use for floating point values. Permissible values | |
6562 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
74291a4b | 6563 | |
39bc1876 NS |
6564 | @samp{soft} and @samp{hard} are equivalent to @option{-msoft-float} |
6565 | and @option{-mhard-float} respectively. @samp{softfp} allows the generation | |
6566 | of floating point instructions, but still uses the soft-float calling | |
6567 | conventions. | |
74291a4b | 6568 | |
39bc1876 NS |
6569 | @item -mlittle-endian |
6570 | @opindex mlittle-endian | |
6571 | Generate code for a processor running in little-endian mode. This is | |
6572 | the default for all standard configurations. | |
74291a4b | 6573 | |
39bc1876 NS |
6574 | @item -mbig-endian |
6575 | @opindex mbig-endian | |
6576 | Generate code for a processor running in big-endian mode; the default is | |
6577 | to compile code for a little-endian processor. | |
74291a4b | 6578 | |
39bc1876 NS |
6579 | @item -mwords-little-endian |
6580 | @opindex mwords-little-endian | |
6581 | This option only applies when generating code for big-endian processors. | |
6582 | Generate code for a little-endian word order but a big-endian byte | |
6583 | order. That is, a byte order of the form @samp{32107654}. Note: this | |
6584 | option should only be used if you require compatibility with code for | |
6585 | big-endian ARM processors generated by versions of the compiler prior to | |
6586 | 2.8. | |
74291a4b | 6587 | |
39bc1876 NS |
6588 | @item -mcpu=@var{name} |
6589 | @opindex mcpu | |
6590 | This specifies the name of the target ARM processor. GCC uses this name | |
6591 | to determine what kind of instructions it can emit when generating | |
6592 | assembly code. Permissible names are: @samp{arm2}, @samp{arm250}, | |
6593 | @samp{arm3}, @samp{arm6}, @samp{arm60}, @samp{arm600}, @samp{arm610}, | |
6594 | @samp{arm620}, @samp{arm7}, @samp{arm7m}, @samp{arm7d}, @samp{arm7dm}, | |
6595 | @samp{arm7di}, @samp{arm7dmi}, @samp{arm70}, @samp{arm700}, | |
6596 | @samp{arm700i}, @samp{arm710}, @samp{arm710c}, @samp{arm7100}, | |
6597 | @samp{arm7500}, @samp{arm7500fe}, @samp{arm7tdmi}, @samp{arm8}, | |
6598 | @samp{strongarm}, @samp{strongarm110}, @samp{strongarm1100}, | |
6599 | @samp{arm8}, @samp{arm810}, @samp{arm9}, @samp{arm9e}, @samp{arm920}, | |
f9e8581a RE |
6600 | @samp{arm920t}, @samp{arm922t}, @samp{arm946es}, @samp{arm966es}, |
6601 | @samp{arm968es}, @samp{arm926ejs}, @samp{arm940t}, @samp{arm9tdmi}, | |
39bc1876 | 6602 | @samp{arm10tdmi}, @samp{arm1020t}, @samp{arm1026ejs}, |
f9e8581a | 6603 | @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e}, |
39bc1876 NS |
6604 | @samp{arm1136js}, @samp{arm1136jfs} ,@samp{xscale}, @samp{iwmmxt}, |
6605 | @samp{ep9312}. | |
74291a4b | 6606 | |
39bc1876 NS |
6607 | @itemx -mtune=@var{name} |
6608 | @opindex mtune | |
6609 | This option is very similar to the @option{-mcpu=} option, except that | |
6610 | instead of specifying the actual target processor type, and hence | |
6611 | restricting which instructions can be used, it specifies that GCC should | |
6612 | tune the performance of the code as if the target were of the type | |
6613 | specified in this option, but still choosing the instructions that it | |
6614 | will generate based on the cpu specified by a @option{-mcpu=} option. | |
6615 | For some ARM implementations better performance can be obtained by using | |
6616 | this option. | |
861bb6c1 | 6617 | |
39bc1876 NS |
6618 | @item -march=@var{name} |
6619 | @opindex march | |
6620 | This specifies the name of the target ARM architecture. GCC uses this | |
6621 | name to determine what kind of instructions it can emit when generating | |
6622 | assembly code. This option can be used in conjunction with or instead | |
6623 | of the @option{-mcpu=} option. Permissible names are: @samp{armv2}, | |
6624 | @samp{armv2a}, @samp{armv3}, @samp{armv3m}, @samp{armv4}, @samp{armv4t}, | |
6625 | @samp{armv5}, @samp{armv5t}, @samp{armv5te}, @samp{armv6}, @samp{armv6j}, | |
6626 | @samp{iwmmxt}, @samp{ep9312}. | |
861bb6c1 | 6627 | |
39bc1876 NS |
6628 | @item -mfpu=@var{name} |
6629 | @itemx -mfpe=@var{number} | |
6630 | @itemx -mfp=@var{number} | |
6631 | @opindex mfpu | |
6632 | @opindex mfpe | |
6633 | @opindex mfp | |
6634 | This specifies what floating point hardware (or hardware emulation) is | |
6635 | available on the target. Permissible names are: @samp{fpa}, @samp{fpe2}, | |
6636 | @samp{fpe3}, @samp{maverick}, @samp{vfp}. @option{-mfp} and @option{-mfpe} | |
6637 | are synonyms for @option{-mfpu}=@samp{fpe}@var{number}, for compatibility | |
6638 | with older versions of GCC@. | |
861bb6c1 | 6639 | |
39bc1876 NS |
6640 | If @option{-msoft-float} is specified this specifies the format of |
6641 | floating point values. | |
fb868474 | 6642 | |
39bc1876 NS |
6643 | @item -mstructure-size-boundary=@var{n} |
6644 | @opindex mstructure-size-boundary | |
6645 | The size of all structures and unions will be rounded up to a multiple | |
6646 | of the number of bits set by this option. Permissible values are 8, 32 | |
6647 | and 64. The default value varies for different toolchains. For the COFF | |
6648 | targeted toolchain the default value is 8. A value of 64 is only allowed | |
6649 | if the underlying ABI supports it. | |
b71733d5 | 6650 | |
39bc1876 NS |
6651 | Specifying the larger number can produce faster, more efficient code, but |
6652 | can also increase the size of the program. Different values are potentially | |
6653 | incompatible. Code compiled with one value cannot necessarily expect to | |
6654 | work with code or libraries compiled with another value, if they exchange | |
6655 | information using structures or unions. | |
24f9c4df | 6656 | |
39bc1876 NS |
6657 | @item -mabort-on-noreturn |
6658 | @opindex mabort-on-noreturn | |
6659 | Generate a call to the function @code{abort} at the end of a | |
6660 | @code{noreturn} function. It will be executed if the function tries to | |
6661 | return. | |
24f9c4df | 6662 | |
39bc1876 NS |
6663 | @item -mlong-calls |
6664 | @itemx -mno-long-calls | |
6665 | @opindex mlong-calls | |
6666 | @opindex mno-long-calls | |
6667 | Tells the compiler to perform function calls by first loading the | |
6668 | address of the function into a register and then performing a subroutine | |
6669 | call on this register. This switch is needed if the target function | |
6670 | will lie outside of the 64 megabyte addressing range of the offset based | |
6671 | version of subroutine call instruction. | |
24f9c4df | 6672 | |
39bc1876 NS |
6673 | Even if this switch is enabled, not all function calls will be turned |
6674 | into long calls. The heuristic is that static functions, functions | |
6675 | which have the @samp{short-call} attribute, functions that are inside | |
6676 | the scope of a @samp{#pragma no_long_calls} directive and functions whose | |
6677 | definitions have already been compiled within the current compilation | |
6678 | unit, will not be turned into long calls. The exception to this rule is | |
6679 | that weak function definitions, functions with the @samp{long-call} | |
6680 | attribute or the @samp{section} attribute, and functions that are within | |
6681 | the scope of a @samp{#pragma long_calls} directive, will always be | |
6682 | turned into long calls. | |
24f9c4df | 6683 | |
39bc1876 NS |
6684 | This feature is not enabled by default. Specifying |
6685 | @option{-mno-long-calls} will restore the default behavior, as will | |
6686 | placing the function calls within the scope of a @samp{#pragma | |
6687 | long_calls_off} directive. Note these switches have no effect on how | |
6688 | the compiler generates code to handle function calls via function | |
6689 | pointers. | |
24f9c4df | 6690 | |
39bc1876 NS |
6691 | @item -mnop-fun-dllimport |
6692 | @opindex mnop-fun-dllimport | |
6693 | Disable support for the @code{dllimport} attribute. | |
74291a4b | 6694 | |
39bc1876 NS |
6695 | @item -msingle-pic-base |
6696 | @opindex msingle-pic-base | |
6697 | Treat the register used for PIC addressing as read-only, rather than | |
6698 | loading it in the prologue for each function. The run-time system is | |
6699 | responsible for initializing this register with an appropriate value | |
6700 | before execution begins. | |
2856c3e3 | 6701 | |
39bc1876 NS |
6702 | @item -mpic-register=@var{reg} |
6703 | @opindex mpic-register | |
6704 | Specify the register to be used for PIC addressing. The default is R10 | |
6705 | unless stack-checking is enabled, when R9 is used. | |
2856c3e3 | 6706 | |
39bc1876 NS |
6707 | @item -mcirrus-fix-invalid-insns |
6708 | @opindex mcirrus-fix-invalid-insns | |
6709 | @opindex mno-cirrus-fix-invalid-insns | |
6710 | Insert NOPs into the instruction stream to in order to work around | |
6711 | problems with invalid Maverick instruction combinations. This option | |
6712 | is only valid if the @option{-mcpu=ep9312} option has been used to | |
6713 | enable generation of instructions for the Cirrus Maverick floating | |
6714 | point co-processor. This option is not enabled by default, since the | |
6715 | problem is only present in older Maverick implementations. The default | |
6716 | can be re-enabled by use of the @option{-mno-cirrus-fix-invalid-insns} | |
6717 | switch. | |
2856c3e3 | 6718 | |
39bc1876 NS |
6719 | @item -mpoke-function-name |
6720 | @opindex mpoke-function-name | |
6721 | Write the name of each function into the text section, directly | |
6722 | preceding the function prologue. The generated code is similar to this: | |
2856c3e3 | 6723 | |
39bc1876 NS |
6724 | @smallexample |
6725 | t0 | |
6726 | .ascii "arm_poke_function_name", 0 | |
6727 | .align | |
6728 | t1 | |
6729 | .word 0xff000000 + (t1 - t0) | |
6730 | arm_poke_function_name | |
6731 | mov ip, sp | |
6732 | stmfd sp!, @{fp, ip, lr, pc@} | |
6733 | sub fp, ip, #4 | |
6734 | @end smallexample | |
f077f169 | 6735 | |
39bc1876 NS |
6736 | When performing a stack backtrace, code can inspect the value of |
6737 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
6738 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
6739 | there is a function name embedded immediately preceding this location | |
6740 | and has length @code{((pc[-3]) & 0xff000000)}. | |
2856c3e3 | 6741 | |
39bc1876 NS |
6742 | @item -mthumb |
6743 | @opindex mthumb | |
6744 | Generate code for the 16-bit Thumb instruction set. The default is to | |
6745 | use the 32-bit ARM instruction set. | |
8a0b86f5 | 6746 | |
39bc1876 NS |
6747 | @item -mtpcs-frame |
6748 | @opindex mtpcs-frame | |
6749 | Generate a stack frame that is compliant with the Thumb Procedure Call | |
6750 | Standard for all non-leaf functions. (A leaf function is one that does | |
6751 | not call any other functions.) The default is @option{-mno-tpcs-frame}. | |
058edcdb | 6752 | |
39bc1876 NS |
6753 | @item -mtpcs-leaf-frame |
6754 | @opindex mtpcs-leaf-frame | |
6755 | Generate a stack frame that is compliant with the Thumb Procedure Call | |
6756 | Standard for all leaf functions. (A leaf function is one that does | |
6757 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. | |
2856c3e3 | 6758 | |
39bc1876 NS |
6759 | @item -mcallee-super-interworking |
6760 | @opindex mcallee-super-interworking | |
6761 | Gives all externally visible functions in the file being compiled an ARM | |
6762 | instruction set header which switches to Thumb mode before executing the | |
6763 | rest of the function. This allows these functions to be called from | |
6764 | non-interworking code. | |
6765 | ||
6766 | @item -mcaller-super-interworking | |
6767 | @opindex mcaller-super-interworking | |
6768 | Allows calls via function pointers (including virtual functions) to | |
6769 | execute correctly regardless of whether the target code has been | |
6770 | compiled for interworking or not. There is a small overhead in the cost | |
6771 | of executing a function pointer if this option is enabled. | |
2856c3e3 SC |
6772 | |
6773 | @end table | |
6774 | ||
39bc1876 NS |
6775 | @node AVR Options |
6776 | @subsection AVR Options | |
6777 | @cindex AVR Options | |
74291a4b | 6778 | |
39bc1876 | 6779 | These options are defined for AVR implementations: |
74291a4b | 6780 | |
2642624b | 6781 | @table @gcctabopt |
39bc1876 NS |
6782 | @item -mmcu=@var{mcu} |
6783 | @opindex mmcu | |
6784 | Specify ATMEL AVR instruction set or MCU type. | |
74291a4b | 6785 | |
39bc1876 NS |
6786 | Instruction set avr1 is for the minimal AVR core, not supported by the C |
6787 | compiler, only for assembler programs (MCU types: at90s1200, attiny10, | |
6788 | attiny11, attiny12, attiny15, attiny28). | |
74291a4b | 6789 | |
39bc1876 NS |
6790 | Instruction set avr2 (default) is for the classic AVR core with up to |
6791 | 8K program memory space (MCU types: at90s2313, at90s2323, attiny22, | |
6792 | at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515, | |
6793 | at90c8534, at90s8535). | |
74291a4b | 6794 | |
39bc1876 NS |
6795 | Instruction set avr3 is for the classic AVR core with up to 128K program |
6796 | memory space (MCU types: atmega103, atmega603, at43usb320, at76c711). | |
74291a4b | 6797 | |
39bc1876 NS |
6798 | Instruction set avr4 is for the enhanced AVR core with up to 8K program |
6799 | memory space (MCU types: atmega8, atmega83, atmega85). | |
74291a4b | 6800 | |
39bc1876 NS |
6801 | Instruction set avr5 is for the enhanced AVR core with up to 128K program |
6802 | memory space (MCU types: atmega16, atmega161, atmega163, atmega32, atmega323, | |
6803 | atmega64, atmega128, at43usb355, at94k). | |
74291a4b | 6804 | |
39bc1876 NS |
6805 | @item -msize |
6806 | @opindex msize | |
6807 | Output instruction sizes to the asm file. | |
74291a4b | 6808 | |
39bc1876 NS |
6809 | @item -minit-stack=@var{N} |
6810 | @opindex minit-stack | |
6811 | Specify the initial stack address, which may be a symbol or numeric value, | |
6812 | @samp{__stack} is the default. | |
74291a4b | 6813 | |
39bc1876 NS |
6814 | @item -mno-interrupts |
6815 | @opindex mno-interrupts | |
6816 | Generated code is not compatible with hardware interrupts. | |
6817 | Code size will be smaller. | |
74291a4b | 6818 | |
39bc1876 NS |
6819 | @item -mcall-prologues |
6820 | @opindex mcall-prologues | |
6821 | Functions prologues/epilogues expanded as call to appropriate | |
6822 | subroutines. Code size will be smaller. | |
74291a4b | 6823 | |
39bc1876 NS |
6824 | @item -mno-tablejump |
6825 | @opindex mno-tablejump | |
6826 | Do not generate tablejump insns which sometimes increase code size. | |
74291a4b | 6827 | |
39bc1876 NS |
6828 | @item -mtiny-stack |
6829 | @opindex mtiny-stack | |
6830 | Change only the low 8 bits of the stack pointer. | |
74291a4b | 6831 | |
39bc1876 NS |
6832 | @item -mint8 |
6833 | @opindex mint8 | |
6834 | Assume int to be 8 bit integer. This affects the sizes of all types: A | |
6835 | char will be 1 byte, an int will be 1 byte, an long will be 2 bytes | |
6836 | and long long will be 4 bytes. Please note that this option does not | |
6837 | comply to the C standards, but it will provide you with smaller code | |
6838 | size. | |
6839 | @end table | |
74291a4b | 6840 | |
39bc1876 NS |
6841 | @node CRIS Options |
6842 | @subsection CRIS Options | |
6843 | @cindex CRIS Options | |
74291a4b | 6844 | |
39bc1876 | 6845 | These options are defined specifically for the CRIS ports. |
74291a4b | 6846 | |
39bc1876 NS |
6847 | @table @gcctabopt |
6848 | @item -march=@var{architecture-type} | |
6849 | @itemx -mcpu=@var{architecture-type} | |
6850 | @opindex march | |
6851 | @opindex mcpu | |
6852 | Generate code for the specified architecture. The choices for | |
6853 | @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for | |
6854 | respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX. | |
6855 | Default is @samp{v0} except for cris-axis-linux-gnu, where the default is | |
6856 | @samp{v10}. | |
c219ddf7 | 6857 | |
39bc1876 NS |
6858 | @item -mtune=@var{architecture-type} |
6859 | @opindex mtune | |
6860 | Tune to @var{architecture-type} everything applicable about the generated | |
6861 | code, except for the ABI and the set of available instructions. The | |
6862 | choices for @var{architecture-type} are the same as for | |
6863 | @option{-march=@var{architecture-type}}. | |
54284728 | 6864 | |
39bc1876 NS |
6865 | @item -mmax-stack-frame=@var{n} |
6866 | @opindex mmax-stack-frame | |
6867 | Warn when the stack frame of a function exceeds @var{n} bytes. | |
54284728 | 6868 | |
39bc1876 NS |
6869 | @item -melinux-stacksize=@var{n} |
6870 | @opindex melinux-stacksize | |
6871 | Only available with the @samp{cris-axis-aout} target. Arranges for | |
6872 | indications in the program to the kernel loader that the stack of the | |
6873 | program should be set to @var{n} bytes. | |
54284728 | 6874 | |
39bc1876 NS |
6875 | @item -metrax4 |
6876 | @itemx -metrax100 | |
6877 | @opindex metrax4 | |
6878 | @opindex metrax100 | |
6879 | The options @option{-metrax4} and @option{-metrax100} are synonyms for | |
6880 | @option{-march=v3} and @option{-march=v8} respectively. | |
c0498f43 | 6881 | |
39bc1876 NS |
6882 | @item -mmul-bug-workaround |
6883 | @itemx -mno-mul-bug-workaround | |
6884 | @opindex mmul-bug-workaround | |
6885 | @opindex mno-mul-bug-workaround | |
6886 | Work around a bug in the @code{muls} and @code{mulu} instructions for CPU | |
6887 | models where it applies. This option is active by default. | |
c0498f43 | 6888 | |
39bc1876 NS |
6889 | @item -mpdebug |
6890 | @opindex mpdebug | |
6891 | Enable CRIS-specific verbose debug-related information in the assembly | |
6892 | code. This option also has the effect to turn off the @samp{#NO_APP} | |
6893 | formatted-code indicator to the assembler at the beginning of the | |
6894 | assembly file. | |
c0498f43 | 6895 | |
39bc1876 NS |
6896 | @item -mcc-init |
6897 | @opindex mcc-init | |
6898 | Do not use condition-code results from previous instruction; always emit | |
6899 | compare and test instructions before use of condition codes. | |
74291a4b | 6900 | |
39bc1876 NS |
6901 | @item -mno-side-effects |
6902 | @opindex mno-side-effects | |
6903 | Do not emit instructions with side-effects in addressing modes other than | |
6904 | post-increment. | |
238b11b5 | 6905 | |
39bc1876 NS |
6906 | @item -mstack-align |
6907 | @itemx -mno-stack-align | |
6908 | @itemx -mdata-align | |
6909 | @itemx -mno-data-align | |
6910 | @itemx -mconst-align | |
6911 | @itemx -mno-const-align | |
6912 | @opindex mstack-align | |
6913 | @opindex mno-stack-align | |
6914 | @opindex mdata-align | |
6915 | @opindex mno-data-align | |
6916 | @opindex mconst-align | |
6917 | @opindex mno-const-align | |
6918 | These options (no-options) arranges (eliminate arrangements) for the | |
6919 | stack-frame, individual data and constants to be aligned for the maximum | |
6920 | single data access size for the chosen CPU model. The default is to | |
6921 | arrange for 32-bit alignment. ABI details such as structure layout are | |
6922 | not affected by these options. | |
238b11b5 | 6923 | |
39bc1876 NS |
6924 | @item -m32-bit |
6925 | @itemx -m16-bit | |
6926 | @itemx -m8-bit | |
6927 | @opindex m32-bit | |
6928 | @opindex m16-bit | |
6929 | @opindex m8-bit | |
6930 | Similar to the stack- data- and const-align options above, these options | |
6931 | arrange for stack-frame, writable data and constants to all be 32-bit, | |
6932 | 16-bit or 8-bit aligned. The default is 32-bit alignment. | |
238b11b5 | 6933 | |
39bc1876 NS |
6934 | @item -mno-prologue-epilogue |
6935 | @itemx -mprologue-epilogue | |
6936 | @opindex mno-prologue-epilogue | |
6937 | @opindex mprologue-epilogue | |
6938 | With @option{-mno-prologue-epilogue}, the normal function prologue and | |
6939 | epilogue that sets up the stack-frame are omitted and no return | |
6940 | instructions or return sequences are generated in the code. Use this | |
6941 | option only together with visual inspection of the compiled code: no | |
6942 | warnings or errors are generated when call-saved registers must be saved, | |
6943 | or storage for local variable needs to be allocated. | |
238b11b5 | 6944 | |
39bc1876 NS |
6945 | @item -mno-gotplt |
6946 | @itemx -mgotplt | |
6947 | @opindex mno-gotplt | |
6948 | @opindex mgotplt | |
6949 | With @option{-fpic} and @option{-fPIC}, don't generate (do generate) | |
6950 | instruction sequences that load addresses for functions from the PLT part | |
6951 | of the GOT rather than (traditional on other architectures) calls to the | |
6952 | PLT. The default is @option{-mgotplt}. | |
238b11b5 | 6953 | |
39bc1876 NS |
6954 | @item -maout |
6955 | @opindex maout | |
6956 | Legacy no-op option only recognized with the cris-axis-aout target. | |
c0498f43 | 6957 | |
39bc1876 NS |
6958 | @item -melf |
6959 | @opindex melf | |
6960 | Legacy no-op option only recognized with the cris-axis-elf and | |
6961 | cris-axis-linux-gnu targets. | |
74291a4b | 6962 | |
39bc1876 NS |
6963 | @item -melinux |
6964 | @opindex melinux | |
6965 | Only recognized with the cris-axis-aout target, where it selects a | |
6966 | GNU/linux-like multilib, include files and instruction set for | |
6967 | @option{-march=v8}. | |
ded17aad | 6968 | |
39bc1876 NS |
6969 | @item -mlinux |
6970 | @opindex mlinux | |
6971 | Legacy no-op option only recognized with the cris-axis-linux-gnu target. | |
ded17aad | 6972 | |
39bc1876 NS |
6973 | @item -sim |
6974 | @opindex sim | |
6975 | This option, recognized for the cris-axis-aout and cris-axis-elf arranges | |
6976 | to link with input-output functions from a simulator library. Code, | |
6977 | initialized data and zero-initialized data are allocated consecutively. | |
74291a4b | 6978 | |
39bc1876 NS |
6979 | @item -sim2 |
6980 | @opindex sim2 | |
6981 | Like @option{-sim}, but pass linker options to locate initialized data at | |
6982 | 0x40000000 and zero-initialized data at 0x80000000. | |
74291a4b MM |
6983 | @end table |
6984 | ||
39bc1876 NS |
6985 | @node Darwin Options |
6986 | @subsection Darwin Options | |
6987 | @cindex Darwin options | |
74291a4b | 6988 | |
39bc1876 NS |
6989 | These options are defined for all architectures running the Darwin operating |
6990 | system. They are useful for compatibility with other Mac OS compilers. | |
74291a4b | 6991 | |
2642624b | 6992 | @table @gcctabopt |
39bc1876 NS |
6993 | @item -F@var{dir} |
6994 | @opindex F | |
6995 | Add the framework directory @var{dir} to the head of the list of | |
6996 | directories to be searched for header files. These directories are | |
6997 | interleaved with those specified by @option{-I} options and are | |
6998 | scanned in a left-to-right order. | |
5848830f | 6999 | |
39bc1876 NS |
7000 | A framework directory is a directory with frameworks in it. A |
7001 | framework is a directory with a @samp{"Headers"} and/or | |
7002 | @samp{"PrivateHeaders"} directory contained directly in it that ends | |
7003 | in @samp{".framework"}. The name of a framework is the name of this | |
7004 | directory excluding the @samp{".framework"}. Headers associated with | |
7005 | the framework are found in one of those two directories, with | |
7006 | @samp{"Headers"} being searched first. A subframework is a framework | |
7007 | directory that is in a framework's @samp{"Frameworks"} directory. | |
7008 | Includes of subframework headers can only appear in a header of a | |
7009 | framework that contains the subframework, or in a sibling subframework | |
7010 | header. Two subframeworks are siblings if they occur in the same | |
7011 | framework. A subframework should not have the same name as a | |
7012 | framework, a warning will be issued if this is violated. Currently a | |
7013 | subframework cannot have subframeworks, in the future, the mechanism | |
7014 | may be extended to support this. The standard frameworks can be found | |
3e558e80 MS |
7015 | in @samp{"/System/Library/Frameworks"} and |
7016 | @samp{"/Library/Frameworks"}. An example include looks like | |
39bc1876 NS |
7017 | @code{#include <Framework/header.h>}, where @samp{Framework} denotes |
7018 | the name of the framework and header.h is found in the | |
7019 | @samp{"PrivateHeaders"} or @samp{"Headers"} directory. | |
157a620e | 7020 | |
7aded944 DP |
7021 | @item -gused |
7022 | @opindex -gused | |
7023 | Emit debugging information for symbols that are used. For STABS | |
7024 | debugging format, this enables @option{-feliminate-unused-debug-symbols}. | |
7025 | This is by default ON. | |
7026 | ||
7027 | @item -gfull | |
7028 | @opindex -gfull | |
7029 | Emit debugging information for all symbols and types. | |
7030 | ||
8f4220dc MA |
7031 | @item -mone-byte-bool |
7032 | @opindex -mone-byte-bool | |
7033 | Override the defaults for @samp{bool} so that @samp{sizeof(bool)==1}. | |
7034 | By default @samp{sizeof(bool)} is @samp{4} when compiling for | |
7035 | Darwin/PowerPC and @samp{1} when compiling for Darwin/x86, so this | |
7036 | option has no effect on x86. | |
7037 | ||
7038 | @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC | |
7039 | to generate code that is not binary compatible with code generated | |
7040 | without that switch. Using this switch may require recompiling all | |
7041 | other modules in a program, including system libraries. Use this | |
7042 | switch to conform to a non-default data model. | |
7043 | ||
699c914a MS |
7044 | @item -mfix-and-continue |
7045 | @itemx -ffix-and-continue | |
7046 | @itemx -findirect-data | |
7047 | @opindex mfix-and-continue | |
7048 | @opindex ffix-and-continue | |
7049 | @opindex findirect-data | |
7050 | Generate code suitable for fast turn around development. Needed to | |
7051 | enable gdb to dynamically load @code{.o} files into already running | |
7052 | programs. @option{-findirect-data} and @option{-ffix-and-continue} | |
7053 | are provided for backwards compatibility. | |
7054 | ||
39bc1876 NS |
7055 | @item -all_load |
7056 | @opindex all_load | |
7057 | Loads all members of static archive libraries. | |
7058 | See man ld(1) for more information. | |
74291a4b | 7059 | |
39bc1876 NS |
7060 | @item -arch_errors_fatal |
7061 | @opindex arch_errors_fatal | |
7062 | Cause the errors having to do with files that have the wrong architecture | |
7063 | to be fatal. | |
157a620e | 7064 | |
39bc1876 NS |
7065 | @item -bind_at_load |
7066 | @opindex bind_at_load | |
7067 | Causes the output file to be marked such that the dynamic linker will | |
7068 | bind all undefined references when the file is loaded or launched. | |
157a620e | 7069 | |
39bc1876 NS |
7070 | @item -bundle |
7071 | @opindex bundle | |
7072 | Produce a Mach-o bundle format file. | |
7073 | See man ld(1) for more information. | |
157a620e | 7074 | |
39bc1876 NS |
7075 | @item -bundle_loader @var{executable} |
7076 | @opindex bundle_loader | |
7077 | This specifies the @var{executable} that will be loading the build | |
7078 | output file being linked. See man ld(1) for more information. | |
157a620e | 7079 | |
39bc1876 NS |
7080 | @item -allowable_client @var{client_name} |
7081 | @itemx -arch_only | |
157a620e | 7082 | |
39bc1876 NS |
7083 | @itemx -client_name |
7084 | @itemx -compatibility_version | |
7085 | @itemx -current_version | |
5079843a | 7086 | @itemx -dead_strip |
39bc1876 NS |
7087 | @itemx -dependency-file |
7088 | @itemx -dylib_file | |
7089 | @itemx -dylinker_install_name | |
7090 | @itemx -dynamic | |
7091 | @itemx -dynamiclib | |
7092 | @itemx -exported_symbols_list | |
7093 | @itemx -filelist | |
7094 | @itemx -flat_namespace | |
7095 | @itemx -force_cpusubtype_ALL | |
7096 | @itemx -force_flat_namespace | |
7097 | @itemx -headerpad_max_install_names | |
7098 | @itemx -image_base | |
7099 | @itemx -init | |
7100 | @itemx -install_name | |
7101 | @itemx -keep_private_externs | |
7102 | @itemx -multi_module | |
7103 | @itemx -multiply_defined | |
7104 | @itemx -multiply_defined_unused | |
7105 | @itemx -noall_load | |
89aa5a20 | 7106 | @itemx -no_dead_strip_inits_and_terms |
39bc1876 NS |
7107 | @itemx -nofixprebinding |
7108 | @itemx -nomultidefs | |
7109 | @itemx -noprebind | |
7110 | @itemx -noseglinkedit | |
7111 | @itemx -pagezero_size | |
7112 | @itemx -prebind | |
7113 | @itemx -prebind_all_twolevel_modules | |
7114 | @itemx -private_bundle | |
7115 | @itemx -read_only_relocs | |
7116 | @itemx -sectalign | |
7117 | @itemx -sectobjectsymbols | |
7118 | @itemx -whyload | |
7119 | @itemx -seg1addr | |
7120 | @itemx -sectcreate | |
7121 | @itemx -sectobjectsymbols | |
7122 | @itemx -sectorder | |
7123 | @itemx -seg_addr_table | |
7124 | @itemx -seg_addr_table_filename | |
7125 | @itemx -seglinkedit | |
7126 | @itemx -segprot | |
7127 | @itemx -segs_read_only_addr | |
7128 | @itemx -segs_read_write_addr | |
7129 | @itemx -single_module | |
7130 | @itemx -static | |
7131 | @itemx -sub_library | |
7132 | @itemx -sub_umbrella | |
7133 | @itemx -twolevel_namespace | |
7134 | @itemx -umbrella | |
7135 | @itemx -undefined | |
7136 | @itemx -unexported_symbols_list | |
7137 | @itemx -weak_reference_mismatches | |
7138 | @itemx -whatsloaded | |
74291a4b | 7139 | |
39bc1876 NS |
7140 | @opindex allowable_client |
7141 | @opindex arch_only | |
7142 | @opindex client_name | |
7143 | @opindex compatibility_version | |
7144 | @opindex current_version | |
5079843a | 7145 | @opindex dead_strip |
39bc1876 NS |
7146 | @opindex dependency-file |
7147 | @opindex dylib_file | |
7148 | @opindex dylinker_install_name | |
7149 | @opindex dynamic | |
7150 | @opindex dynamiclib | |
7151 | @opindex exported_symbols_list | |
7152 | @opindex filelist | |
7153 | @opindex flat_namespace | |
7154 | @opindex force_cpusubtype_ALL | |
7155 | @opindex force_flat_namespace | |
7156 | @opindex headerpad_max_install_names | |
7157 | @opindex image_base | |
7158 | @opindex init | |
7159 | @opindex install_name | |
7160 | @opindex keep_private_externs | |
7161 | @opindex multi_module | |
7162 | @opindex multiply_defined | |
7163 | @opindex multiply_defined_unused | |
7164 | @opindex noall_load | |
5079843a | 7165 | @opindex no_dead_strip_inits_and_terms |
39bc1876 NS |
7166 | @opindex nofixprebinding |
7167 | @opindex nomultidefs | |
7168 | @opindex noprebind | |
7169 | @opindex noseglinkedit | |
7170 | @opindex pagezero_size | |
7171 | @opindex prebind | |
7172 | @opindex prebind_all_twolevel_modules | |
7173 | @opindex private_bundle | |
7174 | @opindex read_only_relocs | |
7175 | @opindex sectalign | |
7176 | @opindex sectobjectsymbols | |
7177 | @opindex whyload | |
7178 | @opindex seg1addr | |
7179 | @opindex sectcreate | |
7180 | @opindex sectobjectsymbols | |
7181 | @opindex sectorder | |
7182 | @opindex seg_addr_table | |
7183 | @opindex seg_addr_table_filename | |
7184 | @opindex seglinkedit | |
7185 | @opindex segprot | |
7186 | @opindex segs_read_only_addr | |
7187 | @opindex segs_read_write_addr | |
7188 | @opindex single_module | |
7189 | @opindex static | |
7190 | @opindex sub_library | |
7191 | @opindex sub_umbrella | |
7192 | @opindex twolevel_namespace | |
7193 | @opindex umbrella | |
7194 | @opindex undefined | |
7195 | @opindex unexported_symbols_list | |
7196 | @opindex weak_reference_mismatches | |
7197 | @opindex whatsloaded | |
7198 | ||
7199 | These options are available for Darwin linker. Darwin linker man page | |
7200 | describes them in detail. | |
7201 | @end table | |
7202 | ||
7203 | @node DEC Alpha Options | |
7204 | @subsection DEC Alpha Options | |
7205 | ||
7206 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
7207 | ||
7208 | @table @gcctabopt | |
7209 | @item -mno-soft-float | |
7210 | @itemx -msoft-float | |
7211 | @opindex mno-soft-float | |
cd3bb277 | 7212 | @opindex msoft-float |
39bc1876 NS |
7213 | Use (do not use) the hardware floating-point instructions for |
7214 | floating-point operations. When @option{-msoft-float} is specified, | |
7215 | functions in @file{libgcc.a} will be used to perform floating-point | |
7216 | operations. Unless they are replaced by routines that emulate the | |
7217 | floating-point operations, or compiled in such a way as to call such | |
7218 | emulations routines, these routines will issue floating-point | |
7219 | operations. If you are compiling for an Alpha without floating-point | |
7220 | operations, you must ensure that the library is built so as not to call | |
7221 | them. | |
74291a4b | 7222 | |
39bc1876 NS |
7223 | Note that Alpha implementations without floating-point operations are |
7224 | required to have floating-point registers. | |
74291a4b | 7225 | |
39bc1876 NS |
7226 | @item -mfp-reg |
7227 | @itemx -mno-fp-regs | |
7228 | @opindex mfp-reg | |
7229 | @opindex mno-fp-regs | |
7230 | Generate code that uses (does not use) the floating-point register set. | |
7231 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point | |
7232 | register set is not used, floating point operands are passed in integer | |
7233 | registers as if they were integers and floating-point results are passed | |
7234 | in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence, | |
7235 | so any function with a floating-point argument or return value called by code | |
7236 | compiled with @option{-mno-fp-regs} must also be compiled with that | |
7237 | option. | |
9b66ebb1 | 7238 | |
39bc1876 NS |
7239 | A typical use of this option is building a kernel that does not use, |
7240 | and hence need not save and restore, any floating-point registers. | |
9b66ebb1 | 7241 | |
39bc1876 NS |
7242 | @item -mieee |
7243 | @opindex mieee | |
7244 | The Alpha architecture implements floating-point hardware optimized for | |
7245 | maximum performance. It is mostly compliant with the IEEE floating | |
7246 | point standard. However, for full compliance, software assistance is | |
7247 | required. This option generates code fully IEEE compliant code | |
7248 | @emph{except} that the @var{inexact-flag} is not maintained (see below). | |
7249 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is | |
7250 | defined during compilation. The resulting code is less efficient but is | |
7251 | able to correctly support denormalized numbers and exceptional IEEE | |
7252 | values such as not-a-number and plus/minus infinity. Other Alpha | |
7253 | compilers call this option @option{-ieee_with_no_inexact}. | |
74291a4b | 7254 | |
39bc1876 NS |
7255 | @item -mieee-with-inexact |
7256 | @opindex mieee-with-inexact | |
7257 | This is like @option{-mieee} except the generated code also maintains | |
7258 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
7259 | generated code to implement fully-compliant IEEE math. In addition to | |
7260 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
7261 | macro. On some Alpha implementations the resulting code may execute | |
7262 | significantly slower than the code generated by default. Since there is | |
7263 | very little code that depends on the @var{inexact-flag}, you should | |
7264 | normally not specify this option. Other Alpha compilers call this | |
7265 | option @option{-ieee_with_inexact}. | |
74291a4b | 7266 | |
39bc1876 NS |
7267 | @item -mfp-trap-mode=@var{trap-mode} |
7268 | @opindex mfp-trap-mode | |
7269 | This option controls what floating-point related traps are enabled. | |
7270 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. | |
7271 | The trap mode can be set to one of four values: | |
74291a4b | 7272 | |
39bc1876 NS |
7273 | @table @samp |
7274 | @item n | |
7275 | This is the default (normal) setting. The only traps that are enabled | |
7276 | are the ones that cannot be disabled in software (e.g., division by zero | |
7277 | trap). | |
62b10bbc | 7278 | |
39bc1876 NS |
7279 | @item u |
7280 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
7281 | as well. | |
157a620e | 7282 | |
39bc1876 NS |
7283 | @item su |
7284 | Like @samp{su}, but the instructions are marked to be safe for software | |
7285 | completion (see Alpha architecture manual for details). | |
157a620e | 7286 | |
39bc1876 NS |
7287 | @item sui |
7288 | Like @samp{su}, but inexact traps are enabled as well. | |
7289 | @end table | |
9b66ebb1 | 7290 | |
39bc1876 NS |
7291 | @item -mfp-rounding-mode=@var{rounding-mode} |
7292 | @opindex mfp-rounding-mode | |
7293 | Selects the IEEE rounding mode. Other Alpha compilers call this option | |
7294 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one | |
7295 | of: | |
157a620e | 7296 | |
39bc1876 NS |
7297 | @table @samp |
7298 | @item n | |
7299 | Normal IEEE rounding mode. Floating point numbers are rounded towards | |
7300 | the nearest machine number or towards the even machine number in case | |
7301 | of a tie. | |
5848830f | 7302 | |
39bc1876 NS |
7303 | @item m |
7304 | Round towards minus infinity. | |
157a620e | 7305 | |
39bc1876 NS |
7306 | @item c |
7307 | Chopped rounding mode. Floating point numbers are rounded towards zero. | |
f5a1b0d2 | 7308 | |
39bc1876 NS |
7309 | @item d |
7310 | Dynamic rounding mode. A field in the floating point control register | |
7311 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
7312 | rounding mode in effect. The C library initializes this register for | |
7313 | rounding towards plus infinity. Thus, unless your program modifies the | |
7314 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. | |
7315 | @end table | |
c27ba912 | 7316 | |
39bc1876 NS |
7317 | @item -mtrap-precision=@var{trap-precision} |
7318 | @opindex mtrap-precision | |
7319 | In the Alpha architecture, floating point traps are imprecise. This | |
7320 | means without software assistance it is impossible to recover from a | |
7321 | floating trap and program execution normally needs to be terminated. | |
7322 | GCC can generate code that can assist operating system trap handlers | |
7323 | in determining the exact location that caused a floating point trap. | |
7324 | Depending on the requirements of an application, different levels of | |
7325 | precisions can be selected: | |
c27ba912 | 7326 | |
39bc1876 NS |
7327 | @table @samp |
7328 | @item p | |
7329 | Program precision. This option is the default and means a trap handler | |
7330 | can only identify which program caused a floating point exception. | |
c27ba912 | 7331 | |
39bc1876 NS |
7332 | @item f |
7333 | Function precision. The trap handler can determine the function that | |
7334 | caused a floating point exception. | |
62b10bbc | 7335 | |
39bc1876 NS |
7336 | @item i |
7337 | Instruction precision. The trap handler can determine the exact | |
7338 | instruction that caused a floating point exception. | |
7339 | @end table | |
ed0e6530 | 7340 | |
39bc1876 NS |
7341 | Other Alpha compilers provide the equivalent options called |
7342 | @option{-scope_safe} and @option{-resumption_safe}. | |
ed0e6530 | 7343 | |
39bc1876 NS |
7344 | @item -mieee-conformant |
7345 | @opindex mieee-conformant | |
7346 | This option marks the generated code as IEEE conformant. You must not | |
7347 | use this option unless you also specify @option{-mtrap-precision=i} and either | |
7348 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
7349 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
7350 | generated assembly file. Under DEC Unix, this has the effect that | |
7351 | IEEE-conformant math library routines will be linked in. | |
9b6b54e2 | 7352 | |
39bc1876 NS |
7353 | @item -mbuild-constants |
7354 | @opindex mbuild-constants | |
7355 | Normally GCC examines a 32- or 64-bit integer constant to | |
7356 | see if it can construct it from smaller constants in two or three | |
7357 | instructions. If it cannot, it will output the constant as a literal and | |
7358 | generate code to load it from the data segment at runtime. | |
74291a4b | 7359 | |
39bc1876 NS |
7360 | Use this option to require GCC to construct @emph{all} integer constants |
7361 | using code, even if it takes more instructions (the maximum is six). | |
157a620e | 7362 | |
39bc1876 NS |
7363 | You would typically use this option to build a shared library dynamic |
7364 | loader. Itself a shared library, it must relocate itself in memory | |
7365 | before it can find the variables and constants in its own data segment. | |
7366 | ||
7367 | @item -malpha-as | |
7368 | @itemx -mgas | |
7369 | @opindex malpha-as | |
7370 | @opindex mgas | |
7371 | Select whether to generate code to be assembled by the vendor-supplied | |
7372 | assembler (@option{-malpha-as}) or by the GNU assembler @option{-mgas}. | |
7373 | ||
7374 | @item -mbwx | |
7375 | @itemx -mno-bwx | |
7376 | @itemx -mcix | |
7377 | @itemx -mno-cix | |
7378 | @itemx -mfix | |
7379 | @itemx -mno-fix | |
7380 | @itemx -mmax | |
7381 | @itemx -mno-max | |
7382 | @opindex mbwx | |
7383 | @opindex mno-bwx | |
7384 | @opindex mcix | |
7385 | @opindex mno-cix | |
7386 | @opindex mfix | |
7387 | @opindex mno-fix | |
7388 | @opindex mmax | |
7389 | @opindex mno-max | |
7390 | Indicate whether GCC should generate code to use the optional BWX, | |
7391 | CIX, FIX and MAX instruction sets. The default is to use the instruction | |
7392 | sets supported by the CPU type specified via @option{-mcpu=} option or that | |
7393 | of the CPU on which GCC was built if none was specified. | |
157a620e | 7394 | |
39bc1876 NS |
7395 | @item -mfloat-vax |
7396 | @itemx -mfloat-ieee | |
7397 | @opindex mfloat-vax | |
7398 | @opindex mfloat-ieee | |
7399 | Generate code that uses (does not use) VAX F and G floating point | |
7400 | arithmetic instead of IEEE single and double precision. | |
157a620e | 7401 | |
39bc1876 NS |
7402 | @item -mexplicit-relocs |
7403 | @itemx -mno-explicit-relocs | |
7404 | @opindex mexplicit-relocs | |
7405 | @opindex mno-explicit-relocs | |
7406 | Older Alpha assemblers provided no way to generate symbol relocations | |
7407 | except via assembler macros. Use of these macros does not allow | |
7408 | optimal instruction scheduling. GNU binutils as of version 2.12 | |
7409 | supports a new syntax that allows the compiler to explicitly mark | |
7410 | which relocations should apply to which instructions. This option | |
7411 | is mostly useful for debugging, as GCC detects the capabilities of | |
7412 | the assembler when it is built and sets the default accordingly. | |
157a620e | 7413 | |
39bc1876 NS |
7414 | @item -msmall-data |
7415 | @itemx -mlarge-data | |
7416 | @opindex msmall-data | |
7417 | @opindex mlarge-data | |
7418 | When @option{-mexplicit-relocs} is in effect, static data is | |
7419 | accessed via @dfn{gp-relative} relocations. When @option{-msmall-data} | |
7420 | is used, objects 8 bytes long or smaller are placed in a @dfn{small data area} | |
7421 | (the @code{.sdata} and @code{.sbss} sections) and are accessed via | |
7422 | 16-bit relocations off of the @code{$gp} register. This limits the | |
7423 | size of the small data area to 64KB, but allows the variables to be | |
7424 | directly accessed via a single instruction. | |
62b10bbc | 7425 | |
39bc1876 NS |
7426 | The default is @option{-mlarge-data}. With this option the data area |
7427 | is limited to just below 2GB. Programs that require more than 2GB of | |
7428 | data must use @code{malloc} or @code{mmap} to allocate the data in the | |
7429 | heap instead of in the program's data segment. | |
62b10bbc | 7430 | |
39bc1876 NS |
7431 | When generating code for shared libraries, @option{-fpic} implies |
7432 | @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}. | |
4bdc1ac7 | 7433 | |
39bc1876 NS |
7434 | @item -msmall-text |
7435 | @itemx -mlarge-text | |
7436 | @opindex msmall-text | |
7437 | @opindex mlarge-text | |
7438 | When @option{-msmall-text} is used, the compiler assumes that the | |
7439 | code of the entire program (or shared library) fits in 4MB, and is | |
7440 | thus reachable with a branch instruction. When @option{-msmall-data} | |
7441 | is used, the compiler can assume that all local symbols share the | |
7442 | same @code{$gp} value, and thus reduce the number of instructions | |
7443 | required for a function call from 4 to 1. | |
157a620e | 7444 | |
39bc1876 | 7445 | The default is @option{-mlarge-text}. |
d2d42a91 | 7446 | |
39bc1876 NS |
7447 | @item -mcpu=@var{cpu_type} |
7448 | @opindex mcpu | |
7449 | Set the instruction set and instruction scheduling parameters for | |
7450 | machine type @var{cpu_type}. You can specify either the @samp{EV} | |
7451 | style name or the corresponding chip number. GCC supports scheduling | |
7452 | parameters for the EV4, EV5 and EV6 family of processors and will | |
7453 | choose the default values for the instruction set from the processor | |
7454 | you specify. If you do not specify a processor type, GCC will default | |
7455 | to the processor on which the compiler was built. | |
6d6d0fa0 | 7456 | |
39bc1876 | 7457 | Supported values for @var{cpu_type} are |
6d6d0fa0 | 7458 | |
39bc1876 NS |
7459 | @table @samp |
7460 | @item ev4 | |
7461 | @itemx ev45 | |
7462 | @itemx 21064 | |
7463 | Schedules as an EV4 and has no instruction set extensions. | |
ecff22ab | 7464 | |
39bc1876 NS |
7465 | @item ev5 |
7466 | @itemx 21164 | |
7467 | Schedules as an EV5 and has no instruction set extensions. | |
705ac34f | 7468 | |
39bc1876 NS |
7469 | @item ev56 |
7470 | @itemx 21164a | |
7471 | Schedules as an EV5 and supports the BWX extension. | |
705ac34f | 7472 | |
39bc1876 NS |
7473 | @item pca56 |
7474 | @itemx 21164pc | |
7475 | @itemx 21164PC | |
7476 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
c474f76b | 7477 | |
39bc1876 NS |
7478 | @item ev6 |
7479 | @itemx 21264 | |
7480 | Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. | |
ecff22ab | 7481 | |
39bc1876 NS |
7482 | @item ev67 |
7483 | @itemx 21264a | |
7484 | Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. | |
6d6d0fa0 JL |
7485 | @end table |
7486 | ||
39bc1876 NS |
7487 | @item -mtune=@var{cpu_type} |
7488 | @opindex mtune | |
7489 | Set only the instruction scheduling parameters for machine type | |
7490 | @var{cpu_type}. The instruction set is not changed. | |
ecff22ab | 7491 | |
39bc1876 NS |
7492 | @item -mmemory-latency=@var{time} |
7493 | @opindex mmemory-latency | |
7494 | Sets the latency the scheduler should assume for typical memory | |
7495 | references as seen by the application. This number is highly | |
7496 | dependent on the memory access patterns used by the application | |
7497 | and the size of the external cache on the machine. | |
861bb6c1 | 7498 | |
39bc1876 | 7499 | Valid options for @var{time} are |
6975bd2c | 7500 | |
39bc1876 NS |
7501 | @table @samp |
7502 | @item @var{number} | |
7503 | A decimal number representing clock cycles. | |
98180123 | 7504 | |
39bc1876 NS |
7505 | @item L1 |
7506 | @itemx L2 | |
7507 | @itemx L3 | |
7508 | @itemx main | |
7509 | The compiler contains estimates of the number of clock cycles for | |
7510 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
7511 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
7512 | Note that L3 is only valid for EV5. | |
de41e41c | 7513 | |
39bc1876 NS |
7514 | @end table |
7515 | @end table | |
861bb6c1 | 7516 | |
39bc1876 NS |
7517 | @node DEC Alpha/VMS Options |
7518 | @subsection DEC Alpha/VMS Options | |
861bb6c1 | 7519 | |
39bc1876 | 7520 | These @samp{-m} options are defined for the DEC Alpha/VMS implementations: |
861bb6c1 | 7521 | |
39bc1876 NS |
7522 | @table @gcctabopt |
7523 | @item -mvms-return-codes | |
7524 | @opindex mvms-return-codes | |
7525 | Return VMS condition codes from main. The default is to return POSIX | |
7526 | style condition (e.g.@ error) codes. | |
7527 | @end table | |
861bb6c1 | 7528 | |
39bc1876 NS |
7529 | @node FRV Options |
7530 | @subsection FRV Options | |
7531 | @cindex FRV Options | |
861bb6c1 | 7532 | |
39bc1876 NS |
7533 | @table @gcctabopt |
7534 | @item -mgpr-32 | |
7535 | @opindex mgpr-32 | |
861bb6c1 | 7536 | |
39bc1876 | 7537 | Only use the first 32 general purpose registers. |
861bb6c1 | 7538 | |
39bc1876 NS |
7539 | @item -mgpr-64 |
7540 | @opindex mgpr-64 | |
861bb6c1 | 7541 | |
39bc1876 | 7542 | Use all 64 general purpose registers. |
861bb6c1 | 7543 | |
39bc1876 NS |
7544 | @item -mfpr-32 |
7545 | @opindex mfpr-32 | |
861bb6c1 | 7546 | |
39bc1876 | 7547 | Use only the first 32 floating point registers. |
ad126521 | 7548 | |
39bc1876 NS |
7549 | @item -mfpr-64 |
7550 | @opindex mfpr-64 | |
ad126521 | 7551 | |
39bc1876 | 7552 | Use all 64 floating point registers |
ad126521 | 7553 | |
39bc1876 NS |
7554 | @item -mhard-float |
7555 | @opindex mhard-float | |
ad126521 | 7556 | |
39bc1876 | 7557 | Use hardware instructions for floating point operations. |
ad126521 | 7558 | |
39bc1876 NS |
7559 | @item -msoft-float |
7560 | @opindex msoft-float | |
ad126521 | 7561 | |
39bc1876 | 7562 | Use library routines for floating point operations. |
ad126521 | 7563 | |
39bc1876 NS |
7564 | @item -malloc-cc |
7565 | @opindex malloc-cc | |
ad126521 | 7566 | |
39bc1876 | 7567 | Dynamically allocate condition code registers. |
ad126521 | 7568 | |
39bc1876 NS |
7569 | @item -mfixed-cc |
7570 | @opindex mfixed-cc | |
861bb6c1 | 7571 | |
39bc1876 NS |
7572 | Do not try to dynamically allocate condition code registers, only |
7573 | use @code{icc0} and @code{fcc0}. | |
74291a4b | 7574 | |
39bc1876 NS |
7575 | @item -mdword |
7576 | @opindex mdword | |
74291a4b | 7577 | |
39bc1876 | 7578 | Change ABI to use double word insns. |
74291a4b | 7579 | |
39bc1876 NS |
7580 | @item -mno-dword |
7581 | @opindex mno-dword | |
74291a4b | 7582 | |
39bc1876 | 7583 | Do not use double word instructions. |
74291a4b | 7584 | |
39bc1876 NS |
7585 | @item -mdouble |
7586 | @opindex mdouble | |
74291a4b | 7587 | |
39bc1876 | 7588 | Use floating point double instructions. |
7fe90e7b | 7589 | |
39bc1876 NS |
7590 | @item -mno-double |
7591 | @opindex mno-double | |
74291a4b | 7592 | |
39bc1876 | 7593 | Do not use floating point double instructions. |
74291a4b | 7594 | |
39bc1876 NS |
7595 | @item -mmedia |
7596 | @opindex mmedia | |
74291a4b | 7597 | |
39bc1876 | 7598 | Use media instructions. |
9c34dbbf | 7599 | |
39bc1876 NS |
7600 | @item -mno-media |
7601 | @opindex mno-media | |
74291a4b | 7602 | |
39bc1876 | 7603 | Do not use media instructions. |
74291a4b | 7604 | |
39bc1876 NS |
7605 | @item -mmuladd |
7606 | @opindex mmuladd | |
9c34dbbf | 7607 | |
39bc1876 | 7608 | Use multiply and add/subtract instructions. |
66188a7e | 7609 | |
39bc1876 NS |
7610 | @item -mno-muladd |
7611 | @opindex mno-muladd | |
74291a4b | 7612 | |
39bc1876 | 7613 | Do not use multiply and add/subtract instructions. |
74291a4b | 7614 | |
d711cf67 JDA |
7615 | @item -mfdpic |
7616 | @opindex mfdpic | |
7617 | ||
7618 | Select the FDPIC ABI, that uses function descriptors to represent | |
7619 | pointers to functions. Without any PIC/PIE-related options, it | |
7620 | implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it | |
7621 | assumes GOT entries and small data are within a 12-bit range from the | |
7622 | GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets | |
7623 | are computed with 32 bits. | |
7624 | ||
7625 | @item -minline-plt | |
7626 | @opindex minline-plt | |
7627 | ||
7628 | Enable inlining of PLT entries in function calls to functions that are | |
7629 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
7630 | It's enabled by default if optimizing for speed and compiling for | |
7631 | shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an | |
7632 | optimization option such as @option{-O3} or above is present in the | |
7633 | command line. | |
7634 | ||
7635 | @item -mgprel-ro | |
7636 | @opindex mgprel-ro | |
7637 | ||
7638 | Enable the use of @code{GPREL} relocations in the FDPIC ABI for data | |
7639 | that is known to be in read-only sections. It's enabled by default, | |
7640 | except for @option{-fpic} or @option{-fpie}: even though it may help | |
7641 | make the global offset table smaller, it trades 1 instruction for 4. | |
7642 | With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4, | |
7643 | one of which may be shared by multiple symbols, and it avoids the need | |
7644 | for a GOT entry for the referenced symbol, so it's more likely to be a | |
7645 | win. If it is not, @option{-mno-gprel-ro} can be used to disable it. | |
7646 | ||
7647 | @item -multilib-library-pic | |
7648 | @opindex multilib-library-pic | |
7649 | ||
7650 | Link with the (library, not FD) pic libraries. It's implied by | |
7651 | @option{-mlibrary-pic}, as well as by @option{-fPIC} and | |
7652 | @option{-fpic} without @option{-mfdpic}. You should never have to use | |
7653 | it explicitly. | |
7654 | ||
7655 | @item -mlinked-fp | |
7656 | @opindex mlinked-fp | |
7657 | ||
7658 | Follow the EABI requirement of always creating a frame pointer whenever | |
7659 | a stack frame is allocated. This option is enabled by default and can | |
7660 | be disabled with @option{-mno-linked-fp}. | |
7661 | ||
39bc1876 NS |
7662 | @item -mlibrary-pic |
7663 | @opindex mlibrary-pic | |
0ac081f6 | 7664 | |
39bc1876 | 7665 | Generate position-independent EABI code. |
6c8875e5 | 7666 | |
39bc1876 NS |
7667 | @item -macc-4 |
7668 | @opindex macc-4 | |
6c8875e5 | 7669 | |
39bc1876 | 7670 | Use only the first four media accumulator registers. |
6c8875e5 | 7671 | |
39bc1876 NS |
7672 | @item -macc-8 |
7673 | @opindex macc-8 | |
993f19a8 | 7674 | |
39bc1876 | 7675 | Use all eight media accumulator registers. |
5da702b1 | 7676 | |
39bc1876 NS |
7677 | @item -mpack |
7678 | @opindex mpack | |
74291a4b | 7679 | |
39bc1876 | 7680 | Pack VLIW instructions. |
74291a4b | 7681 | |
39bc1876 NS |
7682 | @item -mno-pack |
7683 | @opindex mno-pack | |
74291a4b | 7684 | |
39bc1876 | 7685 | Do not pack VLIW instructions. |
7fe90e7b | 7686 | |
39bc1876 NS |
7687 | @item -mno-eflags |
7688 | @opindex mno-eflags | |
74291a4b | 7689 | |
39bc1876 | 7690 | Do not mark ABI switches in e_flags. |
861bb6c1 | 7691 | |
39bc1876 NS |
7692 | @item -mcond-move |
7693 | @opindex mcond-move | |
6184e8a4 | 7694 | |
39bc1876 | 7695 | Enable the use of conditional-move instructions (default). |
74291a4b | 7696 | |
39bc1876 NS |
7697 | This switch is mainly for debugging the compiler and will likely be removed |
7698 | in a future version. | |
74291a4b | 7699 | |
39bc1876 NS |
7700 | @item -mno-cond-move |
7701 | @opindex mno-cond-move | |
74291a4b | 7702 | |
39bc1876 | 7703 | Disable the use of conditional-move instructions. |
861bb6c1 | 7704 | |
39bc1876 NS |
7705 | This switch is mainly for debugging the compiler and will likely be removed |
7706 | in a future version. | |
861bb6c1 | 7707 | |
39bc1876 NS |
7708 | @item -mscc |
7709 | @opindex mscc | |
74291a4b | 7710 | |
39bc1876 | 7711 | Enable the use of conditional set instructions (default). |
74291a4b | 7712 | |
39bc1876 NS |
7713 | This switch is mainly for debugging the compiler and will likely be removed |
7714 | in a future version. | |
74291a4b | 7715 | |
39bc1876 NS |
7716 | @item -mno-scc |
7717 | @opindex mno-scc | |
74291a4b | 7718 | |
39bc1876 | 7719 | Disable the use of conditional set instructions. |
74291a4b | 7720 | |
39bc1876 NS |
7721 | This switch is mainly for debugging the compiler and will likely be removed |
7722 | in a future version. | |
74291a4b | 7723 | |
39bc1876 NS |
7724 | @item -mcond-exec |
7725 | @opindex mcond-exec | |
74291a4b | 7726 | |
39bc1876 | 7727 | Enable the use of conditional execution (default). |
74291a4b | 7728 | |
39bc1876 NS |
7729 | This switch is mainly for debugging the compiler and will likely be removed |
7730 | in a future version. | |
ab82a49f | 7731 | |
39bc1876 NS |
7732 | @item -mno-cond-exec |
7733 | @opindex mno-cond-exec | |
79ae11c4 | 7734 | |
39bc1876 | 7735 | Disable the use of conditional execution. |
daf2f129 | 7736 | |
39bc1876 NS |
7737 | This switch is mainly for debugging the compiler and will likely be removed |
7738 | in a future version. | |
cbe26ab8 | 7739 | |
39bc1876 NS |
7740 | @item -mvliw-branch |
7741 | @opindex mvliw-branch | |
7742 | ||
7743 | Run a pass to pack branches into VLIW instructions (default). | |
7744 | ||
7745 | This switch is mainly for debugging the compiler and will likely be removed | |
7746 | in a future version. | |
7747 | ||
7748 | @item -mno-vliw-branch | |
7749 | @opindex mno-vliw-branch | |
7750 | ||
7751 | Do not run a pass to pack branches into VLIW instructions. | |
7752 | ||
7753 | This switch is mainly for debugging the compiler and will likely be removed | |
7754 | in a future version. | |
74291a4b | 7755 | |
39bc1876 NS |
7756 | @item -mmulti-cond-exec |
7757 | @opindex mmulti-cond-exec | |
74291a4b | 7758 | |
39bc1876 NS |
7759 | Enable optimization of @code{&&} and @code{||} in conditional execution |
7760 | (default). | |
74291a4b | 7761 | |
39bc1876 NS |
7762 | This switch is mainly for debugging the compiler and will likely be removed |
7763 | in a future version. | |
74291a4b | 7764 | |
39bc1876 NS |
7765 | @item -mno-multi-cond-exec |
7766 | @opindex mno-multi-cond-exec | |
74291a4b | 7767 | |
39bc1876 | 7768 | Disable optimization of @code{&&} and @code{||} in conditional execution. |
48180d68 | 7769 | |
39bc1876 NS |
7770 | This switch is mainly for debugging the compiler and will likely be removed |
7771 | in a future version. | |
edf1b3f3 | 7772 | |
39bc1876 NS |
7773 | @item -mnested-cond-exec |
7774 | @opindex mnested-cond-exec | |
9904592e | 7775 | |
39bc1876 | 7776 | Enable nested conditional execution optimizations (default). |
9904592e | 7777 | |
39bc1876 NS |
7778 | This switch is mainly for debugging the compiler and will likely be removed |
7779 | in a future version. | |
0ac081f6 | 7780 | |
39bc1876 NS |
7781 | @item -mno-nested-cond-exec |
7782 | @opindex mno-nested-cond-exec | |
76a773f3 | 7783 | |
39bc1876 | 7784 | Disable nested conditional execution optimizations. |
74291a4b | 7785 | |
39bc1876 NS |
7786 | This switch is mainly for debugging the compiler and will likely be removed |
7787 | in a future version. | |
74291a4b | 7788 | |
39bc1876 NS |
7789 | @item -mtomcat-stats |
7790 | @opindex mtomcat-stats | |
e9a25f70 | 7791 | |
39bc1876 | 7792 | Cause gas to print out tomcat statistics. |
e9a25f70 | 7793 | |
39bc1876 NS |
7794 | @item -mcpu=@var{cpu} |
7795 | @opindex mcpu | |
74291a4b | 7796 | |
39bc1876 NS |
7797 | Select the processor type for which to generate code. Possible values are |
7798 | @samp{simple}, @samp{tomcat}, @samp{fr500}, @samp{fr400}, @samp{fr300}, | |
7799 | @samp{frv}. | |
bff46771 | 7800 | |
39bc1876 | 7801 | @end table |
8d8269fa | 7802 | |
39bc1876 NS |
7803 | @node H8/300 Options |
7804 | @subsection H8/300 Options | |
74291a4b | 7805 | |
39bc1876 | 7806 | These @samp{-m} options are defined for the H8/300 implementations: |
74291a4b | 7807 | |
39bc1876 NS |
7808 | @table @gcctabopt |
7809 | @item -mrelax | |
7810 | @opindex mrelax | |
7811 | Shorten some address references at link time, when possible; uses the | |
7812 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
7813 | ld, Using ld}, for a fuller description. | |
74291a4b | 7814 | |
39bc1876 NS |
7815 | @item -mh |
7816 | @opindex mh | |
7817 | Generate code for the H8/300H@. | |
74291a4b | 7818 | |
39bc1876 NS |
7819 | @item -ms |
7820 | @opindex ms | |
7821 | Generate code for the H8S@. | |
74291a4b | 7822 | |
39bc1876 NS |
7823 | @item -mn |
7824 | @opindex mn | |
7825 | Generate code for the H8S and H8/300H in the normal mode. This switch | |
7826 | must be used either with -mh or -ms. | |
74291a4b | 7827 | |
39bc1876 NS |
7828 | @item -ms2600 |
7829 | @opindex ms2600 | |
7830 | Generate code for the H8S/2600. This switch must be used with @option{-ms}. | |
74291a4b | 7831 | |
39bc1876 NS |
7832 | @item -mint32 |
7833 | @opindex mint32 | |
7834 | Make @code{int} data 32 bits by default. | |
74291a4b | 7835 | |
39bc1876 NS |
7836 | @item -malign-300 |
7837 | @opindex malign-300 | |
7838 | On the H8/300H and H8S, use the same alignment rules as for the H8/300. | |
7839 | The default for the H8/300H and H8S is to align longs and floats on 4 | |
7840 | byte boundaries. | |
7841 | @option{-malign-300} causes them to be aligned on 2 byte boundaries. | |
7842 | This option has no effect on the H8/300. | |
7843 | @end table | |
f5a1b0d2 | 7844 | |
39bc1876 NS |
7845 | @node HPPA Options |
7846 | @subsection HPPA Options | |
7847 | @cindex HPPA Options | |
a5c76ee6 | 7848 | |
39bc1876 | 7849 | These @samp{-m} options are defined for the HPPA family of computers: |
a5c76ee6 | 7850 | |
39bc1876 NS |
7851 | @table @gcctabopt |
7852 | @item -march=@var{architecture-type} | |
7853 | @opindex march | |
7854 | Generate code for the specified architecture. The choices for | |
7855 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA | |
7856 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to | |
7857 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
7858 | architecture option for your machine. Code compiled for lower numbered | |
7859 | architectures will run on higher numbered architectures, but not the | |
7860 | other way around. | |
7861 | ||
39bc1876 NS |
7862 | @item -mpa-risc-1-0 |
7863 | @itemx -mpa-risc-1-1 | |
7864 | @itemx -mpa-risc-2-0 | |
7865 | @opindex mpa-risc-1-0 | |
7866 | @opindex mpa-risc-1-1 | |
7867 | @opindex mpa-risc-2-0 | |
7868 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. | |
5a26b329 | 7869 | |
39bc1876 NS |
7870 | @item -mbig-switch |
7871 | @opindex mbig-switch | |
7872 | Generate code suitable for big switch tables. Use this option only if | |
7873 | the assembler/linker complain about out of range branches within a switch | |
7874 | table. | |
efdba735 | 7875 | |
39bc1876 NS |
7876 | @item -mjump-in-delay |
7877 | @opindex mjump-in-delay | |
7878 | Fill delay slots of function calls with unconditional jump instructions | |
7879 | by modifying the return pointer for the function call to be the target | |
7880 | of the conditional jump. | |
a5c76ee6 | 7881 | |
39bc1876 NS |
7882 | @item -mdisable-fpregs |
7883 | @opindex mdisable-fpregs | |
7884 | Prevent floating point registers from being used in any manner. This is | |
7885 | necessary for compiling kernels which perform lazy context switching of | |
7886 | floating point registers. If you use this option and attempt to perform | |
7887 | floating point operations, the compiler will abort. | |
0a379b7a | 7888 | |
39bc1876 NS |
7889 | @item -mdisable-indexing |
7890 | @opindex mdisable-indexing | |
7891 | Prevent the compiler from using indexing address modes. This avoids some | |
7892 | rather obscure problems when compiling MIG generated code under MACH@. | |
f5a1b0d2 | 7893 | |
39bc1876 NS |
7894 | @item -mno-space-regs |
7895 | @opindex mno-space-regs | |
7896 | Generate code that assumes the target has no space registers. This allows | |
7897 | GCC to generate faster indirect calls and use unscaled index address modes. | |
d2d42a91 | 7898 | |
39bc1876 | 7899 | Such code is suitable for level 0 PA systems and kernels. |
d2d42a91 | 7900 | |
39bc1876 NS |
7901 | @item -mfast-indirect-calls |
7902 | @opindex mfast-indirect-calls | |
7903 | Generate code that assumes calls never cross space boundaries. This | |
7904 | allows GCC to emit code which performs faster indirect calls. | |
f08a3544 | 7905 | |
39bc1876 NS |
7906 | This option will not work in the presence of shared libraries or nested |
7907 | functions. | |
f08a3544 | 7908 | |
a2017852 JDA |
7909 | @item -mfixed-range=@var{register-range} |
7910 | @opindex mfixed-range | |
7911 | Generate code treating the given register range as fixed registers. | |
7912 | A fixed register is one that the register allocator can not use. This is | |
7913 | useful when compiling kernel code. A register range is specified as | |
7914 | two registers separated by a dash. Multiple register ranges can be | |
7915 | specified separated by a comma. | |
7916 | ||
39bc1876 NS |
7917 | @item -mlong-load-store |
7918 | @opindex mlong-load-store | |
7919 | Generate 3-instruction load and store sequences as sometimes required by | |
7920 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
7921 | the HP compilers. | |
61c85ff1 | 7922 | |
39bc1876 NS |
7923 | @item -mportable-runtime |
7924 | @opindex mportable-runtime | |
7925 | Use the portable calling conventions proposed by HP for ELF systems. | |
61c85ff1 | 7926 | |
39bc1876 NS |
7927 | @item -mgas |
7928 | @opindex mgas | |
7929 | Enable the use of assembler directives only GAS understands. | |
61c85ff1 | 7930 | |
39bc1876 NS |
7931 | @item -mschedule=@var{cpu-type} |
7932 | @opindex mschedule | |
7933 | Schedule code according to the constraints for the machine type | |
7934 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} | |
7935 | @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer | |
7936 | to @file{/usr/lib/sched.models} on an HP-UX system to determine the | |
7937 | proper scheduling option for your machine. The default scheduling is | |
7938 | @samp{8000}. | |
61c85ff1 | 7939 | |
39bc1876 NS |
7940 | @item -mlinker-opt |
7941 | @opindex mlinker-opt | |
7942 | Enable the optimization pass in the HP-UX linker. Note this makes symbolic | |
7943 | debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 | |
7944 | linkers in which they give bogus error messages when linking some programs. | |
61c85ff1 | 7945 | |
39bc1876 NS |
7946 | @item -msoft-float |
7947 | @opindex msoft-float | |
7948 | Generate output containing library calls for floating point. | |
7949 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
7950 | targets. Normally the facilities of the machine's usual C compiler are | |
7951 | used, but this cannot be done directly in cross-compilation. You must make | |
7952 | your own arrangements to provide suitable library functions for | |
7953 | cross-compilation. The embedded target @samp{hppa1.1-*-pro} | |
7954 | does provide software floating point support. | |
31775d31 | 7955 | |
39bc1876 NS |
7956 | @option{-msoft-float} changes the calling convention in the output file; |
7957 | therefore, it is only useful if you compile @emph{all} of a program with | |
7958 | this option. In particular, you need to compile @file{libgcc.a}, the | |
7959 | library that comes with GCC, with @option{-msoft-float} in order for | |
7960 | this to work. | |
61c85ff1 | 7961 | |
39bc1876 NS |
7962 | @item -msio |
7963 | @opindex msio | |
7964 | Generate the predefine, @code{_SIO}, for server IO. The default is | |
7965 | @option{-mwsio}. This generates the predefines, @code{__hp9000s700}, | |
7966 | @code{__hp9000s700__} and @code{_WSIO}, for workstation IO. These | |
7967 | options are available under HP-UX and HI-UX. | |
7968 | ||
7969 | @item -mgnu-ld | |
7970 | @opindex gnu-ld | |
7971 | Use GNU ld specific options. This passes @option{-shared} to ld when | |
7972 | building a shared library. It is the default when GCC is configured, | |
7973 | explicitly or implicitly, with the GNU linker. This option does not | |
7974 | have any affect on which ld is called, it only changes what parameters | |
7975 | are passed to that ld. The ld that is called is determined by the | |
7976 | @option{--with-ld} configure option, GCC's program search path, and | |
7977 | finally by the user's @env{PATH}. The linker used by GCC can be printed | |
7978 | using @samp{which `gcc -print-prog-name=ld`}. | |
48aec0bc | 7979 | |
39bc1876 NS |
7980 | @item -mhp-ld |
7981 | @opindex hp-ld | |
7982 | Use HP ld specific options. This passes @option{-b} to ld when building | |
7983 | a shared library and passes @option{+Accept TypeMismatch} to ld on all | |
7984 | links. It is the default when GCC is configured, explicitly or | |
7985 | implicitly, with the HP linker. This option does not have any affect on | |
7986 | which ld is called, it only changes what parameters are passed to that | |
7987 | ld. The ld that is called is determined by the @option{--with-ld} | |
7988 | configure option, GCC's program search path, and finally by the user's | |
7989 | @env{PATH}. The linker used by GCC can be printed using @samp{which | |
7990 | `gcc -print-prog-name=ld`}. | |
48aec0bc | 7991 | |
39bc1876 NS |
7992 | @item -mlong-calls |
7993 | @opindex mno-long-calls | |
7994 | Generate code that uses long call sequences. This ensures that a call | |
7995 | is always able to reach linker generated stubs. The default is to generate | |
7996 | long calls only when the distance from the call site to the beginning | |
7997 | of the function or translation unit, as the case may be, exceeds a | |
7998 | predefined limit set by the branch type being used. The limits for | |
7999 | normal calls are 7,600,000 and 240,000 bytes, respectively for the | |
8000 | PA 2.0 and PA 1.X architectures. Sibcalls are always limited at | |
8001 | 240,000 bytes. | |
a27fb29b | 8002 | |
39bc1876 NS |
8003 | Distances are measured from the beginning of functions when using the |
8004 | @option{-ffunction-sections} option, or when using the @option{-mgas} | |
8005 | and @option{-mno-portable-runtime} options together under HP-UX with | |
8006 | the SOM linker. | |
7dac2f89 | 8007 | |
39bc1876 NS |
8008 | It is normally not desirable to use this option as it will degrade |
8009 | performance. However, it may be useful in large applications, | |
8010 | particularly when partial linking is used to build the application. | |
74291a4b | 8011 | |
39bc1876 NS |
8012 | The types of long calls used depends on the capabilities of the |
8013 | assembler and linker, and the type of code being generated. The | |
8014 | impact on systems that support long absolute calls, and long pic | |
8015 | symbol-difference or pc-relative calls should be relatively small. | |
8016 | However, an indirect call is used on 32-bit ELF systems in pic code | |
8017 | and it is quite long. | |
74291a4b | 8018 | |
d711cf67 JDA |
8019 | @item -munix=@var{unix-std} |
8020 | @opindex march | |
8021 | Generate compiler predefines and select a startfile for the specified | |
8022 | UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95} | |
8023 | and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95} | |
8024 | is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX | |
8025 | 11.11 and later. The default values are @samp{93} for HP-UX 10.00, | |
8026 | @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11 | |
8027 | and later. | |
8028 | ||
8029 | @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4. | |
8030 | @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX} | |
8031 | and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}. | |
8032 | @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX}, | |
8033 | @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and | |
8034 | @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}. | |
8035 | ||
8036 | It is @emph{important} to note that this option changes the interfaces | |
8037 | for various library routines. It also affects the operational behavior | |
8038 | of the C library. Thus, @emph{extreme} care is needed in using this | |
8039 | option. | |
8040 | ||
8041 | Library code that is intended to operate with more than one UNIX | |
8042 | standard must test, set and restore the variable @var{__xpg4_extended_mask} | |
8043 | as appropriate. Most GNU software doesn't provide this capability. | |
8044 | ||
39bc1876 NS |
8045 | @item -nolibdld |
8046 | @opindex nolibdld | |
8047 | Suppress the generation of link options to search libdld.sl when the | |
8048 | @option{-static} option is specified on HP-UX 10 and later. | |
8049 | ||
8050 | @item -static | |
8051 | @opindex static | |
8052 | The HP-UX implementation of setlocale in libc has a dependency on | |
8053 | libdld.sl. There isn't an archive version of libdld.sl. Thus, | |
8054 | when the @option{-static} option is specified, special link options | |
8055 | are needed to resolve this dependency. | |
8056 | ||
8057 | On HP-UX 10 and later, the GCC driver adds the necessary options to | |
8058 | link with libdld.sl when the @option{-static} option is specified. | |
8059 | This causes the resulting binary to be dynamic. On the 64-bit port, | |
8060 | the linkers generate dynamic binaries by default in any case. The | |
8061 | @option{-nolibdld} option can be used to prevent the GCC driver from | |
8062 | adding these link options. | |
8063 | ||
8064 | @item -threads | |
8065 | @opindex threads | |
8066 | Add support for multithreading with the @dfn{dce thread} library | |
8067 | under HP-UX. This option sets flags for both the preprocessor and | |
8068 | linker. | |
8069 | @end table | |
8070 | ||
8071 | @node i386 and x86-64 Options | |
8072 | @subsection Intel 386 and AMD x86-64 Options | |
8073 | @cindex i386 Options | |
8074 | @cindex x86-64 Options | |
8075 | @cindex Intel 386 Options | |
8076 | @cindex AMD x86-64 Options | |
8077 | ||
8078 | These @samp{-m} options are defined for the i386 and x86-64 family of | |
8079 | computers: | |
8080 | ||
8081 | @table @gcctabopt | |
8082 | @item -mtune=@var{cpu-type} | |
8083 | @opindex mtune | |
8084 | Tune to @var{cpu-type} everything applicable about the generated code, except | |
8085 | for the ABI and the set of available instructions. The choices for | |
8086 | @var{cpu-type} are: | |
8087 | @table @emph | |
8088 | @item i386 | |
8089 | Original Intel's i386 CPU. | |
8090 | @item i486 | |
8091 | Intel's i486 CPU. (No scheduling is implemented for this chip.) | |
8092 | @item i586, pentium | |
8093 | Intel Pentium CPU with no MMX support. | |
8094 | @item pentium-mmx | |
8095 | Intel PentiumMMX CPU based on Pentium core with MMX instruction set support. | |
8096 | @item i686, pentiumpro | |
8097 | Intel PentiumPro CPU. | |
8098 | @item pentium2 | |
8099 | Intel Pentium2 CPU based on PentiumPro core with MMX instruction set support. | |
8100 | @item pentium3, pentium3m | |
8101 | Intel Pentium3 CPU based on PentiumPro core with MMX and SSE instruction set | |
8102 | support. | |
8103 | @item pentium-m | |
8104 | Low power version of Intel Pentium3 CPU with MMX, SSE and SSE2 instruction set | |
8105 | support. Used by Centrino notebooks. | |
8106 | @item pentium4, pentium4m | |
8107 | Intel Pentium4 CPU with MMX, SSE and SSE2 instruction set support. | |
8108 | @item prescott | |
8109 | Improved version of Intel Pentium4 CPU with MMX, SSE, SSE2 and SSE3 instruction | |
8110 | set support. | |
8111 | @item nocona | |
8112 | Improved version of Intel Pentium4 CPU with 64-bit extensions, MMX, SSE, | |
8113 | SSE2 and SSE3 instruction set support. | |
8114 | @item k6 | |
8115 | AMD K6 CPU with MMX instruction set support. | |
8116 | @item k6-2, k6-3 | |
8117 | Improved versions of AMD K6 CPU with MMX and 3dNOW! instruction set support. | |
8118 | @item athlon, athlon-tbird | |
8119 | AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and SSE prefetch instructions | |
8120 | support. | |
8121 | @item athlon-4, athlon-xp, athlon-mp | |
8122 | Improved AMD Athlon CPU with MMX, 3dNOW!, enhanced 3dNOW! and full SSE | |
8123 | instruction set support. | |
8124 | @item k8, opteron, athlon64, athlon-fx | |
8125 | AMD K8 core based CPUs with x86-64 instruction set support. (This supersets | |
8126 | MMX, SSE, SSE2, 3dNOW!, enhanced 3dNOW! and 64-bit instruction set extensions.) | |
8127 | @item winchip-c6 | |
8128 | IDT Winchip C6 CPU, dealt in same way as i486 with additional MMX instruction | |
8129 | set support. | |
8130 | @item winchip2 | |
8131 | IDT Winchip2 CPU, dealt in same way as i486 with additional MMX and 3dNOW! | |
8132 | instruction set support. | |
8133 | @item c3 | |
8134 | Via C3 CPU with MMX and 3dNOW! instruction set support. (No scheduling is | |
8135 | implemented for this chip.) | |
8136 | @item c3-2 | |
8137 | Via C3-2 CPU with MMX and SSE instruction set support. (No scheduling is | |
8138 | implemented for this chip.) | |
8139 | @end table | |
8140 | ||
8141 | While picking a specific @var{cpu-type} will schedule things appropriately | |
8142 | for that particular chip, the compiler will not generate any code that | |
8143 | does not run on the i386 without the @option{-march=@var{cpu-type}} option | |
8144 | being used. | |
8145 | ||
8146 | @item -march=@var{cpu-type} | |
8147 | @opindex march | |
8148 | Generate instructions for the machine type @var{cpu-type}. The choices | |
8149 | for @var{cpu-type} are the same as for @option{-mtune}. Moreover, | |
8150 | specifying @option{-march=@var{cpu-type}} implies @option{-mtune=@var{cpu-type}}. | |
74291a4b | 8151 | |
39bc1876 NS |
8152 | @item -mcpu=@var{cpu-type} |
8153 | @opindex mcpu | |
8154 | A deprecated synonym for @option{-mtune}. | |
3398f47f | 8155 | |
39bc1876 NS |
8156 | @item -m386 |
8157 | @itemx -m486 | |
8158 | @itemx -mpentium | |
8159 | @itemx -mpentiumpro | |
8160 | @opindex m386 | |
8161 | @opindex m486 | |
8162 | @opindex mpentium | |
8163 | @opindex mpentiumpro | |
8164 | These options are synonyms for @option{-mtune=i386}, @option{-mtune=i486}, | |
8165 | @option{-mtune=pentium}, and @option{-mtune=pentiumpro} respectively. | |
8166 | These synonyms are deprecated. | |
74291a4b | 8167 | |
39bc1876 NS |
8168 | @item -mfpmath=@var{unit} |
8169 | @opindex march | |
8170 | Generate floating point arithmetics for selected unit @var{unit}. The choices | |
8171 | for @var{unit} are: | |
2d2a50c3 | 8172 | |
39bc1876 NS |
8173 | @table @samp |
8174 | @item 387 | |
8175 | Use the standard 387 floating point coprocessor present majority of chips and | |
8176 | emulated otherwise. Code compiled with this option will run almost everywhere. | |
8177 | The temporary results are computed in 80bit precision instead of precision | |
8178 | specified by the type resulting in slightly different results compared to most | |
8179 | of other chips. See @option{-ffloat-store} for more detailed description. | |
74291a4b | 8180 | |
39bc1876 | 8181 | This is the default choice for i386 compiler. |
74291a4b | 8182 | |
39bc1876 NS |
8183 | @item sse |
8184 | Use scalar floating point instructions present in the SSE instruction set. | |
8185 | This instruction set is supported by Pentium3 and newer chips, in the AMD line | |
8186 | by Athlon-4, Athlon-xp and Athlon-mp chips. The earlier version of SSE | |
8187 | instruction set supports only single precision arithmetics, thus the double and | |
8188 | extended precision arithmetics is still done using 387. Later version, present | |
8189 | only in Pentium4 and the future AMD x86-64 chips supports double precision | |
8190 | arithmetics too. | |
a27fb29b | 8191 | |
39bc1876 NS |
8192 | For i387 you need to use @option{-march=@var{cpu-type}}, @option{-msse} or |
8193 | @option{-msse2} switches to enable SSE extensions and make this option | |
8194 | effective. For x86-64 compiler, these extensions are enabled by default. | |
3398f47f | 8195 | |
39bc1876 NS |
8196 | The resulting code should be considerably faster in the majority of cases and avoid |
8197 | the numerical instability problems of 387 code, but may break some existing | |
8198 | code that expects temporaries to be 80bit. | |
cd3f11a6 | 8199 | |
39bc1876 | 8200 | This is the default choice for the x86-64 compiler. |
74291a4b | 8201 | |
39bc1876 NS |
8202 | @item sse,387 |
8203 | Attempt to utilize both instruction sets at once. This effectively double the | |
8204 | amount of available registers and on chips with separate execution units for | |
8205 | 387 and SSE the execution resources too. Use this option with care, as it is | |
8206 | still experimental, because the GCC register allocator does not model separate | |
8207 | functional units well resulting in instable performance. | |
8208 | @end table | |
ee692410 | 8209 | |
39bc1876 NS |
8210 | @item -masm=@var{dialect} |
8211 | @opindex masm=@var{dialect} | |
8212 | Output asm instructions using selected @var{dialect}. Supported choices are | |
8213 | @samp{intel} or @samp{att} (the default one). | |
ee692410 | 8214 | |
39bc1876 NS |
8215 | @item -mieee-fp |
8216 | @itemx -mno-ieee-fp | |
8217 | @opindex mieee-fp | |
8218 | @opindex mno-ieee-fp | |
8219 | Control whether or not the compiler uses IEEE floating point | |
8220 | comparisons. These handle correctly the case where the result of a | |
8221 | comparison is unordered. | |
ee692410 | 8222 | |
39bc1876 NS |
8223 | @item -msoft-float |
8224 | @opindex msoft-float | |
8225 | Generate output containing library calls for floating point. | |
8226 | @strong{Warning:} the requisite libraries are not part of GCC@. | |
8227 | Normally the facilities of the machine's usual C compiler are used, but | |
8228 | this can't be done directly in cross-compilation. You must make your | |
8229 | own arrangements to provide suitable library functions for | |
8230 | cross-compilation. | |
ee692410 | 8231 | |
39bc1876 NS |
8232 | On machines where a function returns floating point results in the 80387 |
8233 | register stack, some floating point opcodes may be emitted even if | |
8234 | @option{-msoft-float} is used. | |
ee692410 | 8235 | |
39bc1876 NS |
8236 | @item -mno-fp-ret-in-387 |
8237 | @opindex mno-fp-ret-in-387 | |
8238 | Do not use the FPU registers for return values of functions. | |
ee692410 | 8239 | |
39bc1876 NS |
8240 | The usual calling convention has functions return values of types |
8241 | @code{float} and @code{double} in an FPU register, even if there | |
8242 | is no FPU@. The idea is that the operating system should emulate | |
8243 | an FPU@. | |
5a4b3afd | 8244 | |
39bc1876 NS |
8245 | The option @option{-mno-fp-ret-in-387} causes such values to be returned |
8246 | in ordinary CPU registers instead. | |
5a4b3afd | 8247 | |
39bc1876 NS |
8248 | @item -mno-fancy-math-387 |
8249 | @opindex mno-fancy-math-387 | |
8250 | Some 387 emulators do not support the @code{sin}, @code{cos} and | |
8251 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
8252 | generating those instructions. This option is the default on FreeBSD, | |
8253 | OpenBSD and NetBSD@. This option is overridden when @option{-march} | |
8254 | indicates that the target cpu will always have an FPU and so the | |
8255 | instruction will not need emulation. As of revision 2.6.1, these | |
8256 | instructions are not generated unless you also use the | |
8257 | @option{-funsafe-math-optimizations} switch. | |
5a4b3afd | 8258 | |
39bc1876 NS |
8259 | @item -malign-double |
8260 | @itemx -mno-align-double | |
8261 | @opindex malign-double | |
8262 | @opindex mno-align-double | |
8263 | Control whether GCC aligns @code{double}, @code{long double}, and | |
8264 | @code{long long} variables on a two word boundary or a one word | |
8265 | boundary. Aligning @code{double} variables on a two word boundary will | |
8266 | produce code that runs somewhat faster on a @samp{Pentium} at the | |
8267 | expense of more memory. | |
5a4b3afd | 8268 | |
39bc1876 NS |
8269 | @strong{Warning:} if you use the @option{-malign-double} switch, |
8270 | structures containing the above types will be aligned differently than | |
8271 | the published application binary interface specifications for the 386 | |
8272 | and will not be binary compatible with structures in code compiled | |
8273 | without that switch. | |
5a4b3afd | 8274 | |
39bc1876 NS |
8275 | @item -m96bit-long-double |
8276 | @itemx -m128bit-long-double | |
8277 | @opindex m96bit-long-double | |
8278 | @opindex m128bit-long-double | |
8279 | These switches control the size of @code{long double} type. The i386 | |
8280 | application binary interface specifies the size to be 96 bits, | |
8281 | so @option{-m96bit-long-double} is the default in 32 bit mode. | |
5a4b3afd | 8282 | |
39bc1876 NS |
8283 | Modern architectures (Pentium and newer) would prefer @code{long double} |
8284 | to be aligned to an 8 or 16 byte boundary. In arrays or structures | |
8285 | conforming to the ABI, this would not be possible. So specifying a | |
8286 | @option{-m128bit-long-double} will align @code{long double} | |
8287 | to a 16 byte boundary by padding the @code{long double} with an additional | |
8288 | 32 bit zero. | |
5a4b3afd | 8289 | |
39bc1876 NS |
8290 | In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as |
8291 | its ABI specifies that @code{long double} is to be aligned on 16 byte boundary. | |
5a4b3afd | 8292 | |
39bc1876 NS |
8293 | Notice that neither of these options enable any extra precision over the x87 |
8294 | standard of 80 bits for a @code{long double}. | |
5a4b3afd | 8295 | |
39bc1876 NS |
8296 | @strong{Warning:} if you override the default value for your target ABI, the |
8297 | structures and arrays containing @code{long double} variables will change | |
8298 | their size as well as function calling convention for function taking | |
8299 | @code{long double} will be modified. Hence they will not be binary | |
8300 | compatible with arrays or structures in code compiled without that switch. | |
5a4b3afd | 8301 | |
5a4b3afd | 8302 | |
39bc1876 NS |
8303 | @item -msvr3-shlib |
8304 | @itemx -mno-svr3-shlib | |
8305 | @opindex msvr3-shlib | |
8306 | @opindex mno-svr3-shlib | |
8307 | Control whether GCC places uninitialized local variables into the | |
8308 | @code{bss} or @code{data} segments. @option{-msvr3-shlib} places them | |
8309 | into @code{bss}. These options are meaningful only on System V Release 3. | |
5a4b3afd | 8310 | |
39bc1876 NS |
8311 | @item -mrtd |
8312 | @opindex mrtd | |
8313 | Use a different function-calling convention, in which functions that | |
8314 | take a fixed number of arguments return with the @code{ret} @var{num} | |
8315 | instruction, which pops their arguments while returning. This saves one | |
8316 | instruction in the caller since there is no need to pop the arguments | |
8317 | there. | |
5a4b3afd | 8318 | |
39bc1876 NS |
8319 | You can specify that an individual function is called with this calling |
8320 | sequence with the function attribute @samp{stdcall}. You can also | |
8321 | override the @option{-mrtd} option by using the function attribute | |
8322 | @samp{cdecl}. @xref{Function Attributes}. | |
74291a4b | 8323 | |
39bc1876 NS |
8324 | @strong{Warning:} this calling convention is incompatible with the one |
8325 | normally used on Unix, so you cannot use it if you need to call | |
8326 | libraries compiled with the Unix compiler. | |
74291a4b | 8327 | |
39bc1876 NS |
8328 | Also, you must provide function prototypes for all functions that |
8329 | take variable numbers of arguments (including @code{printf}); | |
8330 | otherwise incorrect code will be generated for calls to those | |
8331 | functions. | |
02f52e19 | 8332 | |
39bc1876 NS |
8333 | In addition, seriously incorrect code will result if you call a |
8334 | function with too many arguments. (Normally, extra arguments are | |
8335 | harmlessly ignored.) | |
1cf959cb | 8336 | |
39bc1876 NS |
8337 | @item -mregparm=@var{num} |
8338 | @opindex mregparm | |
8339 | Control how many registers are used to pass integer arguments. By | |
8340 | default, no registers are used to pass arguments, and at most 3 | |
8341 | registers can be used. You can control this behavior for a specific | |
8342 | function by using the function attribute @samp{regparm}. | |
8343 | @xref{Function Attributes}. | |
1cf959cb | 8344 | |
39bc1876 NS |
8345 | @strong{Warning:} if you use this switch, and |
8346 | @var{num} is nonzero, then you must build all modules with the same | |
8347 | value, including any libraries. This includes the system libraries and | |
8348 | startup modules. | |
5a4b3afd | 8349 | |
39bc1876 NS |
8350 | @item -mpreferred-stack-boundary=@var{num} |
8351 | @opindex mpreferred-stack-boundary | |
8352 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} | |
8353 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
8354 | the default is 4 (16 bytes or 128 bits), except when optimizing for code | |
8355 | size (@option{-Os}), in which case the default is the minimum correct | |
8356 | alignment (4 bytes for x86, and 8 bytes for x86-64). | |
5a4b3afd | 8357 | |
39bc1876 NS |
8358 | On Pentium and PentiumPro, @code{double} and @code{long double} values |
8359 | should be aligned to an 8 byte boundary (see @option{-malign-double}) or | |
8360 | suffer significant run time performance penalties. On Pentium III, the | |
8361 | Streaming SIMD Extension (SSE) data type @code{__m128} suffers similar | |
8362 | penalties if it is not 16 byte aligned. | |
5a4b3afd | 8363 | |
39bc1876 NS |
8364 | To ensure proper alignment of this values on the stack, the stack boundary |
8365 | must be as aligned as that required by any value stored on the stack. | |
8366 | Further, every function must be generated such that it keeps the stack | |
8367 | aligned. Thus calling a function compiled with a higher preferred | |
8368 | stack boundary from a function compiled with a lower preferred stack | |
8369 | boundary will most likely misalign the stack. It is recommended that | |
8370 | libraries that use callbacks always use the default setting. | |
5a4b3afd | 8371 | |
39bc1876 NS |
8372 | This extra alignment does consume extra stack space, and generally |
8373 | increases code size. Code that is sensitive to stack space usage, such | |
8374 | as embedded systems and operating system kernels, may want to reduce the | |
8375 | preferred alignment to @option{-mpreferred-stack-boundary=2}. | |
5a4b3afd | 8376 | |
39bc1876 NS |
8377 | @item -mmmx |
8378 | @itemx -mno-mmx | |
8379 | @item -msse | |
8380 | @itemx -mno-sse | |
8381 | @item -msse2 | |
8382 | @itemx -mno-sse2 | |
8383 | @item -msse3 | |
8384 | @itemx -mno-sse3 | |
8385 | @item -m3dnow | |
8386 | @itemx -mno-3dnow | |
8387 | @opindex mmmx | |
8388 | @opindex mno-mmx | |
8389 | @opindex msse | |
8390 | @opindex mno-sse | |
8391 | @opindex m3dnow | |
8392 | @opindex mno-3dnow | |
8393 | These switches enable or disable the use of built-in functions that allow | |
8394 | direct access to the MMX, SSE, SSE2, SSE3 and 3Dnow extensions of the | |
8395 | instruction set. | |
74291a4b | 8396 | |
39bc1876 NS |
8397 | @xref{X86 Built-in Functions}, for details of the functions enabled |
8398 | and disabled by these switches. | |
74291a4b | 8399 | |
39bc1876 NS |
8400 | To have SSE/SSE2 instructions generated automatically from floating-point |
8401 | code, see @option{-mfpmath=sse}. | |
74291a4b | 8402 | |
39bc1876 NS |
8403 | @item -mpush-args |
8404 | @itemx -mno-push-args | |
8405 | @opindex mpush-args | |
8406 | @opindex mno-push-args | |
8407 | Use PUSH operations to store outgoing parameters. This method is shorter | |
8408 | and usually equally fast as method using SUB/MOV operations and is enabled | |
8409 | by default. In some cases disabling it may improve performance because of | |
8410 | improved scheduling and reduced dependencies. | |
74291a4b | 8411 | |
39bc1876 NS |
8412 | @item -maccumulate-outgoing-args |
8413 | @opindex maccumulate-outgoing-args | |
8414 | If enabled, the maximum amount of space required for outgoing arguments will be | |
8415 | computed in the function prologue. This is faster on most modern CPUs | |
8416 | because of reduced dependencies, improved scheduling and reduced stack usage | |
8417 | when preferred stack boundary is not equal to 2. The drawback is a notable | |
8418 | increase in code size. This switch implies @option{-mno-push-args}. | |
63357d93 | 8419 | |
39bc1876 NS |
8420 | @item -mthreads |
8421 | @opindex mthreads | |
8422 | Support thread-safe exception handling on @samp{Mingw32}. Code that relies | |
8423 | on thread-safe exception handling must compile and link all code with the | |
8424 | @option{-mthreads} option. When compiling, @option{-mthreads} defines | |
8425 | @option{-D_MT}; when linking, it links in a special thread helper library | |
8426 | @option{-lmingwthrd} which cleans up per thread exception handling data. | |
5ef1a99d | 8427 | |
39bc1876 NS |
8428 | @item -mno-align-stringops |
8429 | @opindex mno-align-stringops | |
8430 | Do not align destination of inlined string operations. This switch reduces | |
8431 | code size and improves performance in case the destination is already aligned, | |
8432 | but GCC doesn't know about it. | |
46490403 | 8433 | |
39bc1876 NS |
8434 | @item -minline-all-stringops |
8435 | @opindex minline-all-stringops | |
8436 | By default GCC inlines string operations only when destination is known to be | |
8437 | aligned at least to 4 byte boundary. This enables more inlining, increase code | |
8438 | size, but may improve performance of code that depends on fast memcpy, strlen | |
8439 | and memset for short lengths. | |
c235ddf2 | 8440 | |
39bc1876 NS |
8441 | @item -momit-leaf-frame-pointer |
8442 | @opindex momit-leaf-frame-pointer | |
8443 | Don't keep the frame pointer in a register for leaf functions. This | |
8444 | avoids the instructions to save, set up and restore frame pointers and | |
8445 | makes an extra register available in leaf functions. The option | |
8446 | @option{-fomit-frame-pointer} removes the frame pointer for all functions | |
8447 | which might make debugging harder. | |
c235ddf2 | 8448 | |
39bc1876 NS |
8449 | @item -mtls-direct-seg-refs |
8450 | @itemx -mno-tls-direct-seg-refs | |
8451 | @opindex mtls-direct-seg-refs | |
8452 | Controls whether TLS variables may be accessed with offsets from the | |
8453 | TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit), | |
8454 | or whether the thread base pointer must be added. Whether or not this | |
8455 | is legal depends on the operating system, and whether it maps the | |
8456 | segment to cover the entire TLS area. | |
beadc644 | 8457 | |
39bc1876 NS |
8458 | For systems that use GNU libc, the default is on. |
8459 | @end table | |
af34e51e | 8460 | |
39bc1876 NS |
8461 | These @samp{-m} switches are supported in addition to the above |
8462 | on AMD x86-64 processors in 64-bit environments. | |
50d32cf6 | 8463 | |
39bc1876 NS |
8464 | @table @gcctabopt |
8465 | @item -m32 | |
8466 | @itemx -m64 | |
8467 | @opindex m32 | |
8468 | @opindex m64 | |
8469 | Generate code for a 32-bit or 64-bit environment. | |
8470 | The 32-bit environment sets int, long and pointer to 32 bits and | |
8471 | generates code that runs on any i386 system. | |
8472 | The 64-bit environment sets int to 32 bits and long and pointer | |
8473 | to 64 bits and generates code for AMD's x86-64 architecture. | |
50d32cf6 | 8474 | |
39bc1876 NS |
8475 | @item -mno-red-zone |
8476 | @opindex no-red-zone | |
8477 | Do not use a so called red zone for x86-64 code. The red zone is mandated | |
8478 | by the x86-64 ABI, it is a 128-byte area beyond the location of the | |
8479 | stack pointer that will not be modified by signal or interrupt handlers | |
8480 | and therefore can be used for temporary data without adjusting the stack | |
8481 | pointer. The flag @option{-mno-red-zone} disables this red zone. | |
dc884a86 | 8482 | |
39bc1876 NS |
8483 | @item -mcmodel=small |
8484 | @opindex mcmodel=small | |
8485 | Generate code for the small code model: the program and its symbols must | |
8486 | be linked in the lower 2 GB of the address space. Pointers are 64 bits. | |
8487 | Programs can be statically or dynamically linked. This is the default | |
8488 | code model. | |
dc884a86 | 8489 | |
39bc1876 NS |
8490 | @item -mcmodel=kernel |
8491 | @opindex mcmodel=kernel | |
8492 | Generate code for the kernel code model. The kernel runs in the | |
8493 | negative 2 GB of the address space. | |
8494 | This model has to be used for Linux kernel code. | |
8495 | ||
8496 | @item -mcmodel=medium | |
8497 | @opindex mcmodel=medium | |
8498 | Generate code for the medium model: The program is linked in the lower 2 | |
8499 | GB of the address space but symbols can be located anywhere in the | |
8500 | address space. Programs can be statically or dynamically linked, but | |
8501 | building of shared libraries are not supported with the medium model. | |
8502 | ||
8503 | @item -mcmodel=large | |
8504 | @opindex mcmodel=large | |
8505 | Generate code for the large model: This model makes no assumptions | |
8506 | about addresses and sizes of sections. Currently GCC does not implement | |
8507 | this model. | |
74291a4b MM |
8508 | @end table |
8509 | ||
39bc1876 NS |
8510 | @node IA-64 Options |
8511 | @subsection IA-64 Options | |
8512 | @cindex IA-64 Options | |
74291a4b | 8513 | |
39bc1876 | 8514 | These are the @samp{-m} options defined for the Intel IA-64 architecture. |
74291a4b | 8515 | |
2642624b | 8516 | @table @gcctabopt |
39bc1876 NS |
8517 | @item -mbig-endian |
8518 | @opindex mbig-endian | |
8519 | Generate code for a big endian target. This is the default for HP-UX@. | |
6f670fde | 8520 | |
39bc1876 NS |
8521 | @item -mlittle-endian |
8522 | @opindex mlittle-endian | |
8523 | Generate code for a little endian target. This is the default for AIX5 | |
8524 | and GNU/Linux. | |
a9f3e1a4 | 8525 | |
39bc1876 NS |
8526 | @item -mgnu-as |
8527 | @itemx -mno-gnu-as | |
8528 | @opindex mgnu-as | |
8529 | @opindex mno-gnu-as | |
8530 | Generate (or don't) code for the GNU assembler. This is the default. | |
8531 | @c Also, this is the default if the configure option @option{--with-gnu-as} | |
8532 | @c is used. | |
9d913bbf | 8533 | |
39bc1876 NS |
8534 | @item -mgnu-ld |
8535 | @itemx -mno-gnu-ld | |
8536 | @opindex mgnu-ld | |
8537 | @opindex mno-gnu-ld | |
8538 | Generate (or don't) code for the GNU linker. This is the default. | |
8539 | @c Also, this is the default if the configure option @option{--with-gnu-ld} | |
8540 | @c is used. | |
a9f3e1a4 | 8541 | |
39bc1876 NS |
8542 | @item -mno-pic |
8543 | @opindex mno-pic | |
8544 | Generate code that does not use a global pointer register. The result | |
8545 | is not position independent code, and violates the IA-64 ABI@. | |
74291a4b | 8546 | |
39bc1876 NS |
8547 | @item -mvolatile-asm-stop |
8548 | @itemx -mno-volatile-asm-stop | |
8549 | @opindex mvolatile-asm-stop | |
8550 | @opindex mno-volatile-asm-stop | |
8551 | Generate (or don't) a stop bit immediately before and after volatile asm | |
8552 | statements. | |
965f5423 | 8553 | |
39bc1876 NS |
8554 | @item -mb-step |
8555 | @opindex mb-step | |
8556 | Generate code that works around Itanium B step errata. | |
965f5423 | 8557 | |
39bc1876 NS |
8558 | @item -mregister-names |
8559 | @itemx -mno-register-names | |
8560 | @opindex mregister-names | |
8561 | @opindex mno-register-names | |
8562 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for | |
8563 | the stacked registers. This may make assembler output more readable. | |
965f5423 | 8564 | |
39bc1876 NS |
8565 | @item -mno-sdata |
8566 | @itemx -msdata | |
8567 | @opindex mno-sdata | |
8568 | @opindex msdata | |
8569 | Disable (or enable) optimizations that use the small data section. This may | |
8570 | be useful for working around optimizer bugs. | |
8571 | ||
8572 | @item -mconstant-gp | |
8573 | @opindex mconstant-gp | |
8574 | Generate code that uses a single constant global pointer value. This is | |
8575 | useful when compiling kernel code. | |
8576 | ||
8577 | @item -mauto-pic | |
8578 | @opindex mauto-pic | |
8579 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. | |
8580 | This is useful when compiling firmware code. | |
8581 | ||
8582 | @item -minline-float-divide-min-latency | |
8583 | @opindex minline-float-divide-min-latency | |
8584 | Generate code for inline divides of floating point values | |
8585 | using the minimum latency algorithm. | |
965f5423 | 8586 | |
39bc1876 NS |
8587 | @item -minline-float-divide-max-throughput |
8588 | @opindex minline-float-divide-max-throughput | |
8589 | Generate code for inline divides of floating point values | |
8590 | using the maximum throughput algorithm. | |
965f5423 | 8591 | |
39bc1876 NS |
8592 | @item -minline-int-divide-min-latency |
8593 | @opindex minline-int-divide-min-latency | |
8594 | Generate code for inline divides of integer values | |
8595 | using the minimum latency algorithm. | |
965f5423 | 8596 | |
39bc1876 NS |
8597 | @item -minline-int-divide-max-throughput |
8598 | @opindex minline-int-divide-max-throughput | |
8599 | Generate code for inline divides of integer values | |
8600 | using the maximum throughput algorithm. | |
965f5423 | 8601 | |
39bc1876 NS |
8602 | @item -mno-dwarf2-asm |
8603 | @itemx -mdwarf2-asm | |
8604 | @opindex mno-dwarf2-asm | |
8605 | @opindex mdwarf2-asm | |
8606 | Don't (or do) generate assembler code for the DWARF2 line number debugging | |
8607 | info. This may be useful when not using the GNU assembler. | |
965f5423 | 8608 | |
39bc1876 NS |
8609 | @item -mfixed-range=@var{register-range} |
8610 | @opindex mfixed-range | |
8611 | Generate code treating the given register range as fixed registers. | |
8612 | A fixed register is one that the register allocator can not use. This is | |
8613 | useful when compiling kernel code. A register range is specified as | |
8614 | two registers separated by a dash. Multiple register ranges can be | |
8615 | specified separated by a comma. | |
04e149ab | 8616 | |
39bc1876 NS |
8617 | @item -mearly-stop-bits |
8618 | @itemx -mno-early-stop-bits | |
8619 | @opindex mearly-stop-bits | |
8620 | @opindex mno-early-stop-bits | |
8621 | Allow stop bits to be placed earlier than immediately preceding the | |
8622 | instruction that triggered the stop bit. This can improve instruction | |
8623 | scheduling, but does not always do so. | |
8624 | @end table | |
74291a4b | 8625 | |
39bc1876 NS |
8626 | @node M32R/D Options |
8627 | @subsection M32R/D Options | |
8628 | @cindex M32R/D options | |
74291a4b | 8629 | |
39bc1876 | 8630 | These @option{-m} options are defined for Renesas M32R/D architectures: |
74291a4b | 8631 | |
39bc1876 NS |
8632 | @table @gcctabopt |
8633 | @item -m32r2 | |
8634 | @opindex m32r2 | |
8635 | Generate code for the M32R/2@. | |
74291a4b | 8636 | |
39bc1876 NS |
8637 | @item -m32rx |
8638 | @opindex m32rx | |
8639 | Generate code for the M32R/X@. | |
74291a4b | 8640 | |
39bc1876 NS |
8641 | @item -m32r |
8642 | @opindex m32r | |
8643 | Generate code for the M32R@. This is the default. | |
74291a4b | 8644 | |
39bc1876 NS |
8645 | @item -mmodel=small |
8646 | @opindex mmodel=small | |
8647 | Assume all objects live in the lower 16MB of memory (so that their addresses | |
8648 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
8649 | are reachable with the @code{bl} instruction. | |
8650 | This is the default. | |
74291a4b | 8651 | |
39bc1876 NS |
8652 | The addressability of a particular object can be set with the |
8653 | @code{model} attribute. | |
74291a4b | 8654 | |
39bc1876 NS |
8655 | @item -mmodel=medium |
8656 | @opindex mmodel=medium | |
8657 | Assume objects may be anywhere in the 32-bit address space (the compiler | |
8658 | will generate @code{seth/add3} instructions to load their addresses), and | |
8659 | assume all subroutines are reachable with the @code{bl} instruction. | |
194734e9 | 8660 | |
39bc1876 NS |
8661 | @item -mmodel=large |
8662 | @opindex mmodel=large | |
8663 | Assume objects may be anywhere in the 32-bit address space (the compiler | |
8664 | will generate @code{seth/add3} instructions to load their addresses), and | |
8665 | assume subroutines may not be reachable with the @code{bl} instruction | |
8666 | (the compiler will generate the much slower @code{seth/add3/jl} | |
8667 | instruction sequence). | |
a5f3dd66 | 8668 | |
39bc1876 NS |
8669 | @item -msdata=none |
8670 | @opindex msdata=none | |
8671 | Disable use of the small data area. Variables will be put into | |
8672 | one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the | |
8673 | @code{section} attribute has been specified). | |
8674 | This is the default. | |
a5f3dd66 | 8675 | |
39bc1876 NS |
8676 | The small data area consists of sections @samp{.sdata} and @samp{.sbss}. |
8677 | Objects may be explicitly put in the small data area with the | |
8678 | @code{section} attribute using one of these sections. | |
daf2f129 | 8679 | |
39bc1876 NS |
8680 | @item -msdata=sdata |
8681 | @opindex msdata=sdata | |
8682 | Put small global and static data in the small data area, but do not | |
8683 | generate special code to reference them. | |
2b589241 | 8684 | |
39bc1876 NS |
8685 | @item -msdata=use |
8686 | @opindex msdata=use | |
8687 | Put small global and static data in the small data area, and generate | |
8688 | special instructions to reference them. | |
2b589241 | 8689 | |
39bc1876 NS |
8690 | @item -G @var{num} |
8691 | @opindex G | |
8692 | @cindex smaller data references | |
8693 | Put global and static objects less than or equal to @var{num} bytes | |
8694 | into the small data or bss sections instead of the normal data or bss | |
8695 | sections. The default value of @var{num} is 8. | |
8696 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
8697 | for this option to have any effect. | |
74291a4b | 8698 | |
39bc1876 NS |
8699 | All modules should be compiled with the same @option{-G @var{num}} value. |
8700 | Compiling with different values of @var{num} may or may not work; if it | |
8701 | doesn't the linker will give an error message---incorrect code will not be | |
8702 | generated. | |
74291a4b | 8703 | |
39bc1876 NS |
8704 | @item -mdebug |
8705 | @opindex mdebug | |
8706 | Makes the M32R specific code in the compiler display some statistics | |
8707 | that might help in debugging programs. | |
74291a4b | 8708 | |
39bc1876 NS |
8709 | @item -malign-loops |
8710 | @opindex malign-loops | |
8711 | Align all loops to a 32-byte boundary. | |
74291a4b | 8712 | |
39bc1876 NS |
8713 | @item -mno-align-loops |
8714 | @opindex mno-align-loops | |
8715 | Do not enforce a 32-byte alignment for loops. This is the default. | |
74291a4b | 8716 | |
39bc1876 NS |
8717 | @item -missue-rate=@var{number} |
8718 | @opindex missue-rate=@var{number} | |
8719 | Issue @var{number} instructions per cycle. @var{number} can only be 1 | |
8720 | or 2. | |
74291a4b | 8721 | |
39bc1876 NS |
8722 | @item -mbranch-cost=@var{number} |
8723 | @opindex mbranch-cost=@var{number} | |
8724 | @var{number} can only be 1 or 2. If it is 1 then branches will be | |
8725 | preferred over conditional code, if it is 2, then the opposite will | |
8726 | apply. | |
74291a4b | 8727 | |
39bc1876 NS |
8728 | @item -mflush-trap=@var{number} |
8729 | @opindex mflush-trap=@var{number} | |
8730 | Specifies the trap number to use to flush the cache. The default is | |
8731 | 12. Valid numbers are between 0 and 15 inclusive. | |
74291a4b | 8732 | |
39bc1876 NS |
8733 | @item -mno-flush-trap |
8734 | @opindex mno-flush-trap | |
8735 | Specifies that the cache cannot be flushed by using a trap. | |
74291a4b | 8736 | |
39bc1876 NS |
8737 | @item -mflush-func=@var{name} |
8738 | @opindex mflush-func=@var{name} | |
8739 | Specifies the name of the operating system function to call to flush | |
8740 | the cache. The default is @emph{_flush_cache}, but a function call | |
8741 | will only be used if a trap is not available. | |
3af4bd89 | 8742 | |
39bc1876 NS |
8743 | @item -mno-flush-func |
8744 | @opindex mno-flush-func | |
8745 | Indicates that there is no OS function for flushing the cache. | |
3af4bd89 | 8746 | |
39bc1876 | 8747 | @end table |
3af4bd89 | 8748 | |
39bc1876 NS |
8749 | @node M680x0 Options |
8750 | @subsection M680x0 Options | |
8751 | @cindex M680x0 options | |
f22a97d2 | 8752 | |
39bc1876 NS |
8753 | These are the @samp{-m} options defined for the 68000 series. The default |
8754 | values for these options depends on which style of 68000 was selected when | |
8755 | the compiler was configured; the defaults for the most common choices are | |
8756 | given below. | |
1255c85c | 8757 | |
39bc1876 NS |
8758 | @table @gcctabopt |
8759 | @item -m68000 | |
8760 | @itemx -mc68000 | |
8761 | @opindex m68000 | |
8762 | @opindex mc68000 | |
8763 | Generate output for a 68000. This is the default | |
8764 | when the compiler is configured for 68000-based systems. | |
1255c85c | 8765 | |
39bc1876 NS |
8766 | Use this option for microcontrollers with a 68000 or EC000 core, |
8767 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
7eafc329 | 8768 | |
39bc1876 NS |
8769 | @item -m68020 |
8770 | @itemx -mc68020 | |
8771 | @opindex m68020 | |
8772 | @opindex mc68020 | |
8773 | Generate output for a 68020. This is the default | |
8774 | when the compiler is configured for 68020-based systems. | |
f73ad30e | 8775 | |
39bc1876 NS |
8776 | @item -m68881 |
8777 | @opindex m68881 | |
8778 | Generate output containing 68881 instructions for floating point. | |
8779 | This is the default for most 68020 systems unless @option{--nfp} was | |
8780 | specified when the compiler was configured. | |
f73ad30e | 8781 | |
39bc1876 NS |
8782 | @item -m68030 |
8783 | @opindex m68030 | |
8784 | Generate output for a 68030. This is the default when the compiler is | |
8785 | configured for 68030-based systems. | |
79f05c19 | 8786 | |
39bc1876 NS |
8787 | @item -m68040 |
8788 | @opindex m68040 | |
8789 | Generate output for a 68040. This is the default when the compiler is | |
8790 | configured for 68040-based systems. | |
79f05c19 | 8791 | |
39bc1876 NS |
8792 | This option inhibits the use of 68881/68882 instructions that have to be |
8793 | emulated by software on the 68040. Use this option if your 68040 does not | |
8794 | have code to emulate those instructions. | |
762e166b | 8795 | |
39bc1876 NS |
8796 | @item -m68060 |
8797 | @opindex m68060 | |
8798 | Generate output for a 68060. This is the default when the compiler is | |
8799 | configured for 68060-based systems. | |
74dc3e94 | 8800 | |
39bc1876 NS |
8801 | This option inhibits the use of 68020 and 68881/68882 instructions that |
8802 | have to be emulated by software on the 68060. Use this option if your 68060 | |
8803 | does not have code to emulate those instructions. | |
74dc3e94 | 8804 | |
39bc1876 NS |
8805 | @item -mcpu32 |
8806 | @opindex mcpu32 | |
8807 | Generate output for a CPU32. This is the default | |
8808 | when the compiler is configured for CPU32-based systems. | |
3af4bd89 | 8809 | |
39bc1876 NS |
8810 | Use this option for microcontrollers with a |
8811 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
8812 | 68336, 68340, 68341, 68349 and 68360. | |
14f73b5a | 8813 | |
39bc1876 NS |
8814 | @item -m5200 |
8815 | @opindex m5200 | |
8816 | Generate output for a 520X ``coldfire'' family cpu. This is the default | |
8817 | when the compiler is configured for 520X-based systems. | |
14f73b5a | 8818 | |
39bc1876 NS |
8819 | Use this option for microcontroller with a 5200 core, including |
8820 | the MCF5202, MCF5203, MCF5204 and MCF5202. | |
a7701995 | 8821 | |
a7701995 | 8822 | |
39bc1876 NS |
8823 | @item -m68020-40 |
8824 | @opindex m68020-40 | |
8825 | Generate output for a 68040, without using any of the new instructions. | |
8826 | This results in code which can run relatively efficiently on either a | |
8827 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
8828 | 68881 instructions that are emulated on the 68040. | |
a7701995 | 8829 | |
39bc1876 NS |
8830 | @item -m68020-60 |
8831 | @opindex m68020-60 | |
8832 | Generate output for a 68060, without using any of the new instructions. | |
8833 | This results in code which can run relatively efficiently on either a | |
8834 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
8835 | 68881 instructions that are emulated on the 68060. | |
a7701995 | 8836 | |
39bc1876 NS |
8837 | @item -msoft-float |
8838 | @opindex msoft-float | |
8839 | Generate output containing library calls for floating point. | |
8840 | @strong{Warning:} the requisite libraries are not available for all m68k | |
8841 | targets. Normally the facilities of the machine's usual C compiler are | |
8842 | used, but this can't be done directly in cross-compilation. You must | |
8843 | make your own arrangements to provide suitable library functions for | |
8844 | cross-compilation. The embedded targets @samp{m68k-*-aout} and | |
8845 | @samp{m68k-*-coff} do provide software floating point support. | |
14f73b5a | 8846 | |
39bc1876 NS |
8847 | @item -mshort |
8848 | @opindex mshort | |
8849 | Consider type @code{int} to be 16 bits wide, like @code{short int}. | |
8850 | Additionally, parameters passed on the stack are also aligned to a | |
8851 | 16-bit boundary even on targets whose API mandates promotion to 32-bit. | |
74291a4b | 8852 | |
39bc1876 NS |
8853 | @item -mnobitfield |
8854 | @opindex mnobitfield | |
8855 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} | |
8856 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
74291a4b | 8857 | |
39bc1876 NS |
8858 | @item -mbitfield |
8859 | @opindex mbitfield | |
8860 | Do use the bit-field instructions. The @option{-m68020} option implies | |
8861 | @option{-mbitfield}. This is the default if you use a configuration | |
8862 | designed for a 68020. | |
8863 | ||
8864 | @item -mrtd | |
8865 | @opindex mrtd | |
8866 | Use a different function-calling convention, in which functions | |
8867 | that take a fixed number of arguments return with the @code{rtd} | |
8868 | instruction, which pops their arguments while returning. This | |
8869 | saves one instruction in the caller since there is no need to pop | |
8870 | the arguments there. | |
ea3bfbfe | 8871 | |
39bc1876 NS |
8872 | This calling convention is incompatible with the one normally |
8873 | used on Unix, so you cannot use it if you need to call libraries | |
8874 | compiled with the Unix compiler. | |
74291a4b | 8875 | |
39bc1876 NS |
8876 | Also, you must provide function prototypes for all functions that |
8877 | take variable numbers of arguments (including @code{printf}); | |
8878 | otherwise incorrect code will be generated for calls to those | |
8879 | functions. | |
861bb6c1 | 8880 | |
39bc1876 NS |
8881 | In addition, seriously incorrect code will result if you call a |
8882 | function with too many arguments. (Normally, extra arguments are | |
8883 | harmlessly ignored.) | |
74291a4b | 8884 | |
39bc1876 NS |
8885 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, |
8886 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. | |
74291a4b | 8887 | |
39bc1876 NS |
8888 | @item -malign-int |
8889 | @itemx -mno-align-int | |
8890 | @opindex malign-int | |
8891 | @opindex mno-align-int | |
8892 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, | |
8893 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
8894 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). | |
8895 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
8896 | faster on processors with 32-bit busses at the expense of more memory. | |
74291a4b | 8897 | |
39bc1876 NS |
8898 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC will |
8899 | align structures containing the above types differently than | |
8900 | most published application binary interface specifications for the m68k. | |
74291a4b | 8901 | |
39bc1876 NS |
8902 | @item -mpcrel |
8903 | @opindex mpcrel | |
8904 | Use the pc-relative addressing mode of the 68000 directly, instead of | |
8905 | using a global offset table. At present, this option implies @option{-fpic}, | |
8906 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
8907 | not presently supported with @option{-mpcrel}, though this could be supported for | |
8908 | 68020 and higher processors. | |
74291a4b | 8909 | |
39bc1876 NS |
8910 | @item -mno-strict-align |
8911 | @itemx -mstrict-align | |
8912 | @opindex mno-strict-align | |
8913 | @opindex mstrict-align | |
8914 | Do not (do) assume that unaligned memory references will be handled by | |
8915 | the system. | |
74291a4b | 8916 | |
39bc1876 NS |
8917 | @item -msep-data |
8918 | Generate code that allows the data segment to be located in a different | |
8919 | area of memory from the text segment. This allows for execute in place in | |
8920 | an environment without virtual memory management. This option implies -fPIC. | |
74291a4b | 8921 | |
39bc1876 NS |
8922 | @item -mno-sep-data |
8923 | Generate code that assumes that the data segment follows the text segment. | |
8924 | This is the default. | |
74291a4b | 8925 | |
39bc1876 NS |
8926 | @item -mid-shared-library |
8927 | Generate code that supports shared libraries via the library ID method. | |
8928 | This allows for execute in place and shared libraries in an environment | |
8929 | without virtual memory management. This option implies -fPIC. | |
74291a4b | 8930 | |
39bc1876 NS |
8931 | @item -mno-id-shared-library |
8932 | Generate code that doesn't assume ID based shared libraries are being used. | |
8933 | This is the default. | |
74291a4b | 8934 | |
39bc1876 NS |
8935 | @item -mshared-library-id=n |
8936 | Specified the identification number of the ID based shared library being | |
8937 | compiled. Specifying a value of 0 will generate more compact code, specifying | |
8938 | other values will force the allocation of that number to the current | |
8939 | library but is no more space or time efficient than omitting this option. | |
74291a4b | 8940 | |
39bc1876 | 8941 | @end table |
74291a4b | 8942 | |
39bc1876 NS |
8943 | @node M68hc1x Options |
8944 | @subsection M68hc1x Options | |
8945 | @cindex M68hc1x options | |
74291a4b | 8946 | |
39bc1876 NS |
8947 | These are the @samp{-m} options defined for the 68hc11 and 68hc12 |
8948 | microcontrollers. The default values for these options depends on | |
8949 | which style of microcontroller was selected when the compiler was configured; | |
8950 | the defaults for the most common choices are given below. | |
c219e1da | 8951 | |
39bc1876 NS |
8952 | @table @gcctabopt |
8953 | @item -m6811 | |
8954 | @itemx -m68hc11 | |
8955 | @opindex m6811 | |
8956 | @opindex m68hc11 | |
8957 | Generate output for a 68HC11. This is the default | |
8958 | when the compiler is configured for 68HC11-based systems. | |
c5d3d49b | 8959 | |
39bc1876 NS |
8960 | @item -m6812 |
8961 | @itemx -m68hc12 | |
8962 | @opindex m6812 | |
8963 | @opindex m68hc12 | |
8964 | Generate output for a 68HC12. This is the default | |
8965 | when the compiler is configured for 68HC12-based systems. | |
c5d3d49b | 8966 | |
39bc1876 NS |
8967 | @item -m68S12 |
8968 | @itemx -m68hcs12 | |
8969 | @opindex m68S12 | |
8970 | @opindex m68hcs12 | |
8971 | Generate output for a 68HCS12. | |
c5d3d49b | 8972 | |
39bc1876 NS |
8973 | @item -mauto-incdec |
8974 | @opindex mauto-incdec | |
8975 | Enable the use of 68HC12 pre and post auto-increment and auto-decrement | |
8976 | addressing modes. | |
34208acf | 8977 | |
39bc1876 NS |
8978 | @item -minmax |
8979 | @itemx -nominmax | |
8980 | @opindex minmax | |
8981 | @opindex mnominmax | |
8982 | Enable the use of 68HC12 min and max instructions. | |
34208acf | 8983 | |
39bc1876 NS |
8984 | @item -mlong-calls |
8985 | @itemx -mno-long-calls | |
8986 | @opindex mlong-calls | |
8987 | @opindex mno-long-calls | |
8988 | Treat all calls as being far away (near). If calls are assumed to be | |
8989 | far away, the compiler will use the @code{call} instruction to | |
8990 | call a function and the @code{rtc} instruction for returning. | |
34208acf | 8991 | |
39bc1876 NS |
8992 | @item -mshort |
8993 | @opindex mshort | |
8994 | Consider type @code{int} to be 16 bits wide, like @code{short int}. | |
34208acf | 8995 | |
39bc1876 NS |
8996 | @item -msoft-reg-count=@var{count} |
8997 | @opindex msoft-reg-count | |
8998 | Specify the number of pseudo-soft registers which are used for the | |
8999 | code generation. The maximum number is 32. Using more pseudo-soft | |
9000 | register may or may not result in better code depending on the program. | |
9001 | The default is 4 for 68HC11 and 2 for 68HC12. | |
34208acf | 9002 | |
39bc1876 | 9003 | @end table |
34208acf | 9004 | |
39bc1876 NS |
9005 | @node MCore Options |
9006 | @subsection MCore Options | |
9007 | @cindex MCore options | |
34208acf | 9008 | |
39bc1876 NS |
9009 | These are the @samp{-m} options defined for the Motorola M*Core |
9010 | processors. | |
34208acf | 9011 | |
39bc1876 | 9012 | @table @gcctabopt |
34208acf | 9013 | |
39bc1876 NS |
9014 | @item -mhardlit |
9015 | @itemx -mno-hardlit | |
9016 | @opindex mhardlit | |
9017 | @opindex mno-hardlit | |
9018 | Inline constants into the code stream if it can be done in two | |
9019 | instructions or less. | |
34208acf | 9020 | |
39bc1876 NS |
9021 | @item -mdiv |
9022 | @itemx -mno-div | |
9023 | @opindex mdiv | |
9024 | @opindex mno-div | |
9025 | Use the divide instruction. (Enabled by default). | |
a02aa5b0 | 9026 | |
39bc1876 NS |
9027 | @item -mrelax-immediate |
9028 | @itemx -mno-relax-immediate | |
9029 | @opindex mrelax-immediate | |
9030 | @opindex mno-relax-immediate | |
9031 | Allow arbitrary sized immediates in bit operations. | |
a02aa5b0 | 9032 | |
39bc1876 NS |
9033 | @item -mwide-bitfields |
9034 | @itemx -mno-wide-bitfields | |
9035 | @opindex mwide-bitfields | |
9036 | @opindex mno-wide-bitfields | |
9037 | Always treat bit-fields as int-sized. | |
a02aa5b0 | 9038 | |
39bc1876 NS |
9039 | @item -m4byte-functions |
9040 | @itemx -mno-4byte-functions | |
9041 | @opindex m4byte-functions | |
9042 | @opindex mno-4byte-functions | |
9043 | Force all functions to be aligned to a four byte boundary. | |
a02aa5b0 | 9044 | |
39bc1876 NS |
9045 | @item -mcallgraph-data |
9046 | @itemx -mno-callgraph-data | |
9047 | @opindex mcallgraph-data | |
9048 | @opindex mno-callgraph-data | |
9049 | Emit callgraph information. | |
f401d0f5 | 9050 | |
39bc1876 NS |
9051 | @item -mslow-bytes |
9052 | @itemx -mno-slow-bytes | |
9053 | @opindex mslow-bytes | |
9054 | @opindex mno-slow-bytes | |
9055 | Prefer word access when reading byte quantities. | |
f401d0f5 | 9056 | |
39bc1876 NS |
9057 | @item -mlittle-endian |
9058 | @itemx -mbig-endian | |
9059 | @opindex mlittle-endian | |
9060 | @opindex mbig-endian | |
9061 | Generate code for a little endian target. | |
f401d0f5 | 9062 | |
39bc1876 NS |
9063 | @item -m210 |
9064 | @itemx -m340 | |
9065 | @opindex m210 | |
9066 | @opindex m340 | |
9067 | Generate code for the 210 processor. | |
74291a4b MM |
9068 | @end table |
9069 | ||
39bc1876 NS |
9070 | @node MIPS Options |
9071 | @subsection MIPS Options | |
9072 | @cindex MIPS options | |
74291a4b | 9073 | |
2642624b | 9074 | @table @gcctabopt |
74291a4b | 9075 | |
39bc1876 NS |
9076 | @item -EB |
9077 | @opindex EB | |
9078 | Generate big-endian code. | |
74291a4b | 9079 | |
39bc1876 NS |
9080 | @item -EL |
9081 | @opindex EL | |
9082 | Generate little-endian code. This is the default for @samp{mips*el-*-*} | |
9083 | configurations. | |
74291a4b | 9084 | |
39bc1876 NS |
9085 | @item -march=@var{arch} |
9086 | @opindex march | |
9087 | Generate code that will run on @var{arch}, which can be the name of a | |
9088 | generic MIPS ISA, or the name of a particular processor. | |
9089 | The ISA names are: | |
9090 | @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4}, | |
9091 | @samp{mips32}, @samp{mips32r2}, and @samp{mips64}. | |
9092 | The processor names are: | |
9093 | @samp{4kc}, @samp{4kp}, @samp{5kc}, @samp{20kc}, | |
9094 | @samp{m4k}, | |
9095 | @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400}, | |
9096 | @samp{r4600}, @samp{r4650}, @samp{r6000}, @samp{r8000}, @samp{rm7000}, | |
9097 | @samp{rm9000}, | |
9098 | @samp{orion}, | |
9099 | @samp{sb1}, | |
9100 | @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300}, | |
9101 | @samp{vr5000}, @samp{vr5400} and @samp{vr5500}. | |
9102 | The special value @samp{from-abi} selects the | |
9103 | most compatible architecture for the selected ABI (that is, | |
9104 | @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. | |
74291a4b | 9105 | |
39bc1876 NS |
9106 | In processor names, a final @samp{000} can be abbreviated as @samp{k} |
9107 | (for example, @samp{-march=r2k}). Prefixes are optional, and | |
9108 | @samp{vr} may be written @samp{r}. | |
74291a4b | 9109 | |
39bc1876 NS |
9110 | GCC defines two macros based on the value of this option. The first |
9111 | is @samp{_MIPS_ARCH}, which gives the name of target architecture, as | |
9112 | a string. The second has the form @samp{_MIPS_ARCH_@var{foo}}, | |
9113 | where @var{foo} is the capitalized value of @samp{_MIPS_ARCH}@. | |
9114 | For example, @samp{-march=r2000} will set @samp{_MIPS_ARCH} | |
9115 | to @samp{"r2000"} and define the macro @samp{_MIPS_ARCH_R2000}. | |
74291a4b | 9116 | |
39bc1876 NS |
9117 | Note that the @samp{_MIPS_ARCH} macro uses the processor names given |
9118 | above. In other words, it will have the full prefix and will not | |
9119 | abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi}, | |
9120 | the macro names the resolved architecture (either @samp{"mips1"} or | |
9121 | @samp{"mips3"}). It names the default architecture when no | |
9122 | @option{-march} option is given. | |
74291a4b | 9123 | |
39bc1876 NS |
9124 | @item -mtune=@var{arch} |
9125 | @opindex mtune | |
9126 | Optimize for @var{arch}. Among other things, this option controls | |
9127 | the way instructions are scheduled, and the perceived cost of arithmetic | |
9128 | operations. The list of @var{arch} values is the same as for | |
9129 | @option{-march}. | |
74291a4b | 9130 | |
39bc1876 NS |
9131 | When this option is not used, GCC will optimize for the processor |
9132 | specified by @option{-march}. By using @option{-march} and | |
9133 | @option{-mtune} together, it is possible to generate code that will | |
9134 | run on a family of processors, but optimize the code for one | |
9135 | particular member of that family. | |
74291a4b | 9136 | |
39bc1876 NS |
9137 | @samp{-mtune} defines the macros @samp{_MIPS_TUNE} and |
9138 | @samp{_MIPS_TUNE_@var{foo}}, which work in the same way as the | |
9139 | @samp{-march} ones described above. | |
74291a4b | 9140 | |
39bc1876 NS |
9141 | @item -mips1 |
9142 | @opindex mips1 | |
9143 | Equivalent to @samp{-march=mips1}. | |
74291a4b | 9144 | |
39bc1876 NS |
9145 | @item -mips2 |
9146 | @opindex mips2 | |
9147 | Equivalent to @samp{-march=mips2}. | |
74291a4b | 9148 | |
39bc1876 NS |
9149 | @item -mips3 |
9150 | @opindex mips3 | |
9151 | Equivalent to @samp{-march=mips3}. | |
74291a4b | 9152 | |
39bc1876 NS |
9153 | @item -mips4 |
9154 | @opindex mips4 | |
9155 | Equivalent to @samp{-march=mips4}. | |
9156 | ||
9157 | @item -mips32 | |
9158 | @opindex mips32 | |
9159 | Equivalent to @samp{-march=mips32}. | |
74291a4b | 9160 | |
39bc1876 NS |
9161 | @item -mips32r2 |
9162 | @opindex mips32r2 | |
9163 | Equivalent to @samp{-march=mips32r2}. | |
74291a4b | 9164 | |
39bc1876 NS |
9165 | @item -mips64 |
9166 | @opindex mips64 | |
9167 | Equivalent to @samp{-march=mips64}. | |
74291a4b | 9168 | |
39bc1876 NS |
9169 | @item -mips16 |
9170 | @itemx -mno-mips16 | |
9171 | @opindex mips16 | |
9172 | @opindex mno-mips16 | |
9173 | Use (do not use) the MIPS16 ISA. | |
74291a4b | 9174 | |
39bc1876 NS |
9175 | @item -mabi=32 |
9176 | @itemx -mabi=o64 | |
9177 | @itemx -mabi=n32 | |
9178 | @itemx -mabi=64 | |
9179 | @itemx -mabi=eabi | |
9180 | @opindex mabi=32 | |
9181 | @opindex mabi=o64 | |
9182 | @opindex mabi=n32 | |
9183 | @opindex mabi=64 | |
9184 | @opindex mabi=eabi | |
9185 | Generate code for the given ABI@. | |
74291a4b | 9186 | |
39bc1876 NS |
9187 | Note that the EABI has a 32-bit and a 64-bit variant. GCC normally |
9188 | generates 64-bit code when you select a 64-bit architecture, but you | |
9189 | can use @option{-mgp32} to get 32-bit code instead. | |
74291a4b | 9190 | |
39bc1876 NS |
9191 | For information about the O64 ABI, see |
9192 | @w{@uref{http://gcc.gnu.org/projects/mipso64-abi.html}}. | |
74291a4b | 9193 | |
39bc1876 NS |
9194 | @item -mabicalls |
9195 | @itemx -mno-abicalls | |
9196 | @opindex mabicalls | |
9197 | @opindex mno-abicalls | |
9198 | Generate (do not generate) SVR4-style position-independent code. | |
9199 | @option{-mabicalls} is the default for SVR4-based systems. | |
74291a4b | 9200 | |
39bc1876 NS |
9201 | @item -mxgot |
9202 | @itemx -mno-xgot | |
9203 | @opindex mxgot | |
9204 | @opindex mno-xgot | |
9205 | Lift (do not lift) the usual restrictions on the size of the global | |
9206 | offset table. | |
74291a4b | 9207 | |
39bc1876 NS |
9208 | GCC normally uses a single instruction to load values from the GOT. |
9209 | While this is relatively efficient, it will only work if the GOT | |
9210 | is smaller than about 64k. Anything larger will cause the linker | |
9211 | to report an error such as: | |
74291a4b | 9212 | |
39bc1876 NS |
9213 | @cindex relocation truncated to fit (MIPS) |
9214 | @smallexample | |
9215 | relocation truncated to fit: R_MIPS_GOT16 foobar | |
9216 | @end smallexample | |
74291a4b | 9217 | |
39bc1876 NS |
9218 | If this happens, you should recompile your code with @option{-mxgot}. |
9219 | It should then work with very large GOTs, although it will also be | |
9220 | less efficient, since it will take three instructions to fetch the | |
9221 | value of a global symbol. | |
956d6950 | 9222 | |
39bc1876 NS |
9223 | Note that some linkers can create multiple GOTs. If you have such a |
9224 | linker, you should only need to use @option{-mxgot} when a single object | |
9225 | file accesses more than 64k's worth of GOT entries. Very few do. | |
956d6950 | 9226 | |
39bc1876 NS |
9227 | These options have no effect unless GCC is generating position |
9228 | independent code. | |
956d6950 | 9229 | |
39bc1876 NS |
9230 | @item -mgp32 |
9231 | @opindex mgp32 | |
9232 | Assume that general-purpose registers are 32 bits wide. | |
58605ba0 | 9233 | |
39bc1876 NS |
9234 | @item -mgp64 |
9235 | @opindex mgp64 | |
9236 | Assume that general-purpose registers are 64 bits wide. | |
58605ba0 | 9237 | |
39bc1876 NS |
9238 | @item -mfp32 |
9239 | @opindex mfp32 | |
9240 | Assume that floating-point registers are 32 bits wide. | |
58605ba0 | 9241 | |
39bc1876 NS |
9242 | @item -mfp64 |
9243 | @opindex mfp64 | |
9244 | Assume that floating-point registers are 64 bits wide. | |
58605ba0 | 9245 | |
39bc1876 NS |
9246 | @item -mhard-float |
9247 | @opindex mhard-float | |
9248 | Use floating-point coprocessor instructions. | |
58605ba0 | 9249 | |
39bc1876 NS |
9250 | @item -msoft-float |
9251 | @opindex msoft-float | |
9252 | Do not use floating-point coprocessor instructions. Implement | |
9253 | floating-point calculations using library calls instead. | |
3094247f | 9254 | |
39bc1876 NS |
9255 | @item -msingle-float |
9256 | @opindex msingle-float | |
9257 | Assume that the floating-point coprocessor only supports single-precision | |
9258 | operations. | |
3094247f | 9259 | |
39bc1876 NS |
9260 | @itemx -mdouble-float |
9261 | @opindex mdouble-float | |
9262 | Assume that the floating-point coprocessor supports double-precision | |
9263 | operations. This is the default. | |
956d6950 | 9264 | |
39bc1876 NS |
9265 | @item -mint64 |
9266 | @opindex mint64 | |
9267 | Force @code{int} and @code{long} types to be 64 bits wide. See | |
9268 | @option{-mlong32} for an explanation of the default and the way | |
9269 | that the pointer size is determined. | |
956d6950 | 9270 | |
39bc1876 NS |
9271 | @item -mlong64 |
9272 | @opindex mlong64 | |
9273 | Force @code{long} types to be 64 bits wide. See @option{-mlong32} for | |
9274 | an explanation of the default and the way that the pointer size is | |
9275 | determined. | |
956d6950 | 9276 | |
39bc1876 NS |
9277 | @item -mlong32 |
9278 | @opindex mlong32 | |
9279 | Force @code{long}, @code{int}, and pointer types to be 32 bits wide. | |
956d6950 | 9280 | |
39bc1876 NS |
9281 | The default size of @code{int}s, @code{long}s and pointers depends on |
9282 | the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI | |
9283 | uses 64-bit @code{long}s, as does the 64-bit EABI; the others use | |
9284 | 32-bit @code{long}s. Pointers are the same size as @code{long}s, | |
9285 | or the same size as integer registers, whichever is smaller. | |
956d6950 | 9286 | |
39bc1876 NS |
9287 | @item -G @var{num} |
9288 | @opindex G | |
9289 | @cindex smaller data references (MIPS) | |
9290 | @cindex gp-relative references (MIPS) | |
9291 | Put global and static items less than or equal to @var{num} bytes into | |
9292 | the small data or bss section instead of the normal data or bss section. | |
9293 | This allows the data to be accessed using a single instruction. | |
9294 | ||
9295 | All modules should be compiled with the same @option{-G @var{num}} | |
9296 | value. | |
956d6950 | 9297 | |
39bc1876 NS |
9298 | @item -membedded-data |
9299 | @itemx -mno-embedded-data | |
9300 | @opindex membedded-data | |
9301 | @opindex mno-embedded-data | |
9302 | Allocate variables to the read-only data section first if possible, then | |
9303 | next in the small data section if possible, otherwise in data. This gives | |
9304 | slightly slower code than the default, but reduces the amount of RAM required | |
9305 | when executing, and thus may be preferred for some embedded systems. | |
58605ba0 | 9306 | |
39bc1876 NS |
9307 | @item -muninit-const-in-rodata |
9308 | @itemx -mno-uninit-const-in-rodata | |
9309 | @opindex muninit-const-in-rodata | |
9310 | @opindex mno-uninit-const-in-rodata | |
9311 | Put uninitialized @code{const} variables in the read-only data section. | |
9312 | This option is only meaningful in conjunction with @option{-membedded-data}. | |
4f69985c | 9313 | |
39bc1876 NS |
9314 | @item -msplit-addresses |
9315 | @itemx -mno-split-addresses | |
9316 | @opindex msplit-addresses | |
9317 | @opindex mno-split-addresses | |
9318 | Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler | |
9319 | relocation operators. This option has been superceded by | |
9320 | @option{-mexplicit-relocs} but is retained for backwards compatibility. | |
58605ba0 | 9321 | |
39bc1876 NS |
9322 | @item -mexplicit-relocs |
9323 | @itemx -mno-explicit-relocs | |
9324 | @opindex mexplicit-relocs | |
9325 | @opindex mno-explicit-relocs | |
9326 | Use (do not use) assembler relocation operators when dealing with symbolic | |
9327 | addresses. The alternative, selected by @option{-mno-explicit-relocs}, | |
9328 | is to use assembler macros instead. | |
4f69985c | 9329 | |
12e4afe4 RS |
9330 | @option{-mexplicit-relocs} is the default if GCC was configured |
9331 | to use an assembler that supports relocation operators. | |
4f69985c | 9332 | |
39bc1876 NS |
9333 | @item -mcheck-zero-division |
9334 | @itemx -mno-check-zero-division | |
9335 | @opindex mcheck-zero-division | |
9336 | @opindex mno-check-zero-division | |
9337 | Trap (do not trap) on integer division by zero. The default is | |
9338 | @option{-mcheck-zero-division}. | |
4f69985c | 9339 | |
39bc1876 NS |
9340 | @item -mmemcpy |
9341 | @itemx -mno-memcpy | |
9342 | @opindex mmemcpy | |
9343 | @opindex mno-memcpy | |
9344 | Force (do not force) the use of @code{memcpy()} for non-trivial block | |
9345 | moves. The default is @option{-mno-memcpy}, which allows GCC to inline | |
9346 | most constant-sized copies. | |
74291a4b | 9347 | |
39bc1876 NS |
9348 | @item -mlong-calls |
9349 | @itemx -mno-long-calls | |
9350 | @opindex mlong-calls | |
9351 | @opindex mno-long-calls | |
9352 | Disable (do not disable) use of the @code{jal} instruction. Calling | |
9353 | functions using @code{jal} is more efficient but requires the caller | |
9354 | and callee to be in the same 256 megabyte segment. | |
d7c23cdc | 9355 | |
39bc1876 NS |
9356 | This option has no effect on abicalls code. The default is |
9357 | @option{-mno-long-calls}. | |
d7c23cdc | 9358 | |
39bc1876 NS |
9359 | @item -mmad |
9360 | @itemx -mno-mad | |
9361 | @opindex mmad | |
9362 | @opindex mno-mad | |
9363 | Enable (disable) use of the @code{mad}, @code{madu} and @code{mul} | |
9364 | instructions, as provided by the R4650 ISA. | |
d7c23cdc | 9365 | |
39bc1876 NS |
9366 | @item -mfused-madd |
9367 | @itemx -mno-fused-madd | |
9368 | @opindex mfused-madd | |
9369 | @opindex mno-fused-madd | |
9370 | Enable (disable) use of the floating point multiply-accumulate | |
9371 | instructions, when they are available. The default is | |
9372 | @option{-mfused-madd}. | |
74291a4b | 9373 | |
39bc1876 NS |
9374 | When multiply-accumulate instructions are used, the intermediate |
9375 | product is calculated to infinite precision and is not subject to | |
9376 | the FCSR Flush to Zero bit. This may be undesirable in some | |
9377 | circumstances. | |
74291a4b | 9378 | |
39bc1876 NS |
9379 | @item -nocpp |
9380 | @opindex nocpp | |
9381 | Tell the MIPS assembler to not run its preprocessor over user | |
9382 | assembler files (with a @samp{.s} suffix) when assembling them. | |
74291a4b | 9383 | |
39bc1876 NS |
9384 | @item -mfix-r4000 |
9385 | @itemx -mno-fix-r4000 | |
9386 | @opindex mfix-r4000 | |
9387 | @opindex mno-fix-r4000 | |
9388 | Work around certain R4000 CPU errata: | |
9389 | @itemize @minus | |
9390 | @item | |
9391 | A double-word or a variable shift may give an incorrect result if executed | |
9392 | immediately after starting an integer division. | |
9393 | @item | |
9394 | A double-word or a variable shift may give an incorrect result if executed | |
9395 | while an integer multiplication is in progress. | |
9396 | @item | |
9397 | An integer division may give an incorrect result if started in a delay slot | |
9398 | of a taken branch or a jump. | |
9399 | @end itemize | |
74291a4b | 9400 | |
39bc1876 NS |
9401 | @item -mfix-r4400 |
9402 | @itemx -mno-fix-r4400 | |
9403 | @opindex mfix-r4400 | |
9404 | @opindex mno-fix-r4400 | |
9405 | Work around certain R4400 CPU errata: | |
9406 | @itemize @minus | |
9407 | @item | |
9408 | A double-word or a variable shift may give an incorrect result if executed | |
9409 | immediately after starting an integer division. | |
9410 | @end itemize | |
dcb9d1f0 | 9411 | |
39bc1876 NS |
9412 | @item -mfix-vr4120 |
9413 | @itemx -mno-fix-vr4120 | |
9414 | @opindex mfix-vr4120 | |
9415 | Work around certain VR4120 errata: | |
9416 | @itemize @minus | |
9417 | @item | |
9418 | @code{dmultu} does not always produce the correct result. | |
9419 | @item | |
9420 | @code{div} and @code{ddiv} do not always produce the correct result if one | |
9421 | of the operands is negative. | |
9422 | @end itemize | |
9423 | The workarounds for the division errata rely on special functions in | |
9424 | @file{libgcc.a}. At present, these functions are only provided by | |
9425 | the @code{mips64vr*-elf} configurations. | |
39ba95b5 | 9426 | |
39bc1876 NS |
9427 | Other VR4120 errata require a nop to be inserted between certain pairs of |
9428 | instructions. These errata are handled by the assembler, not by GCC itself. | |
17f0f8fa | 9429 | |
39bc1876 NS |
9430 | @item -mfix-sb1 |
9431 | @itemx -mno-fix-sb1 | |
9432 | @opindex mfix-sb1 | |
9433 | Work around certain SB-1 CPU core errata. | |
9434 | (This flag currently works around the SB-1 revision 2 | |
9435 | ``F1'' and ``F2'' floating point errata.) | |
74291a4b | 9436 | |
39bc1876 NS |
9437 | @item -mflush-func=@var{func} |
9438 | @itemx -mno-flush-func | |
9439 | @opindex mflush-func | |
9440 | Specifies the function to call to flush the I and D caches, or to not | |
9441 | call any such function. If called, the function must take the same | |
9442 | arguments as the common @code{_flush_func()}, that is, the address of the | |
9443 | memory range for which the cache is being flushed, the size of the | |
9444 | memory range, and the number 3 (to flush both caches). The default | |
9445 | depends on the target GCC was configured for, but commonly is either | |
9446 | @samp{_flush_func} or @samp{__cpu_flush}. | |
74291a4b | 9447 | |
39bc1876 NS |
9448 | @item -mbranch-likely |
9449 | @itemx -mno-branch-likely | |
9450 | @opindex mbranch-likely | |
9451 | @opindex mno-branch-likely | |
9452 | Enable or disable use of Branch Likely instructions, regardless of the | |
9453 | default for the selected architecture. By default, Branch Likely | |
9454 | instructions may be generated if they are supported by the selected | |
9455 | architecture. An exception is for the MIPS32 and MIPS64 architectures | |
9456 | and processors which implement those architectures; for those, Branch | |
9457 | Likely instructions will not be generated by default because the MIPS32 | |
9458 | and MIPS64 architectures specifically deprecate their use. | |
74291a4b | 9459 | |
39bc1876 NS |
9460 | @item -mfp-exceptions |
9461 | @itemx -mno-fp-exceptions | |
9462 | @opindex mfp-exceptions | |
9463 | Specifies whether FP exceptions are enabled. This affects how we schedule | |
9464 | FP instructions for some processors. The default is that FP exceptions are | |
9465 | enabled. | |
74291a4b | 9466 | |
39bc1876 NS |
9467 | For instance, on the SB-1, if FP exceptions are disabled, and we are emitting |
9468 | 64-bit code, then we can use both FP pipes. Otherwise, we can only use one | |
9469 | FP pipe. | |
74291a4b | 9470 | |
39bc1876 NS |
9471 | @item -mvr4130-align |
9472 | @itemx -mno-vr4130-align | |
9473 | @opindex mvr4130-align | |
9474 | The VR4130 pipeline is two-way superscalar, but can only issue two | |
9475 | instructions together if the first one is 8-byte aligned. When this | |
9476 | option is enabled, GCC will align pairs of instructions that it | |
9477 | thinks should execute in parallel. | |
74291a4b | 9478 | |
39bc1876 NS |
9479 | This option only has an effect when optimizing for the VR4130. |
9480 | It normally makes code faster, but at the expense of making it bigger. | |
9481 | It is enabled by default at optimization level @option{-O3}. | |
9482 | @end table | |
3a8699c7 | 9483 | |
39bc1876 NS |
9484 | @node MMIX Options |
9485 | @subsection MMIX Options | |
9486 | @cindex MMIX Options | |
74291a4b | 9487 | |
39bc1876 | 9488 | These options are defined for the MMIX: |
74291a4b | 9489 | |
39bc1876 NS |
9490 | @table @gcctabopt |
9491 | @item -mlibfuncs | |
9492 | @itemx -mno-libfuncs | |
9493 | @opindex mlibfuncs | |
9494 | @opindex mno-libfuncs | |
9495 | Specify that intrinsic library functions are being compiled, passing all | |
9496 | values in registers, no matter the size. | |
3cadd778 | 9497 | |
39bc1876 NS |
9498 | @item -mepsilon |
9499 | @itemx -mno-epsilon | |
9500 | @opindex mepsilon | |
9501 | @opindex mno-epsilon | |
9502 | Generate floating-point comparison instructions that compare with respect | |
9503 | to the @code{rE} epsilon register. | |
3cadd778 | 9504 | |
39bc1876 NS |
9505 | @item -mabi=mmixware |
9506 | @itemx -mabi=gnu | |
9507 | @opindex mabi-mmixware | |
9508 | @opindex mabi=gnu | |
9509 | Generate code that passes function parameters and return values that (in | |
9510 | the called function) are seen as registers @code{$0} and up, as opposed to | |
9511 | the GNU ABI which uses global registers @code{$231} and up. | |
3cadd778 | 9512 | |
39bc1876 NS |
9513 | @item -mzero-extend |
9514 | @itemx -mno-zero-extend | |
9515 | @opindex mzero-extend | |
9516 | @opindex mno-zero-extend | |
9517 | When reading data from memory in sizes shorter than 64 bits, use (do not | |
9518 | use) zero-extending load instructions by default, rather than | |
9519 | sign-extending ones. | |
3cadd778 | 9520 | |
39bc1876 NS |
9521 | @item -mknuthdiv |
9522 | @itemx -mno-knuthdiv | |
9523 | @opindex mknuthdiv | |
9524 | @opindex mno-knuthdiv | |
9525 | Make the result of a division yielding a remainder have the same sign as | |
9526 | the divisor. With the default, @option{-mno-knuthdiv}, the sign of the | |
9527 | remainder follows the sign of the dividend. Both methods are | |
9528 | arithmetically valid, the latter being almost exclusively used. | |
74291a4b | 9529 | |
39bc1876 NS |
9530 | @item -mtoplevel-symbols |
9531 | @itemx -mno-toplevel-symbols | |
9532 | @opindex mtoplevel-symbols | |
9533 | @opindex mno-toplevel-symbols | |
9534 | Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly | |
9535 | code can be used with the @code{PREFIX} assembly directive. | |
74291a4b | 9536 | |
39bc1876 NS |
9537 | @item -melf |
9538 | @opindex melf | |
9539 | Generate an executable in the ELF format, rather than the default | |
9540 | @samp{mmo} format used by the @command{mmix} simulator. | |
3d5a0820 | 9541 | |
39bc1876 NS |
9542 | @item -mbranch-predict |
9543 | @itemx -mno-branch-predict | |
9544 | @opindex mbranch-predict | |
9545 | @opindex mno-branch-predict | |
9546 | Use (do not use) the probable-branch instructions, when static branch | |
9547 | prediction indicates a probable branch. | |
3cadd778 | 9548 | |
39bc1876 NS |
9549 | @item -mbase-addresses |
9550 | @itemx -mno-base-addresses | |
9551 | @opindex mbase-addresses | |
9552 | @opindex mno-base-addresses | |
9553 | Generate (do not generate) code that uses @emph{base addresses}. Using a | |
9554 | base address automatically generates a request (handled by the assembler | |
9555 | and the linker) for a constant to be set up in a global register. The | |
9556 | register is used for one or more base address requests within the range 0 | |
9557 | to 255 from the value held in the register. The generally leads to short | |
9558 | and fast code, but the number of different data items that can be | |
9559 | addressed is limited. This means that a program that uses lots of static | |
9560 | data may require @option{-mno-base-addresses}. | |
3cadd778 | 9561 | |
39bc1876 NS |
9562 | @item -msingle-exit |
9563 | @itemx -mno-single-exit | |
9564 | @opindex msingle-exit | |
9565 | @opindex mno-single-exit | |
9566 | Force (do not force) generated code to have a single exit point in each | |
9567 | function. | |
9568 | @end table | |
3cadd778 | 9569 | |
39bc1876 NS |
9570 | @node MN10300 Options |
9571 | @subsection MN10300 Options | |
9572 | @cindex MN10300 options | |
3cadd778 | 9573 | |
39bc1876 | 9574 | These @option{-m} options are defined for Matsushita MN10300 architectures: |
3cadd778 | 9575 | |
39bc1876 NS |
9576 | @table @gcctabopt |
9577 | @item -mmult-bug | |
9578 | @opindex mmult-bug | |
9579 | Generate code to avoid bugs in the multiply instructions for the MN10300 | |
9580 | processors. This is the default. | |
c474f76b | 9581 | |
39bc1876 NS |
9582 | @item -mno-mult-bug |
9583 | @opindex mno-mult-bug | |
9584 | Do not generate code to avoid bugs in the multiply instructions for the | |
9585 | MN10300 processors. | |
3cadd778 | 9586 | |
39bc1876 NS |
9587 | @item -mam33 |
9588 | @opindex mam33 | |
9589 | Generate code which uses features specific to the AM33 processor. | |
3cadd778 | 9590 | |
39bc1876 NS |
9591 | @item -mno-am33 |
9592 | @opindex mno-am33 | |
9593 | Do not generate code which uses features specific to the AM33 processor. This | |
9594 | is the default. | |
1a66cd67 | 9595 | |
39bc1876 NS |
9596 | @item -mno-crt0 |
9597 | @opindex mno-crt0 | |
9598 | Do not link in the C run-time initialization object file. | |
93ca1662 | 9599 | |
39bc1876 NS |
9600 | @item -mrelax |
9601 | @opindex mrelax | |
9602 | Indicate to the linker that it should perform a relaxation optimization pass | |
9603 | to shorten branches, calls and absolute memory addresses. This option only | |
9604 | has an effect when used on the command line for the final link step. | |
9605 | ||
9606 | This option makes symbolic debugging impossible. | |
74291a4b MM |
9607 | @end table |
9608 | ||
39bc1876 NS |
9609 | @node NS32K Options |
9610 | @subsection NS32K Options | |
9611 | @cindex NS32K options | |
74291a4b | 9612 | |
39bc1876 NS |
9613 | These are the @samp{-m} options defined for the 32000 series. The default |
9614 | values for these options depends on which style of 32000 was selected when | |
9615 | the compiler was configured; the defaults for the most common choices are | |
9616 | given below. | |
74291a4b | 9617 | |
2642624b | 9618 | @table @gcctabopt |
39bc1876 NS |
9619 | @item -m32032 |
9620 | @itemx -m32032 | |
9621 | @opindex m32032 | |
9622 | @opindex m32032 | |
9623 | Generate output for a 32032. This is the default | |
9624 | when the compiler is configured for 32032 and 32016 based systems. | |
74291a4b | 9625 | |
39bc1876 NS |
9626 | @item -m32332 |
9627 | @itemx -m32332 | |
9628 | @opindex m32332 | |
9629 | @opindex m32332 | |
9630 | Generate output for a 32332. This is the default | |
9631 | when the compiler is configured for 32332-based systems. | |
74291a4b | 9632 | |
39bc1876 NS |
9633 | @item -m32532 |
9634 | @itemx -m32532 | |
9635 | @opindex m32532 | |
9636 | @opindex m32532 | |
9637 | Generate output for a 32532. This is the default | |
9638 | when the compiler is configured for 32532-based systems. | |
74291a4b | 9639 | |
39bc1876 NS |
9640 | @item -m32081 |
9641 | @opindex m32081 | |
9642 | Generate output containing 32081 instructions for floating point. | |
9643 | This is the default for all systems. | |
74291a4b | 9644 | |
39bc1876 NS |
9645 | @item -m32381 |
9646 | @opindex m32381 | |
9647 | Generate output containing 32381 instructions for floating point. This | |
9648 | also implies @option{-m32081}. The 32381 is only compatible with the 32332 | |
9649 | and 32532 cpus. This is the default for the pc532-netbsd configuration. | |
9650 | ||
9651 | @item -mmulti-add | |
9652 | @opindex mmulti-add | |
9653 | Try and generate multiply-add floating point instructions @code{polyF} | |
9654 | and @code{dotF}. This option is only available if the @option{-m32381} | |
9655 | option is in effect. Using these instructions requires changes to | |
9656 | register allocation which generally has a negative impact on | |
9657 | performance. This option should only be enabled when compiling code | |
9658 | particularly likely to make heavy use of multiply-add instructions. | |
9659 | ||
9660 | @item -mnomulti-add | |
9661 | @opindex mnomulti-add | |
9662 | Do not try and generate multiply-add floating point instructions | |
9663 | @code{polyF} and @code{dotF}. This is the default on all platforms. | |
74291a4b | 9664 | |
39bc1876 NS |
9665 | @item -msoft-float |
9666 | @opindex msoft-float | |
9667 | Generate output containing library calls for floating point. | |
9668 | @strong{Warning:} the requisite libraries may not be available. | |
282a61e6 | 9669 | |
39bc1876 NS |
9670 | @item -mieee-compare |
9671 | @itemx -mno-ieee-compare | |
9672 | @opindex mieee-compare | |
9673 | @opindex mno-ieee-compare | |
9674 | Control whether or not the compiler uses IEEE floating point | |
9675 | comparisons. These handle correctly the case where the result of a | |
9676 | comparison is unordered. | |
9677 | @strong{Warning:} the requisite kernel support may not be available. | |
282a61e6 | 9678 | |
39bc1876 NS |
9679 | @item -mnobitfield |
9680 | @opindex mnobitfield | |
9681 | Do not use the bit-field instructions. On some machines it is faster to | |
9682 | use shifting and masking operations. This is the default for the pc532. | |
282a61e6 | 9683 | |
39bc1876 NS |
9684 | @item -mbitfield |
9685 | @opindex mbitfield | |
9686 | Do use the bit-field instructions. This is the default for all platforms | |
9687 | except the pc532. | |
282a61e6 | 9688 | |
39bc1876 NS |
9689 | @item -mrtd |
9690 | @opindex mrtd | |
9691 | Use a different function-calling convention, in which functions | |
9692 | that take a fixed number of arguments return pop their | |
9693 | arguments on return with the @code{ret} instruction. | |
282a61e6 | 9694 | |
39bc1876 NS |
9695 | This calling convention is incompatible with the one normally |
9696 | used on Unix, so you cannot use it if you need to call libraries | |
9697 | compiled with the Unix compiler. | |
282a61e6 | 9698 | |
39bc1876 NS |
9699 | Also, you must provide function prototypes for all functions that |
9700 | take variable numbers of arguments (including @code{printf}); | |
9701 | otherwise incorrect code will be generated for calls to those | |
9702 | functions. | |
282a61e6 | 9703 | |
39bc1876 NS |
9704 | In addition, seriously incorrect code will result if you call a |
9705 | function with too many arguments. (Normally, extra arguments are | |
9706 | harmlessly ignored.) | |
282a61e6 | 9707 | |
39bc1876 | 9708 | This option takes its name from the 680x0 @code{rtd} instruction. |
282a61e6 | 9709 | |
282a61e6 | 9710 | |
39bc1876 NS |
9711 | @item -mregparam |
9712 | @opindex mregparam | |
9713 | Use a different function-calling convention where the first two arguments | |
9714 | are passed in registers. | |
282a61e6 | 9715 | |
39bc1876 NS |
9716 | This calling convention is incompatible with the one normally |
9717 | used on Unix, so you cannot use it if you need to call libraries | |
9718 | compiled with the Unix compiler. | |
282a61e6 | 9719 | |
39bc1876 NS |
9720 | @item -mnoregparam |
9721 | @opindex mnoregparam | |
9722 | Do not pass any arguments in registers. This is the default for all | |
9723 | targets. | |
282a61e6 | 9724 | |
39bc1876 NS |
9725 | @item -msb |
9726 | @opindex msb | |
9727 | It is OK to use the sb as an index register which is always loaded with | |
9728 | zero. This is the default for the pc532-netbsd target. | |
282a61e6 | 9729 | |
39bc1876 NS |
9730 | @item -mnosb |
9731 | @opindex mnosb | |
9732 | The sb register is not available for use or has not been initialized to | |
9733 | zero by the run time system. This is the default for all targets except | |
9734 | the pc532-netbsd. It is also implied whenever @option{-mhimem} or | |
9735 | @option{-fpic} is set. | |
282a61e6 | 9736 | |
39bc1876 NS |
9737 | @item -mhimem |
9738 | @opindex mhimem | |
9739 | Many ns32000 series addressing modes use displacements of up to 512MB@. | |
9740 | If an address is above 512MB then displacements from zero can not be used. | |
9741 | This option causes code to be generated which can be loaded above 512MB@. | |
9742 | This may be useful for operating systems or ROM code. | |
282a61e6 | 9743 | |
39bc1876 NS |
9744 | @item -mnohimem |
9745 | @opindex mnohimem | |
9746 | Assume code will be loaded in the first 512MB of virtual address space. | |
9747 | This is the default for all platforms. | |
282a61e6 MH |
9748 | |
9749 | @end table | |
9750 | ||
39bc1876 NS |
9751 | @node PDP-11 Options |
9752 | @subsection PDP-11 Options | |
9753 | @cindex PDP-11 Options | |
f84271d9 | 9754 | |
39bc1876 | 9755 | These options are defined for the PDP-11: |
f84271d9 | 9756 | |
2642624b | 9757 | @table @gcctabopt |
39bc1876 NS |
9758 | @item -mfpu |
9759 | @opindex mfpu | |
9760 | Use hardware FPP floating point. This is the default. (FIS floating | |
9761 | point on the PDP-11/40 is not supported.) | |
f84271d9 | 9762 | |
39bc1876 NS |
9763 | @item -msoft-float |
9764 | @opindex msoft-float | |
9765 | Do not use hardware floating point. | |
f84271d9 | 9766 | |
39bc1876 NS |
9767 | @item -mac0 |
9768 | @opindex mac0 | |
9769 | Return floating-point results in ac0 (fr0 in Unix assembler syntax). | |
f84271d9 | 9770 | |
39bc1876 NS |
9771 | @item -mno-ac0 |
9772 | @opindex mno-ac0 | |
9773 | Return floating-point results in memory. This is the default. | |
9774 | ||
9775 | @item -m40 | |
9776 | @opindex m40 | |
9777 | Generate code for a PDP-11/40. | |
9778 | ||
9779 | @item -m45 | |
9780 | @opindex m45 | |
9781 | Generate code for a PDP-11/45. This is the default. | |
f84271d9 | 9782 | |
39bc1876 NS |
9783 | @item -m10 |
9784 | @opindex m10 | |
9785 | Generate code for a PDP-11/10. | |
f84271d9 | 9786 | |
39bc1876 NS |
9787 | @item -mbcopy-builtin |
9788 | @opindex bcopy-builtin | |
70128ad9 | 9789 | Use inline @code{movmemhi} patterns for copying memory. This is the |
39bc1876 | 9790 | default. |
f84271d9 | 9791 | |
39bc1876 NS |
9792 | @item -mbcopy |
9793 | @opindex mbcopy | |
70128ad9 | 9794 | Do not use inline @code{movmemhi} patterns for copying memory. |
02f52e19 | 9795 | |
39bc1876 NS |
9796 | @item -mint16 |
9797 | @itemx -mno-int32 | |
9798 | @opindex mint16 | |
9799 | @opindex mno-int32 | |
9800 | Use 16-bit @code{int}. This is the default. | |
48f0be1b | 9801 | |
39bc1876 NS |
9802 | @item -mint32 |
9803 | @itemx -mno-int16 | |
9804 | @opindex mint32 | |
9805 | @opindex mno-int16 | |
9806 | Use 32-bit @code{int}. | |
b4378319 | 9807 | |
39bc1876 NS |
9808 | @item -mfloat64 |
9809 | @itemx -mno-float32 | |
9810 | @opindex mfloat64 | |
9811 | @opindex mno-float32 | |
9812 | Use 64-bit @code{float}. This is the default. | |
b4378319 | 9813 | |
39bc1876 NS |
9814 | @item -mfloat32 |
9815 | @itemx -mno-float64 | |
9816 | @opindex mfloat32 | |
9817 | @opindex mno-float64 | |
9818 | Use 32-bit @code{float}. | |
daf2f129 | 9819 | |
39bc1876 NS |
9820 | @item -mabshi |
9821 | @opindex mabshi | |
9822 | Use @code{abshi2} pattern. This is the default. | |
232830b7 | 9823 | |
39bc1876 NS |
9824 | @item -mno-abshi |
9825 | @opindex mno-abshi | |
9826 | Do not use @code{abshi2} pattern. | |
b4378319 | 9827 | |
39bc1876 NS |
9828 | @item -mbranch-expensive |
9829 | @opindex mbranch-expensive | |
9830 | Pretend that branches are expensive. This is for experimenting with | |
9831 | code generation only. | |
b4378319 | 9832 | |
39bc1876 NS |
9833 | @item -mbranch-cheap |
9834 | @opindex mbranch-cheap | |
9835 | Do not pretend that branches are expensive. This is the default. | |
b4378319 | 9836 | |
39bc1876 NS |
9837 | @item -msplit |
9838 | @opindex msplit | |
9839 | Generate code for a system with split I&D. | |
b4378319 | 9840 | |
39bc1876 NS |
9841 | @item -mno-split |
9842 | @opindex mno-split | |
9843 | Generate code for a system without split I&D. This is the default. | |
f84271d9 | 9844 | |
39bc1876 NS |
9845 | @item -munix-asm |
9846 | @opindex munix-asm | |
9847 | Use Unix assembler syntax. This is the default when configured for | |
9848 | @samp{pdp11-*-bsd}. | |
56b2d7a7 | 9849 | |
39bc1876 NS |
9850 | @item -mdec-asm |
9851 | @opindex mdec-asm | |
9852 | Use DEC assembler syntax. This is the default when configured for any | |
9853 | PDP-11 target other than @samp{pdp11-*-bsd}. | |
9854 | @end table | |
56b2d7a7 | 9855 | |
39bc1876 NS |
9856 | @node PowerPC Options |
9857 | @subsection PowerPC Options | |
9858 | @cindex PowerPC options | |
56b2d7a7 | 9859 | |
39bc1876 | 9860 | These are listed under @xref{RS/6000 and PowerPC Options}. |
56b2d7a7 | 9861 | |
39bc1876 NS |
9862 | @node RS/6000 and PowerPC Options |
9863 | @subsection IBM RS/6000 and PowerPC Options | |
9864 | @cindex RS/6000 and PowerPC Options | |
9865 | @cindex IBM RS/6000 and PowerPC Options | |
56b2d7a7 | 9866 | |
39bc1876 NS |
9867 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: |
9868 | @table @gcctabopt | |
9869 | @item -mpower | |
9870 | @itemx -mno-power | |
9871 | @itemx -mpower2 | |
9872 | @itemx -mno-power2 | |
9873 | @itemx -mpowerpc | |
9874 | @itemx -mno-powerpc | |
9875 | @itemx -mpowerpc-gpopt | |
9876 | @itemx -mno-powerpc-gpopt | |
9877 | @itemx -mpowerpc-gfxopt | |
9878 | @itemx -mno-powerpc-gfxopt | |
9879 | @itemx -mpowerpc64 | |
9880 | @itemx -mno-powerpc64 | |
9881 | @opindex mpower | |
9882 | @opindex mno-power | |
9883 | @opindex mpower2 | |
9884 | @opindex mno-power2 | |
9885 | @opindex mpowerpc | |
9886 | @opindex mno-powerpc | |
9887 | @opindex mpowerpc-gpopt | |
9888 | @opindex mno-powerpc-gpopt | |
9889 | @opindex mpowerpc-gfxopt | |
9890 | @opindex mno-powerpc-gfxopt | |
9891 | @opindex mpowerpc64 | |
9892 | @opindex mno-powerpc64 | |
9893 | GCC supports two related instruction set architectures for the | |
9894 | RS/6000 and PowerPC@. The @dfn{POWER} instruction set are those | |
9895 | instructions supported by the @samp{rios} chip set used in the original | |
9896 | RS/6000 systems and the @dfn{PowerPC} instruction set is the | |
9897 | architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and | |
9898 | the IBM 4xx microprocessors. | |
56b2d7a7 | 9899 | |
39bc1876 NS |
9900 | Neither architecture is a subset of the other. However there is a |
9901 | large common subset of instructions supported by both. An MQ | |
9902 | register is included in processors supporting the POWER architecture. | |
56b2d7a7 | 9903 | |
39bc1876 NS |
9904 | You use these options to specify which instructions are available on the |
9905 | processor you are using. The default value of these options is | |
9906 | determined when configuring GCC@. Specifying the | |
9907 | @option{-mcpu=@var{cpu_type}} overrides the specification of these | |
9908 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
9909 | rather than the options listed above. | |
56b2d7a7 | 9910 | |
39bc1876 NS |
9911 | The @option{-mpower} option allows GCC to generate instructions that |
9912 | are found only in the POWER architecture and to use the MQ register. | |
9913 | Specifying @option{-mpower2} implies @option{-power} and also allows GCC | |
9914 | to generate instructions that are present in the POWER2 architecture but | |
9915 | not the original POWER architecture. | |
83575957 | 9916 | |
39bc1876 NS |
9917 | The @option{-mpowerpc} option allows GCC to generate instructions that |
9918 | are found only in the 32-bit subset of the PowerPC architecture. | |
9919 | Specifying @option{-mpowerpc-gpopt} implies @option{-mpowerpc} and also allows | |
9920 | GCC to use the optional PowerPC architecture instructions in the | |
9921 | General Purpose group, including floating-point square root. Specifying | |
9922 | @option{-mpowerpc-gfxopt} implies @option{-mpowerpc} and also allows GCC to | |
9923 | use the optional PowerPC architecture instructions in the Graphics | |
9924 | group, including floating-point select. | |
83575957 | 9925 | |
39bc1876 NS |
9926 | The @option{-mpowerpc64} option allows GCC to generate the additional |
9927 | 64-bit instructions that are found in the full PowerPC64 architecture | |
9928 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to | |
9929 | @option{-mno-powerpc64}. | |
83575957 | 9930 | |
39bc1876 NS |
9931 | If you specify both @option{-mno-power} and @option{-mno-powerpc}, GCC |
9932 | will use only the instructions in the common subset of both | |
9933 | architectures plus some special AIX common-mode calls, and will not use | |
9934 | the MQ register. Specifying both @option{-mpower} and @option{-mpowerpc} | |
9935 | permits GCC to use any instruction from either architecture and to | |
9936 | allow use of the MQ register; specify this for the Motorola MPC601. | |
83575957 | 9937 | |
39bc1876 NS |
9938 | @item -mnew-mnemonics |
9939 | @itemx -mold-mnemonics | |
9940 | @opindex mnew-mnemonics | |
9941 | @opindex mold-mnemonics | |
9942 | Select which mnemonics to use in the generated assembler code. With | |
9943 | @option{-mnew-mnemonics}, GCC uses the assembler mnemonics defined for | |
9944 | the PowerPC architecture. With @option{-mold-mnemonics} it uses the | |
9945 | assembler mnemonics defined for the POWER architecture. Instructions | |
9946 | defined in only one architecture have only one mnemonic; GCC uses that | |
9947 | mnemonic irrespective of which of these options is specified. | |
83575957 | 9948 | |
39bc1876 NS |
9949 | GCC defaults to the mnemonics appropriate for the architecture in |
9950 | use. Specifying @option{-mcpu=@var{cpu_type}} sometimes overrides the | |
9951 | value of these option. Unless you are building a cross-compiler, you | |
9952 | should normally not specify either @option{-mnew-mnemonics} or | |
9953 | @option{-mold-mnemonics}, but should instead accept the default. | |
83575957 | 9954 | |
39bc1876 NS |
9955 | @item -mcpu=@var{cpu_type} |
9956 | @opindex mcpu | |
9957 | Set architecture type, register usage, choice of mnemonics, and | |
9958 | instruction scheduling parameters for machine type @var{cpu_type}. | |
9959 | Supported values for @var{cpu_type} are @samp{401}, @samp{403}, | |
9960 | @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{505}, | |
9961 | @samp{601}, @samp{602}, @samp{603}, @samp{603e}, @samp{604}, | |
9962 | @samp{604e}, @samp{620}, @samp{630}, @samp{740}, @samp{7400}, | |
9963 | @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823}, | |
9964 | @samp{860}, @samp{970}, @samp{common}, @samp{ec603e}, @samp{G3}, | |
9965 | @samp{G4}, @samp{G5}, @samp{power}, @samp{power2}, @samp{power3}, | |
9966 | @samp{power4}, @samp{power5}, @samp{powerpc}, @samp{powerpc64}, | |
9967 | @samp{rios}, @samp{rios1}, @samp{rios2}, @samp{rsc}, and @samp{rs64a}. | |
83575957 | 9968 | |
39bc1876 NS |
9969 | @option{-mcpu=common} selects a completely generic processor. Code |
9970 | generated under this option will run on any POWER or PowerPC processor. | |
9971 | GCC will use only the instructions in the common subset of both | |
9972 | architectures, and will not use the MQ register. GCC assumes a generic | |
9973 | processor model for scheduling purposes. | |
83575957 | 9974 | |
39bc1876 NS |
9975 | @option{-mcpu=power}, @option{-mcpu=power2}, @option{-mcpu=powerpc}, and |
9976 | @option{-mcpu=powerpc64} specify generic POWER, POWER2, pure 32-bit | |
9977 | PowerPC (i.e., not MPC601), and 64-bit PowerPC architecture machine | |
9978 | types, with an appropriate, generic processor model assumed for | |
9979 | scheduling purposes. | |
83575957 | 9980 | |
39bc1876 NS |
9981 | The other options specify a specific processor. Code generated under |
9982 | those options will run best on that processor, and may not run at all on | |
9983 | others. | |
83575957 | 9984 | |
39bc1876 NS |
9985 | The @option{-mcpu} options automatically enable or disable the |
9986 | following options: @option{-maltivec}, @option{-mhard-float}, | |
9987 | @option{-mmfcrf}, @option{-mmultiple}, @option{-mnew-mnemonics}, | |
9988 | @option{-mpower}, @option{-mpower2}, @option{-mpowerpc64}, | |
9989 | @option{-mpowerpc-gpopt}, @option{-mpowerpc-gfxopt}, | |
9990 | @option{-mstring}. The particular options set for any particular CPU | |
9991 | will vary between compiler versions, depending on what setting seems | |
9992 | to produce optimal code for that CPU; it doesn't necessarily reflect | |
9993 | the actual hardware's capabilities. If you wish to set an individual | |
9994 | option to a particular value, you may specify it after the | |
9995 | @option{-mcpu} option, like @samp{-mcpu=970 -mno-altivec}. | |
5d7c2819 | 9996 | |
39bc1876 NS |
9997 | On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are |
9998 | not enabled or disabled by the @option{-mcpu} option at present, since | |
9999 | AIX does not have full support for these options. You may still | |
10000 | enable or disable them individually if you're sure it'll work in your | |
10001 | environment. | |
83575957 | 10002 | |
39bc1876 NS |
10003 | @item -mtune=@var{cpu_type} |
10004 | @opindex mtune | |
10005 | Set the instruction scheduling parameters for machine type | |
10006 | @var{cpu_type}, but do not set the architecture type, register usage, or | |
10007 | choice of mnemonics, as @option{-mcpu=@var{cpu_type}} would. The same | |
10008 | values for @var{cpu_type} are used for @option{-mtune} as for | |
10009 | @option{-mcpu}. If both are specified, the code generated will use the | |
10010 | architecture, registers, and mnemonics set by @option{-mcpu}, but the | |
10011 | scheduling parameters set by @option{-mtune}. | |
83575957 | 10012 | |
39bc1876 NS |
10013 | @item -maltivec |
10014 | @itemx -mno-altivec | |
10015 | @opindex maltivec | |
10016 | @opindex mno-altivec | |
10017 | These switches enable or disable the use of built-in functions that | |
10018 | allow access to the AltiVec instruction set. You may also need to set | |
10019 | @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI | |
10020 | enhancements. | |
83575957 | 10021 | |
39bc1876 NS |
10022 | @item -mabi=spe |
10023 | @opindex mabi=spe | |
10024 | Extend the current ABI with SPE ABI extensions. This does not change | |
10025 | the default ABI, instead it adds the SPE ABI extensions to the current | |
10026 | ABI@. | |
83575957 | 10027 | |
39bc1876 NS |
10028 | @item -mabi=no-spe |
10029 | @opindex mabi=no-spe | |
10030 | Disable Booke SPE ABI extensions for the current ABI. | |
83575957 | 10031 | |
39bc1876 NS |
10032 | @item -misel=@var{yes/no} |
10033 | @itemx -misel | |
10034 | @opindex misel | |
10035 | This switch enables or disables the generation of ISEL instructions. | |
83575957 | 10036 | |
39bc1876 NS |
10037 | @item -mspe=@var{yes/no} |
10038 | @itemx -mspe | |
10039 | @opindex mspe | |
10040 | This switch enables or disables the generation of SPE simd | |
10041 | instructions. | |
83575957 | 10042 | |
39bc1876 NS |
10043 | @item -mfloat-gprs=@var{yes/no} |
10044 | @itemx -mfloat-gprs | |
10045 | @opindex mfloat-gprs | |
10046 | This switch enables or disables the generation of floating point | |
10047 | operations on the general purpose registers for architectures that | |
10048 | support it. This option is currently only available on the MPC8540. | |
83575957 | 10049 | |
49bd1d27 SS |
10050 | @item -m32 |
10051 | @itemx -m64 | |
10052 | @opindex m32 | |
10053 | @opindex m64 | |
10054 | Generate code for 32-bit or 64-bit environments of Darwin and SVR4 | |
10055 | targets (including GNU/Linux). The 32-bit environment sets int, long | |
10056 | and pointer to 32 bits and generates code that runs on any PowerPC | |
10057 | variant. The 64-bit environment sets int to 32 bits and long and | |
10058 | pointer to 64 bits, and generates code for PowerPC64, as for | |
10059 | @option{-mpowerpc64}. | |
10060 | ||
39bc1876 NS |
10061 | @item -mfull-toc |
10062 | @itemx -mno-fp-in-toc | |
10063 | @itemx -mno-sum-in-toc | |
10064 | @itemx -mminimal-toc | |
10065 | @opindex mfull-toc | |
10066 | @opindex mno-fp-in-toc | |
10067 | @opindex mno-sum-in-toc | |
10068 | @opindex mminimal-toc | |
10069 | Modify generation of the TOC (Table Of Contents), which is created for | |
10070 | every executable file. The @option{-mfull-toc} option is selected by | |
10071 | default. In that case, GCC will allocate at least one TOC entry for | |
10072 | each unique non-automatic variable reference in your program. GCC | |
10073 | will also place floating-point constants in the TOC@. However, only | |
10074 | 16,384 entries are available in the TOC@. | |
83575957 | 10075 | |
39bc1876 NS |
10076 | If you receive a linker error message that saying you have overflowed |
10077 | the available TOC space, you can reduce the amount of TOC space used | |
10078 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. | |
10079 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
10080 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
10081 | generate code to calculate the sum of an address and a constant at | |
10082 | run-time instead of putting that sum into the TOC@. You may specify one | |
10083 | or both of these options. Each causes GCC to produce very slightly | |
10084 | slower and larger code at the expense of conserving TOC space. | |
83575957 | 10085 | |
39bc1876 NS |
10086 | If you still run out of space in the TOC even when you specify both of |
10087 | these options, specify @option{-mminimal-toc} instead. This option causes | |
10088 | GCC to make only one TOC entry for every file. When you specify this | |
10089 | option, GCC will produce code that is slower and larger but which | |
10090 | uses extremely little TOC space. You may wish to use this option | |
10091 | only on files that contain less frequently executed code. | |
83575957 | 10092 | |
39bc1876 NS |
10093 | @item -maix64 |
10094 | @itemx -maix32 | |
10095 | @opindex maix64 | |
10096 | @opindex maix32 | |
10097 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit | |
10098 | @code{long} type, and the infrastructure needed to support them. | |
10099 | Specifying @option{-maix64} implies @option{-mpowerpc64} and | |
10100 | @option{-mpowerpc}, while @option{-maix32} disables the 64-bit ABI and | |
10101 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
83575957 | 10102 | |
39bc1876 NS |
10103 | @item -mxl-call |
10104 | @itemx -mno-xl-call | |
10105 | @opindex mxl-call | |
10106 | @opindex mno-xl-call | |
10107 | On AIX, pass floating-point arguments to prototyped functions beyond the | |
10108 | register save area (RSA) on the stack in addition to argument FPRs. The | |
10109 | AIX calling convention was extended but not initially documented to | |
10110 | handle an obscure K&R C case of calling a function that takes the | |
10111 | address of its arguments with fewer arguments than declared. AIX XL | |
10112 | compilers access floating point arguments which do not fit in the | |
10113 | RSA from the stack when a subroutine is compiled without | |
10114 | optimization. Because always storing floating-point arguments on the | |
10115 | stack is inefficient and rarely needed, this option is not enabled by | |
10116 | default and only is necessary when calling subroutines compiled by AIX | |
10117 | XL compilers without optimization. | |
83575957 | 10118 | |
39bc1876 NS |
10119 | @item -mpe |
10120 | @opindex mpe | |
10121 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an | |
10122 | application written to use message passing with special startup code to | |
10123 | enable the application to run. The system must have PE installed in the | |
10124 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
10125 | must be overridden with the @option{-specs=} option to specify the | |
10126 | appropriate directory location. The Parallel Environment does not | |
10127 | support threads, so the @option{-mpe} option and the @option{-pthread} | |
10128 | option are incompatible. | |
83575957 | 10129 | |
39bc1876 NS |
10130 | @item -malign-natural |
10131 | @itemx -malign-power | |
10132 | @opindex malign-natural | |
10133 | @opindex malign-power | |
10134 | On AIX, Darwin, and 64-bit PowerPC GNU/Linux, the option | |
10135 | @option{-malign-natural} overrides the ABI-defined alignment of larger | |
10136 | types, such as floating-point doubles, on their natural size-based boundary. | |
10137 | The option @option{-malign-power} instructs GCC to follow the ABI-specified | |
10138 | alignment rules. GCC defaults to the standard alignment defined in the ABI. | |
83575957 | 10139 | |
39bc1876 NS |
10140 | @item -msoft-float |
10141 | @itemx -mhard-float | |
10142 | @opindex msoft-float | |
10143 | @opindex mhard-float | |
10144 | Generate code that does not use (uses) the floating-point register set. | |
10145 | Software floating point emulation is provided if you use the | |
10146 | @option{-msoft-float} option, and pass the option to GCC when linking. | |
83575957 | 10147 | |
39bc1876 NS |
10148 | @item -mmultiple |
10149 | @itemx -mno-multiple | |
10150 | @opindex mmultiple | |
10151 | @opindex mno-multiple | |
10152 | Generate code that uses (does not use) the load multiple word | |
10153 | instructions and the store multiple word instructions. These | |
10154 | instructions are generated by default on POWER systems, and not | |
10155 | generated on PowerPC systems. Do not use @option{-mmultiple} on little | |
10156 | endian PowerPC systems, since those instructions do not work when the | |
10157 | processor is in little endian mode. The exceptions are PPC740 and | |
10158 | PPC750 which permit the instructions usage in little endian mode. | |
83575957 | 10159 | |
39bc1876 NS |
10160 | @item -mstring |
10161 | @itemx -mno-string | |
10162 | @opindex mstring | |
10163 | @opindex mno-string | |
10164 | Generate code that uses (does not use) the load string instructions | |
10165 | and the store string word instructions to save multiple registers and | |
10166 | do small block moves. These instructions are generated by default on | |
10167 | POWER systems, and not generated on PowerPC systems. Do not use | |
10168 | @option{-mstring} on little endian PowerPC systems, since those | |
10169 | instructions do not work when the processor is in little endian mode. | |
10170 | The exceptions are PPC740 and PPC750 which permit the instructions | |
10171 | usage in little endian mode. | |
052a4b28 | 10172 | |
39bc1876 NS |
10173 | @item -mupdate |
10174 | @itemx -mno-update | |
10175 | @opindex mupdate | |
10176 | @opindex mno-update | |
10177 | Generate code that uses (does not use) the load or store instructions | |
10178 | that update the base register to the address of the calculated memory | |
10179 | location. These instructions are generated by default. If you use | |
10180 | @option{-mno-update}, there is a small window between the time that the | |
10181 | stack pointer is updated and the address of the previous frame is | |
10182 | stored, which means code that walks the stack frame across interrupts or | |
10183 | signals may get corrupted data. | |
052a4b28 | 10184 | |
39bc1876 NS |
10185 | @item -mfused-madd |
10186 | @itemx -mno-fused-madd | |
10187 | @opindex mfused-madd | |
10188 | @opindex mno-fused-madd | |
10189 | Generate code that uses (does not use) the floating point multiply and | |
10190 | accumulate instructions. These instructions are generated by default if | |
10191 | hardware floating is used. | |
3a69a7d5 | 10192 | |
39bc1876 NS |
10193 | @item -mno-bit-align |
10194 | @itemx -mbit-align | |
10195 | @opindex mno-bit-align | |
10196 | @opindex mbit-align | |
10197 | On System V.4 and embedded PowerPC systems do not (do) force structures | |
10198 | and unions that contain bit-fields to be aligned to the base type of the | |
10199 | bit-field. | |
3a69a7d5 | 10200 | |
39bc1876 NS |
10201 | For example, by default a structure containing nothing but 8 |
10202 | @code{unsigned} bit-fields of length 1 would be aligned to a 4 byte | |
10203 | boundary and have a size of 4 bytes. By using @option{-mno-bit-align}, | |
10204 | the structure would be aligned to a 1 byte boundary and be one byte in | |
10205 | size. | |
3a69a7d5 | 10206 | |
39bc1876 NS |
10207 | @item -mno-strict-align |
10208 | @itemx -mstrict-align | |
10209 | @opindex mno-strict-align | |
10210 | @opindex mstrict-align | |
10211 | On System V.4 and embedded PowerPC systems do not (do) assume that | |
10212 | unaligned memory references will be handled by the system. | |
3a69a7d5 | 10213 | |
39bc1876 NS |
10214 | @item -mrelocatable |
10215 | @itemx -mno-relocatable | |
10216 | @opindex mrelocatable | |
10217 | @opindex mno-relocatable | |
10218 | On embedded PowerPC systems generate code that allows (does not allow) | |
10219 | the program to be relocated to a different address at runtime. If you | |
10220 | use @option{-mrelocatable} on any module, all objects linked together must | |
10221 | be compiled with @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
3a69a7d5 | 10222 | |
39bc1876 NS |
10223 | @item -mrelocatable-lib |
10224 | @itemx -mno-relocatable-lib | |
10225 | @opindex mrelocatable-lib | |
10226 | @opindex mno-relocatable-lib | |
10227 | On embedded PowerPC systems generate code that allows (does not allow) | |
10228 | the program to be relocated to a different address at runtime. Modules | |
10229 | compiled with @option{-mrelocatable-lib} can be linked with either modules | |
10230 | compiled without @option{-mrelocatable} and @option{-mrelocatable-lib} or | |
10231 | with modules compiled with the @option{-mrelocatable} options. | |
052a4b28 | 10232 | |
39bc1876 NS |
10233 | @item -mno-toc |
10234 | @itemx -mtoc | |
10235 | @opindex mno-toc | |
10236 | @opindex mtoc | |
10237 | On System V.4 and embedded PowerPC systems do not (do) assume that | |
10238 | register 2 contains a pointer to a global area pointing to the addresses | |
10239 | used in the program. | |
052a4b28 | 10240 | |
39bc1876 NS |
10241 | @item -mlittle |
10242 | @itemx -mlittle-endian | |
10243 | @opindex mlittle | |
10244 | @opindex mlittle-endian | |
10245 | On System V.4 and embedded PowerPC systems compile code for the | |
10246 | processor in little endian mode. The @option{-mlittle-endian} option is | |
10247 | the same as @option{-mlittle}. | |
052a4b28 | 10248 | |
39bc1876 NS |
10249 | @item -mbig |
10250 | @itemx -mbig-endian | |
10251 | @opindex mbig | |
10252 | @opindex mbig-endian | |
10253 | On System V.4 and embedded PowerPC systems compile code for the | |
10254 | processor in big endian mode. The @option{-mbig-endian} option is | |
10255 | the same as @option{-mbig}. | |
052a4b28 | 10256 | |
39bc1876 NS |
10257 | @item -mdynamic-no-pic |
10258 | @opindex mdynamic-no-pic | |
10259 | On Darwin and Mac OS X systems, compile code so that it is not | |
10260 | relocatable, but that its external references are relocatable. The | |
10261 | resulting code is suitable for applications, but not shared | |
10262 | libraries. | |
3a69a7d5 | 10263 | |
39bc1876 NS |
10264 | @item -mprioritize-restricted-insns=@var{priority} |
10265 | @opindex mprioritize-restricted-insns | |
10266 | This option controls the priority that is assigned to | |
10267 | dispatch-slot restricted instructions during the second scheduling | |
10268 | pass. The argument @var{priority} takes the value @var{0/1/2} to assign | |
10269 | @var{no/highest/second-highest} priority to dispatch slot restricted | |
10270 | instructions. | |
3a69a7d5 | 10271 | |
39bc1876 NS |
10272 | @item -msched-costly-dep=@var{dependence_type} |
10273 | @opindex msched-costly-dep | |
10274 | This option controls which dependences are considered costly | |
10275 | by the target during instruction scheduling. The argument | |
10276 | @var{dependence_type} takes one of the following values: | |
10277 | @var{no}: no dependence is costly, | |
10278 | @var{all}: all dependences are costly, | |
10279 | @var{true_store_to_load}: a true dependence from store to load is costly, | |
10280 | @var{store_to_load}: any dependence from store to load is costly, | |
10281 | @var{number}: any dependence which latency >= @var{number} is costly. | |
11338cda | 10282 | |
39bc1876 NS |
10283 | @item -minsert-sched-nops=@var{scheme} |
10284 | @opindex minsert-sched-nops | |
10285 | This option controls which nop insertion scheme will be used during | |
10286 | the second scheduling pass. The argument @var{scheme} takes one of the | |
10287 | following values: | |
10288 | @var{no}: Don't insert nops. | |
10289 | @var{pad}: Pad with nops any dispatch group which has vacant issue slots, | |
10290 | according to the scheduler's grouping. | |
10291 | @var{regroup_exact}: Insert nops to force costly dependent insns into | |
10292 | separate groups. Insert exactly as many nops as needed to force an insn | |
10293 | to a new group, according to the estimated processor grouping. | |
10294 | @var{number}: Insert nops to force costly dependent insns into | |
10295 | separate groups. Insert @var{number} nops to force an insn to a new group. | |
052a4b28 | 10296 | |
39bc1876 NS |
10297 | @item -mcall-sysv |
10298 | @opindex mcall-sysv | |
10299 | On System V.4 and embedded PowerPC systems compile code using calling | |
10300 | conventions that adheres to the March 1995 draft of the System V | |
10301 | Application Binary Interface, PowerPC processor supplement. This is the | |
10302 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
789a3090 | 10303 | |
39bc1876 NS |
10304 | @item -mcall-sysv-eabi |
10305 | @opindex mcall-sysv-eabi | |
10306 | Specify both @option{-mcall-sysv} and @option{-meabi} options. | |
789a3090 | 10307 | |
39bc1876 NS |
10308 | @item -mcall-sysv-noeabi |
10309 | @opindex mcall-sysv-noeabi | |
10310 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. | |
789a3090 | 10311 | |
39bc1876 NS |
10312 | @item -mcall-solaris |
10313 | @opindex mcall-solaris | |
10314 | On System V.4 and embedded PowerPC systems compile code for the Solaris | |
10315 | operating system. | |
789a3090 | 10316 | |
39bc1876 NS |
10317 | @item -mcall-linux |
10318 | @opindex mcall-linux | |
10319 | On System V.4 and embedded PowerPC systems compile code for the | |
10320 | Linux-based GNU system. | |
789a3090 | 10321 | |
39bc1876 NS |
10322 | @item -mcall-gnu |
10323 | @opindex mcall-gnu | |
10324 | On System V.4 and embedded PowerPC systems compile code for the | |
10325 | Hurd-based GNU system. | |
789a3090 | 10326 | |
39bc1876 NS |
10327 | @item -mcall-netbsd |
10328 | @opindex mcall-netbsd | |
10329 | On System V.4 and embedded PowerPC systems compile code for the | |
10330 | NetBSD operating system. | |
789a3090 | 10331 | |
39bc1876 NS |
10332 | @item -maix-struct-return |
10333 | @opindex maix-struct-return | |
10334 | Return all structures in memory (as specified by the AIX ABI)@. | |
789a3090 | 10335 | |
39bc1876 NS |
10336 | @item -msvr4-struct-return |
10337 | @opindex msvr4-struct-return | |
10338 | Return structures smaller than 8 bytes in registers (as specified by the | |
10339 | SVR4 ABI)@. | |
789a3090 | 10340 | |
39bc1876 NS |
10341 | @item -mabi=altivec |
10342 | @opindex mabi=altivec | |
10343 | Extend the current ABI with AltiVec ABI extensions. This does not | |
10344 | change the default ABI, instead it adds the AltiVec ABI extensions to | |
10345 | the current ABI@. | |
789a3090 | 10346 | |
39bc1876 NS |
10347 | @item -mabi=no-altivec |
10348 | @opindex mabi=no-altivec | |
10349 | Disable AltiVec ABI extensions for the current ABI. | |
789a3090 | 10350 | |
39bc1876 NS |
10351 | @item -mprototype |
10352 | @itemx -mno-prototype | |
10353 | @opindex mprototype | |
10354 | @opindex mno-prototype | |
10355 | On System V.4 and embedded PowerPC systems assume that all calls to | |
10356 | variable argument functions are properly prototyped. Otherwise, the | |
10357 | compiler must insert an instruction before every non prototyped call to | |
10358 | set or clear bit 6 of the condition code register (@var{CR}) to | |
10359 | indicate whether floating point values were passed in the floating point | |
10360 | registers in case the function takes a variable arguments. With | |
10361 | @option{-mprototype}, only calls to prototyped variable argument functions | |
10362 | will set or clear the bit. | |
83575957 | 10363 | |
39bc1876 NS |
10364 | @item -msim |
10365 | @opindex msim | |
10366 | On embedded PowerPC systems, assume that the startup module is called | |
10367 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
10368 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}. | |
10369 | configurations. | |
df6194d4 | 10370 | |
39bc1876 NS |
10371 | @item -mmvme |
10372 | @opindex mmvme | |
10373 | On embedded PowerPC systems, assume that the startup module is called | |
10374 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and | |
10375 | @file{libc.a}. | |
df6194d4 | 10376 | |
39bc1876 NS |
10377 | @item -mads |
10378 | @opindex mads | |
10379 | On embedded PowerPC systems, assume that the startup module is called | |
10380 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
10381 | @file{libc.a}. | |
df6194d4 | 10382 | |
39bc1876 NS |
10383 | @item -myellowknife |
10384 | @opindex myellowknife | |
10385 | On embedded PowerPC systems, assume that the startup module is called | |
10386 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
10387 | @file{libc.a}. | |
df6194d4 | 10388 | |
39bc1876 NS |
10389 | @item -mvxworks |
10390 | @opindex mvxworks | |
10391 | On System V.4 and embedded PowerPC systems, specify that you are | |
10392 | compiling for a VxWorks system. | |
df6194d4 | 10393 | |
39bc1876 NS |
10394 | @item -mwindiss |
10395 | @opindex mwindiss | |
10396 | Specify that you are compiling for the WindISS simulation environment. | |
df6194d4 | 10397 | |
39bc1876 NS |
10398 | @item -memb |
10399 | @opindex memb | |
10400 | On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags | |
10401 | header to indicate that @samp{eabi} extended relocations are used. | |
df6194d4 | 10402 | |
39bc1876 NS |
10403 | @item -meabi |
10404 | @itemx -mno-eabi | |
10405 | @opindex meabi | |
10406 | @opindex mno-eabi | |
10407 | On System V.4 and embedded PowerPC systems do (do not) adhere to the | |
10408 | Embedded Applications Binary Interface (eabi) which is a set of | |
10409 | modifications to the System V.4 specifications. Selecting @option{-meabi} | |
10410 | means that the stack is aligned to an 8 byte boundary, a function | |
10411 | @code{__eabi} is called to from @code{main} to set up the eabi | |
10412 | environment, and the @option{-msdata} option can use both @code{r2} and | |
10413 | @code{r13} to point to two separate small data areas. Selecting | |
10414 | @option{-mno-eabi} means that the stack is aligned to a 16 byte boundary, | |
10415 | do not call an initialization function from @code{main}, and the | |
10416 | @option{-msdata} option will only use @code{r13} to point to a single | |
10417 | small data area. The @option{-meabi} option is on by default if you | |
10418 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
df6194d4 | 10419 | |
39bc1876 NS |
10420 | @item -msdata=eabi |
10421 | @opindex msdata=eabi | |
10422 | On System V.4 and embedded PowerPC systems, put small initialized | |
10423 | @code{const} global and static data in the @samp{.sdata2} section, which | |
10424 | is pointed to by register @code{r2}. Put small initialized | |
10425 | non-@code{const} global and static data in the @samp{.sdata} section, | |
10426 | which is pointed to by register @code{r13}. Put small uninitialized | |
10427 | global and static data in the @samp{.sbss} section, which is adjacent to | |
10428 | the @samp{.sdata} section. The @option{-msdata=eabi} option is | |
10429 | incompatible with the @option{-mrelocatable} option. The | |
10430 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
df6194d4 | 10431 | |
39bc1876 NS |
10432 | @item -msdata=sysv |
10433 | @opindex msdata=sysv | |
10434 | On System V.4 and embedded PowerPC systems, put small global and static | |
10435 | data in the @samp{.sdata} section, which is pointed to by register | |
10436 | @code{r13}. Put small uninitialized global and static data in the | |
10437 | @samp{.sbss} section, which is adjacent to the @samp{.sdata} section. | |
10438 | The @option{-msdata=sysv} option is incompatible with the | |
10439 | @option{-mrelocatable} option. | |
df6194d4 | 10440 | |
39bc1876 | 10441 | @item -msdata=default |
df6194d4 | 10442 | @itemx -msdata |
39bc1876 | 10443 | @opindex msdata=default |
cd3bb277 | 10444 | @opindex msdata |
39bc1876 NS |
10445 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
10446 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
10447 | same as @option{-msdata=sysv}. | |
df6194d4 | 10448 | |
39bc1876 NS |
10449 | @item -msdata-data |
10450 | @opindex msdata-data | |
10451 | On System V.4 and embedded PowerPC systems, put small global and static | |
10452 | data in the @samp{.sdata} section. Put small uninitialized global and | |
10453 | static data in the @samp{.sbss} section. Do not use register @code{r13} | |
10454 | to address small data however. This is the default behavior unless | |
10455 | other @option{-msdata} options are used. | |
df6194d4 | 10456 | |
39bc1876 NS |
10457 | @item -msdata=none |
10458 | @itemx -mno-sdata | |
10459 | @opindex msdata=none | |
10460 | @opindex mno-sdata | |
10461 | On embedded PowerPC systems, put all initialized global and static data | |
10462 | in the @samp{.data} section, and all uninitialized data in the | |
10463 | @samp{.bss} section. | |
df6194d4 | 10464 | |
39bc1876 NS |
10465 | @item -G @var{num} |
10466 | @opindex G | |
10467 | @cindex smaller data references (PowerPC) | |
10468 | @cindex .sdata/.sdata2 references (PowerPC) | |
10469 | On embedded PowerPC systems, put global and static items less than or | |
10470 | equal to @var{num} bytes into the small data or bss sections instead of | |
10471 | the normal data or bss section. By default, @var{num} is 8. The | |
10472 | @option{-G @var{num}} switch is also passed to the linker. | |
10473 | All modules should be compiled with the same @option{-G @var{num}} value. | |
dcffbade | 10474 | |
39bc1876 NS |
10475 | @item -mregnames |
10476 | @itemx -mno-regnames | |
10477 | @opindex mregnames | |
10478 | @opindex mno-regnames | |
10479 | On System V.4 and embedded PowerPC systems do (do not) emit register | |
10480 | names in the assembly language output using symbolic forms. | |
dcffbade | 10481 | |
39bc1876 NS |
10482 | @item -mlongcall |
10483 | @itemx -mno-longcall | |
10484 | @opindex mlongcall | |
10485 | @opindex mno-longcall | |
10486 | Default to making all function calls indirectly, using a register, so | |
10487 | that functions which reside further than 32 megabytes (33,554,432 | |
10488 | bytes) from the current location can be called. This setting can be | |
10489 | overridden by the @code{shortcall} function attribute, or by | |
10490 | @code{#pragma longcall(0)}. | |
dcffbade | 10491 | |
39bc1876 NS |
10492 | Some linkers are capable of detecting out-of-range calls and generating |
10493 | glue code on the fly. On these systems, long calls are unnecessary and | |
10494 | generate slower code. As of this writing, the AIX linker can do this, | |
10495 | as can the GNU linker for PowerPC/64. It is planned to add this feature | |
10496 | to the GNU linker for 32-bit PowerPC systems as well. | |
df6194d4 | 10497 | |
39bc1876 NS |
10498 | On Darwin/PPC systems, @code{#pragma longcall} will generate ``jbsr |
10499 | callee, L42'', plus a ``branch island'' (glue code). The two target | |
10500 | addresses represent the callee and the ``branch island.'' The | |
10501 | Darwin/PPC linker will prefer the first address and generate a ``bl | |
10502 | callee'' if the PPC ``bl'' instruction will reach the callee directly; | |
10503 | otherwise, the linker will generate ``bl L42'' to call the ``branch | |
10504 | island.'' The ``branch island'' is appended to the body of the | |
10505 | calling function; it computes the full 32-bit address of the callee | |
10506 | and jumps to it. | |
df6194d4 | 10507 | |
39bc1876 NS |
10508 | On Mach-O (Darwin) systems, this option directs the compiler emit to |
10509 | the glue for every direct call, and the Darwin linker decides whether | |
10510 | to use or discard it. | |
10511 | ||
10512 | In the future, we may cause GCC to ignore all longcall specifications | |
10513 | when the linker is known to generate glue. | |
10514 | ||
10515 | @item -pthread | |
10516 | @opindex pthread | |
10517 | Adds support for multithreading with the @dfn{pthreads} library. | |
10518 | This option sets flags for both the preprocessor and linker. | |
30028c85 | 10519 | |
df6194d4 JW |
10520 | @end table |
10521 | ||
91abf72d HP |
10522 | @node S/390 and zSeries Options |
10523 | @subsection S/390 and zSeries Options | |
10524 | @cindex S/390 and zSeries Options | |
10525 | ||
10526 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
10527 | ||
10528 | @table @gcctabopt | |
10529 | @item -mhard-float | |
10530 | @itemx -msoft-float | |
10531 | @opindex mhard-float | |
10532 | @opindex msoft-float | |
10533 | Use (do not use) the hardware floating-point instructions and registers | |
10534 | for floating-point operations. When @option{-msoft-float} is specified, | |
10535 | functions in @file{libgcc.a} will be used to perform floating-point | |
10536 | operations. When @option{-mhard-float} is specified, the compiler | |
10537 | generates IEEE floating-point instructions. This is the default. | |
10538 | ||
10539 | @item -mbackchain | |
10540 | @itemx -mno-backchain | |
adf39f8f | 10541 | @itemx -mkernel-backchain |
91abf72d HP |
10542 | @opindex mbackchain |
10543 | @opindex mno-backchain | |
adf39f8f AK |
10544 | @opindex mkernel-backchain |
10545 | In order to provide a backchain the address of the caller's frame | |
10546 | is stored within the callee's stack frame. | |
10547 | A backchain may be needed to allow debugging using tools that do not understand | |
10548 | DWARF-2 call frame information. | |
10549 | For @option{-mno-backchain} no backchain is maintained at all which is the | |
10550 | default. | |
10551 | If one of the other options is present the backchain pointer is placed either | |
10552 | on top of the stack frame (@option{-mkernel-backchain}) or on | |
10553 | the bottom (@option{-mbackchain}). | |
10554 | Beside the different backchain location @option{-mkernel-backchain} | |
10555 | also changes stack frame layout breaking the ABI. This option | |
10556 | is intended to be used for code which internally needs a backchain but has | |
10557 | to get by with a limited stack size e.g. the linux kernel. | |
10558 | Internal unwinding code not using DWARF-2 info has to be able to locate the | |
10559 | return address of a function. That will be eased be the fact that | |
10560 | the return address of a function is placed two words below the backchain | |
10561 | pointer. | |
91abf72d HP |
10562 | |
10563 | @item -msmall-exec | |
10564 | @itemx -mno-small-exec | |
10565 | @opindex msmall-exec | |
10566 | @opindex mno-small-exec | |
f282ffb3 JM |
10567 | Generate (or do not generate) code using the @code{bras} instruction |
10568 | to do subroutine calls. | |
91abf72d HP |
10569 | This only works reliably if the total executable size does not |
10570 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
10571 | which does not have this limitation. | |
10572 | ||
10573 | @item -m64 | |
10574 | @itemx -m31 | |
10575 | @opindex m64 | |
10576 | @opindex m31 | |
10577 | When @option{-m31} is specified, generate code compliant to the | |
95fef11f JM |
10578 | GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate |
10579 | code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in | |
91abf72d | 10580 | particular to generate 64-bit instructions. For the @samp{s390} |
f282ffb3 | 10581 | targets, the default is @option{-m31}, while the @samp{s390x} |
91abf72d HP |
10582 | targets default to @option{-m64}. |
10583 | ||
1fec52be HP |
10584 | @item -mzarch |
10585 | @itemx -mesa | |
10586 | @opindex mzarch | |
10587 | @opindex mesa | |
daf2f129 JM |
10588 | When @option{-mzarch} is specified, generate code using the |
10589 | instructions available on z/Architecture. | |
10590 | When @option{-mesa} is specified, generate code using the | |
1fec52be HP |
10591 | instructions available on ESA/390. Note that @option{-mesa} is |
10592 | not possible with @option{-m64}. | |
95fef11f | 10593 | When generating code compliant to the GNU/Linux for S/390 ABI, |
f13e0d4e | 10594 | the default is @option{-mesa}. When generating code compliant |
95fef11f | 10595 | to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}. |
1fec52be | 10596 | |
91abf72d HP |
10597 | @item -mmvcle |
10598 | @itemx -mno-mvcle | |
10599 | @opindex mmvcle | |
10600 | @opindex mno-mvcle | |
f282ffb3 | 10601 | Generate (or do not generate) code using the @code{mvcle} instruction |
3364c33b | 10602 | to perform block moves. When @option{-mno-mvcle} is specified, |
91abf72d HP |
10603 | use a @code{mvc} loop instead. This is the default. |
10604 | ||
10605 | @item -mdebug | |
10606 | @itemx -mno-debug | |
10607 | @opindex mdebug | |
10608 | @opindex mno-debug | |
10609 | Print (or do not print) additional debug information when compiling. | |
10610 | The default is to not print debug information. | |
10611 | ||
f13e0d4e | 10612 | @item -march=@var{cpu-type} |
1fec52be | 10613 | @opindex march |
f13e0d4e | 10614 | Generate code that will run on @var{cpu-type}, which is the name of a system |
1fec52be | 10615 | representing a certain processor type. Possible values for |
f13e0d4e UW |
10616 | @var{cpu-type} are @samp{g5}, @samp{g6}, @samp{z900}, and @samp{z990}. |
10617 | When generating code using the instructions available on z/Architecture, | |
10618 | the default is @option{-march=z900}. Otherwise, the default is | |
10619 | @option{-march=g5}. | |
1fec52be | 10620 | |
f13e0d4e | 10621 | @item -mtune=@var{cpu-type} |
35082351 | 10622 | @opindex mtune |
1fec52be | 10623 | Tune to @var{cpu-type} everything applicable about the generated code, |
f13e0d4e UW |
10624 | except for the ABI and the set of available instructions. |
10625 | The list of @var{cpu-type} values is the same as for @option{-march}. | |
10626 | The default is the value used for @option{-march}. | |
1fec52be | 10627 | |
f26c1794 EC |
10628 | @item -mtpf-trace |
10629 | @itemx -mno-tpf-trace | |
10630 | @opindex mtpf-trace | |
10631 | @opindex mno-tpf-trace | |
10632 | Generate code that adds (does not add) in TPF OS specific branches to trace | |
10633 | routines in the operating system. This option is off by default, even | |
10634 | when compiling for the TPF OS. | |
10635 | ||
f2d226e1 AK |
10636 | @item -mfused-madd |
10637 | @itemx -mno-fused-madd | |
10638 | @opindex mfused-madd | |
10639 | @opindex mno-fused-madd | |
10640 | Generate code that uses (does not use) the floating point multiply and | |
10641 | accumulate instructions. These instructions are generated by default if | |
10642 | hardware floating point is used. | |
d75f90f1 AK |
10643 | |
10644 | @item -mwarn-framesize=@var{framesize} | |
10645 | @opindex mwarn-framesize | |
10646 | Emit a warning if the current function exceeds the given frame size. Because | |
10647 | this is a compile time check it doesn't need to be a real problem when the program | |
10648 | runs. It is intended to identify functions which most probably cause | |
10649 | a stack overflow. It is useful to be used in an environment with limited stack | |
10650 | size e.g. the linux kernel. | |
10651 | ||
10652 | @item -mwarn-dynamicstack | |
10653 | @opindex mwarn-dynamicstack | |
10654 | Emit a warning if the function calls alloca or uses dynamically | |
10655 | sized arrays. This is generally a bad idea with a limited stack size. | |
10656 | ||
10657 | @item -mstack-guard=@var{stack-guard} | |
10658 | @item -mstack-size=@var{stack-size} | |
10659 | @opindex mstack-guard | |
10660 | @opindex mstack-size | |
10661 | These arguments always have to be used in conjunction. If they are present the s390 | |
10662 | back end emits additional instructions in the function prologue which trigger a trap | |
10663 | if the stack size is @var{stack-guard} bytes above the @var{stack-size} | |
10664 | (remember that the stack on s390 grows downward). These options are intended to | |
10665 | be used to help debugging stack overflow problems. The additionally emitted code | |
10666 | cause only little overhead and hence can also be used in production like systems | |
10667 | without greater performance degradation. The given values have to be exact | |
10668 | powers of 2 and @var{stack-size} has to be greater than @var{stack-guard}. | |
10669 | In order to be efficient the extra code makes the assumption that the stack starts | |
10670 | at an address aligned to the value given by @var{stack-size}. | |
91abf72d HP |
10671 | @end table |
10672 | ||
39bc1876 NS |
10673 | @node SH Options |
10674 | @subsection SH Options | |
bcf684c7 | 10675 | |
39bc1876 | 10676 | These @samp{-m} options are defined for the SH implementations: |
bcf684c7 | 10677 | |
5d22c1a5 | 10678 | @table @gcctabopt |
39bc1876 NS |
10679 | @item -m1 |
10680 | @opindex m1 | |
10681 | Generate code for the SH1. | |
9f85bca7 | 10682 | |
39bc1876 NS |
10683 | @item -m2 |
10684 | @opindex m2 | |
10685 | Generate code for the SH2. | |
9f85bca7 | 10686 | |
39bc1876 NS |
10687 | @item -m2e |
10688 | Generate code for the SH2e. | |
9f85bca7 | 10689 | |
39bc1876 NS |
10690 | @item -m3 |
10691 | @opindex m3 | |
10692 | Generate code for the SH3. | |
9f85bca7 | 10693 | |
39bc1876 NS |
10694 | @item -m3e |
10695 | @opindex m3e | |
10696 | Generate code for the SH3e. | |
9f85bca7 | 10697 | |
39bc1876 NS |
10698 | @item -m4-nofpu |
10699 | @opindex m4-nofpu | |
10700 | Generate code for the SH4 without a floating-point unit. | |
9f85bca7 | 10701 | |
39bc1876 NS |
10702 | @item -m4-single-only |
10703 | @opindex m4-single-only | |
10704 | Generate code for the SH4 with a floating-point unit that only | |
10705 | supports single-precision arithmetic. | |
9f85bca7 | 10706 | |
39bc1876 NS |
10707 | @item -m4-single |
10708 | @opindex m4-single | |
10709 | Generate code for the SH4 assuming the floating-point unit is in | |
10710 | single-precision mode by default. | |
9f85bca7 | 10711 | |
39bc1876 NS |
10712 | @item -m4 |
10713 | @opindex m4 | |
10714 | Generate code for the SH4. | |
9f85bca7 | 10715 | |
312209c6 AO |
10716 | @item -m4a-nofpu |
10717 | @opindex m4a-nofpu | |
10718 | Generate code for the SH4al-dsp, or for a SH4a in such a way that the | |
10719 | floating-point unit is not used. | |
10720 | ||
10721 | @item -m4a-single-only | |
10722 | @opindex m4a-single-only | |
10723 | Generate code for the SH4a, in such a way that no double-precision | |
10724 | floating point operations are used. | |
10725 | ||
10726 | @item -m4a-single | |
10727 | @opindex m4a-single | |
10728 | Generate code for the SH4a assuming the floating-point unit is in | |
10729 | single-precision mode by default. | |
10730 | ||
10731 | @item -m4a | |
10732 | @opindex m4a | |
10733 | Generate code for the SH4a. | |
10734 | ||
10735 | @item -m4al | |
10736 | @opindex m4al | |
10737 | Same as @option{-m4a-nofpu}, except that it implicitly passes | |
10738 | @option{-dsp} to the assembler. GCC doesn't generate any DSP | |
10739 | instructions at the moment. | |
10740 | ||
39bc1876 NS |
10741 | @item -mb |
10742 | @opindex mb | |
10743 | Compile code for the processor in big endian mode. | |
9f85bca7 | 10744 | |
39bc1876 NS |
10745 | @item -ml |
10746 | @opindex ml | |
10747 | Compile code for the processor in little endian mode. | |
9f85bca7 | 10748 | |
39bc1876 NS |
10749 | @item -mdalign |
10750 | @opindex mdalign | |
10751 | Align doubles at 64-bit boundaries. Note that this changes the calling | |
10752 | conventions, and thus some functions from the standard C library will | |
10753 | not work unless you recompile it first with @option{-mdalign}. | |
9f85bca7 | 10754 | |
39bc1876 NS |
10755 | @item -mrelax |
10756 | @opindex mrelax | |
10757 | Shorten some address references at link time, when possible; uses the | |
10758 | linker option @option{-relax}. | |
9f85bca7 | 10759 | |
39bc1876 NS |
10760 | @item -mbigtable |
10761 | @opindex mbigtable | |
10762 | Use 32-bit offsets in @code{switch} tables. The default is to use | |
10763 | 16-bit offsets. | |
9f85bca7 | 10764 | |
39bc1876 NS |
10765 | @item -mfmovd |
10766 | @opindex mfmovd | |
10767 | Enable the use of the instruction @code{fmovd}. | |
9f85bca7 | 10768 | |
39bc1876 NS |
10769 | @item -mhitachi |
10770 | @opindex mhitachi | |
10771 | Comply with the calling conventions defined by Renesas. | |
9f85bca7 | 10772 | |
2acc29bd NC |
10773 | @item -mrenesas |
10774 | @opindex mhitachi | |
10775 | Comply with the calling conventions defined by Renesas. | |
10776 | ||
10777 | @item -mno-renesas | |
10778 | @opindex mhitachi | |
10779 | Comply with the calling conventions defined for GCC before the Renesas | |
10780 | conventions were available. This option is the default for all | |
10781 | targets of the SH toolchain except for @samp{sh-symbianelf}. | |
10782 | ||
39bc1876 NS |
10783 | @item -mnomacsave |
10784 | @opindex mnomacsave | |
10785 | Mark the @code{MAC} register as call-clobbered, even if | |
10786 | @option{-mhitachi} is given. | |
9f85bca7 | 10787 | |
39bc1876 NS |
10788 | @item -mieee |
10789 | @opindex mieee | |
10790 | Increase IEEE-compliance of floating-point code. | |
9f85bca7 | 10791 | |
39bc1876 NS |
10792 | @item -misize |
10793 | @opindex misize | |
10794 | Dump instruction size and location in the assembly code. | |
9f85bca7 | 10795 | |
39bc1876 NS |
10796 | @item -mpadstruct |
10797 | @opindex mpadstruct | |
10798 | This option is deprecated. It pads structures to multiple of 4 bytes, | |
10799 | which is incompatible with the SH ABI@. | |
9f85bca7 | 10800 | |
39bc1876 NS |
10801 | @item -mspace |
10802 | @opindex mspace | |
10803 | Optimize for space instead of speed. Implied by @option{-Os}. | |
9f85bca7 | 10804 | |
39bc1876 NS |
10805 | @item -mprefergot |
10806 | @opindex mprefergot | |
10807 | When generating position-independent code, emit function calls using | |
10808 | the Global Offset Table instead of the Procedure Linkage Table. | |
9f85bca7 | 10809 | |
39bc1876 NS |
10810 | @item -musermode |
10811 | @opindex musermode | |
10812 | Generate a library function call to invalidate instruction cache | |
10813 | entries, after fixing up a trampoline. This library function call | |
10814 | doesn't assume it can write to the whole memory address space. This | |
10815 | is the default when the target is @code{sh-*-linux*}. | |
9f85bca7 JM |
10816 | @end table |
10817 | ||
39bc1876 NS |
10818 | @node SPARC Options |
10819 | @subsection SPARC Options | |
10820 | @cindex SPARC options | |
69a0611f | 10821 | |
39bc1876 | 10822 | These @samp{-m} options are supported on the SPARC: |
69a0611f GK |
10823 | |
10824 | @table @gcctabopt | |
39bc1876 NS |
10825 | @item -mno-app-regs |
10826 | @itemx -mapp-regs | |
10827 | @opindex mno-app-regs | |
10828 | @opindex mapp-regs | |
10829 | Specify @option{-mapp-regs} to generate output using the global registers | |
10830 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. This | |
10831 | is the default. | |
69a0611f | 10832 | |
39bc1876 NS |
10833 | To be fully SVR4 ABI compliant at the cost of some performance loss, |
10834 | specify @option{-mno-app-regs}. You should compile libraries and system | |
10835 | software with this option. | |
70899148 | 10836 | |
39bc1876 NS |
10837 | @item -mfpu |
10838 | @itemx -mhard-float | |
10839 | @opindex mfpu | |
10840 | @opindex mhard-float | |
10841 | Generate output containing floating point instructions. This is the | |
10842 | default. | |
70899148 | 10843 | |
39bc1876 NS |
10844 | @item -mno-fpu |
10845 | @itemx -msoft-float | |
10846 | @opindex mno-fpu | |
10847 | @opindex msoft-float | |
10848 | Generate output containing library calls for floating point. | |
10849 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
10850 | targets. Normally the facilities of the machine's usual C compiler are | |
10851 | used, but this cannot be done directly in cross-compilation. You must make | |
10852 | your own arrangements to provide suitable library functions for | |
10853 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
10854 | @samp{sparclite-*-*} do provide software floating point support. | |
70899148 | 10855 | |
39bc1876 NS |
10856 | @option{-msoft-float} changes the calling convention in the output file; |
10857 | therefore, it is only useful if you compile @emph{all} of a program with | |
10858 | this option. In particular, you need to compile @file{libgcc.a}, the | |
10859 | library that comes with GCC, with @option{-msoft-float} in order for | |
10860 | this to work. | |
70899148 | 10861 | |
39bc1876 NS |
10862 | @item -mhard-quad-float |
10863 | @opindex mhard-quad-float | |
10864 | Generate output containing quad-word (long double) floating point | |
10865 | instructions. | |
70899148 | 10866 | |
39bc1876 NS |
10867 | @item -msoft-quad-float |
10868 | @opindex msoft-quad-float | |
10869 | Generate output containing library calls for quad-word (long double) | |
10870 | floating point instructions. The functions called are those specified | |
10871 | in the SPARC ABI@. This is the default. | |
70899148 | 10872 | |
39bc1876 NS |
10873 | As of this writing, there are no SPARC implementations that have hardware |
10874 | support for the quad-word floating point instructions. They all invoke | |
10875 | a trap handler for one of these instructions, and then the trap handler | |
10876 | emulates the effect of the instruction. Because of the trap handler overhead, | |
10877 | this is much slower than calling the ABI library routines. Thus the | |
10878 | @option{-msoft-quad-float} option is the default. | |
70899148 | 10879 | |
39bc1876 NS |
10880 | @item -mno-unaligned-doubles |
10881 | @itemx -munaligned-doubles | |
10882 | @opindex mno-unaligned-doubles | |
10883 | @opindex munaligned-doubles | |
10884 | Assume that doubles have 8 byte alignment. This is the default. | |
70899148 | 10885 | |
39bc1876 NS |
10886 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8 byte |
10887 | alignment only if they are contained in another type, or if they have an | |
10888 | absolute address. Otherwise, it assumes they have 4 byte alignment. | |
10889 | Specifying this option avoids some rare compatibility problems with code | |
10890 | generated by other compilers. It is not the default because it results | |
10891 | in a performance loss, especially for floating point code. | |
70899148 | 10892 | |
39bc1876 NS |
10893 | @item -mno-faster-structs |
10894 | @itemx -mfaster-structs | |
10895 | @opindex mno-faster-structs | |
10896 | @opindex mfaster-structs | |
10897 | With @option{-mfaster-structs}, the compiler assumes that structures | |
10898 | should have 8 byte alignment. This enables the use of pairs of | |
10899 | @code{ldd} and @code{std} instructions for copies in structure | |
10900 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
10901 | However, the use of this changed alignment directly violates the SPARC | |
10902 | ABI@. Thus, it's intended only for use on targets where the developer | |
10903 | acknowledges that their resulting code will not be directly in line with | |
10904 | the rules of the ABI@. | |
70899148 | 10905 | |
39bc1876 NS |
10906 | @item -mimpure-text |
10907 | @opindex mimpure-text | |
10908 | @option{-mimpure-text}, used in addition to @option{-shared}, tells | |
10909 | the compiler to not pass @option{-z text} to the linker when linking a | |
10910 | shared object. Using this option, you can link position-dependent | |
10911 | code into a shared object. | |
70899148 | 10912 | |
39bc1876 NS |
10913 | @option{-mimpure-text} suppresses the ``relocations remain against |
10914 | allocatable but non-writable sections'' linker error message. | |
10915 | However, the necessary relocations will trigger copy-on-write, and the | |
10916 | shared object is not actually shared across processes. Instead of | |
10917 | using @option{-mimpure-text}, you should compile all source code with | |
10918 | @option{-fpic} or @option{-fPIC}. | |
10919 | ||
10920 | This option is only available on SunOS and Solaris. | |
10921 | ||
10922 | @item -mcpu=@var{cpu_type} | |
10923 | @opindex mcpu | |
10924 | Set the instruction set, register set, and instruction scheduling parameters | |
10925 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
10926 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite}, | |
10927 | @samp{f930}, @samp{f934}, @samp{hypersparc}, @samp{sparclite86x}, | |
10928 | @samp{sparclet}, @samp{tsc701}, @samp{v9}, @samp{ultrasparc}, and | |
10929 | @samp{ultrasparc3}. | |
70899148 | 10930 | |
39bc1876 NS |
10931 | Default instruction scheduling parameters are used for values that select |
10932 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
10933 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
70899148 | 10934 | |
39bc1876 NS |
10935 | Here is a list of each supported architecture and their supported |
10936 | implementations. | |
70899148 | 10937 | |
39bc1876 NS |
10938 | @smallexample |
10939 | v7: cypress | |
10940 | v8: supersparc, hypersparc | |
10941 | sparclite: f930, f934, sparclite86x | |
10942 | sparclet: tsc701 | |
10943 | v9: ultrasparc, ultrasparc3 | |
10944 | @end smallexample | |
70899148 | 10945 | |
39bc1876 NS |
10946 | By default (unless configured otherwise), GCC generates code for the V7 |
10947 | variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler | |
10948 | additionally optimizes it for the Cypress CY7C602 chip, as used in the | |
10949 | SPARCStation/SPARCServer 3xx series. This is also appropriate for the older | |
10950 | SPARCStation 1, 2, IPX etc. | |
70899148 | 10951 | |
39bc1876 NS |
10952 | With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC |
10953 | architecture. The only difference from V7 code is that the compiler emits | |
10954 | the integer multiply and integer divide instructions which exist in SPARC-V8 | |
10955 | but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally | |
10956 | optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and | |
10957 | 2000 series. | |
70899148 | 10958 | |
39bc1876 NS |
10959 | With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of |
10960 | the SPARC architecture. This adds the integer multiply, integer divide step | |
10961 | and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7. | |
10962 | With @option{-mcpu=f930}, the compiler additionally optimizes it for the | |
10963 | Fujitsu MB86930 chip, which is the original SPARClite, with no FPU. With | |
10964 | @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu | |
10965 | MB86934 chip, which is the more recent SPARClite with FPU. | |
70899148 | 10966 | |
39bc1876 NS |
10967 | With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of |
10968 | the SPARC architecture. This adds the integer multiply, multiply/accumulate, | |
10969 | integer divide step and scan (@code{ffs}) instructions which exist in SPARClet | |
10970 | but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally | |
10971 | optimizes it for the TEMIC SPARClet chip. | |
70899148 | 10972 | |
39bc1876 NS |
10973 | With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC |
10974 | architecture. This adds 64-bit integer and floating-point move instructions, | |
10975 | 3 additional floating-point condition code registers and conditional move | |
10976 | instructions. With @option{-mcpu=ultrasparc}, the compiler additionally | |
10977 | optimizes it for the Sun UltraSPARC I/II chips. With | |
10978 | @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the | |
10979 | Sun UltraSPARC III chip. | |
70899148 | 10980 | |
39bc1876 NS |
10981 | @item -mtune=@var{cpu_type} |
10982 | @opindex mtune | |
10983 | Set the instruction scheduling parameters for machine type | |
10984 | @var{cpu_type}, but do not set the instruction set or register set that the | |
10985 | option @option{-mcpu=@var{cpu_type}} would. | |
70899148 | 10986 | |
39bc1876 NS |
10987 | The same values for @option{-mcpu=@var{cpu_type}} can be used for |
10988 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
10989 | that select a particular cpu implementation. Those are @samp{cypress}, | |
10990 | @samp{supersparc}, @samp{hypersparc}, @samp{f930}, @samp{f934}, | |
10991 | @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, and | |
10992 | @samp{ultrasparc3}. | |
70899148 | 10993 | |
39bc1876 NS |
10994 | @item -mv8plus |
10995 | @itemx -mno-v8plus | |
10996 | @opindex mv8plus | |
10997 | @opindex mno-v8plus | |
10998 | With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI. The | |
10999 | difference from the V8 ABI is that the global and out registers are | |
11000 | considered 64-bit wide. This is enabled by default on Solaris in 32-bit | |
11001 | mode for all SPARC-V9 processors. | |
70899148 | 11002 | |
39bc1876 NS |
11003 | @item -mvis |
11004 | @itemx -mno-vis | |
11005 | @opindex mvis | |
11006 | @opindex mno-vis | |
11007 | With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC | |
11008 | Visual Instruction Set extensions. The default is @option{-mno-vis}. | |
11009 | @end table | |
70899148 | 11010 | |
39bc1876 NS |
11011 | These @samp{-m} options are supported in addition to the above |
11012 | on SPARC-V9 processors in 64-bit environments: | |
70899148 | 11013 | |
39bc1876 NS |
11014 | @table @gcctabopt |
11015 | @item -mlittle-endian | |
11016 | @opindex mlittle-endian | |
11017 | Generate code for a processor running in little-endian mode. It is only | |
11018 | available for a few configurations and most notably not on Solaris. | |
70899148 | 11019 | |
39bc1876 NS |
11020 | @item -m32 |
11021 | @itemx -m64 | |
11022 | @opindex m32 | |
11023 | @opindex m64 | |
11024 | Generate code for a 32-bit or 64-bit environment. | |
11025 | The 32-bit environment sets int, long and pointer to 32 bits. | |
11026 | The 64-bit environment sets int to 32 bits and long and pointer | |
11027 | to 64 bits. | |
70899148 | 11028 | |
39bc1876 NS |
11029 | @item -mcmodel=medlow |
11030 | @opindex mcmodel=medlow | |
11031 | Generate code for the Medium/Low code model: 64-bit addresses, programs | |
11032 | must be linked in the low 32 bits of memory. Programs can be statically | |
11033 | or dynamically linked. | |
70899148 | 11034 | |
39bc1876 NS |
11035 | @item -mcmodel=medmid |
11036 | @opindex mcmodel=medmid | |
11037 | Generate code for the Medium/Middle code model: 64-bit addresses, programs | |
11038 | must be linked in the low 44 bits of memory, the text and data segments must | |
11039 | be less than 2GB in size and the data segment must be located within 2GB of | |
11040 | the text segment. | |
70899148 | 11041 | |
39bc1876 NS |
11042 | @item -mcmodel=medany |
11043 | @opindex mcmodel=medany | |
11044 | Generate code for the Medium/Anywhere code model: 64-bit addresses, programs | |
11045 | may be linked anywhere in memory, the text and data segments must be less | |
11046 | than 2GB in size and the data segment must be located within 2GB of the | |
11047 | text segment. | |
70899148 | 11048 | |
39bc1876 NS |
11049 | @item -mcmodel=embmedany |
11050 | @opindex mcmodel=embmedany | |
11051 | Generate code for the Medium/Anywhere code model for embedded systems: | |
11052 | 64-bit addresses, the text and data segments must be less than 2GB in | |
11053 | size, both starting anywhere in memory (determined at link time). The | |
11054 | global register %g4 points to the base of the data segment. Programs | |
11055 | are statically linked and PIC is not supported. | |
70899148 | 11056 | |
39bc1876 NS |
11057 | @item -mstack-bias |
11058 | @itemx -mno-stack-bias | |
11059 | @opindex mstack-bias | |
11060 | @opindex mno-stack-bias | |
11061 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and | |
11062 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
11063 | when making stack frame references. This is the default in 64-bit mode. | |
11064 | Otherwise, assume no such offset is present. | |
11065 | @end table | |
70899148 | 11066 | |
6bfb2f93 EB |
11067 | These switches are supported in addition to the above on Solaris: |
11068 | ||
11069 | @table @gcctabopt | |
11070 | @item -threads | |
11071 | @opindex threads | |
11072 | Add support for multithreading using the Solaris threads library. This | |
11073 | option sets flags for both the preprocessor and linker. This option does | |
11074 | not affect the thread safety of object code produced by the compiler or | |
11075 | that of libraries supplied with it. | |
11076 | ||
11077 | @item -pthreads | |
11078 | @opindex pthreads | |
11079 | Add support for multithreading using the POSIX threads library. This | |
11080 | option sets flags for both the preprocessor and linker. This option does | |
11081 | not affect the thread safety of object code produced by the compiler or | |
11082 | that of libraries supplied with it. | |
11083 | @end table | |
11084 | ||
39bc1876 NS |
11085 | @node System V Options |
11086 | @subsection Options for System V | |
70899148 | 11087 | |
39bc1876 NS |
11088 | These additional options are available on System V Release 4 for |
11089 | compatibility with other compilers on those systems: | |
70899148 | 11090 | |
39bc1876 NS |
11091 | @table @gcctabopt |
11092 | @item -G | |
11093 | @opindex G | |
11094 | Create a shared object. | |
11095 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. | |
70899148 | 11096 | |
39bc1876 NS |
11097 | @item -Qy |
11098 | @opindex Qy | |
11099 | Identify the versions of each tool used by the compiler, in a | |
11100 | @code{.ident} assembler directive in the output. | |
70899148 | 11101 | |
39bc1876 NS |
11102 | @item -Qn |
11103 | @opindex Qn | |
11104 | Refrain from adding @code{.ident} directives to the output file (this is | |
11105 | the default). | |
70899148 | 11106 | |
39bc1876 NS |
11107 | @item -YP,@var{dirs} |
11108 | @opindex YP | |
11109 | Search the directories @var{dirs}, and no others, for libraries | |
11110 | specified with @option{-l}. | |
70899148 | 11111 | |
39bc1876 NS |
11112 | @item -Ym,@var{dir} |
11113 | @opindex Ym | |
11114 | Look in the directory @var{dir} to find the M4 preprocessor. | |
11115 | The assembler uses this option. | |
11116 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
11117 | @c the generic assembler that comes with Solaris takes just -Ym. | |
11118 | @end table | |
70899148 | 11119 | |
39bc1876 NS |
11120 | @node TMS320C3x/C4x Options |
11121 | @subsection TMS320C3x/C4x Options | |
11122 | @cindex TMS320C3x/C4x Options | |
70899148 | 11123 | |
39bc1876 | 11124 | These @samp{-m} options are defined for TMS320C3x/C4x implementations: |
70899148 | 11125 | |
39bc1876 | 11126 | @table @gcctabopt |
70899148 | 11127 | |
39bc1876 NS |
11128 | @item -mcpu=@var{cpu_type} |
11129 | @opindex mcpu | |
11130 | Set the instruction set, register set, and instruction scheduling | |
11131 | parameters for machine type @var{cpu_type}. Supported values for | |
11132 | @var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and | |
11133 | @samp{c44}. The default is @samp{c40} to generate code for the | |
11134 | TMS320C40. | |
70899148 | 11135 | |
39bc1876 NS |
11136 | @item -mbig-memory |
11137 | @itemx -mbig | |
11138 | @itemx -msmall-memory | |
11139 | @itemx -msmall | |
11140 | @opindex mbig-memory | |
11141 | @opindex mbig | |
11142 | @opindex msmall-memory | |
11143 | @opindex msmall | |
11144 | Generates code for the big or small memory model. The small memory | |
11145 | model assumed that all data fits into one 64K word page. At run-time | |
11146 | the data page (DP) register must be set to point to the 64K page | |
11147 | containing the .bss and .data program sections. The big memory model is | |
11148 | the default and requires reloading of the DP register for every direct | |
11149 | memory access. | |
70899148 | 11150 | |
39bc1876 NS |
11151 | @item -mbk |
11152 | @itemx -mno-bk | |
11153 | @opindex mbk | |
11154 | @opindex mno-bk | |
11155 | Allow (disallow) allocation of general integer operands into the block | |
11156 | count register BK@. | |
70899148 | 11157 | |
39bc1876 NS |
11158 | @item -mdb |
11159 | @itemx -mno-db | |
11160 | @opindex mdb | |
11161 | @opindex mno-db | |
11162 | Enable (disable) generation of code using decrement and branch, | |
11163 | DBcond(D), instructions. This is enabled by default for the C4x. To be | |
11164 | on the safe side, this is disabled for the C3x, since the maximum | |
11165 | iteration count on the C3x is @math{2^{23} + 1} (but who iterates loops more than | |
11166 | @math{2^{23}} times on the C3x?). Note that GCC will try to reverse a loop so | |
11167 | that it can utilize the decrement and branch instruction, but will give | |
11168 | up if there is more than one memory reference in the loop. Thus a loop | |
11169 | where the loop counter is decremented can generate slightly more | |
11170 | efficient code, in cases where the RPTB instruction cannot be utilized. | |
70899148 | 11171 | |
39bc1876 NS |
11172 | @item -mdp-isr-reload |
11173 | @itemx -mparanoid | |
11174 | @opindex mdp-isr-reload | |
11175 | @opindex mparanoid | |
11176 | Force the DP register to be saved on entry to an interrupt service | |
11177 | routine (ISR), reloaded to point to the data section, and restored on | |
11178 | exit from the ISR@. This should not be required unless someone has | |
11179 | violated the small memory model by modifying the DP register, say within | |
11180 | an object library. | |
70899148 | 11181 | |
39bc1876 NS |
11182 | @item -mmpyi |
11183 | @itemx -mno-mpyi | |
11184 | @opindex mmpyi | |
11185 | @opindex mno-mpyi | |
11186 | For the C3x use the 24-bit MPYI instruction for integer multiplies | |
11187 | instead of a library call to guarantee 32-bit results. Note that if one | |
11188 | of the operands is a constant, then the multiplication will be performed | |
11189 | using shifts and adds. If the @option{-mmpyi} option is not specified for the C3x, | |
11190 | then squaring operations are performed inline instead of a library call. | |
70899148 | 11191 | |
39bc1876 NS |
11192 | @item -mfast-fix |
11193 | @itemx -mno-fast-fix | |
11194 | @opindex mfast-fix | |
11195 | @opindex mno-fast-fix | |
11196 | The C3x/C4x FIX instruction to convert a floating point value to an | |
11197 | integer value chooses the nearest integer less than or equal to the | |
11198 | floating point value rather than to the nearest integer. Thus if the | |
11199 | floating point number is negative, the result will be incorrectly | |
11200 | truncated an additional code is necessary to detect and correct this | |
11201 | case. This option can be used to disable generation of the additional | |
11202 | code required to correct the result. | |
70899148 | 11203 | |
39bc1876 NS |
11204 | @item -mrptb |
11205 | @itemx -mno-rptb | |
11206 | @opindex mrptb | |
11207 | @opindex mno-rptb | |
11208 | Enable (disable) generation of repeat block sequences using the RPTB | |
11209 | instruction for zero overhead looping. The RPTB construct is only used | |
11210 | for innermost loops that do not call functions or jump across the loop | |
11211 | boundaries. There is no advantage having nested RPTB loops due to the | |
11212 | overhead required to save and restore the RC, RS, and RE registers. | |
11213 | This is enabled by default with @option{-O2}. | |
70899148 | 11214 | |
39bc1876 NS |
11215 | @item -mrpts=@var{count} |
11216 | @itemx -mno-rpts | |
11217 | @opindex mrpts | |
11218 | @opindex mno-rpts | |
11219 | Enable (disable) the use of the single instruction repeat instruction | |
11220 | RPTS@. If a repeat block contains a single instruction, and the loop | |
11221 | count can be guaranteed to be less than the value @var{count}, GCC will | |
11222 | emit a RPTS instruction instead of a RPTB@. If no value is specified, | |
11223 | then a RPTS will be emitted even if the loop count cannot be determined | |
11224 | at compile time. Note that the repeated instruction following RPTS does | |
11225 | not have to be reloaded from memory each iteration, thus freeing up the | |
11226 | CPU buses for operands. However, since interrupts are blocked by this | |
11227 | instruction, it is disabled by default. | |
70899148 | 11228 | |
39bc1876 NS |
11229 | @item -mloop-unsigned |
11230 | @itemx -mno-loop-unsigned | |
11231 | @opindex mloop-unsigned | |
11232 | @opindex mno-loop-unsigned | |
11233 | The maximum iteration count when using RPTS and RPTB (and DB on the C40) | |
11234 | is @math{2^{31} + 1} since these instructions test if the iteration count is | |
11235 | negative to terminate the loop. If the iteration count is unsigned | |
11236 | there is a possibility than the @math{2^{31} + 1} maximum iteration count may be | |
11237 | exceeded. This switch allows an unsigned iteration count. | |
70899148 | 11238 | |
39bc1876 NS |
11239 | @item -mti |
11240 | @opindex mti | |
11241 | Try to emit an assembler syntax that the TI assembler (asm30) is happy | |
11242 | with. This also enforces compatibility with the API employed by the TI | |
11243 | C3x C compiler. For example, long doubles are passed as structures | |
11244 | rather than in floating point registers. | |
70899148 | 11245 | |
39bc1876 NS |
11246 | @item -mregparm |
11247 | @itemx -mmemparm | |
11248 | @opindex mregparm | |
11249 | @opindex mmemparm | |
11250 | Generate code that uses registers (stack) for passing arguments to functions. | |
11251 | By default, arguments are passed in registers where possible rather | |
11252 | than by pushing arguments on to the stack. | |
70899148 | 11253 | |
39bc1876 NS |
11254 | @item -mparallel-insns |
11255 | @itemx -mno-parallel-insns | |
11256 | @opindex mparallel-insns | |
11257 | @opindex mno-parallel-insns | |
11258 | Allow the generation of parallel instructions. This is enabled by | |
11259 | default with @option{-O2}. | |
70899148 | 11260 | |
39bc1876 NS |
11261 | @item -mparallel-mpy |
11262 | @itemx -mno-parallel-mpy | |
11263 | @opindex mparallel-mpy | |
11264 | @opindex mno-parallel-mpy | |
11265 | Allow the generation of MPY||ADD and MPY||SUB parallel instructions, | |
11266 | provided @option{-mparallel-insns} is also specified. These instructions have | |
11267 | tight register constraints which can pessimize the code generation | |
11268 | of large functions. | |
70899148 | 11269 | |
39bc1876 | 11270 | @end table |
70899148 | 11271 | |
39bc1876 NS |
11272 | @node V850 Options |
11273 | @subsection V850 Options | |
11274 | @cindex V850 Options | |
70899148 | 11275 | |
39bc1876 | 11276 | These @samp{-m} options are defined for V850 implementations: |
70899148 | 11277 | |
39bc1876 NS |
11278 | @table @gcctabopt |
11279 | @item -mlong-calls | |
11280 | @itemx -mno-long-calls | |
11281 | @opindex mlong-calls | |
11282 | @opindex mno-long-calls | |
11283 | Treat all calls as being far away (near). If calls are assumed to be | |
11284 | far away, the compiler will always load the functions address up into a | |
11285 | register, and call indirect through the pointer. | |
70899148 | 11286 | |
39bc1876 NS |
11287 | @item -mno-ep |
11288 | @itemx -mep | |
11289 | @opindex mno-ep | |
11290 | @opindex mep | |
11291 | Do not optimize (do optimize) basic blocks that use the same index | |
11292 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
11293 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} | |
11294 | option is on by default if you optimize. | |
70899148 | 11295 | |
39bc1876 NS |
11296 | @item -mno-prolog-function |
11297 | @itemx -mprolog-function | |
11298 | @opindex mno-prolog-function | |
11299 | @opindex mprolog-function | |
11300 | Do not use (do use) external functions to save and restore registers | |
11301 | at the prologue and epilogue of a function. The external functions | |
11302 | are slower, but use less code space if more than one function saves | |
11303 | the same number of registers. The @option{-mprolog-function} option | |
11304 | is on by default if you optimize. | |
70899148 | 11305 | |
39bc1876 NS |
11306 | @item -mspace |
11307 | @opindex mspace | |
11308 | Try to make the code as small as possible. At present, this just turns | |
11309 | on the @option{-mep} and @option{-mprolog-function} options. | |
70899148 | 11310 | |
39bc1876 NS |
11311 | @item -mtda=@var{n} |
11312 | @opindex mtda | |
11313 | Put static or global variables whose size is @var{n} bytes or less into | |
11314 | the tiny data area that register @code{ep} points to. The tiny data | |
11315 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
70899148 | 11316 | |
39bc1876 NS |
11317 | @item -msda=@var{n} |
11318 | @opindex msda | |
11319 | Put static or global variables whose size is @var{n} bytes or less into | |
11320 | the small data area that register @code{gp} points to. The small data | |
11321 | area can hold up to 64 kilobytes. | |
70899148 | 11322 | |
39bc1876 NS |
11323 | @item -mzda=@var{n} |
11324 | @opindex mzda | |
11325 | Put static or global variables whose size is @var{n} bytes or less into | |
11326 | the first 32 kilobytes of memory. | |
70899148 | 11327 | |
39bc1876 NS |
11328 | @item -mv850 |
11329 | @opindex mv850 | |
11330 | Specify that the target processor is the V850. | |
70899148 | 11331 | |
39bc1876 NS |
11332 | @item -mbig-switch |
11333 | @opindex mbig-switch | |
11334 | Generate code suitable for big switch tables. Use this option only if | |
11335 | the assembler/linker complain about out of range branches within a switch | |
11336 | table. | |
70899148 | 11337 | |
39bc1876 NS |
11338 | @item -mapp-regs |
11339 | @opindex mapp-regs | |
11340 | This option will cause r2 and r5 to be used in the code generated by | |
11341 | the compiler. This setting is the default. | |
70899148 | 11342 | |
39bc1876 NS |
11343 | @item -mno-app-regs |
11344 | @opindex mno-app-regs | |
11345 | This option will cause r2 and r5 to be treated as fixed registers. | |
70899148 | 11346 | |
39bc1876 NS |
11347 | @item -mv850e1 |
11348 | @opindex mv850e1 | |
11349 | Specify that the target processor is the V850E1. The preprocessor | |
11350 | constants @samp{__v850e1__} and @samp{__v850e__} will be defined if | |
11351 | this option is used. | |
70899148 | 11352 | |
39bc1876 NS |
11353 | @item -mv850e |
11354 | @opindex mv850e | |
11355 | Specify that the target processor is the V850E. The preprocessor | |
11356 | constant @samp{__v850e__} will be defined if this option is used. | |
70899148 | 11357 | |
39bc1876 NS |
11358 | If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1} |
11359 | are defined then a default target processor will be chosen and the | |
11360 | relevant @samp{__v850*__} preprocessor constant will be defined. | |
70899148 | 11361 | |
39bc1876 NS |
11362 | The preprocessor constants @samp{__v850} and @samp{__v851__} are always |
11363 | defined, regardless of which processor variant is the target. | |
70899148 | 11364 | |
39bc1876 NS |
11365 | @item -mdisable-callt |
11366 | @opindex mdisable-callt | |
11367 | This option will suppress generation of the CALLT instruction for the | |
11368 | v850e and v850e1 flavors of the v850 architecture. The default is | |
11369 | @option{-mno-disable-callt} which allows the CALLT instruction to be used. | |
70899148 | 11370 | |
39bc1876 | 11371 | @end table |
70899148 | 11372 | |
39bc1876 NS |
11373 | @node VAX Options |
11374 | @subsection VAX Options | |
11375 | @cindex VAX options | |
70899148 | 11376 | |
39bc1876 | 11377 | These @samp{-m} options are defined for the VAX: |
70899148 | 11378 | |
39bc1876 NS |
11379 | @table @gcctabopt |
11380 | @item -munix | |
11381 | @opindex munix | |
11382 | Do not output certain jump instructions (@code{aobleq} and so on) | |
11383 | that the Unix assembler for the VAX cannot handle across long | |
11384 | ranges. | |
70899148 | 11385 | |
39bc1876 NS |
11386 | @item -mgnu |
11387 | @opindex mgnu | |
11388 | Do output those jump instructions, on the assumption that you | |
11389 | will assemble with the GNU assembler. | |
70899148 | 11390 | |
39bc1876 NS |
11391 | @item -mg |
11392 | @opindex mg | |
11393 | Output code for g-format floating point numbers instead of d-format. | |
11394 | @end table | |
70899148 | 11395 | |
39bc1876 NS |
11396 | @node x86-64 Options |
11397 | @subsection x86-64 Options | |
11398 | @cindex x86-64 options | |
70899148 | 11399 | |
39bc1876 | 11400 | These are listed under @xref{i386 and x86-64 Options}. |
70899148 | 11401 | |
39bc1876 NS |
11402 | @node Xstormy16 Options |
11403 | @subsection Xstormy16 Options | |
11404 | @cindex Xstormy16 Options | |
70899148 | 11405 | |
39bc1876 | 11406 | These options are defined for Xstormy16: |
70899148 | 11407 | |
39bc1876 NS |
11408 | @table @gcctabopt |
11409 | @item -msim | |
11410 | @opindex msim | |
11411 | Choose startup files and linker script suitable for the simulator. | |
70899148 BS |
11412 | @end table |
11413 | ||
03984308 BW |
11414 | @node Xtensa Options |
11415 | @subsection Xtensa Options | |
11416 | @cindex Xtensa Options | |
11417 | ||
6cedbe44 | 11418 | These options are supported for Xtensa targets: |
03984308 BW |
11419 | |
11420 | @table @gcctabopt | |
f42f5a1b BW |
11421 | @item -mconst16 |
11422 | @itemx -mno-const16 | |
11423 | @opindex mconst16 | |
11424 | @opindex mno-const16 | |
6c2e8d1c BW |
11425 | Enable or disable use of @code{CONST16} instructions for loading |
11426 | constant values. The @code{CONST16} instruction is currently not a | |
11427 | standard option from Tensilica. When enabled, @code{CONST16} | |
11428 | instructions are always used in place of the standard @code{L32R} | |
11429 | instructions. The use of @code{CONST16} is enabled by default only if | |
11430 | the @code{L32R} instruction is not available. | |
11431 | ||
03984308 BW |
11432 | @item -mfused-madd |
11433 | @itemx -mno-fused-madd | |
11434 | @opindex mfused-madd | |
11435 | @opindex mno-fused-madd | |
11436 | Enable or disable use of fused multiply/add and multiply/subtract | |
11437 | instructions in the floating-point option. This has no effect if the | |
11438 | floating-point option is not also enabled. Disabling fused multiply/add | |
11439 | and multiply/subtract instructions forces the compiler to use separate | |
11440 | instructions for the multiply and add/subtract operations. This may be | |
11441 | desirable in some cases where strict IEEE 754-compliant results are | |
11442 | required: the fused multiply add/subtract instructions do not round the | |
11443 | intermediate result, thereby producing results with @emph{more} bits of | |
11444 | precision than specified by the IEEE standard. Disabling fused multiply | |
11445 | add/subtract instructions also ensures that the program output is not | |
11446 | sensitive to the compiler's ability to combine multiply and add/subtract | |
11447 | operations. | |
11448 | ||
03984308 BW |
11449 | @item -mtext-section-literals |
11450 | @itemx -mno-text-section-literals | |
11451 | @opindex mtext-section-literals | |
11452 | @opindex mno-text-section-literals | |
11453 | Control the treatment of literal pools. The default is | |
11454 | @option{-mno-text-section-literals}, which places literals in a separate | |
11455 | section in the output file. This allows the literal pool to be placed | |
11456 | in a data RAM/ROM, and it also allows the linker to combine literal | |
11457 | pools from separate object files to remove redundant literals and | |
11458 | improve code size. With @option{-mtext-section-literals}, the literals | |
11459 | are interspersed in the text section in order to keep them as close as | |
11460 | possible to their references. This may be necessary for large assembly | |
11461 | files. | |
11462 | ||
11463 | @item -mtarget-align | |
11464 | @itemx -mno-target-align | |
11465 | @opindex mtarget-align | |
11466 | @opindex mno-target-align | |
11467 | When this option is enabled, GCC instructs the assembler to | |
11468 | automatically align instructions to reduce branch penalties at the | |
11469 | expense of some code density. The assembler attempts to widen density | |
11470 | instructions to align branch targets and the instructions following call | |
11471 | instructions. If there are not enough preceding safe density | |
11472 | instructions to align a target, no widening will be performed. The | |
11473 | default is @option{-mtarget-align}. These options do not affect the | |
11474 | treatment of auto-aligned instructions like @code{LOOP}, which the | |
11475 | assembler will always align, either by widening density instructions or | |
11476 | by inserting no-op instructions. | |
11477 | ||
11478 | @item -mlongcalls | |
11479 | @itemx -mno-longcalls | |
11480 | @opindex mlongcalls | |
11481 | @opindex mno-longcalls | |
11482 | When this option is enabled, GCC instructs the assembler to translate | |
11483 | direct calls to indirect calls unless it can determine that the target | |
11484 | of a direct call is in the range allowed by the call instruction. This | |
11485 | translation typically occurs for calls to functions in other source | |
11486 | files. Specifically, the assembler translates a direct @code{CALL} | |
11487 | instruction into an @code{L32R} followed by a @code{CALLX} instruction. | |
11488 | The default is @option{-mno-longcalls}. This option should be used in | |
11489 | programs where the call target can potentially be out of range. This | |
11490 | option is implemented in the assembler, not the compiler, so the | |
11491 | assembly code generated by GCC will still show direct call | |
11492 | instructions---look at the disassembled object code to see the actual | |
11493 | instructions. Note that the assembler will use an indirect call for | |
11494 | every cross-file call, not just those that really will be out of range. | |
11495 | @end table | |
11496 | ||
39bc1876 NS |
11497 | @node zSeries Options |
11498 | @subsection zSeries Options | |
11499 | @cindex zSeries options | |
11500 | ||
11501 | These are listed under @xref{S/390 and zSeries Options}. | |
11502 | ||
74291a4b MM |
11503 | @node Code Gen Options |
11504 | @section Options for Code Generation Conventions | |
11505 | @cindex code generation conventions | |
11506 | @cindex options, code generation | |
11507 | @cindex run-time options | |
11508 | ||
11509 | These machine-independent options control the interface conventions | |
11510 | used in code generation. | |
11511 | ||
11512 | Most of them have both positive and negative forms; the negative form | |
630d3d5a | 11513 | of @option{-ffoo} would be @option{-fno-foo}. In the table below, only |
74291a4b MM |
11514 | one of the forms is listed---the one which is not the default. You |
11515 | can figure out the other form by either removing @samp{no-} or adding | |
11516 | it. | |
11517 | ||
2642624b | 11518 | @table @gcctabopt |
d4463dfc JQ |
11519 | @item -fbounds-check |
11520 | @opindex fbounds-check | |
11521 | For front-ends that support it, generate additional code to check that | |
11522 | indices used to access arrays are within the declared range. This is | |
11523 | currently only supported by the Java and Fortran 77 front-ends, where | |
11524 | this option defaults to true and false respectively. | |
11525 | ||
11526 | @item -ftrapv | |
11527 | @opindex ftrapv | |
11528 | This option generates traps for signed overflow on addition, subtraction, | |
11529 | multiplication operations. | |
11530 | ||
4fa26a60 RS |
11531 | @item -fwrapv |
11532 | @opindex fwrapv | |
11533 | This option instructs the compiler to assume that signed arithmetic | |
11534 | overflow of addition, subtraction and multiplication wraps around | |
c0cbdbd9 | 11535 | using twos-complement representation. This flag enables some optimizations |
4fa26a60 RS |
11536 | and disables other. This option is enabled by default for the Java |
11537 | front-end, as required by the Java language specification. | |
11538 | ||
956d6950 | 11539 | @item -fexceptions |
cd3bb277 | 11540 | @opindex fexceptions |
767094dd | 11541 | Enable exception handling. Generates extra code needed to propagate |
f0523f02 | 11542 | exceptions. For some targets, this implies GCC will generate frame |
c5c76735 JL |
11543 | unwind information for all functions, which can produce significant data |
11544 | size overhead, although it does not affect execution. If you do not | |
f0523f02 | 11545 | specify this option, GCC will enable it by default for languages like |
90ecce3e | 11546 | C++ which normally require exception handling, and disable it for |
c5c76735 JL |
11547 | languages like C that do not normally require it. However, you may need |
11548 | to enable this option when compiling C code that needs to interoperate | |
11549 | properly with exception handlers written in C++. You may also wish to | |
11550 | disable this option if you are compiling older C++ programs that don't | |
11551 | use exception handling. | |
956d6950 | 11552 | |
6cfc0341 RH |
11553 | @item -fnon-call-exceptions |
11554 | @opindex fnon-call-exceptions | |
11555 | Generate code that allows trapping instructions to throw exceptions. | |
11556 | Note that this requires platform-specific runtime support that does | |
11557 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
e979f9e8 | 11558 | instructions to throw exceptions, i.e.@: memory references or floating |
6cfc0341 RH |
11559 | point instructions. It does not allow exceptions to be thrown from |
11560 | arbitrary signal handlers such as @code{SIGALRM}. | |
11561 | ||
14a774a9 | 11562 | @item -funwind-tables |
cd3bb277 | 11563 | @opindex funwind-tables |
bedc7537 | 11564 | Similar to @option{-fexceptions}, except that it will just generate any needed |
14a774a9 RK |
11565 | static data, but will not affect the generated code in any other way. |
11566 | You will normally not enable this option; instead, a language processor | |
11567 | that needs this handling would enable it on your behalf. | |
11568 | ||
b932f770 | 11569 | @item -fasynchronous-unwind-tables |
2a9dc917 | 11570 | @opindex fasynchronous-unwind-tables |
b932f770 JH |
11571 | Generate unwind table in dwarf2 format, if supported by target machine. The |
11572 | table is exact at each instruction boundary, so it can be used for stack | |
11573 | unwinding from asynchronous events (such as debugger or garbage collector). | |
11574 | ||
74291a4b | 11575 | @item -fpcc-struct-return |
cd3bb277 | 11576 | @opindex fpcc-struct-return |
74291a4b MM |
11577 | Return ``short'' @code{struct} and @code{union} values in memory like |
11578 | longer ones, rather than in registers. This convention is less | |
11579 | efficient, but it has the advantage of allowing intercallability between | |
a9c60612 JJ |
11580 | GCC-compiled files and files compiled with other compilers, particularly |
11581 | the Portable C Compiler (pcc). | |
74291a4b MM |
11582 | |
11583 | The precise convention for returning structures in memory depends | |
11584 | on the target configuration macros. | |
11585 | ||
11586 | Short structures and unions are those whose size and alignment match | |
11587 | that of some integer type. | |
11588 | ||
a9c60612 JJ |
11589 | @strong{Warning:} code compiled with the @option{-fpcc-struct-return} |
11590 | switch is not binary compatible with code compiled with the | |
11591 | @option{-freg-struct-return} switch. | |
11592 | Use it to conform to a non-default application binary interface. | |
11593 | ||
74291a4b | 11594 | @item -freg-struct-return |
cd3bb277 | 11595 | @opindex freg-struct-return |
9c34dbbf ZW |
11596 | Return @code{struct} and @code{union} values in registers when possible. |
11597 | This is more efficient for small structures than | |
11598 | @option{-fpcc-struct-return}. | |
74291a4b | 11599 | |
9c34dbbf | 11600 | If you specify neither @option{-fpcc-struct-return} nor |
630d3d5a | 11601 | @option{-freg-struct-return}, GCC defaults to whichever convention is |
0c2d1a2a | 11602 | standard for the target. If there is no standard convention, GCC |
9c34dbbf ZW |
11603 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is |
11604 | the principal compiler. In those cases, we can choose the standard, and | |
11605 | we chose the more efficient register return alternative. | |
74291a4b | 11606 | |
a9c60612 JJ |
11607 | @strong{Warning:} code compiled with the @option{-freg-struct-return} |
11608 | switch is not binary compatible with code compiled with the | |
11609 | @option{-fpcc-struct-return} switch. | |
11610 | Use it to conform to a non-default application binary interface. | |
11611 | ||
74291a4b | 11612 | @item -fshort-enums |
cd3bb277 | 11613 | @opindex fshort-enums |
74291a4b MM |
11614 | Allocate to an @code{enum} type only as many bytes as it needs for the |
11615 | declared range of possible values. Specifically, the @code{enum} type | |
11616 | will be equivalent to the smallest integer type which has enough room. | |
11617 | ||
a9c60612 JJ |
11618 | @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate |
11619 | code that is not binary compatible with code generated without that switch. | |
11620 | Use it to conform to a non-default application binary interface. | |
11621 | ||
74291a4b | 11622 | @item -fshort-double |
cd3bb277 | 11623 | @opindex fshort-double |
74291a4b MM |
11624 | Use the same size for @code{double} as for @code{float}. |
11625 | ||
a9c60612 JJ |
11626 | @strong{Warning:} the @option{-fshort-double} switch causes GCC to generate |
11627 | code that is not binary compatible with code generated without that switch. | |
11628 | Use it to conform to a non-default application binary interface. | |
11629 | ||
11630 | @item -fshort-wchar | |
11631 | @opindex fshort-wchar | |
11632 | Override the underlying type for @samp{wchar_t} to be @samp{short | |
11633 | unsigned int} instead of the default for the target. This option is | |
11634 | useful for building programs to run under WINE@. | |
11635 | ||
11636 | @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate | |
11637 | code that is not binary compatible with code generated without that switch. | |
11638 | Use it to conform to a non-default application binary interface. | |
11639 | ||
74291a4b | 11640 | @item -fshared-data |
cd3bb277 | 11641 | @opindex fshared-data |
74291a4b MM |
11642 | Requests that the data and non-@code{const} variables of this |
11643 | compilation be shared data rather than private data. The distinction | |
11644 | makes sense only on certain operating systems, where shared data is | |
11645 | shared between processes running the same program, while private data | |
11646 | exists in one copy per process. | |
11647 | ||
11648 | @item -fno-common | |
cd3bb277 | 11649 | @opindex fno-common |
90ecce3e | 11650 | In C, allocate even uninitialized global variables in the data section of the |
74291a4b MM |
11651 | object file, rather than generating them as common blocks. This has the |
11652 | effect that if the same variable is declared (without @code{extern}) in | |
11653 | two different compilations, you will get an error when you link them. | |
11654 | The only reason this might be useful is if you wish to verify that the | |
11655 | program will work on other systems which always work this way. | |
11656 | ||
11657 | @item -fno-ident | |
cd3bb277 | 11658 | @opindex fno-ident |
74291a4b MM |
11659 | Ignore the @samp{#ident} directive. |
11660 | ||
74291a4b | 11661 | @item -finhibit-size-directive |
cd3bb277 | 11662 | @opindex finhibit-size-directive |
74291a4b MM |
11663 | Don't output a @code{.size} assembler directive, or anything else that |
11664 | would cause trouble if the function is split in the middle, and the | |
11665 | two halves are placed at locations far apart in memory. This option is | |
11666 | used when compiling @file{crtstuff.c}; you should not need to use it | |
11667 | for anything else. | |
11668 | ||
11669 | @item -fverbose-asm | |
cd3bb277 | 11670 | @opindex fverbose-asm |
74291a4b MM |
11671 | Put extra commentary information in the generated assembly code to |
11672 | make it more readable. This option is generally only of use to those | |
11673 | who actually need to read the generated assembly code (perhaps while | |
11674 | debugging the compiler itself). | |
11675 | ||
630d3d5a | 11676 | @option{-fno-verbose-asm}, the default, causes the |
74291a4b MM |
11677 | extra information to be omitted and is useful when comparing two assembler |
11678 | files. | |
11679 | ||
74291a4b | 11680 | @item -fpic |
cd3bb277 | 11681 | @opindex fpic |
74291a4b MM |
11682 | @cindex global offset table |
11683 | @cindex PIC | |
11684 | Generate position-independent code (PIC) suitable for use in a shared | |
11685 | library, if supported for the target machine. Such code accesses all | |
161d7b59 | 11686 | constant addresses through a global offset table (GOT)@. The dynamic |
861bb6c1 | 11687 | loader resolves the GOT entries when the program starts (the dynamic |
0c2d1a2a | 11688 | loader is not part of GCC; it is part of the operating system). If |
861bb6c1 JL |
11689 | the GOT size for the linked executable exceeds a machine-specific |
11690 | maximum size, you get an error message from the linker indicating that | |
630d3d5a | 11691 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} |
b6e69d94 | 11692 | instead. (These maximums are 8k on the SPARC and 32k |
861bb6c1 | 11693 | on the m68k and RS/6000. The 386 has no such limit.) |
74291a4b MM |
11694 | |
11695 | Position-independent code requires special support, and therefore works | |
0c2d1a2a | 11696 | only on certain machines. For the 386, GCC supports PIC for System V |
74291a4b MM |
11697 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always |
11698 | position-independent. | |
11699 | ||
74291a4b | 11700 | @item -fPIC |
cd3bb277 | 11701 | @opindex fPIC |
74291a4b MM |
11702 | If supported for the target machine, emit position-independent code, |
11703 | suitable for dynamic linking and avoiding any limit on the size of the | |
b6e69d94 | 11704 | global offset table. This option makes a difference on the m68k |
981f6289 | 11705 | and the SPARC. |
74291a4b MM |
11706 | |
11707 | Position-independent code requires special support, and therefore works | |
11708 | only on certain machines. | |
11709 | ||
24a4dd31 JJ |
11710 | @item -fpie |
11711 | @itemx -fPIE | |
11712 | @opindex fpie | |
11713 | @opindex fPIE | |
11714 | These options are similar to @option{-fpic} and @option{-fPIC}, but | |
11715 | generated position independent code can be only linked into executables. | |
11716 | Usually these options are used when @option{-pie} GCC option will be | |
11717 | used during linking. | |
11718 | ||
74291a4b | 11719 | @item -ffixed-@var{reg} |
cd3bb277 | 11720 | @opindex ffixed |
74291a4b MM |
11721 | Treat the register named @var{reg} as a fixed register; generated code |
11722 | should never refer to it (except perhaps as a stack pointer, frame | |
11723 | pointer or in some other fixed role). | |
11724 | ||
11725 | @var{reg} must be the name of a register. The register names accepted | |
11726 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
11727 | macro in the machine description macro file. | |
11728 | ||
11729 | This flag does not have a negative form, because it specifies a | |
11730 | three-way choice. | |
11731 | ||
11732 | @item -fcall-used-@var{reg} | |
cd3bb277 | 11733 | @opindex fcall-used |
956d6950 | 11734 | Treat the register named @var{reg} as an allocable register that is |
74291a4b MM |
11735 | clobbered by function calls. It may be allocated for temporaries or |
11736 | variables that do not live across a call. Functions compiled this way | |
11737 | will not save and restore the register @var{reg}. | |
11738 | ||
cb2fdc84 GRK |
11739 | It is an error to used this flag with the frame pointer or stack pointer. |
11740 | Use of this flag for other registers that have fixed pervasive roles in | |
11741 | the machine's execution model will produce disastrous results. | |
74291a4b MM |
11742 | |
11743 | This flag does not have a negative form, because it specifies a | |
11744 | three-way choice. | |
11745 | ||
11746 | @item -fcall-saved-@var{reg} | |
cd3bb277 | 11747 | @opindex fcall-saved |
956d6950 | 11748 | Treat the register named @var{reg} as an allocable register saved by |
74291a4b MM |
11749 | functions. It may be allocated even for temporaries or variables that |
11750 | live across a call. Functions compiled this way will save and restore | |
11751 | the register @var{reg} if they use it. | |
11752 | ||
cb2fdc84 GRK |
11753 | It is an error to used this flag with the frame pointer or stack pointer. |
11754 | Use of this flag for other registers that have fixed pervasive roles in | |
11755 | the machine's execution model will produce disastrous results. | |
74291a4b MM |
11756 | |
11757 | A different sort of disaster will result from the use of this flag for | |
11758 | a register in which function values may be returned. | |
11759 | ||
11760 | This flag does not have a negative form, because it specifies a | |
11761 | three-way choice. | |
11762 | ||
11763 | @item -fpack-struct | |
cd3bb277 | 11764 | @opindex fpack-struct |
a9c60612 JJ |
11765 | Pack all structure members together without holes. |
11766 | ||
11767 | @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate | |
11768 | code that is not binary compatible with code generated without that switch. | |
3364c33b | 11769 | Additionally, it makes the code suboptimal. |
a9c60612 | 11770 | Use it to conform to a non-default application binary interface. |
74291a4b | 11771 | |
07417085 | 11772 | @item -finstrument-functions |
cd3bb277 | 11773 | @opindex finstrument-functions |
07417085 KR |
11774 | Generate instrumentation calls for entry and exit to functions. Just |
11775 | after function entry and just before function exit, the following | |
11776 | profiling functions will be called with the address of the current | |
11777 | function and its call site. (On some platforms, | |
11778 | @code{__builtin_return_address} does not work beyond the current | |
11779 | function, so the call site information may not be available to the | |
11780 | profiling functions otherwise.) | |
11781 | ||
3ab51846 | 11782 | @smallexample |
310668e8 JM |
11783 | void __cyg_profile_func_enter (void *this_fn, |
11784 | void *call_site); | |
11785 | void __cyg_profile_func_exit (void *this_fn, | |
11786 | void *call_site); | |
3ab51846 | 11787 | @end smallexample |
07417085 KR |
11788 | |
11789 | The first argument is the address of the start of the current function, | |
11790 | which may be looked up exactly in the symbol table. | |
11791 | ||
11792 | This instrumentation is also done for functions expanded inline in other | |
11793 | functions. The profiling calls will indicate where, conceptually, the | |
11794 | inline function is entered and exited. This means that addressable | |
11795 | versions of such functions must be available. If all your uses of a | |
11796 | function are expanded inline, this may mean an additional expansion of | |
11797 | code size. If you use @samp{extern inline} in your C code, an | |
11798 | addressable version of such functions must be provided. (This is | |
11799 | normally the case anyways, but if you get lucky and the optimizer always | |
11800 | expands the functions inline, you might have gotten away without | |
11801 | providing static copies.) | |
11802 | ||
11803 | A function may be given the attribute @code{no_instrument_function}, in | |
11804 | which case this instrumentation will not be done. This can be used, for | |
11805 | example, for the profiling functions listed above, high-priority | |
11806 | interrupt routines, and any functions from which the profiling functions | |
11807 | cannot safely be called (perhaps signal handlers, if the profiling | |
11808 | routines generate output or allocate memory). | |
11809 | ||
861bb6c1 | 11810 | @item -fstack-check |
cd3bb277 | 11811 | @opindex fstack-check |
861bb6c1 JL |
11812 | Generate code to verify that you do not go beyond the boundary of the |
11813 | stack. You should specify this flag if you are running in an | |
11814 | environment with multiple threads, but only rarely need to specify it in | |
11815 | a single-threaded environment since stack overflow is automatically | |
11816 | detected on nearly all systems if there is only one stack. | |
11817 | ||
a157febd GK |
11818 | Note that this switch does not actually cause checking to be done; the |
11819 | operating system must do that. The switch causes generation of code | |
11820 | to ensure that the operating system sees the stack being extended. | |
11821 | ||
11822 | @item -fstack-limit-register=@var{reg} | |
11823 | @itemx -fstack-limit-symbol=@var{sym} | |
11824 | @itemx -fno-stack-limit | |
cd3bb277 JM |
11825 | @opindex fstack-limit-register |
11826 | @opindex fstack-limit-symbol | |
11827 | @opindex fno-stack-limit | |
a157febd GK |
11828 | Generate code to ensure that the stack does not grow beyond a certain value, |
11829 | either the value of a register or the address of a symbol. If the stack | |
11830 | would grow beyond the value, a signal is raised. For most targets, | |
11831 | the signal is raised before the stack overruns the boundary, so | |
11832 | it is possible to catch the signal without taking special precautions. | |
11833 | ||
9c34dbbf ZW |
11834 | For instance, if the stack starts at absolute address @samp{0x80000000} |
11835 | and grows downwards, you can use the flags | |
11836 | @option{-fstack-limit-symbol=__stack_limit} and | |
11837 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
11838 | of 128KB@. Note that this may only work with the GNU linker. | |
a157febd | 11839 | |
e5eb27e5 JL |
11840 | @cindex aliasing of parameters |
11841 | @cindex parameters, aliased | |
11842 | @item -fargument-alias | |
04afd9d6 JL |
11843 | @itemx -fargument-noalias |
11844 | @itemx -fargument-noalias-global | |
cd3bb277 JM |
11845 | @opindex fargument-alias |
11846 | @opindex fargument-noalias | |
11847 | @opindex fargument-noalias-global | |
e5eb27e5 JL |
11848 | Specify the possible relationships among parameters and between |
11849 | parameters and global data. | |
11850 | ||
630d3d5a | 11851 | @option{-fargument-alias} specifies that arguments (parameters) may |
9c34dbbf | 11852 | alias each other and may alias global storage.@* |
630d3d5a | 11853 | @option{-fargument-noalias} specifies that arguments do not alias |
9c34dbbf | 11854 | each other, but may alias global storage.@* |
630d3d5a | 11855 | @option{-fargument-noalias-global} specifies that arguments do not |
e5eb27e5 JL |
11856 | alias each other and do not alias global storage. |
11857 | ||
11858 | Each language will automatically use whatever option is required by | |
11859 | the language standard. You should not need to use these options yourself. | |
19283265 RH |
11860 | |
11861 | @item -fleading-underscore | |
cd3bb277 | 11862 | @opindex fleading-underscore |
695ac33f | 11863 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
19283265 RH |
11864 | change the way C symbols are represented in the object file. One use |
11865 | is to help link with legacy assembly code. | |
11866 | ||
a9c60612 JJ |
11867 | @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to |
11868 | generate code that is not binary compatible with code generated without that | |
11869 | switch. Use it to conform to a non-default application binary interface. | |
11870 | Not all targets provide complete support for this switch. | |
3d78f2e9 RH |
11871 | |
11872 | @item -ftls-model=@var{model} | |
11873 | Alter the thread-local storage model to be used (@pxref{Thread-Local}). | |
11874 | The @var{model} argument should be one of @code{global-dynamic}, | |
11875 | @code{local-dynamic}, @code{initial-exec} or @code{local-exec}. | |
11876 | ||
11877 | The default without @option{-fpic} is @code{initial-exec}; with | |
11878 | @option{-fpic} the default is @code{global-dynamic}. | |
d7afec4b ND |
11879 | |
11880 | @item -fvisibility=@var{default|internal|hidden|protected} | |
11881 | @opindex fvisibility | |
11882 | Set the default ELF image symbol visibility to the specified option - all | |
11883 | symbols will be marked with this unless overrided within the code. | |
11884 | Using this feature can very substantially improve linking and | |
11885 | load times of shared object libraries, produce more optimised | |
11886 | code, provide near-perfect API export and prevent symbol clashes. | |
11887 | It is @strong{strongly} recommended that you use this in any shared objects | |
11888 | you distribute. | |
11889 | ||
11890 | Despite the nomenclature, @code{default} always means public ie; | |
11891 | available to be linked against from outside the shared object. | |
11892 | @code{protected} and @code{internal} are pretty useless in real-world | |
11893 | usage so the only other commonly used option will be @code{hidden}. | |
11894 | The default if -fvisibility isn't specified is @code{default} ie; make every | |
11895 | symbol public - this causes the same behaviour as previous versions of | |
11896 | GCC. | |
11897 | ||
11898 | A good explanation of the benefits offered by ensuring ELF | |
11899 | symbols have the correct visibility is given by ``How To Write | |
11900 | Shared Libraries'' by Ulrich Drepper (which can be found at | |
11901 | @w{@uref{http://people.redhat.com/~drepper/}}) - however a superior | |
11902 | solution made possible by this option to marking things hidden when | |
11903 | the default is public is to make the default hidden and mark things | |
11904 | public. This is the norm with DLL's on Windows and with @option{-fvisibility=hidden} | |
11905 | and @code{__attribute__ ((visibility("default")))} instead of | |
11906 | @code{__declspec(dllexport)} you get almost identical semantics with | |
11907 | identical syntax. This is a great boon to those working with | |
11908 | cross-platform projects. | |
11909 | ||
11910 | For those adding visibility support to existing code, you may find | |
11911 | @samp{#pragma GCC visibility} of use. This works by you enclosing | |
11912 | the declarations you wish to set visibility for with (for example) | |
11913 | @samp{#pragma GCC visibility push(hidden)} and | |
11914 | @samp{#pragma GCC visibility pop}. These can be nested up to sixteen | |
11915 | times. Bear in mind that symbol visibility should be viewed @strong{as | |
11916 | part of the API interface contract} and thus all new code should | |
11917 | always specify visibility when it is not the default ie; declarations | |
11918 | only for use within the local DSO should @strong{always} be marked explicitly | |
11919 | as hidden as so to avoid PLT indirection overheads - making this | |
11920 | abundantly clear also aids readability and self-documentation of the code. | |
11921 | Note that due to ISO C++ specification requirements, operator new and | |
11922 | operator delete must always be of default visibility. | |
11923 | ||
11924 | An overview of these techniques, their benefits and how to use them | |
11925 | is at @w{@uref{http://www.nedprod.com/programs/gccvisibility.html}}. | |
11926 | ||
74291a4b MM |
11927 | @end table |
11928 | ||
ee457005 JM |
11929 | @c man end |
11930 | ||
74291a4b | 11931 | @node Environment Variables |
0c2d1a2a | 11932 | @section Environment Variables Affecting GCC |
74291a4b MM |
11933 | @cindex environment variables |
11934 | ||
ee457005 | 11935 | @c man begin ENVIRONMENT |
0c2d1a2a JB |
11936 | This section describes several environment variables that affect how GCC |
11937 | operates. Some of them work by specifying directories or prefixes to use | |
767094dd | 11938 | when searching for various kinds of files. Some are used to specify other |
46103ab4 | 11939 | aspects of the compilation environment. |
74291a4b | 11940 | |
74291a4b | 11941 | Note that you can also specify places to search using options such as |
630d3d5a | 11942 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These |
74291a4b | 11943 | take precedence over places specified using environment variables, which |
161d7b59 | 11944 | in turn take precedence over those specified by the configuration of GCC@. |
b11cc610 JM |
11945 | @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, |
11946 | GNU Compiler Collection (GCC) Internals}. | |
74291a4b | 11947 | |
bedc7537 | 11948 | @table @env |
ab87f8c8 JL |
11949 | @item LANG |
11950 | @itemx LC_CTYPE | |
11951 | @c @itemx LC_COLLATE | |
11952 | @itemx LC_MESSAGES | |
11953 | @c @itemx LC_MONETARY | |
11954 | @c @itemx LC_NUMERIC | |
11955 | @c @itemx LC_TIME | |
11956 | @itemx LC_ALL | |
11957 | @findex LANG | |
11958 | @findex LC_CTYPE | |
11959 | @c @findex LC_COLLATE | |
11960 | @findex LC_MESSAGES | |
11961 | @c @findex LC_MONETARY | |
11962 | @c @findex LC_NUMERIC | |
11963 | @c @findex LC_TIME | |
11964 | @findex LC_ALL | |
11965 | @cindex locale | |
0c2d1a2a JB |
11966 | These environment variables control the way that GCC uses |
11967 | localization information that allow GCC to work with different | |
11968 | national conventions. GCC inspects the locale categories | |
bedc7537 | 11969 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do |
ab87f8c8 JL |
11970 | so. These locale categories can be set to any value supported by your |
11971 | installation. A typical value is @samp{en_UK} for English in the United | |
11972 | Kingdom. | |
11973 | ||
bedc7537 | 11974 | The @env{LC_CTYPE} environment variable specifies character |
0c2d1a2a | 11975 | classification. GCC uses it to determine the character boundaries in |
ab87f8c8 JL |
11976 | a string; this is needed for some multibyte encodings that contain quote |
11977 | and escape characters that would otherwise be interpreted as a string | |
11978 | end or escape. | |
11979 | ||
bedc7537 | 11980 | The @env{LC_MESSAGES} environment variable specifies the language to |
ab87f8c8 JL |
11981 | use in diagnostic messages. |
11982 | ||
bedc7537 NC |
11983 | If the @env{LC_ALL} environment variable is set, it overrides the value |
11984 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
11985 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
0c2d1a2a | 11986 | environment variable. If none of these variables are set, GCC |
ab87f8c8 JL |
11987 | defaults to traditional C English behavior. |
11988 | ||
74291a4b MM |
11989 | @item TMPDIR |
11990 | @findex TMPDIR | |
bedc7537 | 11991 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
0c2d1a2a | 11992 | files. GCC uses temporary files to hold the output of one stage of |
74291a4b MM |
11993 | compilation which is to be used as input to the next stage: for example, |
11994 | the output of the preprocessor, which is the input to the compiler | |
11995 | proper. | |
11996 | ||
11997 | @item GCC_EXEC_PREFIX | |
11998 | @findex GCC_EXEC_PREFIX | |
bedc7537 | 11999 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
74291a4b MM |
12000 | names of the subprograms executed by the compiler. No slash is added |
12001 | when this prefix is combined with the name of a subprogram, but you can | |
12002 | specify a prefix that ends with a slash if you wish. | |
12003 | ||
f0523f02 | 12004 | If @env{GCC_EXEC_PREFIX} is not set, GCC will attempt to figure out |
0deb20df TT |
12005 | an appropriate prefix to use based on the pathname it was invoked with. |
12006 | ||
0c2d1a2a | 12007 | If GCC cannot find the subprogram using the specified prefix, it |
74291a4b MM |
12008 | tries looking in the usual places for the subprogram. |
12009 | ||
bedc7537 | 12010 | The default value of @env{GCC_EXEC_PREFIX} is |
8e5f33ff | 12011 | @file{@var{prefix}/lib/gcc/} where @var{prefix} is the value |
74291a4b MM |
12012 | of @code{prefix} when you ran the @file{configure} script. |
12013 | ||
630d3d5a | 12014 | Other prefixes specified with @option{-B} take precedence over this prefix. |
74291a4b MM |
12015 | |
12016 | This prefix is also used for finding files such as @file{crt0.o} that are | |
12017 | used for linking. | |
12018 | ||
12019 | In addition, the prefix is used in an unusual way in finding the | |
12020 | directories to search for header files. For each of the standard | |
8e5f33ff | 12021 | directories whose name normally begins with @samp{/usr/local/lib/gcc} |
bedc7537 | 12022 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries |
74291a4b | 12023 | replacing that beginning with the specified prefix to produce an |
630d3d5a | 12024 | alternate directory name. Thus, with @option{-Bfoo/}, GCC will search |
74291a4b MM |
12025 | @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}. |
12026 | These alternate directories are searched first; the standard directories | |
12027 | come next. | |
12028 | ||
12029 | @item COMPILER_PATH | |
12030 | @findex COMPILER_PATH | |
bedc7537 NC |
12031 | The value of @env{COMPILER_PATH} is a colon-separated list of |
12032 | directories, much like @env{PATH}. GCC tries the directories thus | |
74291a4b | 12033 | specified when searching for subprograms, if it can't find the |
bedc7537 | 12034 | subprograms using @env{GCC_EXEC_PREFIX}. |
74291a4b MM |
12035 | |
12036 | @item LIBRARY_PATH | |
12037 | @findex LIBRARY_PATH | |
bedc7537 NC |
12038 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
12039 | directories, much like @env{PATH}. When configured as a native compiler, | |
0c2d1a2a | 12040 | GCC tries the directories thus specified when searching for special |
bedc7537 | 12041 | linker files, if it can't find them using @env{GCC_EXEC_PREFIX}. Linking |
0c2d1a2a | 12042 | using GCC also uses these directories when searching for ordinary |
630d3d5a JM |
12043 | libraries for the @option{-l} option (but directories specified with |
12044 | @option{-L} come first). | |
74291a4b | 12045 | |
56f48ce9 DB |
12046 | @item LANG |
12047 | @findex LANG | |
12048 | @cindex locale definition | |
767094dd | 12049 | This variable is used to pass locale information to the compiler. One way in |
56f48ce9 DB |
12050 | which this information is used is to determine the character set to be used |
12051 | when character literals, string literals and comments are parsed in C and C++. | |
12052 | When the compiler is configured to allow multibyte characters, | |
bedc7537 | 12053 | the following values for @env{LANG} are recognized: |
56f48ce9 | 12054 | |
2642624b | 12055 | @table @samp |
56f48ce9 DB |
12056 | @item C-JIS |
12057 | Recognize JIS characters. | |
12058 | @item C-SJIS | |
12059 | Recognize SJIS characters. | |
12060 | @item C-EUCJP | |
12061 | Recognize EUCJP characters. | |
12062 | @end table | |
12063 | ||
bedc7537 | 12064 | If @env{LANG} is not defined, or if it has some other value, then the |
56f48ce9 DB |
12065 | compiler will use mblen and mbtowc as defined by the default locale to |
12066 | recognize and translate multibyte characters. | |
74291a4b MM |
12067 | @end table |
12068 | ||
40adaa27 NB |
12069 | @noindent |
12070 | Some additional environments variables affect the behavior of the | |
12071 | preprocessor. | |
12072 | ||
12073 | @include cppenv.texi | |
12074 | ||
9d86bffc JM |
12075 | @c man end |
12076 | ||
17211ab5 GK |
12077 | @node Precompiled Headers |
12078 | @section Using Precompiled Headers | |
12079 | @cindex precompiled headers | |
12080 | @cindex speed of compilation | |
12081 | ||
12082 | Often large projects have many header files that are included in every | |
12083 | source file. The time the compiler takes to process these header files | |
12084 | over and over again can account for nearly all of the time required to | |
12085 | build the project. To make builds faster, GCC allows users to | |
12086 | `precompile' a header file; then, if builds can use the precompiled | |
12087 | header file they will be much faster. | |
12088 | ||
f7b6f250 MM |
12089 | @strong{Caution:} There are a few known situations where GCC will |
12090 | crash when trying to use a precompiled header. If you have trouble | |
12091 | with a precompiled header, you should remove the precompiled header | |
12092 | and compile without it. In addition, please use GCC's on-line | |
12093 | defect-tracking system to report any problems you encounter with | |
12094 | precompiled headers. @xref{Bugs}. | |
12095 | ||
17211ab5 GK |
12096 | To create a precompiled header file, simply compile it as you would any |
12097 | other file, if necessary using the @option{-x} option to make the driver | |
12098 | treat it as a C or C++ header file. You will probably want to use a | |
12099 | tool like @command{make} to keep the precompiled header up-to-date when | |
12100 | the headers it contains change. | |
12101 | ||
12102 | A precompiled header file will be searched for when @code{#include} is | |
12103 | seen in the compilation. As it searches for the included file | |
24726b96 | 12104 | (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the |
17211ab5 GK |
12105 | compiler looks for a precompiled header in each directory just before it |
12106 | looks for the include file in that directory. The name searched for is | |
d8fad4ea | 12107 | the name specified in the @code{#include} with @samp{.gch} appended. If |
17211ab5 GK |
12108 | the precompiled header file can't be used, it is ignored. |
12109 | ||
12110 | For instance, if you have @code{#include "all.h"}, and you have | |
d8fad4ea | 12111 | @file{all.h.gch} in the same directory as @file{all.h}, then the |
17211ab5 GK |
12112 | precompiled header file will be used if possible, and the original |
12113 | header will be used otherwise. | |
12114 | ||
12115 | Alternatively, you might decide to put the precompiled header file in a | |
12116 | directory and use @option{-I} to ensure that directory is searched | |
12117 | before (or instead of) the directory containing the original header. | |
12118 | Then, if you want to check that the precompiled header file is always | |
12119 | used, you can put a file of the same name as the original header in this | |
12120 | directory containing an @code{#error} command. | |
12121 | ||
12122 | This also works with @option{-include}. So yet another way to use | |
12123 | precompiled headers, good for projects not designed with precompiled | |
12124 | header files in mind, is to simply take most of the header files used by | |
12125 | a project, include them from another header file, precompile that header | |
12126 | file, and @option{-include} the precompiled header. If the header files | |
12127 | have guards against multiple inclusion, they will be skipped because | |
12128 | they've already been included (in the precompiled header). | |
12129 | ||
12130 | If you need to precompile the same header file for different | |
12131 | languages, targets, or compiler options, you can instead make a | |
d8fad4ea | 12132 | @emph{directory} named like @file{all.h.gch}, and put each precompiled |
54e109ed GK |
12133 | header in the directory, perhaps using @option{-o}. It doesn't matter |
12134 | what you call the files in the directory, every precompiled header in | |
12135 | the directory will be considered. The first precompiled header | |
12136 | encountered in the directory that is valid for this compilation will | |
12137 | be used; they're searched in no particular order. | |
17211ab5 GK |
12138 | |
12139 | There are many other possibilities, limited only by your imagination, | |
12140 | good sense, and the constraints of your build system. | |
12141 | ||
12142 | A precompiled header file can be used only when these conditions apply: | |
12143 | ||
12144 | @itemize | |
12145 | @item | |
12146 | Only one precompiled header can be used in a particular compilation. | |
54e109ed | 12147 | |
17211ab5 GK |
12148 | @item |
12149 | A precompiled header can't be used once the first C token is seen. You | |
12150 | can have preprocessor directives before a precompiled header; you can | |
12151 | even include a precompiled header from inside another header, so long as | |
12152 | there are no C tokens before the @code{#include}. | |
54e109ed | 12153 | |
17211ab5 GK |
12154 | @item |
12155 | The precompiled header file must be produced for the same language as | |
12156 | the current compilation. You can't use a C precompiled header for a C++ | |
12157 | compilation. | |
54e109ed | 12158 | |
17211ab5 GK |
12159 | @item |
12160 | The precompiled header file must be produced by the same compiler | |
12161 | version and configuration as the current compilation is using. | |
12162 | The easiest way to guarantee this is to use the same compiler binary | |
12163 | for creating and using precompiled headers. | |
54e109ed | 12164 | |
17211ab5 | 12165 | @item |
54e109ed GK |
12166 | Any macros defined before the precompiled header is included must |
12167 | either be defined in the same way as when the precompiled header was | |
12168 | generated, or must not affect the precompiled header, which usually | |
12169 | means that the they don't appear in the precompiled header at all. | |
12170 | ||
12171 | The @option{-D} option is one way to define a macro before a | |
12172 | precompiled header is included; using a @code{#define} can also do it. | |
12173 | There are also some options that define macros implicitly, like | |
12174 | @option{-O} and @option{-Wdeprecated}; the same rule applies to macros | |
12175 | defined this way. | |
12176 | ||
12177 | @item If debugging information is output when using the precompiled | |
12178 | header, using @option{-g} or similar, the same kind of debugging information | |
12179 | must have been output when building the precompiled header. However, | |
12180 | a precompiled header built using @option{-g} can be used in a compilation | |
12181 | when no debugging information is being output. | |
12182 | ||
12183 | @item The same @option{-m} options must generally be used when building | |
12184 | and using the precompiled header. @xref{Submodel Options}, | |
12185 | for any cases where this rule is relaxed. | |
12186 | ||
12187 | @item Each of the following options must be the same when building and using | |
12188 | the precompiled header: | |
12189 | ||
12190 | @gccoptlist{-fexceptions -funit-at-a-time} | |
12191 | ||
17211ab5 | 12192 | @item |
54e109ed GK |
12193 | Some other command-line options starting with @option{-f}, |
12194 | @option{-p}, or @option{-O} must be defined in the same way as when | |
12195 | the precompiled header was generated. At present, it's not clear | |
12196 | which options are safe to change and which are not; the safest choice | |
12197 | is to use exactly the same options when generating and using the | |
12198 | precompiled header. The following are known to be safe: | |
12199 | ||
c0d578e6 | 12200 | @gccoptlist{-fpreprocessed -pedantic-errors} |
54e109ed | 12201 | |
17211ab5 GK |
12202 | @end itemize |
12203 | ||
54e109ed GK |
12204 | For all of these except the last, the compiler will automatically |
12205 | ignore the precompiled header if the conditions aren't met. If you | |
12206 | find an option combination that doesn't work and doesn't cause the | |
12207 | precompiled header to be ignored, please consider filing a bug report, | |
12208 | see @ref{Bugs}. | |
17211ab5 | 12209 | |
c0d578e6 GK |
12210 | If you do use differing options when generating and using the |
12211 | precompiled header, the actual behaviour will be a mixture of the | |
12212 | behaviour for the options. For instance, if you use @option{-g} to | |
12213 | generate the precompiled header but not when using it, you may or may | |
12214 | not get debugging information for routines in the precompiled header. | |
12215 | ||
74291a4b MM |
12216 | @node Running Protoize |
12217 | @section Running Protoize | |
12218 | ||
161d7b59 | 12219 | The program @code{protoize} is an optional part of GCC@. You can use |
c1030c7c | 12220 | it to add prototypes to a program, thus converting the program to ISO |
74291a4b MM |
12221 | C in one respect. The companion program @code{unprotoize} does the |
12222 | reverse: it removes argument types from any prototypes that are found. | |
12223 | ||
12224 | When you run these programs, you must specify a set of source files as | |
12225 | command line arguments. The conversion programs start out by compiling | |
12226 | these files to see what functions they define. The information gathered | |
12227 | about a file @var{foo} is saved in a file named @file{@var{foo}.X}. | |
12228 | ||
12229 | After scanning comes actual conversion. The specified files are all | |
12230 | eligible to be converted; any files they include (whether sources or | |
12231 | just headers) are eligible as well. | |
12232 | ||
12233 | But not all the eligible files are converted. By default, | |
12234 | @code{protoize} and @code{unprotoize} convert only source and header | |
12235 | files in the current directory. You can specify additional directories | |
630d3d5a | 12236 | whose files should be converted with the @option{-d @var{directory}} |
74291a4b | 12237 | option. You can also specify particular files to exclude with the |
630d3d5a | 12238 | @option{-x @var{file}} option. A file is converted if it is eligible, its |
74291a4b MM |
12239 | directory name matches one of the specified directory names, and its |
12240 | name within the directory has not been excluded. | |
12241 | ||
12242 | Basic conversion with @code{protoize} consists of rewriting most | |
12243 | function definitions and function declarations to specify the types of | |
12244 | the arguments. The only ones not rewritten are those for varargs | |
12245 | functions. | |
12246 | ||
12247 | @code{protoize} optionally inserts prototype declarations at the | |
12248 | beginning of the source file, to make them available for any calls that | |
12249 | precede the function's definition. Or it can insert prototype | |
12250 | declarations with block scope in the blocks where undeclared functions | |
12251 | are called. | |
12252 | ||
12253 | Basic conversion with @code{unprotoize} consists of rewriting most | |
12254 | function declarations to remove any argument types, and rewriting | |
c1030c7c | 12255 | function definitions to the old-style pre-ISO form. |
74291a4b MM |
12256 | |
12257 | Both conversion programs print a warning for any function declaration or | |
12258 | definition that they can't convert. You can suppress these warnings | |
630d3d5a | 12259 | with @option{-q}. |
74291a4b MM |
12260 | |
12261 | The output from @code{protoize} or @code{unprotoize} replaces the | |
12262 | original source file. The original file is renamed to a name ending | |
02f52e19 | 12263 | with @samp{.save} (for DOS, the saved filename ends in @samp{.sav} |
a7db8bbb MK |
12264 | without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav} |
12265 | for DOS) file already exists, then the source file is simply discarded. | |
74291a4b | 12266 | |
0c2d1a2a | 12267 | @code{protoize} and @code{unprotoize} both depend on GCC itself to |
74291a4b | 12268 | scan the program and collect information about the functions it uses. |
0c2d1a2a | 12269 | So neither of these programs will work until GCC is installed. |
74291a4b MM |
12270 | |
12271 | Here is a table of the options you can use with @code{protoize} and | |
12272 | @code{unprotoize}. Each option works with both programs unless | |
12273 | otherwise stated. | |
12274 | ||
12275 | @table @code | |
12276 | @item -B @var{directory} | |
12277 | Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the | |
12278 | usual directory (normally @file{/usr/local/lib}). This file contains | |
12279 | prototype information about standard system functions. This option | |
12280 | applies only to @code{protoize}. | |
12281 | ||
12282 | @item -c @var{compilation-options} | |
05739753 | 12283 | Use @var{compilation-options} as the options when running @command{gcc} to |
630d3d5a | 12284 | produce the @samp{.X} files. The special option @option{-aux-info} is |
05739753 | 12285 | always passed in addition, to tell @command{gcc} to write a @samp{.X} file. |
74291a4b MM |
12286 | |
12287 | Note that the compilation options must be given as a single argument to | |
12288 | @code{protoize} or @code{unprotoize}. If you want to specify several | |
05739753 | 12289 | @command{gcc} options, you must quote the entire set of compilation options |
74291a4b MM |
12290 | to make them a single word in the shell. |
12291 | ||
05739753 | 12292 | There are certain @command{gcc} arguments that you cannot use, because they |
630d3d5a JM |
12293 | would produce the wrong kind of output. These include @option{-g}, |
12294 | @option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in | |
74291a4b MM |
12295 | the @var{compilation-options}, they are ignored. |
12296 | ||
12297 | @item -C | |
a7db8bbb | 12298 | Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file |
02f52e19 | 12299 | systems) instead of @samp{.c}. This is convenient if you are converting |
ee77eda5 | 12300 | a C program to C++. This option applies only to @code{protoize}. |
74291a4b MM |
12301 | |
12302 | @item -g | |
12303 | Add explicit global declarations. This means inserting explicit | |
12304 | declarations at the beginning of each source file for each function | |
12305 | that is called in the file and was not declared. These declarations | |
12306 | precede the first function definition that contains a call to an | |
12307 | undeclared function. This option applies only to @code{protoize}. | |
12308 | ||
12309 | @item -i @var{string} | |
12310 | Indent old-style parameter declarations with the string @var{string}. | |
12311 | This option applies only to @code{protoize}. | |
12312 | ||
12313 | @code{unprotoize} converts prototyped function definitions to old-style | |
12314 | function definitions, where the arguments are declared between the | |
12315 | argument list and the initial @samp{@{}. By default, @code{unprotoize} | |
12316 | uses five spaces as the indentation. If you want to indent with just | |
630d3d5a | 12317 | one space instead, use @option{-i " "}. |
74291a4b MM |
12318 | |
12319 | @item -k | |
12320 | Keep the @samp{.X} files. Normally, they are deleted after conversion | |
12321 | is finished. | |
12322 | ||
12323 | @item -l | |
630d3d5a | 12324 | Add explicit local declarations. @code{protoize} with @option{-l} inserts |
74291a4b MM |
12325 | a prototype declaration for each function in each block which calls the |
12326 | function without any declaration. This option applies only to | |
12327 | @code{protoize}. | |
12328 | ||
12329 | @item -n | |
12330 | Make no real changes. This mode just prints information about the conversions | |
630d3d5a | 12331 | that would have been done without @option{-n}. |
74291a4b MM |
12332 | |
12333 | @item -N | |
12334 | Make no @samp{.save} files. The original files are simply deleted. | |
12335 | Use this option with caution. | |
12336 | ||
12337 | @item -p @var{program} | |
12338 | Use the program @var{program} as the compiler. Normally, the name | |
12339 | @file{gcc} is used. | |
12340 | ||
12341 | @item -q | |
12342 | Work quietly. Most warnings are suppressed. | |
12343 | ||
12344 | @item -v | |
05739753 | 12345 | Print the version number, just like @option{-v} for @command{gcc}. |
74291a4b MM |
12346 | @end table |
12347 | ||
12348 | If you need special compiler options to compile one of your program's | |
12349 | source files, then you should generate that file's @samp{.X} file | |
05739753 | 12350 | specially, by running @command{gcc} on that source file with the |
630d3d5a | 12351 | appropriate options and the option @option{-aux-info}. Then run |
74291a4b MM |
12352 | @code{protoize} on the entire set of files. @code{protoize} will use |
12353 | the existing @samp{.X} file because it is newer than the source file. | |
12354 | For example: | |
12355 | ||
3ab51846 | 12356 | @smallexample |
b1018de6 | 12357 | gcc -Dfoo=bar file1.c -aux-info file1.X |
74291a4b | 12358 | protoize *.c |
3ab51846 | 12359 | @end smallexample |
74291a4b MM |
12360 | |
12361 | @noindent | |
12362 | You need to include the special files along with the rest in the | |
12363 | @code{protoize} command, even though their @samp{.X} files already | |
12364 | exist, because otherwise they won't get converted. | |
12365 | ||
12366 | @xref{Protoize Caveats}, for more information on how to use | |
12367 | @code{protoize} successfully. |