]>
Commit | Line | Data |
---|---|---|
d0a5eb32 RK |
1 | @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2 | @c 2000, 2001 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, | |
21c7361e | 9 | 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
9d86bffc JM |
10 | |
11 | Permission is granted to make and distribute verbatim copies of this | |
12 | manual provided the copyright notice and this permission notice are | |
13 | preserved on all copies. | |
14 | ||
15 | Permission is granted to copy and distribute modified versions of this | |
16 | manual under the conditions for verbatim copying, provided also that the | |
17 | entire resulting derived work is distributed under the terms of a | |
18 | permission notice identical to this one. | |
19 | ||
20 | Permission is granted to copy and distribute translations of this manual | |
21 | into another language, under the above conditions for modified versions, | |
22 | except that this permission notice may be included in translations | |
23 | approved by the Free Software Foundation instead of in the original | |
24 | English. | |
25 | @c man end | |
26 | @c Set file name and title for the man page. | |
27 | @setfilename gcc | |
28 | @settitle GNU project C and C++ compiler | |
29 | @c man begin SYNOPSIS | |
630d3d5a JM |
30 | gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}] |
31 | [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] | |
32 | [@option{-W}@var{warn}@dots{}] [@option{-pedantic}] | |
33 | [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] | |
34 | [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] | |
35 | [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}] | |
36 | [@option{-o} @var{outfile}] @var{infile}@dots{} | |
9d86bffc JM |
37 | |
38 | Only the most useful options are listed here; see below for the | |
39 | remainder. @samp{g++} accepts mostly the same options as @samp{gcc}. | |
40 | @c man end | |
41 | @c man begin SEEALSO | |
42 | cpp(1), gcov(1), g77(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1) | |
43 | and the Info entries for @file{gcc}, @file{cpp}, @file{g77}, @file{as}, | |
44 | @file{ld}, @file{binutils} and @file{gdb}. | |
45 | @c man end | |
2642624b JM |
46 | @c man begin BUGS |
47 | For instructions on reporting bugs, see | |
bedc7537 | 48 | @w{@uref{http://gcc.gnu.org/bugs.html}}. Use of the @command{gccbug} |
2642624b JM |
49 | script to report bugs is recommended. |
50 | @c man end | |
51 | @c man begin AUTHOR | |
52 | See the Info entry for @file{gcc}, or | |
161d7b59 | 53 | @w{@uref{http://gcc.gnu.org/thanks.html}}, for contributors to GCC@. |
2642624b | 54 | @c man end |
9d86bffc JM |
55 | @end ignore |
56 | ||
74291a4b | 57 | @node Invoking GCC |
0c2d1a2a JB |
58 | @chapter GCC Command Options |
59 | @cindex GCC command options | |
74291a4b | 60 | @cindex command options |
0c2d1a2a | 61 | @cindex options, GCC command |
74291a4b | 62 | |
9d86bffc JM |
63 | @c man begin DESCRIPTION |
64 | ||
0c2d1a2a | 65 | When you invoke GCC, it normally does preprocessing, compilation, |
74291a4b | 66 | assembly and linking. The ``overall options'' allow you to stop this |
630d3d5a | 67 | process at an intermediate stage. For example, the @option{-c} option |
74291a4b MM |
68 | says not to run the linker. Then the output consists of object files |
69 | output by the assembler. | |
70 | ||
71 | Other options are passed on to one stage of processing. Some options | |
72 | control the preprocessor and others the compiler itself. Yet other | |
73 | options control the assembler and linker; most of these are not | |
74 | documented here, since you rarely need to use any of them. | |
75 | ||
76 | @cindex C compilation options | |
0c2d1a2a | 77 | Most of the command line options that you can use with GCC are useful |
74291a4b MM |
78 | for C programs; when an option is only useful with another language |
79 | (usually C++), the explanation says so explicitly. If the description | |
80 | for a particular option does not mention a source language, you can use | |
81 | that option with all supported languages. | |
82 | ||
83 | @cindex C++ compilation options | |
84 | @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special | |
85 | options for compiling C++ programs. | |
86 | ||
87 | @cindex grouping options | |
88 | @cindex options, grouping | |
bedc7537 | 89 | The @command{gcc} program accepts options and file names as operands. Many |
b192711e | 90 | options have multi-letter names; therefore multiple single-letter options |
630d3d5a | 91 | may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d |
74291a4b MM |
92 | -r}}. |
93 | ||
94 | @cindex order of options | |
95 | @cindex options, order | |
96 | You can mix options and other arguments. For the most part, the order | |
97 | you use doesn't matter. Order does matter when you use several options | |
630d3d5a | 98 | of the same kind; for example, if you specify @option{-L} more than once, |
74291a4b MM |
99 | the directories are searched in the order specified. |
100 | ||
101 | Many options have long names starting with @samp{-f} or with | |
630d3d5a JM |
102 | @samp{-W}---for example, @option{-fforce-mem}, |
103 | @option{-fstrength-reduce}, @option{-Wformat} and so on. Most of | |
74291a4b | 104 | these have both positive and negative forms; the negative form of |
630d3d5a | 105 | @option{-ffoo} would be @option{-fno-foo}. This manual documents |
74291a4b MM |
106 | only one of these two forms, whichever one is not the default. |
107 | ||
9d86bffc JM |
108 | @c man end |
109 | ||
cd3bb277 JM |
110 | @xref{Option Index}, for an index to GCC's options. |
111 | ||
74291a4b MM |
112 | @menu |
113 | * Option Summary:: Brief list of all options, without explanations. | |
114 | * Overall Options:: Controlling the kind of output: | |
115 | an executable, object files, assembler files, | |
116 | or preprocessed source. | |
117 | * Invoking G++:: Compiling C++ programs. | |
118 | * C Dialect Options:: Controlling the variant of C language compiled. | |
119 | * C++ Dialect Options:: Variations on C++. | |
60de6385 | 120 | * Objective-C Dialect Options:: Variations on Objective-C. |
764dbbf2 | 121 | * Language Independent Options:: Controlling how diagnostics should be |
02f52e19 | 122 | formatted. |
74291a4b MM |
123 | * Warning Options:: How picky should the compiler be? |
124 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
125 | * Optimize Options:: How much optimization? | |
126 | * Preprocessor Options:: Controlling header files and macro definitions. | |
127 | Also, getting dependency information for Make. | |
128 | * Assembler Options:: Passing options to the assembler. | |
129 | * Link Options:: Specifying libraries and so on. | |
130 | * Directory Options:: Where to find header files and libraries. | |
131 | Where to find the compiler executable files. | |
a743d340 | 132 | * Spec Files:: How to pass switches to sub-processes. |
0c2d1a2a | 133 | * Target Options:: Running a cross-compiler, or an old version of GCC. |
74291a4b MM |
134 | * Submodel Options:: Specifying minor hardware or convention variations, |
135 | such as 68010 vs 68020. | |
136 | * Code Gen Options:: Specifying conventions for function calls, data layout | |
137 | and register usage. | |
0c2d1a2a | 138 | * Environment Variables:: Env vars that affect GCC. |
74291a4b MM |
139 | * Running Protoize:: Automatically adding or removing function prototypes. |
140 | @end menu | |
141 | ||
4bc1997b JM |
142 | @c man begin OPTIONS |
143 | ||
74291a4b MM |
144 | @node Option Summary |
145 | @section Option Summary | |
146 | ||
147 | Here is a summary of all the options, grouped by type. Explanations are | |
148 | in the following sections. | |
149 | ||
150 | @table @emph | |
151 | @item Overall Options | |
152 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
4bc1997b JM |
153 | @gccoptlist{ |
154 | -c -S -E -o @var{file} -pipe -pass-exit-codes -x @var{language} @gol | |
155 | -v --target-help --help} | |
74291a4b MM |
156 | |
157 | @item C Language Options | |
158 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
4bc1997b | 159 | @gccoptlist{ |
b1018de6 AO |
160 | -ansi -std=@var{standard} -aux-info @var{filename} @gol |
161 | -fno-asm -fno-builtin @gol | |
4bc1997b JM |
162 | -fhosted -ffreestanding @gol |
163 | -trigraphs -traditional -traditional-cpp @gol | |
164 | -fallow-single-precision -fcond-mismatch @gol | |
165 | -fsigned-bitfields -fsigned-char @gol | |
166 | -funsigned-bitfields -funsigned-char @gol | |
167 | -fwritable-strings -fshort-wchar} | |
74291a4b MM |
168 | |
169 | @item C++ Language Options | |
170 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. | |
4bc1997b JM |
171 | @gccoptlist{ |
172 | -fno-access-control -fcheck-new -fconserve-space @gol | |
aa0cc562 JM |
173 | -fno-const-strings -fdollars-in-identifiers @gol |
174 | -fno-elide-constructors @gol | |
4bc1997b JM |
175 | -fno-enforce-eh-specs -fexternal-templates @gol |
176 | -falt-external-templates @gol | |
25b5b465 | 177 | -ffor-scope -fno-for-scope -fno-gnu-keywords -fno-honor-std @gol |
90ecce3e | 178 | -fno-implicit-templates @gol |
4bc1997b JM |
179 | -fno-implicit-inline-templates @gol |
180 | -fno-implement-inlines -fms-extensions @gol | |
aa0cc562 | 181 | -fno-nonansi-builtins -fno-operator-names @gol |
4bc1997b | 182 | -fno-optional-diags -fpermissive @gol |
aa0cc562 | 183 | -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol |
90ecce3e | 184 | -fuse-cxa-atexit -fvtable-gc -fno-weak -nostdinc++ @gol |
4bc1997b JM |
185 | -fno-default-inline -Wctor-dtor-privacy @gol |
186 | -Wnon-virtual-dtor -Wreorder @gol | |
187 | -Weffc++ -Wno-deprecated @gol | |
188 | -Wno-non-template-friend -Wold-style-cast @gol | |
189 | -Woverloaded-virtual -Wno-pmf-conversions @gol | |
190 | -Wsign-promo -Wsynth} | |
74291a4b | 191 | |
60de6385 SS |
192 | @item Objective-C Language Options |
193 | @xref{Objective-C Dialect Options,,Options Controlling Objective-C Dialect}. | |
194 | @gccoptlist{ | |
630d3d5a | 195 | -fconstant-string-class=@var{class-name} @gol |
310668e8 | 196 | -fgnu-runtime -fnext-runtime -gen-decls @gol |
60de6385 SS |
197 | -Wno-protocol -Wselector} |
198 | ||
764dbbf2 GDR |
199 | @item Language Independent Options |
200 | @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}. | |
4bc1997b JM |
201 | @gccoptlist{ |
202 | -fmessage-length=@var{n} @gol | |
203 | -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}} | |
764dbbf2 | 204 | |
74291a4b MM |
205 | @item Warning Options |
206 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
4bc1997b JM |
207 | @gccoptlist{ |
208 | -fsyntax-only -pedantic -pedantic-errors @gol | |
209 | -w -W -Wall -Waggregate-return @gol | |
210 | -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol | |
feb48bde | 211 | -Wconversion -Wdisabled-optimization -Werror @gol |
4bc1997b | 212 | -Wfloat-equal -Wformat -Wformat=2 @gol |
feb48bde JM |
213 | -Wformat-nonliteral -Wformat-security @gol |
214 | -Wimplicit -Wimplicit-int @gol | |
4bc1997b JM |
215 | -Wimplicit-function-declaration @gol |
216 | -Werror-implicit-function-declaration @gol | |
217 | -Wimport -Winline @gol | |
218 | -Wlarger-than-@var{len} -Wlong-long @gol | |
1f0c3120 | 219 | -Wmain -Wmissing-braces -Wmissing-declarations @gol |
4bc1997b | 220 | -Wmissing-format-attribute -Wmissing-noreturn @gol |
feb48bde | 221 | -Wmultichar -Wno-format-extra-args -Wno-format-y2k @gol |
4bc1997b | 222 | -Wno-import -Wpacked -Wpadded @gol |
310668e8 | 223 | -Wparentheses -Wpointer-arith -Wredundant-decls @gol |
4bc1997b JM |
224 | -Wreturn-type -Wsequence-point -Wshadow @gol |
225 | -Wsign-compare -Wswitch -Wsystem-headers @gol | |
226 | -Wtrigraphs -Wundef -Wuninitialized @gol | |
227 | -Wunknown-pragmas -Wunreachable-code @gol | |
228 | -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol | |
229 | -Wunused-value -Wunused-variable -Wwrite-strings} | |
74291a4b | 230 | |
fe50c0eb | 231 | @item C-only Warning Options |
4bc1997b | 232 | @gccoptlist{ |
310668e8 JM |
233 | -Wbad-function-cast -Wmissing-prototypes -Wnested-externs @gol |
234 | -Wstrict-prototypes -Wtraditional} | |
fe50c0eb | 235 | |
74291a4b MM |
236 | @item Debugging Options |
237 | @xref{Debugging Options,,Options for Debugging Your Program or GCC}. | |
4bc1997b | 238 | @gccoptlist{ |
1f0c3120 | 239 | -a -ax -d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol |
aee96fe9 JM |
240 | -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol |
241 | -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol | |
e76b4820 | 242 | -fdump-ast-original@r{[}-@var{n}@r{]} -fdump-ast-optimized@r{[}-@var{n}@r{]} @gol |
6be77748 | 243 | -fdump-ast-inlined@r{[}-@var{n}@r{]} @gol |
e76b4820 | 244 | -fmem-report -fpretend-float @gol |
1f0c3120 | 245 | -fprofile-arcs -ftest-coverage -ftime-report @gol |
4bc1997b JM |
246 | -g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 @gol |
247 | -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ @gol | |
248 | -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol | |
b1018de6 | 249 | -print-multi-directory -print-multi-lib @gol |
4bc1997b JM |
250 | -print-prog-name=@var{program} -print-search-dirs -Q @gol |
251 | -save-temps -time} | |
74291a4b MM |
252 | |
253 | @item Optimization Options | |
254 | @xref{Optimize Options,,Options that Control Optimization}. | |
4bc1997b JM |
255 | @gccoptlist{ |
256 | -falign-functions=@var{n} -falign-jumps=@var{n} @gol | |
257 | -falign-labels=@var{n} -falign-loops=@var{n} @gol | |
258 | -fbranch-probabilities -fcaller-saves @gol | |
62d285ff | 259 | -fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol |
4bc1997b JM |
260 | -fdelayed-branch -fdelete-null-pointer-checks @gol |
261 | -fexpensive-optimizations -ffast-math -ffloat-store @gol | |
feb48bde JM |
262 | -fforce-addr -fforce-mem -ffunction-sections @gol |
263 | -fgcse -fgcse-lm -fgcse-sm @gol | |
4bc1997b JM |
264 | -finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol |
265 | -fkeep-static-consts -fmove-all-movables @gol | |
266 | -fno-default-inline -fno-defer-pop @gol | |
feb48bde | 267 | -fno-function-cse -fno-guess-branch-probability @gol |
6cfc0341 | 268 | -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol |
de6c5979 | 269 | -funsafe-math-optimizations -fno-trapping-math @gol |
4bc1997b JM |
270 | -fomit-frame-pointer -foptimize-register-move @gol |
271 | -foptimize-sibling-calls -freduce-all-givs @gol | |
272 | -fregmove -frename-registers @gol | |
273 | -frerun-cse-after-loop -frerun-loop-opt @gol | |
274 | -fschedule-insns -fschedule-insns2 @gol | |
0b47e4c1 | 275 | -fsingle-precision-constant -fssa -fssa-ccp -fssa-dce @gol |
4bc1997b JM |
276 | -fstrength-reduce -fstrict-aliasing -fthread-jumps -ftrapv @gol |
277 | -funroll-all-loops -funroll-loops @gol | |
3af64fd6 | 278 | --param @var{name}=@var{value} |
4bc1997b | 279 | -O -O0 -O1 -O2 -O3 -Os} |
74291a4b MM |
280 | |
281 | @item Preprocessor Options | |
282 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
4bc1997b JM |
283 | @gccoptlist{ |
284 | -$ -A@var{question}=@var{answer} -A-@var{question}@r{[}=@var{answer}@r{]} @gol | |
285 | -C -dD -dI -dM -dN @gol | |
286 | -D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol | |
287 | -idirafter @var{dir} @gol | |
288 | -include @var{file} -imacros @var{file} @gol | |
289 | -iprefix @var{file} -iwithprefix @var{dir} @gol | |
bdd42dd9 | 290 | -iwithprefixbefore @var{dir} -isystem @var{dir} @gol |
4bc1997b | 291 | -M -MM -MF -MG -MP -MQ -MT -nostdinc -P -remap @gol |
aee96fe9 | 292 | -trigraphs -undef -U@var{macro} -Wp,@var{option}} |
74291a4b MM |
293 | |
294 | @item Assembler Option | |
295 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
4bc1997b | 296 | @gccoptlist{ |
aee96fe9 | 297 | -Wa,@var{option}} |
74291a4b MM |
298 | |
299 | @item Linker Options | |
300 | @xref{Link Options,,Options for Linking}. | |
4bc1997b JM |
301 | @gccoptlist{ |
302 | @var{object-file-name} -l@var{library} @gol | |
303 | -nostartfiles -nodefaultlibs -nostdlib @gol | |
304 | -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol | |
aee96fe9 | 305 | -Wl,@var{option} -Xlinker @var{option} @gol |
4bc1997b | 306 | -u @var{symbol}} |
74291a4b MM |
307 | |
308 | @item Directory Options | |
309 | @xref{Directory Options,,Options for Directory Search}. | |
4bc1997b JM |
310 | @gccoptlist{ |
311 | -B@var{prefix} -I@var{dir} -I- -L@var{dir} -specs=@var{file}} | |
74291a4b MM |
312 | |
313 | @item Target Options | |
314 | @c I wrote this xref this way to avoid overfull hbox. -- rms | |
315 | @xref{Target Options}. | |
4bc1997b JM |
316 | @gccoptlist{ |
317 | -b @var{machine} -V @var{version}} | |
74291a4b MM |
318 | |
319 | @item Machine Dependent Options | |
320 | @xref{Submodel Options,,Hardware Models and Configurations}. | |
74291a4b | 321 | @emph{M680x0 Options} |
4bc1997b JM |
322 | @gccoptlist{ |
323 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol | |
feb48bde | 324 | -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol |
310668e8 JM |
325 | -mfpa -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol |
326 | -malign-int -mstrict-align} | |
74291a4b | 327 | |
2856c3e3 | 328 | @emph{M68hc1x Options} |
4bc1997b JM |
329 | @gccoptlist{ |
330 | -m6811 -m6812 -m68hc11 -m68hc12 @gol | |
331 | -mauto-incdec -mshort -msoft-reg-count=@var{count}} | |
2856c3e3 | 332 | |
74291a4b | 333 | @emph{VAX Options} |
4bc1997b JM |
334 | @gccoptlist{ |
335 | -mg -mgnu -munix} | |
74291a4b MM |
336 | |
337 | @emph{SPARC Options} | |
4bc1997b | 338 | @gccoptlist{ |
630d3d5a JM |
339 | -mcpu=@var{cpu-type} @gol |
340 | -mtune=@var{cpu-type} @gol | |
341 | -mcmodel=@var{code-model} @gol | |
4bc1997b JM |
342 | -m32 -m64 @gol |
343 | -mapp-regs -mbroken-saverestore -mcypress @gol | |
feb48bde | 344 | -mepilogue -mfaster-structs -mflat @gol |
4bc1997b JM |
345 | -mfpu -mhard-float -mhard-quad-float @gol |
346 | -mimpure-text -mlive-g0 -mno-app-regs @gol | |
310668e8 JM |
347 | -mno-epilogue -mno-faster-structs -mno-flat -mno-fpu @gol |
348 | -mno-impure-text -mno-stack-bias -mno-unaligned-doubles @gol | |
4bc1997b JM |
349 | -msoft-float -msoft-quad-float -msparclite -mstack-bias @gol |
350 | -msupersparc -munaligned-doubles -mv8} | |
74291a4b MM |
351 | |
352 | @emph{Convex Options} | |
4bc1997b JM |
353 | @gccoptlist{ |
354 | -mc1 -mc2 -mc32 -mc34 -mc38 @gol | |
355 | -margcount -mnoargcount @gol | |
356 | -mlong32 -mlong64 @gol | |
357 | -mvolatile-cache -mvolatile-nocache} | |
74291a4b MM |
358 | |
359 | @emph{AMD29K Options} | |
4bc1997b JM |
360 | @gccoptlist{ |
361 | -m29000 -m29050 -mbw -mnbw -mdw -mndw @gol | |
362 | -mlarge -mnormal -msmall @gol | |
363 | -mkernel-registers -mno-reuse-arg-regs @gol | |
364 | -mno-stack-check -mno-storem-bug @gol | |
365 | -mreuse-arg-regs -msoft-float -mstack-check @gol | |
366 | -mstorem-bug -muser-registers} | |
74291a4b MM |
367 | |
368 | @emph{ARM Options} | |
4bc1997b | 369 | @gccoptlist{ |
310668e8 JM |
370 | -mapcs-frame -mno-apcs-frame @gol |
371 | -mapcs-26 -mapcs-32 @gol | |
372 | -mapcs-stack-check -mno-apcs-stack-check @gol | |
373 | -mapcs-float -mno-apcs-float @gol | |
374 | -mapcs-reentrant -mno-apcs-reentrant @gol | |
375 | -msched-prolog -mno-sched-prolog @gol | |
376 | -mlittle-endian -mbig-endian -mwords-little-endian @gol | |
377 | -malignment-traps -mno-alignment-traps @gol | |
378 | -msoft-float -mhard-float -mfpe @gol | |
379 | -mthumb-interwork -mno-thumb-interwork @gol | |
380 | -mcpu=@var{name} -march=@var{name} -mfpe=@var{name} @gol | |
247f8561 | 381 | -mstructure-size-boundary=@var{n} @gol |
310668e8 | 382 | -mbsd -mxopen -mno-symrename @gol |
4bc1997b | 383 | -mabort-on-noreturn @gol |
310668e8 JM |
384 | -mlong-calls -mno-long-calls @gol |
385 | -msingle-pic-base -mno-single-pic-base @gol | |
247f8561 PB |
386 | -mpic-register=@var{reg} @gol |
387 | -mnop-fun-dllimport @gol | |
388 | -mpoke-function-name @gol | |
310668e8 JM |
389 | -mthumb -marm @gol |
390 | -mtpcs-frame -mtpcs-leaf-frame @gol | |
391 | -mcaller-super-interworking -mcallee-super-interworking } | |
74291a4b | 392 | |
ecff22ab | 393 | @emph{MN10200 Options} |
4bc1997b JM |
394 | @gccoptlist{ |
395 | -mrelax} | |
ecff22ab | 396 | |
6d6d0fa0 | 397 | @emph{MN10300 Options} |
4bc1997b | 398 | @gccoptlist{ |
c474f76b AO |
399 | -mmult-bug -mno-mult-bug @gol |
400 | -mam33 -mno-am33 @gol | |
401 | -mno-crt0 -mrelax} | |
6d6d0fa0 | 402 | |
861bb6c1 | 403 | @emph{M32R/D Options} |
4bc1997b | 404 | @gccoptlist{ |
630d3d5a | 405 | -mcode-model=@var{model-type} -msdata=@var{sdata-type} @gol |
4bc1997b | 406 | -G @var{num}} |
861bb6c1 | 407 | |
74291a4b | 408 | @emph{M88K Options} |
4bc1997b JM |
409 | @gccoptlist{ |
410 | -m88000 -m88100 -m88110 -mbig-pic @gol | |
411 | -mcheck-zero-division -mhandle-large-shift @gol | |
412 | -midentify-revision -mno-check-zero-division @gol | |
413 | -mno-ocs-debug-info -mno-ocs-frame-position @gol | |
414 | -mno-optimize-arg-area -mno-serialize-volatile @gol | |
415 | -mno-underscores -mocs-debug-info @gol | |
416 | -mocs-frame-position -moptimize-arg-area @gol | |
417 | -mserialize-volatile -mshort-data-@var{num} -msvr3 @gol | |
418 | -msvr4 -mtrap-large-shift -muse-div-instruction @gol | |
419 | -mversion-03.00 -mwarn-passed-structs} | |
74291a4b MM |
420 | |
421 | @emph{RS/6000 and PowerPC Options} | |
4bc1997b | 422 | @gccoptlist{ |
630d3d5a JM |
423 | -mcpu=@var{cpu-type} @gol |
424 | -mtune=@var{cpu-type} @gol | |
4bc1997b JM |
425 | -mpower -mno-power -mpower2 -mno-power2 @gol |
426 | -mpowerpc -mpowerpc64 -mno-powerpc @gol | |
427 | -mpowerpc-gpopt -mno-powerpc-gpopt @gol | |
428 | -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol | |
429 | -mnew-mnemonics -mold-mnemonics @gol | |
430 | -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc @gol | |
431 | -m64 -m32 -mxl-call -mno-xl-call -mthreads -mpe @gol | |
432 | -msoft-float -mhard-float -mmultiple -mno-multiple @gol | |
433 | -mstring -mno-string -mupdate -mno-update @gol | |
434 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol | |
435 | -mstrict-align -mno-strict-align -mrelocatable @gol | |
436 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol | |
437 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol | |
438 | -mcall-aix -mcall-sysv -mprototype -mno-prototype @gol | |
439 | -msim -mmvme -mads -myellowknife -memb -msdata @gol | |
440 | -msdata=@var{opt} -mvxworks -G @var{num}} | |
74291a4b MM |
441 | |
442 | @emph{RT Options} | |
4bc1997b JM |
443 | @gccoptlist{ |
444 | -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs @gol | |
445 | -mfull-fp-blocks -mhc-struct-return -min-line-mul @gol | |
446 | -mminimum-fp-blocks -mnohc-struct-return} | |
74291a4b MM |
447 | |
448 | @emph{MIPS Options} | |
4bc1997b | 449 | @gccoptlist{ |
7dac2f89 EC |
450 | -mabicalls -march=@var{cpu-type} -mtune=@var{cpu=type} @gol |
451 | -mcpu=@var{cpu-type} -membedded-data -muninit-const-in-rodata @gol | |
4bc1997b JM |
452 | -membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64 @gol |
453 | -mgpopt -mhalf-pic -mhard-float -mint64 -mips1 @gol | |
feb48bde | 454 | -mips2 -mips3 -mips4 -mlong64 -mlong32 -mlong-calls -mmemcpy @gol |
4bc1997b | 455 | -mmips-as -mmips-tfile -mno-abicalls @gol |
feb48bde JM |
456 | -mno-embedded-data -mno-uninit-const-in-rodata @gol |
457 | -mno-embedded-pic -mno-gpopt -mno-long-calls @gol | |
4bc1997b JM |
458 | -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats @gol |
459 | -mrnames -msoft-float @gol | |
460 | -m4650 -msingle-float -mmad @gol | |
461 | -mstats -EL -EB -G @var{num} -nocpp @gol | |
feb48bde JM |
462 | -mabi=32 -mabi=n32 -mabi=64 -mabi=eabi @gol |
463 | -mfix7000 -mno-crt0} | |
74291a4b MM |
464 | |
465 | @emph{i386 Options} | |
4bc1997b | 466 | @gccoptlist{ |
630d3d5a | 467 | -mcpu=@var{cpu-type} -march=@var{cpu-type} @gol |
4bc1997b JM |
468 | -mintel-syntax -mieee-fp -mno-fancy-math-387 @gol |
469 | -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol | |
470 | -mno-wide-multiply -mrtd -malign-double @gol | |
3e18fdf6 | 471 | -mpreferred-stack-boundary=@var{num} @gol |
feb48bde JM |
472 | -mthreads -mno-align-stringops -minline-all-stringops @gol |
473 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol | |
474 | -m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer} | |
74291a4b MM |
475 | |
476 | @emph{HPPA Options} | |
4bc1997b | 477 | @gccoptlist{ |
630d3d5a | 478 | -march=@var{architecture-type} @gol |
feb48bde JM |
479 | -mbig-switch -mdisable-fpregs -mdisable-indexing @gol |
480 | -mfast-indirect-calls -mgas -mjump-in-delay @gol | |
4bc1997b JM |
481 | -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol |
482 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol | |
feb48bde | 483 | -mno-jump-in-delay -mno-long-load-store @gol |
4bc1997b | 484 | -mno-portable-runtime -mno-soft-float @gol |
feb48bde JM |
485 | -mno-space-regs -msoft-float -mpa-risc-1-0 @gol |
486 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol | |
630d3d5a | 487 | -mschedule=@var{cpu-type} -mspace-regs} |
74291a4b MM |
488 | |
489 | @emph{Intel 960 Options} | |
4bc1997b | 490 | @gccoptlist{ |
630d3d5a | 491 | -m@var{cpu-type} -masm-compat -mclean-linkage @gol |
4bc1997b JM |
492 | -mcode-align -mcomplex-addr -mleaf-procedures @gol |
493 | -mic-compat -mic2.0-compat -mic3.0-compat @gol | |
494 | -mintel-asm -mno-clean-linkage -mno-code-align @gol | |
495 | -mno-complex-addr -mno-leaf-procedures @gol | |
496 | -mno-old-align -mno-strict-align -mno-tail-call @gol | |
497 | -mnumerics -mold-align -msoft-float -mstrict-align @gol | |
498 | -mtail-call} | |
74291a4b MM |
499 | |
500 | @emph{DEC Alpha Options} | |
4bc1997b | 501 | @gccoptlist{ |
310668e8 JM |
502 | -mfp-regs -mno-fp-regs -mno-soft-float -msoft-float @gol |
503 | -malpha-as -mgas @gol | |
4bc1997b JM |
504 | -mieee -mieee-with-inexact -mieee-conformant @gol |
505 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol | |
506 | -mtrap-precision=@var{mode} -mbuild-constants @gol | |
630d3d5a | 507 | -mcpu=@var{cpu-type} @gol |
310668e8 | 508 | -mbwx -mno-bwx -mcix -mno-cix -mmax -mno-max @gol |
4bc1997b | 509 | -mmemory-latency=@var{time}} |
74291a4b MM |
510 | |
511 | @emph{Clipper Options} | |
4bc1997b JM |
512 | @gccoptlist{ |
513 | -mc300 -mc400} | |
74291a4b MM |
514 | |
515 | @emph{H8/300 Options} | |
4bc1997b | 516 | @gccoptlist{ |
310668e8 | 517 | -mrelax -mh -ms -mint32 -malign-300} |
74291a4b MM |
518 | |
519 | @emph{SH Options} | |
4bc1997b JM |
520 | @gccoptlist{ |
521 | -m1 -m2 -m3 -m3e @gol | |
522 | -m4-nofpu -m4-single-only -m4-single -m4 @gol | |
523 | -mb -ml -mdalign -mrelax @gol | |
524 | -mbigtable -mfmovd -mhitachi -mnomacsave @gol | |
c474f76b AO |
525 | -mieee -misize -mpadstruct -mspace @gol |
526 | -mprefergot -musermode} | |
74291a4b MM |
527 | |
528 | @emph{System V Options} | |
4bc1997b | 529 | @gccoptlist{ |
aee96fe9 | 530 | -Qy -Qn -YP,@var{paths} -Ym,@var{dir}} |
74291a4b | 531 | |
56b2d7a7 | 532 | @emph{ARC Options} |
4bc1997b JM |
533 | @gccoptlist{ |
534 | -EB -EL @gol | |
630d3d5a JM |
535 | -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol |
536 | -mdata=@var{data-section} -mrodata=@var{readonly-data-section}} | |
56b2d7a7 | 537 | |
282a61e6 | 538 | @emph{TMS320C3x/C4x Options} |
4bc1997b | 539 | @gccoptlist{ |
310668e8 JM |
540 | -mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol |
541 | -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol | |
542 | -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol | |
543 | -mparallel-insns -mparallel-mpy -mpreserve-float} | |
282a61e6 | 544 | |
f84271d9 | 545 | @emph{V850 Options} |
4bc1997b | 546 | @gccoptlist{ |
310668e8 JM |
547 | -mlong-calls -mno-long-calls -mep -mno-ep @gol |
548 | -mprolog-function -mno-prolog-function -mspace @gol | |
549 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol | |
550 | -mv850 -mbig-switch} | |
83575957 ID |
551 | |
552 | @emph{NS32K Options} | |
4bc1997b | 553 | @gccoptlist{ |
310668e8 | 554 | -m32032 -m32332 -m32532 -m32081 -m32381 @gol |
feb48bde | 555 | -mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol |
310668e8 JM |
556 | -mregparam -mnoregparam -msb -mnosb @gol |
557 | -mbitfield -mnobitfield -mhimem -mnohimem} | |
789a3090 | 558 | |
052a4b28 | 559 | @emph{AVR Options} |
4bc1997b | 560 | @gccoptlist{ |
310668e8 JM |
561 | -mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol |
562 | -mcall-prologues -mno-tablejump -mtiny-stack} | |
052a4b28 | 563 | |
789a3090 | 564 | @emph{MCore Options} |
4bc1997b | 565 | @gccoptlist{ |
feb48bde | 566 | -mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol |
310668e8 JM |
567 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol |
568 | -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol | |
569 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol | |
570 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} | |
f84271d9 | 571 | |
df6194d4 JW |
572 | @emph{IA-64 Options} |
573 | @gccoptlist{ | |
310668e8 JM |
574 | -mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol |
575 | -mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol | |
576 | -mconstant-gp -mauto-pic -minline-divide-min-latency @gol | |
577 | -minline-divide-max-throughput -mno-dwarf2-asm @gol | |
630d3d5a | 578 | -mfixed-range=@var{register-range}} |
df6194d4 | 579 | |
74291a4b MM |
580 | @item Code Generation Options |
581 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
4bc1997b JM |
582 | @gccoptlist{ |
583 | -fcall-saved-@var{reg} -fcall-used-@var{reg} @gol | |
6cfc0341 RH |
584 | -ffixed-@var{reg} -fexceptions @gol |
585 | -fnon-call-exceptions -funwind-tables @gol | |
4bc1997b JM |
586 | -finhibit-size-directive -finstrument-functions @gol |
587 | -fcheck-memory-usage -fprefix-function-name @gol | |
588 | -fno-common -fno-ident -fno-gnu-linker @gol | |
589 | -fpcc-struct-return -fpic -fPIC @gol | |
590 | -freg-struct-return -fshared-data -fshort-enums @gol | |
310668e8 JM |
591 | -fshort-double -fvolatile @gol |
592 | -fvolatile-global -fvolatile-static @gol | |
4bc1997b JM |
593 | -fverbose-asm -fpack-struct -fstack-check @gol |
594 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol | |
595 | -fargument-alias -fargument-noalias @gol | |
310668e8 | 596 | -fargument-noalias-global -fleading-underscore} |
74291a4b MM |
597 | @end table |
598 | ||
599 | @menu | |
600 | * Overall Options:: Controlling the kind of output: | |
601 | an executable, object files, assembler files, | |
602 | or preprocessed source. | |
603 | * C Dialect Options:: Controlling the variant of C language compiled. | |
604 | * C++ Dialect Options:: Variations on C++. | |
60de6385 | 605 | * Objective-C Dialect Options:: Variations on Objective-C. |
764dbbf2 | 606 | * Language Independent Options:: Controlling how diagnostics should be |
02f52e19 | 607 | formatted. |
74291a4b MM |
608 | * Warning Options:: How picky should the compiler be? |
609 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
610 | * Optimize Options:: How much optimization? | |
611 | * Preprocessor Options:: Controlling header files and macro definitions. | |
612 | Also, getting dependency information for Make. | |
613 | * Assembler Options:: Passing options to the assembler. | |
614 | * Link Options:: Specifying libraries and so on. | |
615 | * Directory Options:: Where to find header files and libraries. | |
616 | Where to find the compiler executable files. | |
a743d340 | 617 | * Spec Files:: How to pass switches to sub-processes. |
0c2d1a2a | 618 | * Target Options:: Running a cross-compiler, or an old version of GCC. |
74291a4b MM |
619 | @end menu |
620 | ||
621 | @node Overall Options | |
622 | @section Options Controlling the Kind of Output | |
623 | ||
624 | Compilation can involve up to four stages: preprocessing, compilation | |
625 | proper, assembly and linking, always in that order. The first three | |
626 | stages apply to an individual source file, and end by producing an | |
627 | object file; linking combines all the object files (those newly | |
628 | compiled, and those specified as input) into an executable file. | |
629 | ||
630 | @cindex file name suffix | |
631 | For any given input file, the file name suffix determines what kind of | |
632 | compilation is done: | |
633 | ||
2642624b | 634 | @table @gcctabopt |
74291a4b MM |
635 | @item @var{file}.c |
636 | C source code which must be preprocessed. | |
637 | ||
638 | @item @var{file}.i | |
639 | C source code which should not be preprocessed. | |
640 | ||
641 | @item @var{file}.ii | |
642 | C++ source code which should not be preprocessed. | |
643 | ||
644 | @item @var{file}.m | |
645 | Objective-C source code. Note that you must link with the library | |
646 | @file{libobjc.a} to make an Objective-C program work. | |
647 | ||
b9265ec1 JM |
648 | @item @var{file}.mi |
649 | Objective-C source code which should not be preprocessed. | |
650 | ||
74291a4b MM |
651 | @item @var{file}.h |
652 | C header file (not to be compiled or linked). | |
653 | ||
654 | @item @var{file}.cc | |
b9265ec1 | 655 | @itemx @var{file}.cp |
74291a4b MM |
656 | @itemx @var{file}.cxx |
657 | @itemx @var{file}.cpp | |
b9265ec1 | 658 | @itemx @var{file}.c++ |
74291a4b MM |
659 | @itemx @var{file}.C |
660 | C++ source code which must be preprocessed. Note that in @samp{.cxx}, | |
661 | the last two letters must both be literally @samp{x}. Likewise, | |
161d7b59 | 662 | @samp{.C} refers to a literal capital C@. |
74291a4b | 663 | |
b9265ec1 JM |
664 | @item @var{file}.f |
665 | @itemx @var{file}.for | |
666 | @itemx @var{file}.FOR | |
667 | Fortran source code which should not be preprocessed. | |
668 | ||
669 | @item @var{file}.F | |
670 | @itemx @var{file}.fpp | |
671 | @itemx @var{file}.FPP | |
672 | Fortran source code which must be preprocessed (with the traditional | |
673 | preprocessor). | |
674 | ||
675 | @item @var{file}.r | |
676 | Fortran source code which must be preprocessed with a RATFOR | |
161d7b59 | 677 | preprocessor (not included with GCC)@. |
b9265ec1 JM |
678 | |
679 | @xref{Overall Options,,Options Controlling the Kind of Output, g77, | |
680 | Using and Porting GNU Fortran}, for more details of the handling of | |
681 | Fortran input files. | |
682 | ||
683 | @c FIXME: Descriptions of Java file types. | |
684 | @c @var{file}.java | |
685 | @c @var{file}.class | |
686 | @c @var{file}.zip | |
687 | @c @var{file}.jar | |
688 | ||
689 | @c GCC also knows about some suffixes for languages not yet included: | |
690 | @c Ada: | |
691 | @c @var{file}.ads | |
692 | @c @var{file}.adb | |
693 | @c @var{file}.ada | |
694 | @c Pascal: | |
695 | @c @var{file}.p | |
696 | @c @var{file}.pas | |
697 | ||
698 | @item @var{file}.ch | |
699 | @itemx @var{file}.chi | |
700 | CHILL source code (preprocessed with the traditional preprocessor). | |
701 | ||
74291a4b MM |
702 | @item @var{file}.s |
703 | Assembler code. | |
704 | ||
705 | @item @var{file}.S | |
706 | Assembler code which must be preprocessed. | |
707 | ||
708 | @item @var{other} | |
709 | An object file to be fed straight into linking. | |
710 | Any file name with no recognized suffix is treated this way. | |
711 | @end table | |
712 | ||
cd3bb277 | 713 | @opindex x |
630d3d5a | 714 | You can specify the input language explicitly with the @option{-x} option: |
74291a4b | 715 | |
2642624b | 716 | @table @gcctabopt |
74291a4b MM |
717 | @item -x @var{language} |
718 | Specify explicitly the @var{language} for the following input files | |
719 | (rather than letting the compiler choose a default based on the file | |
720 | name suffix). This option applies to all following input files until | |
630d3d5a | 721 | the next @option{-x} option. Possible values for @var{language} are: |
74291a4b | 722 | @example |
b9265ec1 JM |
723 | c c-header cpp-output |
724 | c++ c++-cpp-output | |
725 | objective-c objc-cpp-output | |
74291a4b | 726 | assembler assembler-with-cpp |
b9265ec1 JM |
727 | f77 f77-cpp-input ratfor |
728 | java chill | |
74291a4b | 729 | @end example |
b9265ec1 | 730 | @c Also f77-version, for internal use only. |
74291a4b MM |
731 | |
732 | @item -x none | |
733 | Turn off any specification of a language, so that subsequent files are | |
630d3d5a | 734 | handled according to their file name suffixes (as they are if @option{-x} |
74291a4b | 735 | has not been used at all). |
14a774a9 RK |
736 | |
737 | @item -pass-exit-codes | |
cd3bb277 | 738 | @opindex pass-exit-codes |
bedc7537 | 739 | Normally the @command{gcc} program will exit with the code of 1 if any |
14a774a9 | 740 | phase of the compiler returns a non-success return code. If you specify |
630d3d5a | 741 | @option{-pass-exit-codes}, the @command{gcc} program will instead return with |
14a774a9 RK |
742 | numerically highest error produced by any phase that returned an error |
743 | indication. | |
74291a4b MM |
744 | @end table |
745 | ||
746 | If you only want some of the stages of compilation, you can use | |
630d3d5a JM |
747 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and |
748 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
bedc7537 NC |
749 | @command{gcc} is to stop. Note that some combinations (for example, |
750 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
74291a4b | 751 | |
2642624b | 752 | @table @gcctabopt |
74291a4b | 753 | @item -c |
cd3bb277 | 754 | @opindex c |
74291a4b MM |
755 | Compile or assemble the source files, but do not link. The linking |
756 | stage simply is not done. The ultimate output is in the form of an | |
757 | object file for each source file. | |
758 | ||
759 | By default, the object file name for a source file is made by replacing | |
760 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
761 | ||
762 | Unrecognized input files, not requiring compilation or assembly, are | |
763 | ignored. | |
764 | ||
765 | @item -S | |
cd3bb277 | 766 | @opindex S |
74291a4b MM |
767 | Stop after the stage of compilation proper; do not assemble. The output |
768 | is in the form of an assembler code file for each non-assembler input | |
769 | file specified. | |
770 | ||
771 | By default, the assembler file name for a source file is made by | |
772 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
773 | ||
774 | Input files that don't require compilation are ignored. | |
775 | ||
776 | @item -E | |
cd3bb277 | 777 | @opindex E |
74291a4b MM |
778 | Stop after the preprocessing stage; do not run the compiler proper. The |
779 | output is in the form of preprocessed source code, which is sent to the | |
780 | standard output. | |
781 | ||
782 | Input files which don't require preprocessing are ignored. | |
783 | ||
784 | @cindex output file option | |
785 | @item -o @var{file} | |
cd3bb277 | 786 | @opindex o |
74291a4b MM |
787 | Place output in file @var{file}. This applies regardless to whatever |
788 | sort of output is being produced, whether it be an executable file, | |
789 | an object file, an assembler file or preprocessed C code. | |
790 | ||
791 | Since only one output file can be specified, it does not make sense to | |
630d3d5a | 792 | use @option{-o} when compiling more than one input file, unless you are |
74291a4b MM |
793 | producing an executable file as output. |
794 | ||
630d3d5a | 795 | If @option{-o} is not specified, the default is to put an executable file |
74291a4b MM |
796 | in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in |
797 | @file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and | |
bd819a4a | 798 | all preprocessed C source on standard output. |
74291a4b MM |
799 | |
800 | @item -v | |
cd3bb277 | 801 | @opindex v |
74291a4b MM |
802 | Print (on standard error output) the commands executed to run the stages |
803 | of compilation. Also print the version number of the compiler driver | |
804 | program and of the preprocessor and the compiler proper. | |
805 | ||
806 | @item -pipe | |
cd3bb277 | 807 | @opindex pipe |
74291a4b MM |
808 | Use pipes rather than temporary files for communication between the |
809 | various stages of compilation. This fails to work on some systems where | |
810 | the assembler is unable to read from a pipe; but the GNU assembler has | |
811 | no trouble. | |
844642e6 NC |
812 | |
813 | @item --help | |
cd3bb277 | 814 | @opindex help |
844642e6 | 815 | Print (on the standard output) a description of the command line options |
bedc7537 NC |
816 | understood by @command{gcc}. If the @option{-v} option is also specified |
817 | then @option{--help} will also be passed on to the various processes | |
818 | invoked by @command{gcc}, so that they can display the command line options | |
819 | they accept. If the @option{-W} option is also specified then command | |
844642e6 NC |
820 | line options which have no documentation associated with them will also |
821 | be displayed. | |
10501d8f CC |
822 | |
823 | @item --target-help | |
cd3bb277 | 824 | @opindex target-help |
10501d8f CC |
825 | Print (on the standard output) a description of target specific command |
826 | line options for each tool. | |
74291a4b MM |
827 | @end table |
828 | ||
829 | @node Invoking G++ | |
830 | @section Compiling C++ Programs | |
831 | ||
832 | @cindex suffixes for C++ source | |
833 | @cindex C++ source file suffixes | |
834 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
bba975d4 | 835 | @samp{.cc}, @samp{.cpp}, @samp{.c++}, @samp{.cp}, or @samp{.cxx}; |
0c2d1a2a | 836 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes |
bba975d4 JM |
837 | files with these names and compiles them as C++ programs even if you |
838 | call the compiler the same way as for compiling C programs (usually with | |
bedc7537 | 839 | the name @command{gcc}). |
74291a4b MM |
840 | |
841 | @findex g++ | |
842 | @findex c++ | |
843 | However, C++ programs often require class libraries as well as a | |
844 | compiler that understands the C++ language---and under some | |
845 | circumstances, you might want to compile programs from standard input, | |
846 | or otherwise without a suffix that flags them as C++ programs. | |
bedc7537 | 847 | @command{g++} is a program that calls GCC with the default language |
e5e809f4 | 848 | set to C++, and automatically specifies linking against the C++ |
bedc7537 NC |
849 | library. On many systems, @command{g++} is also |
850 | installed with the name @command{c++}. | |
74291a4b | 851 | |
bedc7537 | 852 | @cindex invoking @command{g++} |
74291a4b MM |
853 | When you compile C++ programs, you may specify many of the same |
854 | command-line options that you use for compiling programs in any | |
855 | language; or command-line options meaningful for C and related | |
856 | languages; or options that are meaningful only for C++ programs. | |
857 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
161d7b59 | 858 | explanations of options for languages related to C@. |
74291a4b MM |
859 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for |
860 | explanations of options that are meaningful only for C++ programs. | |
861 | ||
862 | @node C Dialect Options | |
863 | @section Options Controlling C Dialect | |
864 | @cindex dialect options | |
865 | @cindex language dialect options | |
866 | @cindex options, dialect | |
867 | ||
868 | The following options control the dialect of C (or languages derived | |
2147b154 | 869 | from C, such as C++ and Objective-C) that the compiler accepts: |
74291a4b | 870 | |
2642624b | 871 | @table @gcctabopt |
74291a4b | 872 | @cindex ANSI support |
c1030c7c | 873 | @cindex ISO support |
74291a4b | 874 | @item -ansi |
cd3bb277 | 875 | @opindex ansi |
c1030c7c | 876 | In C mode, support all ISO C89 programs. In C++ mode, |
775afb25 | 877 | remove GNU extensions that conflict with ISO C++. |
74291a4b | 878 | |
c1030c7c | 879 | This turns off certain features of GCC that are incompatible with ISO |
aee96fe9 | 880 | C89 (when compiling C code), or of standard C++ (when compiling C++ code), |
0c2d1a2a | 881 | such as the @code{asm} and @code{typeof} keywords, and |
74291a4b MM |
882 | predefined macros such as @code{unix} and @code{vax} that identify the |
883 | type of system you are using. It also enables the undesirable and | |
02f52e19 | 884 | rarely used ISO trigraph feature. For the C compiler, |
0c2d1a2a | 885 | it disables recognition of C++ style @samp{//} comments as well as |
775afb25 | 886 | the @code{inline} keyword. |
74291a4b MM |
887 | |
888 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
889 | @code{__inline__} and @code{__typeof__} continue to work despite | |
630d3d5a | 890 | @option{-ansi}. You would not want to use them in an ISO C program, of |
74291a4b | 891 | course, but it is useful to put them in header files that might be included |
630d3d5a | 892 | in compilations done with @option{-ansi}. Alternate predefined macros |
74291a4b | 893 | such as @code{__unix__} and @code{__vax__} are also available, with or |
630d3d5a | 894 | without @option{-ansi}. |
74291a4b | 895 | |
630d3d5a JM |
896 | The @option{-ansi} option does not cause non-ISO programs to be |
897 | rejected gratuitously. For that, @option{-pedantic} is required in | |
898 | addition to @option{-ansi}. @xref{Warning Options}. | |
74291a4b | 899 | |
630d3d5a | 900 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} |
74291a4b MM |
901 | option is used. Some header files may notice this macro and refrain |
902 | from declaring certain functions or defining certain macros that the | |
c1030c7c | 903 | ISO standard doesn't call for; this is to avoid interfering with any |
74291a4b MM |
904 | programs that might use these names for other things. |
905 | ||
c771326b JM |
906 | Functions which would normally be built in but do not have semantics |
907 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
630d3d5a | 908 | functions with @option{-ansi} is used. @xref{Other Builtins,,Other |
f0523f02 | 909 | built-in functions provided by GCC}, for details of the functions |
01702459 | 910 | affected. |
74291a4b | 911 | |
49419c8f | 912 | @item -std= |
cd3bb277 | 913 | @opindex std |
aee96fe9 JM |
914 | Determine the language standard. This option is currently only |
915 | supported when compiling C@. A value for this option must be provided; | |
02f52e19 | 916 | possible values are |
3932261a | 917 | |
ee457005 | 918 | @table @samp |
aee96fe9 JM |
919 | @item c89 |
920 | @itemx iso9899:1990 | |
921 | ISO C89 (same as @option{-ansi}). | |
3043b30e ML |
922 | |
923 | @item iso9899:199409 | |
aee96fe9 | 924 | ISO C89 as modified in amendment 1. |
3043b30e | 925 | |
49419c8f | 926 | @item c99 |
aee96fe9 JM |
927 | @itemx c9x |
928 | @itemx iso9899:1999 | |
929 | @itemx iso9899:199x | |
930 | ISO C99. Note that this standard is not yet fully supported; see | |
931 | @w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The | |
932 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
3043b30e ML |
933 | |
934 | @item gnu89 | |
aee96fe9 | 935 | Default, ISO C89 plus GNU extensions (including some C99 features). |
3043b30e | 936 | |
49419c8f | 937 | @item gnu99 |
7dac2f89 | 938 | @item gnu9x |
d15a05b3 EC |
939 | ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC, |
940 | this will become the default. The name @samp{gnu9x} is deprecated. | |
49419c8f | 941 | |
ee457005 | 942 | @end table |
3043b30e ML |
943 | |
944 | Even when this option is not specified, you can still use some of the | |
945 | features of newer standards in so far as they do not conflict with | |
946 | previous C standards. For example, you may use @code{__restrict__} even | |
bedc7537 | 947 | when @option{-std=c99} is not specified. |
3932261a | 948 | |
5490d604 JM |
949 | The @option{-std} options specifying some version of ISO C have the same |
950 | effects as @option{-ansi}, except that features that were not in ISO C89 | |
951 | but are in the specified version (for example, @samp{//} comments and | |
952 | the @code{inline} keyword in ISO C99) are not disabled. | |
953 | ||
c1030c7c JM |
954 | @xref{Standards,,Language Standards Supported by GCC}, for details of |
955 | these standard versions. | |
956 | ||
b1018de6 AO |
957 | @item -aux-info @var{filename} |
958 | @opindex aux-info | |
959 | Output to the given filename prototyped declarations for all functions | |
960 | declared and/or defined in a translation unit, including those in header | |
161d7b59 | 961 | files. This option is silently ignored in any language other than C@. |
b1018de6 AO |
962 | |
963 | Besides declarations, the file indicates, in comments, the origin of | |
964 | each declaration (source file and line), whether the declaration was | |
965 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
966 | @samp{O} for old, respectively, in the first character after the line | |
967 | number and the colon), and whether it came from a declaration or a | |
968 | definition (@samp{C} or @samp{F}, respectively, in the following | |
969 | character). In the case of function definitions, a K&R-style list of | |
970 | arguments followed by their declarations is also provided, inside | |
971 | comments, after the declaration. | |
972 | ||
74291a4b | 973 | @item -fno-asm |
cd3bb277 | 974 | @opindex fno-asm |
74291a4b MM |
975 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
976 | keyword, so that code can use these words as identifiers. You can use | |
977 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
630d3d5a | 978 | instead. @option{-ansi} implies @option{-fno-asm}. |
74291a4b MM |
979 | |
980 | In C++, this switch only affects the @code{typeof} keyword, since | |
981 | @code{asm} and @code{inline} are standard keywords. You may want to | |
630d3d5a | 982 | use the @option{-fno-gnu-keywords} flag instead, which has the same |
5490d604 JM |
983 | effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this |
984 | switch only affects the @code{asm} and @code{typeof} keywords, since | |
985 | @code{inline} is a standard keyword in ISO C99. | |
74291a4b MM |
986 | |
987 | @item -fno-builtin | |
cd3bb277 | 988 | @opindex fno-builtin |
c771326b JM |
989 | @cindex built-in functions |
990 | Don't recognize built-in functions that do not begin with | |
01702459 | 991 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in |
f0523f02 | 992 | functions provided by GCC}, for details of the functions affected, |
c771326b | 993 | including those which are not built-in functions when @option{-ansi} or |
5490d604 JM |
994 | @option{-std} options for strict ISO C conformance are used because they |
995 | do not have an ISO standard meaning. | |
74291a4b | 996 | |
c771326b | 997 | GCC normally generates special code to handle certain built-in functions |
74291a4b MM |
998 | more efficiently; for instance, calls to @code{alloca} may become single |
999 | instructions that adjust the stack directly, and calls to @code{memcpy} | |
1000 | may become inline copy loops. The resulting code is often both smaller | |
1001 | and faster, but since the function calls no longer appear as such, you | |
1002 | cannot set a breakpoint on those calls, nor can you change the behavior | |
1003 | of the functions by linking with a different library. | |
1004 | ||
630d3d5a | 1005 | In C++, @option{-fno-builtin} is always in effect. The @option{-fbuiltin} |
0b1161fc | 1006 | option has no effect. Therefore, in C++, the only way to get the |
c771326b | 1007 | optimization benefits of built-in functions is to call the function |
0b1161fc | 1008 | using the @samp{__builtin_} prefix. The GNU C++ Standard Library uses |
c771326b | 1009 | built-in functions to implement many functions (like |
0b1161fc MM |
1010 | @code{std::strchr}), so that you automatically get efficient code. |
1011 | ||
861bb6c1 | 1012 | @item -fhosted |
cd3bb277 | 1013 | @opindex fhosted |
861bb6c1 JL |
1014 | @cindex hosted environment |
1015 | ||
1016 | Assert that compilation takes place in a hosted environment. This implies | |
630d3d5a | 1017 | @option{-fbuiltin}. A hosted environment is one in which the |
861bb6c1 JL |
1018 | entire standard library is available, and in which @code{main} has a return |
1019 | type of @code{int}. Examples are nearly everything except a kernel. | |
630d3d5a | 1020 | This is equivalent to @option{-fno-freestanding}. |
861bb6c1 JL |
1021 | |
1022 | @item -ffreestanding | |
cd3bb277 | 1023 | @opindex ffreestanding |
861bb6c1 JL |
1024 | @cindex hosted environment |
1025 | ||
1026 | Assert that compilation takes place in a freestanding environment. This | |
630d3d5a | 1027 | implies @option{-fno-builtin}. A freestanding environment |
861bb6c1 JL |
1028 | is one in which the standard library may not exist, and program startup may |
1029 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
630d3d5a | 1030 | This is equivalent to @option{-fno-hosted}. |
861bb6c1 | 1031 | |
c1030c7c JM |
1032 | @xref{Standards,,Language Standards Supported by GCC}, for details of |
1033 | freestanding and hosted environments. | |
1034 | ||
74291a4b | 1035 | @item -trigraphs |
cd3bb277 | 1036 | @opindex trigraphs |
3bce8a01 NB |
1037 | Support ISO C trigraphs. The @option{-ansi} option (and @option{-std} |
1038 | options for strict ISO C conformance) implies @option{-trigraphs}. | |
74291a4b MM |
1039 | |
1040 | @cindex traditional C language | |
1041 | @cindex C language, traditional | |
1042 | @item -traditional | |
cd3bb277 | 1043 | @opindex traditional |
74291a4b MM |
1044 | Attempt to support some aspects of traditional C compilers. |
1045 | Specifically: | |
1046 | ||
1047 | @itemize @bullet | |
1048 | @item | |
1049 | All @code{extern} declarations take effect globally even if they | |
1050 | are written inside of a function definition. This includes implicit | |
1051 | declarations of functions. | |
1052 | ||
1053 | @item | |
1054 | The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const} | |
1055 | and @code{volatile} are not recognized. (You can still use the | |
1056 | alternative keywords such as @code{__typeof__}, @code{__inline__}, and | |
1057 | so on.) | |
1058 | ||
1059 | @item | |
1060 | Comparisons between pointers and integers are always allowed. | |
1061 | ||
1062 | @item | |
1063 | Integer types @code{unsigned short} and @code{unsigned char} promote | |
1064 | to @code{unsigned int}. | |
1065 | ||
1066 | @item | |
1067 | Out-of-range floating point literals are not an error. | |
1068 | ||
1069 | @item | |
c1030c7c | 1070 | Certain constructs which ISO regards as a single invalid preprocessing |
74291a4b MM |
1071 | number, such as @samp{0xe-0xd}, are treated as expressions instead. |
1072 | ||
1073 | @item | |
1074 | String ``constants'' are not necessarily constant; they are stored in | |
1075 | writable space, and identical looking constants are allocated | |
1076 | separately. (This is the same as the effect of | |
630d3d5a | 1077 | @option{-fwritable-strings}.) |
74291a4b MM |
1078 | |
1079 | @cindex @code{longjmp} and automatic variables | |
1080 | @item | |
1081 | All automatic variables not declared @code{register} are preserved by | |
c1030c7c | 1082 | @code{longjmp}. Ordinarily, GNU C follows ISO C: automatic variables |
74291a4b MM |
1083 | not declared @code{volatile} may be clobbered. |
1084 | ||
1085 | @item | |
cd3bb277 JM |
1086 | @cindex @samp{\x} |
1087 | @cindex @samp{\a} | |
74291a4b MM |
1088 | @cindex escape sequences, traditional |
1089 | The character escape sequences @samp{\x} and @samp{\a} evaluate as the | |
1090 | literal characters @samp{x} and @samp{a} respectively. Without | |
630d3d5a | 1091 | @w{@option{-traditional}}, @samp{\x} is a prefix for the hexadecimal |
74291a4b | 1092 | representation of a character, and @samp{\a} produces a bell. |
ad299d9b | 1093 | @end itemize |
74291a4b | 1094 | |
630d3d5a | 1095 | You may wish to use @option{-fno-builtin} as well as @option{-traditional} |
c771326b | 1096 | if your program uses names that are normally GNU C built-in functions for |
74291a4b MM |
1097 | other purposes of its own. |
1098 | ||
630d3d5a | 1099 | You cannot use @option{-traditional} if you include any header files that |
c1030c7c | 1100 | rely on ISO C features. Some vendors are starting to ship systems with |
630d3d5a | 1101 | ISO C header files and you cannot use @option{-traditional} on such |
74291a4b MM |
1102 | systems to compile files that include any system headers. |
1103 | ||
630d3d5a | 1104 | The @option{-traditional} option also enables @option{-traditional-cpp}, |
e5e809f4 | 1105 | which is described next. |
74291a4b MM |
1106 | |
1107 | @item -traditional-cpp | |
cd3bb277 | 1108 | @opindex traditional-cpp |
74291a4b MM |
1109 | Attempt to support some aspects of traditional C preprocessors. |
1110 | Specifically: | |
1111 | ||
1112 | @itemize @bullet | |
1113 | @item | |
1114 | Comments convert to nothing at all, rather than to a space. This allows | |
1115 | traditional token concatenation. | |
1116 | ||
1117 | @item | |
1118 | In a preprocessing directive, the @samp{#} symbol must appear as the first | |
1119 | character of a line. | |
1120 | ||
1121 | @item | |
1122 | Macro arguments are recognized within string constants in a macro | |
1123 | definition (and their values are stringified, though without additional | |
1124 | quote marks, when they appear in such a context). The preprocessor | |
1125 | always considers a string constant to end at a newline. | |
1126 | ||
1127 | @item | |
630d3d5a | 1128 | @cindex detecting @w{@option{-traditional}} |
74291a4b | 1129 | The predefined macro @code{__STDC__} is not defined when you use |
630d3d5a | 1130 | @option{-traditional}, but @code{__GNUC__} is (since the GNU extensions |
74291a4b | 1131 | which @code{__GNUC__} indicates are not affected by |
630d3d5a JM |
1132 | @option{-traditional}). If you need to write header files that work |
1133 | differently depending on whether @option{-traditional} is in use, by | |
74291a4b | 1134 | testing both of these predefined macros you can distinguish four |
c1030c7c | 1135 | situations: GNU C, traditional GNU C, other ISO C compilers, and other |
74291a4b | 1136 | old C compilers. The predefined macro @code{__STDC_VERSION__} is also |
630d3d5a | 1137 | not defined when you use @option{-traditional}. @xref{Standard |
74291a4b MM |
1138 | Predefined,,Standard Predefined Macros,cpp.info,The C Preprocessor}, |
1139 | for more discussion of these and other predefined macros. | |
1140 | ||
1141 | @item | |
1142 | @cindex string constants vs newline | |
1143 | @cindex newline vs string constants | |
1144 | The preprocessor considers a string constant to end at a newline (unless | |
630d3d5a | 1145 | the newline is escaped with @samp{\}). (Without @w{@option{-traditional}}, |
74291a4b MM |
1146 | string constants can contain the newline character as typed.) |
1147 | @end itemize | |
1148 | ||
1149 | @item -fcond-mismatch | |
cd3bb277 | 1150 | @opindex fcond-mismatch |
74291a4b | 1151 | Allow conditional expressions with mismatched types in the second and |
a7537031 JM |
1152 | third arguments. The value of such an expression is void. This option |
1153 | is not supported for C++. | |
74291a4b MM |
1154 | |
1155 | @item -funsigned-char | |
cd3bb277 | 1156 | @opindex funsigned-char |
74291a4b MM |
1157 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
1158 | ||
1159 | Each kind of machine has a default for what @code{char} should | |
1160 | be. It is either like @code{unsigned char} by default or like | |
1161 | @code{signed char} by default. | |
1162 | ||
1163 | Ideally, a portable program should always use @code{signed char} or | |
1164 | @code{unsigned char} when it depends on the signedness of an object. | |
1165 | But many programs have been written to use plain @code{char} and | |
1166 | expect it to be signed, or expect it to be unsigned, depending on the | |
1167 | machines they were written for. This option, and its inverse, let you | |
1168 | make such a program work with the opposite default. | |
1169 | ||
1170 | The type @code{char} is always a distinct type from each of | |
1171 | @code{signed char} or @code{unsigned char}, even though its behavior | |
1172 | is always just like one of those two. | |
1173 | ||
1174 | @item -fsigned-char | |
cd3bb277 | 1175 | @opindex fsigned-char |
74291a4b MM |
1176 | Let the type @code{char} be signed, like @code{signed char}. |
1177 | ||
630d3d5a JM |
1178 | Note that this is equivalent to @option{-fno-unsigned-char}, which is |
1179 | the negative form of @option{-funsigned-char}. Likewise, the option | |
1180 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
74291a4b | 1181 | |
74291a4b MM |
1182 | @item -fsigned-bitfields |
1183 | @itemx -funsigned-bitfields | |
1184 | @itemx -fno-signed-bitfields | |
1185 | @itemx -fno-unsigned-bitfields | |
cd3bb277 JM |
1186 | @opindex fsigned-bitfields |
1187 | @opindex funsigned-bitfields | |
1188 | @opindex fno-signed-bitfields | |
1189 | @opindex fno-unsigned-bitfields | |
c771326b | 1190 | These options control whether a bit-field is signed or unsigned, when the |
74291a4b | 1191 | declaration does not use either @code{signed} or @code{unsigned}. By |
c771326b | 1192 | default, such a bit-field is signed, because this is consistent: the |
74291a4b MM |
1193 | basic integer types such as @code{int} are signed types. |
1194 | ||
c771326b | 1195 | However, when @option{-traditional} is used, bit-fields are all unsigned |
74291a4b MM |
1196 | no matter what. |
1197 | ||
1198 | @item -fwritable-strings | |
cd3bb277 | 1199 | @opindex fwritable-strings |
74291a4b MM |
1200 | Store string constants in the writable data segment and don't uniquize |
1201 | them. This is for compatibility with old programs which assume they can | |
630d3d5a | 1202 | write into string constants. The option @option{-traditional} also has |
74291a4b MM |
1203 | this effect. |
1204 | ||
1205 | Writing into string constants is a very bad idea; ``constants'' should | |
1206 | be constant. | |
1207 | ||
1208 | @item -fallow-single-precision | |
cd3bb277 | 1209 | @opindex fallow-single-precision |
74291a4b | 1210 | Do not promote single precision math operations to double precision, |
630d3d5a | 1211 | even when compiling with @option{-traditional}. |
74291a4b MM |
1212 | |
1213 | Traditional K&R C promotes all floating point operations to double | |
1214 | precision, regardless of the sizes of the operands. On the | |
1215 | architecture for which you are compiling, single precision may be faster | |
630d3d5a | 1216 | than double precision. If you must use @option{-traditional}, but want |
74291a4b MM |
1217 | to use single precision operations when the operands are single |
1218 | precision, use this option. This option has no effect when compiling | |
c1030c7c | 1219 | with ISO or GNU C conventions (the default). |
74291a4b | 1220 | |
3e37bef5 | 1221 | @item -fshort-wchar |
cd3bb277 | 1222 | @opindex fshort-wchar |
3e37bef5 JM |
1223 | Override the underlying type for @samp{wchar_t} to be @samp{short |
1224 | unsigned int} instead of the default for the target. This option is | |
161d7b59 | 1225 | useful for building programs to run under WINE@. |
74291a4b MM |
1226 | @end table |
1227 | ||
1228 | @node C++ Dialect Options | |
1229 | @section Options Controlling C++ Dialect | |
1230 | ||
1231 | @cindex compiler options, C++ | |
1232 | @cindex C++ options, command line | |
1233 | @cindex options, C++ | |
1234 | This section describes the command-line options that are only meaningful | |
1235 | for C++ programs; but you can also use most of the GNU compiler options | |
1236 | regardless of what language your program is in. For example, you | |
1237 | might compile a file @code{firstClass.C} like this: | |
1238 | ||
1239 | @example | |
1dc5fc4b | 1240 | g++ -g -frepo -O -c firstClass.C |
74291a4b MM |
1241 | @end example |
1242 | ||
1243 | @noindent | |
630d3d5a | 1244 | In this example, only @option{-frepo} is an option meant |
74291a4b | 1245 | only for C++ programs; you can use the other options with any |
161d7b59 | 1246 | language supported by GCC@. |
74291a4b MM |
1247 | |
1248 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
1249 | ||
2642624b | 1250 | @table @gcctabopt |
74291a4b | 1251 | @item -fno-access-control |
cd3bb277 | 1252 | @opindex fno-access-control |
74291a4b MM |
1253 | Turn off all access checking. This switch is mainly useful for working |
1254 | around bugs in the access control code. | |
1255 | ||
74291a4b | 1256 | @item -fcheck-new |
cd3bb277 | 1257 | @opindex fcheck-new |
74291a4b MM |
1258 | Check that the pointer returned by @code{operator new} is non-null |
1259 | before attempting to modify the storage allocated. The current Working | |
1260 | Paper requires that @code{operator new} never return a null pointer, so | |
1261 | this check is normally unnecessary. | |
1262 | ||
1dc5fc4b JM |
1263 | An alternative to using this option is to specify that your |
1264 | @code{operator new} does not throw any exceptions; if you declare it | |
aee96fe9 | 1265 | @samp{throw()}, G++ will check the return value. See also @samp{new |
1dc5fc4b JM |
1266 | (nothrow)}. |
1267 | ||
74291a4b | 1268 | @item -fconserve-space |
cd3bb277 | 1269 | @opindex fconserve-space |
74291a4b MM |
1270 | Put uninitialized or runtime-initialized global variables into the |
1271 | common segment, as C does. This saves space in the executable at the | |
1272 | cost of not diagnosing duplicate definitions. If you compile with this | |
1273 | flag and your program mysteriously crashes after @code{main()} has | |
1274 | completed, you may have an object that is being destroyed twice because | |
1275 | two definitions were merged. | |
1276 | ||
1dc5fc4b JM |
1277 | This option is no longer useful on most targets, now that support has |
1278 | been added for putting variables into BSS without making them common. | |
1279 | ||
02f52e19 | 1280 | @item -fno-const-strings |
cd3bb277 | 1281 | @opindex fno-const-strings |
fcca588c MM |
1282 | Give string constants type @code{char *} instead of type @code{const |
1283 | char *}. By default, G++ uses type @code{const char *} as required by | |
630d3d5a | 1284 | the standard. Even if you use @option{-fno-const-strings}, you cannot |
fcca588c | 1285 | actually modify the value of a string constant, unless you also use |
630d3d5a | 1286 | @option{-fwritable-strings}. |
fcca588c MM |
1287 | |
1288 | This option might be removed in a future release of G++. For maximum | |
1289 | portability, you should structure your code so that it works with | |
1290 | string constants that have type @code{const char *}. | |
1291 | ||
74291a4b | 1292 | @item -fdollars-in-identifiers |
cd3bb277 | 1293 | @opindex fdollars-in-identifiers |
74291a4b | 1294 | Accept @samp{$} in identifiers. You can also explicitly prohibit use of |
630d3d5a | 1295 | @samp{$} with the option @option{-fno-dollars-in-identifiers}. (GNU C allows |
eb795509 | 1296 | @samp{$} by default on most target systems, but there are a few exceptions.) |
74291a4b | 1297 | Traditional C allowed the character @samp{$} to form part of |
c1030c7c | 1298 | identifiers. However, ISO C and C++ forbid @samp{$} in identifiers. |
74291a4b | 1299 | |
1dc5fc4b | 1300 | @item -fno-elide-constructors |
cd3bb277 | 1301 | @opindex fno-elide-constructors |
1dc5fc4b JM |
1302 | The C++ standard allows an implementation to omit creating a temporary |
1303 | which is only used to initialize another object of the same type. | |
aee96fe9 | 1304 | Specifying this option disables that optimization, and forces G++ to |
1dc5fc4b | 1305 | call the copy constructor in all cases. |
74291a4b | 1306 | |
dd1ba632 | 1307 | @item -fno-enforce-eh-specs |
cd3bb277 | 1308 | @opindex fno-enforce-eh-specs |
dd1ba632 JM |
1309 | Don't check for violation of exception specifications at runtime. This |
1310 | option violates the C++ standard, but may be useful for reducing code | |
1311 | size in production builds, much like defining @samp{NDEBUG}. The compiler | |
1312 | will still optimize based on the exception specifications. | |
1313 | ||
74291a4b | 1314 | @item -fexternal-templates |
cd3bb277 | 1315 | @opindex fexternal-templates |
74291a4b MM |
1316 | Cause template instantiations to obey @samp{#pragma interface} and |
1317 | @samp{implementation}; template instances are emitted or not according | |
1318 | to the location of the template definition. @xref{Template | |
1319 | Instantiation}, for more information. | |
1320 | ||
37f6b6bf MM |
1321 | This option is deprecated. |
1322 | ||
74291a4b | 1323 | @item -falt-external-templates |
cd3bb277 | 1324 | @opindex falt-external-templates |
695ac33f | 1325 | Similar to @option{-fexternal-templates}, but template instances are emitted or |
74291a4b MM |
1326 | not according to the place where they are first instantiated. |
1327 | @xref{Template Instantiation}, for more information. | |
1328 | ||
37f6b6bf MM |
1329 | This option is deprecated. |
1330 | ||
74291a4b | 1331 | @item -ffor-scope |
8c81598d | 1332 | @itemx -fno-for-scope |
cd3bb277 JM |
1333 | @opindex ffor-scope |
1334 | @opindex fno-for-scope | |
695ac33f | 1335 | If @option{-ffor-scope} is specified, the scope of variables declared in |
74291a4b | 1336 | a @i{for-init-statement} is limited to the @samp{for} loop itself, |
34527c47 | 1337 | as specified by the C++ standard. |
695ac33f | 1338 | If @option{-fno-for-scope} is specified, the scope of variables declared in |
74291a4b | 1339 | a @i{for-init-statement} extends to the end of the enclosing scope, |
aee96fe9 | 1340 | as was the case in old versions of G++, and other (traditional) |
74291a4b MM |
1341 | implementations of C++. |
1342 | ||
1343 | The default if neither flag is given to follow the standard, | |
1344 | but to allow and give a warning for old-style code that would | |
1345 | otherwise be invalid, or have different behavior. | |
1346 | ||
1347 | @item -fno-gnu-keywords | |
cd3bb277 | 1348 | @opindex fno-gnu-keywords |
9762e8a4 | 1349 | Do not recognize @code{typeof} as a keyword, so that code can use this |
767094dd | 1350 | word as an identifier. You can use the keyword @code{__typeof__} instead. |
630d3d5a | 1351 | @option{-ansi} implies @option{-fno-gnu-keywords}. |
74291a4b | 1352 | |
25b5b465 MM |
1353 | @item -fno-honor-std |
1354 | @opindex fno-honor-std | |
1355 | Ignore @code{namespace std}, instead of treating it as a real namespace. | |
1356 | With this switch, the compiler will ignore | |
1357 | @code{namespace-declarations}, @code{using-declarations}, | |
1358 | @code{using-directives}, and @code{namespace-names}, if they involve | |
f9047ed3 | 1359 | @code{std}. |
25b5b465 MM |
1360 | |
1361 | This option is only useful if you have manually compiled the C++ | |
1362 | run-time library with the same switch. Otherwise, your programs will | |
1363 | not link. The use of this option is not recommended, and the option may | |
1364 | be removed from a future version of G++. | |
95c81fb8 | 1365 | |
1dc5fc4b | 1366 | @item -fno-implicit-templates |
cd3bb277 | 1367 | @opindex fno-implicit-templates |
bba975d4 | 1368 | Never emit code for non-inline templates which are instantiated |
e979f9e8 | 1369 | implicitly (i.e.@: by use); only emit code for explicit instantiations. |
bba975d4 JM |
1370 | @xref{Template Instantiation}, for more information. |
1371 | ||
1372 | @item -fno-implicit-inline-templates | |
cd3bb277 | 1373 | @opindex fno-implicit-inline-templates |
bba975d4 JM |
1374 | Don't emit code for implicit instantiations of inline templates, either. |
1375 | The default is to handle inlines differently so that compiles with and | |
1376 | without optimization will need the same set of explicit instantiations. | |
1dc5fc4b | 1377 | |
74291a4b | 1378 | @item -fno-implement-inlines |
cd3bb277 | 1379 | @opindex fno-implement-inlines |
74291a4b MM |
1380 | To save space, do not emit out-of-line copies of inline functions |
1381 | controlled by @samp{#pragma implementation}. This will cause linker | |
1382 | errors if these functions are not inlined everywhere they are called. | |
1383 | ||
631cf95d | 1384 | @item -fms-extensions |
cd3bb277 | 1385 | @opindex fms-extensions |
32fb1fb2 PE |
1386 | Disable pedantic warnings about constructs used in MFC, such as implicit |
1387 | int and getting a pointer to member function via non-standard syntax. | |
631cf95d | 1388 | |
fcca588c | 1389 | @item -fno-nonansi-builtins |
cd3bb277 | 1390 | @opindex fno-nonansi-builtins |
c771326b | 1391 | Disable built-in declarations of functions that are not mandated by |
161d7b59 | 1392 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, |
fcca588c MM |
1393 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. |
1394 | ||
775afb25 | 1395 | @item -fno-operator-names |
cd3bb277 | 1396 | @opindex fno-operator-names |
775afb25 | 1397 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
74291a4b | 1398 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as |
775afb25 | 1399 | synonyms as keywords. |
74291a4b | 1400 | |
4f8b4fd9 | 1401 | @item -fno-optional-diags |
cd3bb277 | 1402 | @opindex fno-optional-diags |
4f8b4fd9 | 1403 | Disable diagnostics that the standard says a compiler does not need to |
aee96fe9 | 1404 | issue. Currently, the only such diagnostic issued by G++ is the one for |
bba975d4 | 1405 | a name having multiple meanings within a class. |
4f8b4fd9 | 1406 | |
8c7707b0 | 1407 | @item -fpermissive |
cd3bb277 | 1408 | @opindex fpermissive |
8c7707b0 | 1409 | Downgrade messages about nonconformant code from errors to warnings. By |
aee96fe9 | 1410 | default, G++ effectively sets @option{-pedantic-errors} without |
630d3d5a | 1411 | @option{-pedantic}; this option reverses that. This behavior and this |
161d7b59 | 1412 | option are superseded by @option{-pedantic}, which works as it does for GNU C@. |
8c7707b0 | 1413 | |
8c81598d | 1414 | @item -frepo |
cd3bb277 | 1415 | @opindex frepo |
8c81598d | 1416 | Enable automatic template instantiation. This option also implies |
630d3d5a | 1417 | @option{-fno-implicit-templates}. @xref{Template Instantiation}, for more |
8c81598d JM |
1418 | information. |
1419 | ||
8c7707b0 | 1420 | @item -fno-rtti |
cd3bb277 | 1421 | @opindex fno-rtti |
a7fbfcf9 JM |
1422 | Disable generation of information about every class with virtual |
1423 | functions for use by the C++ runtime type identification features | |
1424 | (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts | |
1425 | of the language, you can save some space by using this flag. Note that | |
1426 | exception handling uses the same information, but it will generate it as | |
1427 | needed. | |
8c7707b0 | 1428 | |
fcca588c | 1429 | @item -fstats |
cd3bb277 | 1430 | @opindex fstats |
fcca588c MM |
1431 | Emit statistics about front-end processing at the end of the compilation. |
1432 | This information is generally only useful to the G++ development team. | |
1433 | ||
1dc5fc4b | 1434 | @item -ftemplate-depth-@var{n} |
cd3bb277 | 1435 | @opindex ftemplate-depth |
1dc5fc4b JM |
1436 | Set the maximum instantiation depth for template classes to @var{n}. |
1437 | A limit on the template instantiation depth is needed to detect | |
767094dd | 1438 | endless recursions during template class instantiation. ANSI/ISO C++ |
1dc5fc4b JM |
1439 | conforming programs must not rely on a maximum depth greater than 17. |
1440 | ||
fc693822 | 1441 | @item -fuse-cxa-atexit |
cd3bb277 | 1442 | @opindex fuse-cxa-atexit |
fc693822 MM |
1443 | Register destructors for objects with static storage duration with the |
1444 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
1445 | This option is required for fully standards-compliant handling of static | |
1446 | destructors, but will only work if your C library supports | |
1447 | @code{__cxa_atexit}. | |
1448 | ||
90ecce3e | 1449 | @item -fvtable-gc |
cd3bb277 | 1450 | @opindex fvtable-gc |
90ecce3e JM |
1451 | Emit special relocations for vtables and virtual function references |
1452 | so that the linker can identify unused virtual functions and zero out | |
1453 | vtable slots that refer to them. This is most useful with | |
630d3d5a | 1454 | @option{-ffunction-sections} and @option{-Wl,--gc-sections}, in order to |
90ecce3e | 1455 | also discard the functions themselves. |
f5a1b0d2 | 1456 | |
90ecce3e | 1457 | This optimization requires GNU as and GNU ld. Not all systems support |
630d3d5a | 1458 | this option. @option{-Wl,--gc-sections} is ignored without @option{-static}. |
861bb6c1 | 1459 | |
02f52e19 | 1460 | @item -fno-weak |
cd3bb277 | 1461 | @opindex fno-weak |
90ecce3e | 1462 | Do not use weak symbol support, even if it is provided by the linker. |
fcca588c MM |
1463 | By default, G++ will use weak symbols if they are available. This |
1464 | option exists only for testing, and should not be used by end-users; | |
1465 | it will result in inferior code and has no benefits. This option may | |
1466 | be removed in a future release of G++. | |
1467 | ||
74291a4b | 1468 | @item -nostdinc++ |
cd3bb277 | 1469 | @opindex nostdinc++ |
74291a4b MM |
1470 | Do not search for header files in the standard directories specific to |
1471 | C++, but do still search the other standard directories. (This option | |
e5e809f4 | 1472 | is used when building the C++ library.) |
74291a4b MM |
1473 | @end table |
1474 | ||
1475 | In addition, these optimization, warning, and code generation options | |
1476 | have meanings only for C++ programs: | |
1477 | ||
2642624b | 1478 | @table @gcctabopt |
74291a4b | 1479 | @item -fno-default-inline |
cd3bb277 | 1480 | @opindex fno-default-inline |
74291a4b | 1481 | Do not assume @samp{inline} for functions defined inside a class scope. |
1dc5fc4b JM |
1482 | @xref{Optimize Options,,Options That Control Optimization}. Note that these |
1483 | functions will have linkage like inline functions; they just won't be | |
1484 | inlined by default. | |
74291a4b | 1485 | |
aee96fe9 | 1486 | @item -Wctor-dtor-privacy @r{(C++ only)} |
cd3bb277 | 1487 | @opindex Wctor-dtor-privacy |
bba975d4 JM |
1488 | Warn when a class seems unusable, because all the constructors or |
1489 | destructors in a class are private and the class has no friends or | |
1490 | public static member functions. | |
1491 | ||
aee96fe9 | 1492 | @item -Wnon-virtual-dtor @r{(C++ only)} |
cd3bb277 | 1493 | @opindex Wnon-virtual-dtor |
bba975d4 JM |
1494 | Warn when a class declares a non-virtual destructor that should probably |
1495 | be virtual, because it looks like the class will be used polymorphically. | |
1496 | ||
aee96fe9 | 1497 | @item -Wreorder @r{(C++ only)} |
cd3bb277 | 1498 | @opindex Wreorder |
bba975d4 JM |
1499 | @cindex reordering, warning |
1500 | @cindex warning for reordering of member initializers | |
1501 | Warn when the order of member initializers given in the code does not | |
1502 | match the order in which they must be executed. For instance: | |
1503 | ||
1504 | @smallexample | |
1505 | struct A @{ | |
1506 | int i; | |
1507 | int j; | |
1508 | A(): j (0), i (1) @{ @} | |
1509 | @}; | |
1510 | @end smallexample | |
1511 | ||
1512 | Here the compiler will warn that the member initializers for @samp{i} | |
1513 | and @samp{j} will be rearranged to match the declaration order of the | |
1514 | members. | |
1515 | @end table | |
1516 | ||
630d3d5a | 1517 | The following @option{-W@dots{}} options are not affected by @option{-Wall}. |
bba975d4 | 1518 | |
2642624b | 1519 | @table @gcctabopt |
aee96fe9 | 1520 | @item -Weffc++ @r{(C++ only)} |
cd3bb277 | 1521 | @opindex Weffc++ |
bba975d4 JM |
1522 | Warn about violations of various style guidelines from Scott Meyers' |
1523 | @cite{Effective C++} books. If you use this option, you should be aware | |
1524 | that the standard library headers do not obey all of these guidelines; | |
1525 | you can use @samp{grep -v} to filter out those warnings. | |
1526 | ||
aee96fe9 | 1527 | @item -Wno-deprecated @r{(C++ only)} |
cd3bb277 | 1528 | @opindex Wno-deprecated |
767094dd | 1529 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
2de45c06 | 1530 | |
aee96fe9 | 1531 | @item -Wno-non-template-friend @r{(C++ only)} |
cd3bb277 | 1532 | @opindex Wno-non-template-friend |
bba975d4 | 1533 | Disable warnings when non-templatized friend functions are declared |
767094dd | 1534 | within a template. With the advent of explicit template specification |
aee96fe9 | 1535 | support in G++, if the name of the friend is an unqualified-id (i.e., |
bba975d4 | 1536 | @samp{friend foo(int)}), the C++ language specification demands that the |
767094dd | 1537 | friend declare or define an ordinary, nontemplate function. (Section |
aee96fe9 | 1538 | 14.5.3). Before G++ implemented explicit specification, unqualified-ids |
bba975d4 | 1539 | could be interpreted as a particular specialization of a templatized |
767094dd | 1540 | function. Because this non-conforming behavior is no longer the default |
aee96fe9 | 1541 | behavior for G++, @option{-Wnon-template-friend} allows the compiler to |
bba975d4 | 1542 | check existing code for potential trouble spots, and is on by default. |
2228d450 | 1543 | This new compiler behavior can be turned off with |
630d3d5a | 1544 | @option{-Wno-non-template-friend} which keeps the conformant compiler code |
2228d450 | 1545 | but disables the helpful warning. |
bba975d4 | 1546 | |
aee96fe9 | 1547 | @item -Wold-style-cast @r{(C++ only)} |
cd3bb277 | 1548 | @opindex Wold-style-cast |
bba975d4 JM |
1549 | Warn if an old-style (C-style) cast is used within a C++ program. The |
1550 | new-style casts (@samp{static_cast}, @samp{reinterpret_cast}, and | |
90ecce3e JM |
1551 | @samp{const_cast}) are less vulnerable to unintended effects, and much |
1552 | easier to grep for. | |
bba975d4 | 1553 | |
aee96fe9 | 1554 | @item -Woverloaded-virtual @r{(C++ only)} |
cd3bb277 | 1555 | @opindex Woverloaded-virtual |
bba975d4 JM |
1556 | @cindex overloaded virtual fn, warning |
1557 | @cindex warning for overloaded virtual fn | |
3747f3dc MM |
1558 | Warn when a function declaration hides virtual functions from a |
1559 | base class. For example, in: | |
1560 | ||
1561 | @smallexample | |
1562 | struct A @{ | |
1563 | virtual void f(); | |
1564 | @}; | |
1565 | ||
1566 | struct B: public A @{ | |
1567 | void f(int); | |
1568 | @}; | |
1569 | @end smallexample | |
1570 | ||
1571 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
1572 | like this: | |
1573 | ||
1574 | @smallexample | |
1575 | B* b; | |
1576 | b->f(); | |
1577 | @end smallexample | |
1578 | ||
1579 | will fail to compile. | |
bba975d4 | 1580 | |
aee96fe9 | 1581 | @item -Wno-pmf-conversions @r{(C++ only)} |
cd3bb277 | 1582 | @opindex Wno-pmf-conversions |
bba975d4 JM |
1583 | Disable the diagnostic for converting a bound pointer to member function |
1584 | to a plain pointer. | |
1585 | ||
aee96fe9 | 1586 | @item -Wsign-promo @r{(C++ only)} |
cd3bb277 | 1587 | @opindex Wsign-promo |
bba975d4 JM |
1588 | Warn when overload resolution chooses a promotion from unsigned or |
1589 | enumeral type to a signed type over a conversion to an unsigned type of | |
aee96fe9 | 1590 | the same size. Previous versions of G++ would try to preserve |
bba975d4 JM |
1591 | unsignedness, but the standard mandates the current behavior. |
1592 | ||
aee96fe9 | 1593 | @item -Wsynth @r{(C++ only)} |
cd3bb277 | 1594 | @opindex Wsynth |
bba975d4 JM |
1595 | @cindex warning for synthesized methods |
1596 | @cindex synthesized methods, warning | |
aee96fe9 | 1597 | Warn when G++'s synthesis behavior does not match that of cfront. For |
bba975d4 JM |
1598 | instance: |
1599 | ||
1600 | @smallexample | |
1601 | struct A @{ | |
1602 | operator int (); | |
1603 | A& operator = (int); | |
1604 | @}; | |
1605 | ||
1606 | main () | |
1607 | @{ | |
1608 | A a,b; | |
1609 | a = b; | |
1610 | @} | |
1611 | @end smallexample | |
74291a4b | 1612 | |
aee96fe9 | 1613 | In this example, G++ will synthesize a default @samp{A& operator = |
bba975d4 | 1614 | (const A&);}, while cfront will use the user-defined @samp{operator =}. |
74291a4b MM |
1615 | @end table |
1616 | ||
60de6385 SS |
1617 | @node Objective-C Dialect Options |
1618 | @section Options Controlling Objective-C Dialect | |
1619 | ||
1620 | @cindex compiler options, Objective-C | |
1621 | @cindex Objective-C options, command line | |
1622 | @cindex options, Objective-C | |
1623 | This section describes the command-line options that are only meaningful | |
1624 | for Objective-C programs; but you can also use most of the GNU compiler | |
1625 | options regardless of what language your program is in. For example, | |
1626 | you might compile a file @code{some_class.m} like this: | |
1627 | ||
1628 | @example | |
1629 | gcc -g -fgnu-runtime -O -c some_class.m | |
1630 | @end example | |
1631 | ||
1632 | @noindent | |
630d3d5a | 1633 | In this example, only @option{-fgnu-runtime} is an option meant only for |
60de6385 | 1634 | Objective-C programs; you can use the other options with any language |
161d7b59 | 1635 | supported by GCC@. |
60de6385 SS |
1636 | |
1637 | Here is a list of options that are @emph{only} for compiling Objective-C | |
1638 | programs: | |
1639 | ||
1640 | @table @gcctabopt | |
630d3d5a | 1641 | @item -fconstant-string-class=@var{class-name} |
cd3bb277 | 1642 | @opindex fconstant-string-class |
630d3d5a | 1643 | Use @var{class-name} as the name of the class to instantiate for each |
695ac33f | 1644 | literal string specified with the syntax @code{@@"@dots{}"}. The default |
60de6385 SS |
1645 | class name is @code{NXConstantString}. |
1646 | ||
1647 | @item -fgnu-runtime | |
cd3bb277 | 1648 | @opindex fgnu-runtime |
60de6385 SS |
1649 | Generate object code compatible with the standard GNU Objective-C |
1650 | runtime. This is the default for most types of systems. | |
1651 | ||
1652 | @item -fnext-runtime | |
cd3bb277 | 1653 | @opindex fnext-runtime |
60de6385 | 1654 | Generate output compatible with the NeXT runtime. This is the default |
161d7b59 | 1655 | for NeXT-based systems, including Darwin and Mac OS X@. |
60de6385 SS |
1656 | |
1657 | @item -gen-decls | |
cd3bb277 | 1658 | @opindex gen-decls |
60de6385 SS |
1659 | Dump interface declarations for all classes seen in the source file to a |
1660 | file named @file{@var{sourcename}.decl}. | |
1661 | ||
1662 | @item -Wno-protocol | |
cd3bb277 | 1663 | @opindex Wno-protocol |
60de6385 SS |
1664 | Do not warn if methods required by a protocol are not implemented |
1665 | in the class adopting it. | |
1666 | ||
1667 | @item -Wselector | |
cd3bb277 | 1668 | @opindex Wselector |
60de6385 SS |
1669 | Warn if a selector has multiple methods of different types defined. |
1670 | ||
1671 | @c not documented because only avail via -Wp | |
1672 | @c @item -print-objc-runtime-info | |
1673 | ||
1674 | @end table | |
1675 | ||
764dbbf2 GDR |
1676 | @node Language Independent Options |
1677 | @section Options to Control Diagnostic Messages Formatting | |
1678 | @cindex options to control diagnostics formatting | |
1679 | @cindex diagnostic messages | |
1680 | @cindex message formatting | |
1681 | ||
b192711e | 1682 | Traditionally, diagnostic messages have been formatted irrespective of |
e979f9e8 | 1683 | the output device's aspect (e.g.@: its width, @dots{}). The options described |
764dbbf2 | 1684 | below can be used to control the diagnostic messages formatting |
e979f9e8 | 1685 | algorithm, e.g.@: how many characters per line, how often source location |
6c0a4eab | 1686 | information should be reported. Right now, only the C++ front end can |
764dbbf2 | 1687 | honor these options. However it is expected, in the near future, that |
6c0a4eab | 1688 | the remaining front ends would be able to digest them correctly. |
764dbbf2 | 1689 | |
2642624b | 1690 | @table @gcctabopt |
764dbbf2 | 1691 | @item -fmessage-length=@var{n} |
cd3bb277 | 1692 | @opindex fmessage-length |
764dbbf2 | 1693 | Try to format error messages so that they fit on lines of about @var{n} |
aee96fe9 | 1694 | characters. The default is 72 characters for @command{g++} and 0 for the rest of |
161d7b59 | 1695 | the front ends supported by GCC@. If @var{n} is zero, then no |
02f52e19 | 1696 | line-wrapping will be done; each error message will appear on a single |
764dbbf2 GDR |
1697 | line. |
1698 | ||
cd3bb277 | 1699 | @opindex fdiagnostics-show-location |
764dbbf2 | 1700 | @item -fdiagnostics-show-location=once |
b192711e | 1701 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
764dbbf2 GDR |
1702 | reporter to emit @emph{once} source location information; that is, in |
1703 | case the message is too long to fit on a single physical line and has to | |
1704 | be wrapped, the source location won't be emitted (as prefix) again, | |
1705 | over and over, in subsequent continuation lines. This is the default | |
02f52e19 | 1706 | behaviour. |
764dbbf2 GDR |
1707 | |
1708 | @item -fdiagnostics-show-location=every-line | |
1709 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
1710 | messages reporter to emit the same source location information (as | |
1711 | prefix) for physical lines that result from the process of breaking a | |
b192711e | 1712 | a message which is too long to fit on a single line. |
764dbbf2 GDR |
1713 | |
1714 | @end table | |
1715 | ||
74291a4b MM |
1716 | @node Warning Options |
1717 | @section Options to Request or Suppress Warnings | |
1718 | @cindex options to control warnings | |
1719 | @cindex warning messages | |
1720 | @cindex messages, warning | |
1721 | @cindex suppressing warnings | |
1722 | ||
1723 | Warnings are diagnostic messages that report constructions which | |
1724 | are not inherently erroneous but which are risky or suggest there | |
1725 | may have been an error. | |
1726 | ||
1727 | You can request many specific warnings with options beginning @samp{-W}, | |
630d3d5a | 1728 | for example @option{-Wimplicit} to request warnings on implicit |
74291a4b MM |
1729 | declarations. Each of these specific warning options also has a |
1730 | negative form beginning @samp{-Wno-} to turn off warnings; | |
630d3d5a | 1731 | for example, @option{-Wno-implicit}. This manual lists only one of the |
74291a4b MM |
1732 | two forms, whichever is not the default. |
1733 | ||
0c2d1a2a | 1734 | These options control the amount and kinds of warnings produced by GCC: |
74291a4b | 1735 | |
2642624b | 1736 | @table @gcctabopt |
74291a4b MM |
1737 | @cindex syntax checking |
1738 | @item -fsyntax-only | |
cd3bb277 | 1739 | @opindex fsyntax-only |
74291a4b MM |
1740 | Check the code for syntax errors, but don't do anything beyond that. |
1741 | ||
1742 | @item -pedantic | |
cd3bb277 | 1743 | @opindex pedantic |
074e95e3 JM |
1744 | Issue all the warnings demanded by strict ISO C and ISO C++; |
1745 | reject all programs that use forbidden extensions, and some other | |
1746 | programs that do not follow ISO C and ISO C++. For ISO C, follows the | |
630d3d5a | 1747 | version of the ISO C standard specified by any @option{-std} option used. |
74291a4b | 1748 | |
074e95e3 | 1749 | Valid ISO C and ISO C++ programs should compile properly with or without |
5490d604 | 1750 | this option (though a rare few will require @option{-ansi} or a |
161d7b59 | 1751 | @option{-std} option specifying the required version of ISO C)@. However, |
b1d16193 JL |
1752 | without this option, certain GNU extensions and traditional C and C++ |
1753 | features are supported as well. With this option, they are rejected. | |
74291a4b | 1754 | |
630d3d5a | 1755 | @option{-pedantic} does not cause warning messages for use of the |
74291a4b MM |
1756 | alternate keywords whose names begin and end with @samp{__}. Pedantic |
1757 | warnings are also disabled in the expression that follows | |
1758 | @code{__extension__}. However, only system header files should use | |
1759 | these escape routes; application programs should avoid them. | |
1760 | @xref{Alternate Keywords}. | |
1761 | ||
630d3d5a | 1762 | Some users try to use @option{-pedantic} to check programs for strict ISO |
74291a4b | 1763 | C conformance. They soon find that it does not do quite what they want: |
c1030c7c | 1764 | it finds some non-ISO practices, but not all---only those for which |
074e95e3 JM |
1765 | ISO C @emph{requires} a diagnostic, and some others for which |
1766 | diagnostics have been added. | |
74291a4b | 1767 | |
074e95e3 | 1768 | A feature to report any failure to conform to ISO C might be useful in |
74291a4b | 1769 | some instances, but would require considerable additional work and would |
630d3d5a | 1770 | be quite different from @option{-pedantic}. We don't have plans to |
892d0a6d | 1771 | support such a feature in the near future. |
74291a4b | 1772 | |
91ea548a JM |
1773 | Where the standard specified with @option{-std} represents a GNU |
1774 | extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a | |
1775 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
1776 | extended dialect is based. Warnings from @option{-pedantic} are given | |
1777 | where they are required by the base standard. (It would not make sense | |
1778 | for such warnings to be given only for features not in the specified GNU | |
1779 | C dialect, since by definition the GNU dialects of C include all | |
1780 | features the compiler supports with the given option, and there would be | |
1781 | nothing to warn about.) | |
1782 | ||
74291a4b | 1783 | @item -pedantic-errors |
cd3bb277 | 1784 | @opindex pedantic-errors |
630d3d5a | 1785 | Like @option{-pedantic}, except that errors are produced rather than |
74291a4b MM |
1786 | warnings. |
1787 | ||
1788 | @item -w | |
cd3bb277 | 1789 | @opindex w |
74291a4b MM |
1790 | Inhibit all warning messages. |
1791 | ||
1792 | @item -Wno-import | |
cd3bb277 | 1793 | @opindex Wno-import |
74291a4b MM |
1794 | Inhibit warning messages about the use of @samp{#import}. |
1795 | ||
1796 | @item -Wchar-subscripts | |
cd3bb277 | 1797 | @opindex Wchar-subscripts |
74291a4b MM |
1798 | Warn if an array subscript has type @code{char}. This is a common cause |
1799 | of error, as programmers often forget that this type is signed on some | |
1800 | machines. | |
1801 | ||
1802 | @item -Wcomment | |
cd3bb277 | 1803 | @opindex Wcomment |
74291a4b MM |
1804 | Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*} |
1805 | comment, or whenever a Backslash-Newline appears in a @samp{//} comment. | |
1806 | ||
1807 | @item -Wformat | |
cd3bb277 | 1808 | @opindex Wformat |
74291a4b MM |
1809 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
1810 | the arguments supplied have types appropriate to the format string | |
26f6672d JM |
1811 | specified, and that the conversions specified in the format string make |
1812 | sense. This includes standard functions, and others specified by format | |
1813 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
1814 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
1815 | not in the C standard) families. | |
74291a4b | 1816 | |
8308e0b7 JM |
1817 | The formats are checked against the format features supported by GNU |
1818 | libc version 2.2. These include all ISO C89 and C99 features, as well | |
1819 | as features from the Single Unix Specification and some BSD and GNU | |
1820 | extensions. Other library implementations may not support all these | |
1821 | features; GCC does not support warning about features that go beyond a | |
630d3d5a JM |
1822 | particular library's limitations. However, if @option{-pedantic} is used |
1823 | with @option{-Wformat}, warnings will be given about format features not | |
26f6672d JM |
1824 | in the selected standard version (but not for @code{strfmon} formats, |
1825 | since those are not in any version of the C standard). @xref{C Dialect | |
1826 | Options,,Options Controlling C Dialect}. | |
8308e0b7 | 1827 | |
630d3d5a JM |
1828 | @option{-Wformat} is included in @option{-Wall}. For more control over some |
1829 | aspects of format checking, the options @option{-Wno-format-y2k}, | |
1830 | @option{-Wno-format-extra-args}, @option{-Wformat-nonliteral}, | |
1831 | @option{-Wformat-security} and @option{-Wformat=2} are available, but are | |
1832 | not included in @option{-Wall}. | |
4d808927 JM |
1833 | |
1834 | @item -Wno-format-y2k | |
cd3bb277 | 1835 | @opindex Wno-format-y2k |
630d3d5a | 1836 | If @option{-Wformat} is specified, do not warn about @code{strftime} |
4d808927 JM |
1837 | formats which may yield only a two-digit year. |
1838 | ||
1839 | @item -Wno-format-extra-args | |
cd3bb277 | 1840 | @opindex Wno-format-extra-args |
630d3d5a | 1841 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
4d808927 JM |
1842 | @code{printf} or @code{scanf} format function. The C standard specifies |
1843 | that such arguments are ignored. | |
1844 | ||
1845 | @item -Wformat-nonliteral | |
cd3bb277 | 1846 | @opindex Wformat-nonliteral |
630d3d5a | 1847 | If @option{-Wformat} is specified, also warn if the format string is not a |
4d808927 JM |
1848 | string literal and so cannot be checked, unless the format function |
1849 | takes its format arguments as a @code{va_list}. | |
1850 | ||
c907e684 | 1851 | @item -Wformat-security |
cd3bb277 | 1852 | @opindex Wformat-security |
630d3d5a | 1853 | If @option{-Wformat} is specified, also warn about uses of format |
c907e684 JM |
1854 | functions that represent possible security problems. At present, this |
1855 | warns about calls to @code{printf} and @code{scanf} functions where the | |
1856 | format string is not a string literal and there are no format arguments, | |
1857 | as in @code{printf (foo);}. This may be a security hole if the format | |
1858 | string came from untrusted input and contains @samp{%n}. (This is | |
630d3d5a JM |
1859 | currently a subset of what @option{-Wformat-nonliteral} warns about, but |
1860 | in future warnings may be added to @option{-Wformat-security} that are not | |
1861 | included in @option{-Wformat-nonliteral}.) | |
c907e684 | 1862 | |
4d808927 | 1863 | @item -Wformat=2 |
cd3bb277 | 1864 | @opindex Wformat=2 |
630d3d5a JM |
1865 | Enable @option{-Wformat} plus format checks not included in |
1866 | @option{-Wformat}. Currently equivalent to @samp{-Wformat | |
c907e684 | 1867 | -Wformat-nonliteral -Wformat-security}. |
4d808927 | 1868 | |
e9a25f70 | 1869 | @item -Wimplicit-int |
cd3bb277 | 1870 | @opindex Wimplicit-int |
e9a25f70 JL |
1871 | Warn when a declaration does not specify a type. |
1872 | ||
f5963e61 JL |
1873 | @item -Wimplicit-function-declaration |
1874 | @itemx -Werror-implicit-function-declaration | |
cd3bb277 JM |
1875 | @opindex Wimplicit-function-declaration |
1876 | @opindex Werror-implicit-function-declaration | |
f5963e61 JL |
1877 | Give a warning (or error) whenever a function is used before being |
1878 | declared. | |
e9a25f70 | 1879 | |
74291a4b | 1880 | @item -Wimplicit |
cd3bb277 | 1881 | @opindex Wimplicit |
630d3d5a | 1882 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
861bb6c1 JL |
1883 | |
1884 | @item -Wmain | |
cd3bb277 | 1885 | @opindex Wmain |
861bb6c1 JL |
1886 | Warn if the type of @samp{main} is suspicious. @samp{main} should be a |
1887 | function with external linkage, returning int, taking either zero | |
1888 | arguments, two, or three arguments of appropriate types. | |
4a870dba | 1889 | |
1f0c3120 | 1890 | @item -Wmissing-braces |
cd3bb277 | 1891 | @opindex Wmissing-braces |
1f0c3120 JM |
1892 | Warn if an aggregate or union initializer is not fully bracketed. In |
1893 | the following example, the initializer for @samp{a} is not fully | |
1894 | bracketed, but that for @samp{b} is fully bracketed. | |
1895 | ||
1896 | @smallexample | |
1897 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
1898 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
1899 | @end smallexample | |
1900 | ||
4a870dba | 1901 | @item -Wmultichar |
cd3bb277 | 1902 | @opindex Wmultichar |
4a870dba JM |
1903 | Warn if a multicharacter constant (@samp{'FOOF'}) is used. Usually they |
1904 | indicate a typo in the user's code, as they have implementation-defined | |
1905 | values, and should not be used in portable code. | |
3c12fcc2 | 1906 | |
74291a4b | 1907 | @item -Wparentheses |
cd3bb277 | 1908 | @opindex Wparentheses |
74291a4b MM |
1909 | Warn if parentheses are omitted in certain contexts, such |
1910 | as when there is an assignment in a context where a truth value | |
1911 | is expected, or when operators are nested whose precedence people | |
1912 | often get confused about. | |
1913 | ||
e9a25f70 JL |
1914 | Also warn about constructions where there may be confusion to which |
1915 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
1916 | such a case: | |
1917 | ||
1918 | @smallexample | |
aee96fe9 | 1919 | @group |
e9a25f70 JL |
1920 | @{ |
1921 | if (a) | |
1922 | if (b) | |
1923 | foo (); | |
1924 | else | |
1925 | bar (); | |
1926 | @} | |
aee96fe9 | 1927 | @end group |
e9a25f70 JL |
1928 | @end smallexample |
1929 | ||
1930 | In C, every @code{else} branch belongs to the innermost possible @code{if} | |
1931 | statement, which in this example is @code{if (b)}. This is often not | |
1932 | what the programmer expected, as illustrated in the above example by | |
1933 | indentation the programmer chose. When there is the potential for this | |
f0523f02 | 1934 | confusion, GCC will issue a warning when this flag is specified. |
e9a25f70 JL |
1935 | To eliminate the warning, add explicit braces around the innermost |
1936 | @code{if} statement so there is no way the @code{else} could belong to | |
1937 | the enclosing @code{if}. The resulting code would look like this: | |
1938 | ||
1939 | @smallexample | |
aee96fe9 | 1940 | @group |
e9a25f70 JL |
1941 | @{ |
1942 | if (a) | |
1943 | @{ | |
1944 | if (b) | |
1945 | foo (); | |
1946 | else | |
1947 | bar (); | |
1948 | @} | |
1949 | @} | |
aee96fe9 | 1950 | @end group |
e9a25f70 JL |
1951 | @end smallexample |
1952 | ||
bb58bec5 | 1953 | @item -Wsequence-point |
cd3bb277 | 1954 | @opindex Wsequence-point |
bb58bec5 JM |
1955 | Warn about code that may have undefined semantics because of violations |
1956 | of sequence point rules in the C standard. | |
1957 | ||
1958 | The C standard defines the order in which expressions in a C program are | |
1959 | evaluated in terms of @dfn{sequence points}, which represent a partial | |
1960 | ordering between the execution of parts of the program: those executed | |
1961 | before the sequence point, and those executed after it. These occur | |
1962 | after the evaluation of a full expression (one which is not part of a | |
1963 | larger expression), after the evaluation of the first operand of a | |
1964 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
1965 | function is called (but after the evaluation of its arguments and the | |
1966 | expression denoting the called function), and in certain other places. | |
1967 | Other than as expressed by the sequence point rules, the order of | |
1968 | evaluation of subexpressions of an expression is not specified. All | |
1969 | these rules describe only a partial order rather than a total order, | |
1970 | since, for example, if two functions are called within one expression | |
1971 | with no sequence point between them, the order in which the functions | |
1972 | are called is not specified. However, the standards committee have | |
1973 | ruled that function calls do not overlap. | |
1974 | ||
1975 | It is not specified when between sequence points modifications to the | |
1976 | values of objects take effect. Programs whose behavior depends on this | |
1977 | have undefined behavior; the C standard specifies that ``Between the | |
1978 | previous and next sequence point an object shall have its stored value | |
1979 | modified at most once by the evaluation of an expression. Furthermore, | |
1980 | the prior value shall be read only to determine the value to be | |
1981 | stored.''. If a program breaks these rules, the results on any | |
1982 | particular implementation are entirely unpredictable. | |
1983 | ||
1984 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
1985 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
1986 | diagnosed by this option, and it may give an occasional false positive | |
1987 | result, but in general it has been found fairly effective at detecting | |
1988 | this sort of problem in programs. | |
1989 | ||
1990 | The present implementation of this option only works for C programs. A | |
1991 | future implementation may also work for C++ programs. | |
1992 | ||
1993 | There is some controversy over the precise meaning of the sequence point | |
c5122d75 JM |
1994 | rules in subtle cases. Links to papers with alternative formal definitions |
1995 | and other related discussions may be found on our readings page | |
1996 | @w{@uref{http://gcc.gnu.org/readings.html}}. | |
bb58bec5 | 1997 | |
74291a4b | 1998 | @item -Wreturn-type |
cd3bb277 | 1999 | @opindex Wreturn-type |
32c4c36c ML |
2000 | Warn whenever a function is defined with a return-type that defaults to |
2001 | @code{int}. Also warn about any @code{return} statement with no | |
02f52e19 | 2002 | return-value in a function whose return-type is not @code{void}. |
32c4c36c ML |
2003 | |
2004 | For C++, a function without return type always produces a diagnostic | |
767094dd | 2005 | message, even when @option{-Wno-return-type} is specified. The only |
32c4c36c | 2006 | exceptions are @samp{main} and functions defined in system headers. |
74291a4b MM |
2007 | |
2008 | @item -Wswitch | |
cd3bb277 | 2009 | @opindex Wswitch |
74291a4b MM |
2010 | Warn whenever a @code{switch} statement has an index of enumeral type |
2011 | and lacks a @code{case} for one or more of the named codes of that | |
2012 | enumeration. (The presence of a @code{default} label prevents this | |
2013 | warning.) @code{case} labels outside the enumeration range also | |
2014 | provoke warnings when this option is used. | |
2015 | ||
2016 | @item -Wtrigraphs | |
cd3bb277 | 2017 | @opindex Wtrigraphs |
f2ecb02d JM |
2018 | Warn if any trigraphs are encountered that might change the meaning of |
2019 | the program (trigraphs within comments are not warned about). | |
74291a4b | 2020 | |
078721e1 | 2021 | @item -Wunused-function |
cd3bb277 | 2022 | @opindex Wunused-function |
078721e1 AC |
2023 | Warn whenever a static function is declared but not defined or a |
2024 | non\-inline static function is unused. | |
74291a4b | 2025 | |
078721e1 | 2026 | @item -Wunused-label |
cd3bb277 | 2027 | @opindex Wunused-label |
078721e1 AC |
2028 | Warn whenever a label is declared but not used. |
2029 | ||
2030 | To suppress this warning use the @samp{unused} attribute | |
2031 | (@pxref{Variable Attributes}). | |
2032 | ||
2033 | @item -Wunused-parameter | |
cd3bb277 | 2034 | @opindex Wunused-parameter |
078721e1 AC |
2035 | Warn whenever a function parameter is unused aside from its declaration. |
2036 | ||
2037 | To suppress this warning use the @samp{unused} attribute | |
2038 | (@pxref{Variable Attributes}). | |
956d6950 | 2039 | |
078721e1 | 2040 | @item -Wunused-variable |
cd3bb277 | 2041 | @opindex Wunused-variable |
078721e1 AC |
2042 | Warn whenever a local variable or non-constant static variable is unused |
2043 | aside from its declaration | |
2044 | ||
2045 | To suppress this warning use the @samp{unused} attribute | |
74291a4b MM |
2046 | (@pxref{Variable Attributes}). |
2047 | ||
078721e1 | 2048 | @item -Wunused-value |
cd3bb277 | 2049 | @opindex Wunused-value |
078721e1 AC |
2050 | Warn whenever a statement computes a result that is explicitly not used. |
2051 | ||
2052 | To suppress this warning cast the expression to @samp{void}. | |
2053 | ||
2054 | @item -Wunused | |
cd3bb277 | 2055 | @opindex Wunused |
630d3d5a | 2056 | All all the above @option{-Wunused} options combined. |
078721e1 AC |
2057 | |
2058 | In order to get a warning about an unused function parameter, you must | |
b192711e | 2059 | either specify @samp{-W -Wunused} or separately specify |
630d3d5a | 2060 | @option{-Wunused-parameter}. |
078721e1 | 2061 | |
74291a4b | 2062 | @item -Wuninitialized |
cd3bb277 | 2063 | @opindex Wuninitialized |
c5c76735 JL |
2064 | Warn if an automatic variable is used without first being initialized or |
2065 | if a variable may be clobbered by a @code{setjmp} call. | |
74291a4b MM |
2066 | |
2067 | These warnings are possible only in optimizing compilation, | |
2068 | because they require data flow information that is computed only | |
630d3d5a | 2069 | when optimizing. If you don't specify @option{-O}, you simply won't |
74291a4b MM |
2070 | get these warnings. |
2071 | ||
2072 | These warnings occur only for variables that are candidates for | |
2073 | register allocation. Therefore, they do not occur for a variable that | |
2074 | is declared @code{volatile}, or whose address is taken, or whose size | |
2075 | is other than 1, 2, 4 or 8 bytes. Also, they do not occur for | |
2076 | structures, unions or arrays, even when they are in registers. | |
2077 | ||
2078 | Note that there may be no warning about a variable that is used only | |
2079 | to compute a value that itself is never used, because such | |
2080 | computations may be deleted by data flow analysis before the warnings | |
2081 | are printed. | |
2082 | ||
0c2d1a2a | 2083 | These warnings are made optional because GCC is not smart |
74291a4b MM |
2084 | enough to see all the reasons why the code might be correct |
2085 | despite appearing to have an error. Here is one example of how | |
2086 | this can happen: | |
2087 | ||
2088 | @smallexample | |
aee96fe9 | 2089 | @group |
74291a4b MM |
2090 | @{ |
2091 | int x; | |
2092 | switch (y) | |
2093 | @{ | |
2094 | case 1: x = 1; | |
2095 | break; | |
2096 | case 2: x = 4; | |
2097 | break; | |
2098 | case 3: x = 5; | |
2099 | @} | |
2100 | foo (x); | |
2101 | @} | |
aee96fe9 | 2102 | @end group |
74291a4b MM |
2103 | @end smallexample |
2104 | ||
2105 | @noindent | |
2106 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
0c2d1a2a | 2107 | always initialized, but GCC doesn't know this. Here is |
74291a4b MM |
2108 | another common case: |
2109 | ||
2110 | @smallexample | |
2111 | @{ | |
2112 | int save_y; | |
2113 | if (change_y) save_y = y, y = new_y; | |
2114 | @dots{} | |
2115 | if (change_y) y = save_y; | |
2116 | @} | |
2117 | @end smallexample | |
2118 | ||
2119 | @noindent | |
2120 | This has no bug because @code{save_y} is used only if it is set. | |
2121 | ||
20300b05 | 2122 | @cindex @code{longjmp} warnings |
b192711e | 2123 | This option also warns when a non-volatile automatic variable might be |
c5c76735 JL |
2124 | changed by a call to @code{longjmp}. These warnings as well are possible |
2125 | only in optimizing compilation. | |
20300b05 GK |
2126 | |
2127 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
2128 | where @code{longjmp} will be called; in fact, a signal handler could | |
2129 | call it at any point in the code. As a result, you may get a warning | |
2130 | even when there is in fact no problem because @code{longjmp} cannot | |
2131 | in fact be called at the place which would cause a problem. | |
2132 | ||
74291a4b MM |
2133 | Some spurious warnings can be avoided if you declare all the functions |
2134 | you use that never return as @code{noreturn}. @xref{Function | |
2135 | Attributes}. | |
2136 | ||
aee96fe9 | 2137 | @item -Wreorder @r{(C++ only)} |
cd3bb277 | 2138 | @opindex Wreorder |
c5c76735 JL |
2139 | @cindex reordering, warning |
2140 | @cindex warning for reordering of member initializers | |
2141 | Warn when the order of member initializers given in the code does not | |
2142 | match the order in which they must be executed. For instance: | |
2143 | ||
d300e551 | 2144 | @item -Wunknown-pragmas |
cd3bb277 | 2145 | @opindex Wunknown-pragmas |
d300e551 NC |
2146 | @cindex warning for unknown pragmas |
2147 | @cindex unknown pragmas, warning | |
2148 | @cindex pragmas, warning of unknown | |
2149 | Warn when a #pragma directive is encountered which is not understood by | |
161d7b59 | 2150 | GCC@. If this command line option is used, warnings will even be issued |
d300e551 | 2151 | for unknown pragmas in system header files. This is not the case if |
630d3d5a | 2152 | the warnings were only enabled by the @option{-Wall} command line option. |
d300e551 | 2153 | |
74291a4b | 2154 | @item -Wall |
cd3bb277 | 2155 | @opindex Wall |
74291a4b MM |
2156 | All of the above @samp{-W} options combined. This enables all the |
2157 | warnings about constructions that some users consider questionable, and | |
2158 | that are easy to avoid (or modify to prevent the warning), even in | |
2159 | conjunction with macros. | |
317639a8 BC |
2160 | |
2161 | @item -Wsystem-headers | |
cd3bb277 | 2162 | @opindex Wsystem-headers |
317639a8 BC |
2163 | @cindex warnings from system headers |
2164 | @cindex system headers, warnings from | |
2165 | Print warning messages for constructs found in system header files. | |
2166 | Warnings from system headers are normally suppressed, on the assumption | |
2167 | that they usually do not indicate real problems and would only make the | |
2168 | compiler output harder to read. Using this command line option tells | |
2169 | GCC to emit warnings from system headers as if they occurred in user | |
630d3d5a | 2170 | code. However, note that using @option{-Wall} in conjunction with this |
317639a8 | 2171 | option will @emph{not} warn about unknown pragmas in system |
630d3d5a | 2172 | headers---for that, @option{-Wunknown-pragmas} must also be used. |
74291a4b MM |
2173 | @end table |
2174 | ||
630d3d5a | 2175 | The following @option{-W@dots{}} options are not implied by @option{-Wall}. |
74291a4b MM |
2176 | Some of them warn about constructions that users generally do not |
2177 | consider questionable, but which occasionally you might wish to check | |
2178 | for; others warn about constructions that are necessary or hard to avoid | |
2179 | in some cases, and there is no simple way to modify the code to suppress | |
2180 | the warning. | |
2181 | ||
2642624b | 2182 | @table @gcctabopt |
74291a4b | 2183 | @item -W |
cd3bb277 | 2184 | @opindex W |
74291a4b MM |
2185 | Print extra warning messages for these events: |
2186 | ||
2187 | @itemize @bullet | |
74291a4b MM |
2188 | @item |
2189 | A function can return either with or without a value. (Falling | |
2190 | off the end of the function body is considered returning without | |
2191 | a value.) For example, this function would evoke such a | |
2192 | warning: | |
2193 | ||
2194 | @smallexample | |
2195 | @group | |
2196 | foo (a) | |
2197 | @{ | |
2198 | if (a > 0) | |
2199 | return a; | |
2200 | @} | |
2201 | @end group | |
2202 | @end smallexample | |
2203 | ||
2204 | @item | |
2205 | An expression-statement or the left-hand side of a comma expression | |
2206 | contains no side effects. | |
2207 | To suppress the warning, cast the unused expression to void. | |
2208 | For example, an expression such as @samp{x[i,j]} will cause a warning, | |
2209 | but @samp{x[(void)i,j]} will not. | |
2210 | ||
2211 | @item | |
2212 | An unsigned value is compared against zero with @samp{<} or @samp{<=}. | |
2213 | ||
2214 | @item | |
2215 | A comparison like @samp{x<=y<=z} appears; this is equivalent to | |
2216 | @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from | |
2217 | that of ordinary mathematical notation. | |
2218 | ||
2219 | @item | |
2220 | Storage-class specifiers like @code{static} are not the first things in | |
2221 | a declaration. According to the C Standard, this usage is obsolescent. | |
2222 | ||
e0c9fbb7 JM |
2223 | @item |
2224 | The return type of a function has a type qualifier such as @code{const}. | |
2225 | Such a type qualifier has no effect, since the value returned by a | |
2226 | function is not an lvalue. (But don't warn about the GNU extension of | |
2227 | @code{volatile void} return types. That extension will be warned about | |
630d3d5a | 2228 | if @option{-pedantic} is specified.) |
e0c9fbb7 | 2229 | |
74291a4b | 2230 | @item |
630d3d5a | 2231 | If @option{-Wall} or @option{-Wunused} is also specified, warn about unused |
74291a4b MM |
2232 | arguments. |
2233 | ||
e9a25f70 JL |
2234 | @item |
2235 | A comparison between signed and unsigned values could produce an | |
2236 | incorrect result when the signed value is converted to unsigned. | |
630d3d5a | 2237 | (But don't warn if @option{-Wno-sign-compare} is also specified.) |
e9a25f70 | 2238 | |
74291a4b MM |
2239 | @item |
2240 | An aggregate has a partly bracketed initializer. | |
2241 | For example, the following code would evoke such a warning, | |
2242 | because braces are missing around the initializer for @code{x.h}: | |
2243 | ||
2244 | @smallexample | |
2245 | struct s @{ int f, g; @}; | |
2246 | struct t @{ struct s h; int i; @}; | |
2247 | struct t x = @{ 1, 2, 3 @}; | |
2248 | @end smallexample | |
dbde0d5d BH |
2249 | |
2250 | @item | |
2251 | An aggregate has an initializer which does not initialize all members. | |
2252 | For example, the following code would cause such a warning, because | |
2253 | @code{x.h} would be implicitly initialized to zero: | |
2254 | ||
2255 | @smallexample | |
2256 | struct s @{ int f, g, h; @}; | |
2257 | struct s x = @{ 3, 4 @}; | |
2258 | @end smallexample | |
74291a4b MM |
2259 | @end itemize |
2260 | ||
f793a95e | 2261 | @item -Wfloat-equal |
cd3bb277 | 2262 | @opindex Wfloat-equal |
f793a95e JL |
2263 | Warn if floating point values are used in equality comparisons. |
2264 | ||
488d3985 GK |
2265 | The idea behind this is that sometimes it is convenient (for the |
2266 | programmer) to consider floating-point values as approximations to | |
2267 | infinitely precise real numbers. If you are doing this, then you need | |
2268 | to compute (by analysing the code, or in some other way) the maximum or | |
2269 | likely maximum error that the computation introduces, and allow for it | |
2270 | when performing comparisons (and when producing output, but that's a | |
2271 | different problem). In particular, instead of testing for equality, you | |
2272 | would check to see whether the two values have ranges that overlap; and | |
2273 | this is done with the relational operators, so equality comparisons are | |
2274 | probably mistaken. | |
2275 | ||
aee96fe9 | 2276 | @item -Wtraditional @r{(C only)} |
cd3bb277 | 2277 | @opindex Wtraditional |
74291a4b | 2278 | Warn about certain constructs that behave differently in traditional and |
161d7b59 | 2279 | ISO C@. Also warn about ISO C constructs that have no traditional C |
c8abc684 | 2280 | equivalent, and/or problematic constructs which should be avoided. |
74291a4b MM |
2281 | |
2282 | @itemize @bullet | |
2283 | @item | |
da312b55 NB |
2284 | Macro parameters that appear within string literals in the macro body. |
2285 | In traditional C macro replacement takes place within string literals, | |
161d7b59 | 2286 | but does not in ISO C@. |
da312b55 NB |
2287 | |
2288 | @item | |
2289 | In traditional C, some preprocessor directives did not exist. | |
2290 | Traditional preprocessors would only consider a line to be a directive | |
2291 | if the @samp{#} appeared in column 1 on the line. Therefore | |
630d3d5a | 2292 | @option{-Wtraditional} warns about directives that traditional C |
da312b55 NB |
2293 | understands but would ignore because the @samp{#} does not appear as the |
2294 | first character on the line. It also suggests you hide directives like | |
2295 | @samp{#pragma} not understood by traditional C by indenting them. Some | |
2296 | traditional implementations would not recognise @samp{#elif}, so it | |
2297 | suggests avoiding it altogether. | |
2298 | ||
2299 | @item | |
2300 | A function-like macro that appears without arguments. | |
2301 | ||
2302 | @item | |
2303 | The unary plus operator. | |
2304 | ||
2305 | @item | |
c771326b JM |
2306 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point |
2307 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
da312b55 | 2308 | constants.) Note, these suffixes appear in macros defined in the system |
e979f9e8 | 2309 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. |
c8abc684 KG |
2310 | Use of these macros in user code might normally lead to spurious |
2311 | warnings, however gcc's integrated preprocessor has enough context to | |
2312 | avoid warning in these cases. | |
74291a4b MM |
2313 | |
2314 | @item | |
2315 | A function declared external in one block and then used after the end of | |
2316 | the block. | |
2317 | ||
2318 | @item | |
2319 | A @code{switch} statement has an operand of type @code{long}. | |
db838bb8 KG |
2320 | |
2321 | @item | |
2322 | A non-@code{static} function declaration follows a @code{static} one. | |
2323 | This construct is not accepted by some traditional C compilers. | |
48776cde KG |
2324 | |
2325 | @item | |
c1030c7c | 2326 | The ISO type of an integer constant has a different width or |
48776cde | 2327 | signedness from its traditional type. This warning is only issued if |
e979f9e8 | 2328 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which |
48776cde | 2329 | typically represent bit patterns, are not warned about. |
bb66adca KG |
2330 | |
2331 | @item | |
c1030c7c | 2332 | Usage of ISO string concatenation is detected. |
7f094a94 | 2333 | |
895ea614 KG |
2334 | @item |
2335 | Initialization of automatic aggregates. | |
2336 | ||
2337 | @item | |
2338 | Identifier conflicts with labels. Traditional C lacks a separate | |
2339 | namespace for labels. | |
253b6b82 KG |
2340 | |
2341 | @item | |
2342 | Initialization of unions. If the initializer is zero, the warning is | |
2343 | omitted. This is done under the assumption that the zero initializer in | |
e979f9e8 | 2344 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing |
253b6b82 KG |
2345 | initializer warnings and relies on default initialization to zero in the |
2346 | traditional C case. | |
03829ad2 KG |
2347 | |
2348 | @item | |
3ed56f8a KG |
2349 | Conversions by prototypes between fixed/floating point values and vice |
2350 | versa. The absence of these prototypes when compiling with traditional | |
2351 | C would cause serious problems. This is a subset of the possible | |
630d3d5a | 2352 | conversion warnings, for the full set use @option{-Wconversion}. |
74291a4b MM |
2353 | @end itemize |
2354 | ||
861bb6c1 | 2355 | @item -Wundef |
cd3bb277 | 2356 | @opindex Wundef |
861bb6c1 JL |
2357 | Warn if an undefined identifier is evaluated in an @samp{#if} directive. |
2358 | ||
74291a4b | 2359 | @item -Wshadow |
cd3bb277 | 2360 | @opindex Wshadow |
d773df5a DB |
2361 | Warn whenever a local variable shadows another local variable, parameter or |
2362 | global variable or whenever a built-in function is shadowed. | |
74291a4b | 2363 | |
74291a4b | 2364 | @item -Wlarger-than-@var{len} |
cd3bb277 | 2365 | @opindex Wlarger-than |
74291a4b MM |
2366 | Warn whenever an object of larger than @var{len} bytes is defined. |
2367 | ||
2368 | @item -Wpointer-arith | |
cd3bb277 | 2369 | @opindex Wpointer-arith |
74291a4b MM |
2370 | Warn about anything that depends on the ``size of'' a function type or |
2371 | of @code{void}. GNU C assigns these types a size of 1, for | |
2372 | convenience in calculations with @code{void *} pointers and pointers | |
2373 | to functions. | |
2374 | ||
aee96fe9 | 2375 | @item -Wbad-function-cast @r{(C only)} |
cd3bb277 | 2376 | @opindex Wbad-function-cast |
74291a4b MM |
2377 | Warn whenever a function call is cast to a non-matching type. |
2378 | For example, warn if @code{int malloc()} is cast to @code{anything *}. | |
2379 | ||
2380 | @item -Wcast-qual | |
cd3bb277 | 2381 | @opindex Wcast-qual |
74291a4b MM |
2382 | Warn whenever a pointer is cast so as to remove a type qualifier from |
2383 | the target type. For example, warn if a @code{const char *} is cast | |
2384 | to an ordinary @code{char *}. | |
2385 | ||
2386 | @item -Wcast-align | |
cd3bb277 | 2387 | @opindex Wcast-align |
74291a4b MM |
2388 | Warn whenever a pointer is cast such that the required alignment of the |
2389 | target is increased. For example, warn if a @code{char *} is cast to | |
2390 | an @code{int *} on machines where integers can only be accessed at | |
2391 | two- or four-byte boundaries. | |
2392 | ||
2393 | @item -Wwrite-strings | |
cd3bb277 | 2394 | @opindex Wwrite-strings |
aee96fe9 JM |
2395 | When compiling C, give string constants the type @code{const |
2396 | char[@var{length}]} so that | |
74291a4b | 2397 | copying the address of one into a non-@code{const} @code{char *} |
aee96fe9 JM |
2398 | pointer will get a warning; when compiling C++, warn about the |
2399 | deprecated conversion from string constants to @code{char *}. | |
2400 | These warnings will help you find at | |
74291a4b MM |
2401 | compile time code that can try to write into a string constant, but |
2402 | only if you have been very careful about using @code{const} in | |
2403 | declarations and prototypes. Otherwise, it will just be a nuisance; | |
630d3d5a | 2404 | this is why we did not make @option{-Wall} request these warnings. |
74291a4b MM |
2405 | |
2406 | @item -Wconversion | |
cd3bb277 | 2407 | @opindex Wconversion |
74291a4b MM |
2408 | Warn if a prototype causes a type conversion that is different from what |
2409 | would happen to the same argument in the absence of a prototype. This | |
2410 | includes conversions of fixed point to floating and vice versa, and | |
2411 | conversions changing the width or signedness of a fixed point argument | |
2412 | except when the same as the default promotion. | |
2413 | ||
2414 | Also, warn if a negative integer constant expression is implicitly | |
2415 | converted to an unsigned type. For example, warn about the assignment | |
2416 | @code{x = -1} if @code{x} is unsigned. But do not warn about explicit | |
2417 | casts like @code{(unsigned) -1}. | |
2418 | ||
e9a25f70 | 2419 | @item -Wsign-compare |
cd3bb277 | 2420 | @opindex Wsign-compare |
e9a25f70 JL |
2421 | @cindex warning for comparison of signed and unsigned values |
2422 | @cindex comparison of signed and unsigned values, warning | |
2423 | @cindex signed and unsigned values, comparison warning | |
2424 | Warn when a comparison between signed and unsigned values could produce | |
2425 | an incorrect result when the signed value is converted to unsigned. | |
630d3d5a JM |
2426 | This warning is also enabled by @option{-W}; to get the other warnings |
2427 | of @option{-W} without this warning, use @samp{-W -Wno-sign-compare}. | |
e9a25f70 | 2428 | |
74291a4b | 2429 | @item -Waggregate-return |
cd3bb277 | 2430 | @opindex Waggregate-return |
74291a4b MM |
2431 | Warn if any functions that return structures or unions are defined or |
2432 | called. (In languages where you can return an array, this also elicits | |
2433 | a warning.) | |
2434 | ||
aee96fe9 | 2435 | @item -Wstrict-prototypes @r{(C only)} |
cd3bb277 | 2436 | @opindex Wstrict-prototypes |
74291a4b MM |
2437 | Warn if a function is declared or defined without specifying the |
2438 | argument types. (An old-style function definition is permitted without | |
2439 | a warning if preceded by a declaration which specifies the argument | |
2440 | types.) | |
2441 | ||
aee96fe9 | 2442 | @item -Wmissing-prototypes @r{(C only)} |
cd3bb277 | 2443 | @opindex Wmissing-prototypes |
74291a4b MM |
2444 | Warn if a global function is defined without a previous prototype |
2445 | declaration. This warning is issued even if the definition itself | |
2446 | provides a prototype. The aim is to detect global functions that fail | |
2447 | to be declared in header files. | |
2448 | ||
2449 | @item -Wmissing-declarations | |
cd3bb277 | 2450 | @opindex Wmissing-declarations |
74291a4b MM |
2451 | Warn if a global function is defined without a previous declaration. |
2452 | Do so even if the definition itself provides a prototype. | |
2453 | Use this option to detect global functions that are not declared in | |
2454 | header files. | |
2455 | ||
0ca3fb0a | 2456 | @item -Wmissing-noreturn |
cd3bb277 | 2457 | @opindex Wmissing-noreturn |
0ca3fb0a KG |
2458 | Warn about functions which might be candidates for attribute @code{noreturn}. |
2459 | Note these are only possible candidates, not absolute ones. Care should | |
2460 | be taken to manually verify functions actually do not ever return before | |
2461 | adding the @code{noreturn} attribute, otherwise subtle code generation | |
21c7361e AJ |
2462 | bugs could be introduced. You will not get a warning for @code{main} in |
2463 | hosted C environments. | |
0ca3fb0a | 2464 | |
74ff4629 | 2465 | @item -Wmissing-format-attribute |
cd3bb277 JM |
2466 | @opindex Wmissing-format-attribute |
2467 | @opindex Wformat | |
630d3d5a | 2468 | If @option{-Wformat} is enabled, also warn about functions which might be |
74ff4629 JM |
2469 | candidates for @code{format} attributes. Note these are only possible |
2470 | candidates, not absolute ones. GCC will guess that @code{format} | |
2471 | attributes might be appropriate for any function that calls a function | |
2472 | like @code{vprintf} or @code{vscanf}, but this might not always be the | |
2473 | case, and some functions for which @code{format} attributes are | |
2474 | appropriate may not be detected. This option has no effect unless | |
630d3d5a | 2475 | @option{-Wformat} is enabled (possibly by @option{-Wall}). |
74ff4629 | 2476 | |
3c12fcc2 | 2477 | @item -Wpacked |
cd3bb277 | 2478 | @opindex Wpacked |
3c12fcc2 | 2479 | Warn if a structure is given the packed attribute, but the packed |
02f52e19 | 2480 | attribute has no effect on the layout or size of the structure. |
3c12fcc2 GM |
2481 | Such structures may be mis-aligned for little benefit. For |
2482 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
2483 | will be misaligned even though @code{struct bar} does not itself | |
2484 | have the packed attribute: | |
2485 | ||
2486 | @smallexample | |
2487 | @group | |
2488 | struct foo @{ | |
2489 | int x; | |
2490 | char a, b, c, d; | |
2491 | @} __attribute__((packed)); | |
2492 | struct bar @{ | |
2493 | char z; | |
2494 | struct foo f; | |
2495 | @}; | |
2496 | @end group | |
2497 | @end smallexample | |
2498 | ||
2499 | @item -Wpadded | |
cd3bb277 | 2500 | @opindex Wpadded |
3c12fcc2 GM |
2501 | Warn if padding is included in a structure, either to align an element |
2502 | of the structure or to align the whole structure. Sometimes when this | |
2503 | happens it is possible to rearrange the fields of the structure to | |
2504 | reduce the padding and so make the structure smaller. | |
2505 | ||
74291a4b | 2506 | @item -Wredundant-decls |
cd3bb277 | 2507 | @opindex Wredundant-decls |
74291a4b MM |
2508 | Warn if anything is declared more than once in the same scope, even in |
2509 | cases where multiple declaration is valid and changes nothing. | |
2510 | ||
aee96fe9 | 2511 | @item -Wnested-externs @r{(C only)} |
cd3bb277 | 2512 | @opindex Wnested-externs |
252215a7 | 2513 | Warn if an @code{extern} declaration is encountered within a function. |
74291a4b | 2514 | |
312f6255 | 2515 | @item -Wunreachable-code |
cd3bb277 | 2516 | @opindex Wunreachable-code |
312f6255 GK |
2517 | Warn if the compiler detects that code will never be executed. |
2518 | ||
2519 | This option is intended to warn when the compiler detects that at | |
2520 | least a whole line of source code will never be executed, because | |
2521 | some condition is never satisfied or because it is after a | |
2522 | procedure that never returns. | |
2523 | ||
2524 | It is possible for this option to produce a warning even though there | |
2525 | are circumstances under which part of the affected line can be executed, | |
2526 | so care should be taken when removing apparently-unreachable code. | |
2527 | ||
2528 | For instance, when a function is inlined, a warning may mean that the | |
02f52e19 | 2529 | line is unreachable in only one inlined copy of the function. |
312f6255 | 2530 | |
630d3d5a | 2531 | This option is not made part of @option{-Wall} because in a debugging |
312f6255 GK |
2532 | version of a program there is often substantial code which checks |
2533 | correct functioning of the program and is, hopefully, unreachable | |
2534 | because the program does work. Another common use of unreachable | |
2535 | code is to provide behaviour which is selectable at compile-time. | |
2536 | ||
74291a4b | 2537 | @item -Winline |
cd3bb277 | 2538 | @opindex Winline |
c5c76735 | 2539 | Warn if a function can not be inlined and it was declared as inline. |
74291a4b | 2540 | |
795add94 | 2541 | @item -Wlong-long |
cd3bb277 JM |
2542 | @opindex Wlong-long |
2543 | @opindex Wno-long-long | |
795add94 | 2544 | Warn if @samp{long long} type is used. This is default. To inhibit |
630d3d5a JM |
2545 | the warning messages, use @option{-Wno-long-long}. Flags |
2546 | @option{-Wlong-long} and @option{-Wno-long-long} are taken into account | |
2547 | only when @option{-pedantic} flag is used. | |
795add94 | 2548 | |
18424ae1 | 2549 | @item -Wdisabled-optimization |
cd3bb277 | 2550 | @opindex Wdisabled-optimization |
18424ae1 BL |
2551 | Warn if a requested optimization pass is disabled. This warning does |
2552 | not generally indicate that there is anything wrong with your code; it | |
2553 | merely indicates that GCC's optimizers were unable to handle the code | |
2554 | effectively. Often, the problem is that your code is too big or too | |
2555 | complex; GCC will refuse to optimize programs when the optimization | |
2556 | itself is likely to take inordinate amounts of time. | |
2557 | ||
74291a4b | 2558 | @item -Werror |
cd3bb277 | 2559 | @opindex Werror |
74291a4b MM |
2560 | Make all warnings into errors. |
2561 | @end table | |
2562 | ||
2563 | @node Debugging Options | |
0c2d1a2a | 2564 | @section Options for Debugging Your Program or GCC |
74291a4b MM |
2565 | @cindex options, debugging |
2566 | @cindex debugging information options | |
2567 | ||
0c2d1a2a | 2568 | GCC has various special options that are used for debugging |
74291a4b MM |
2569 | either your program or GCC: |
2570 | ||
2642624b | 2571 | @table @gcctabopt |
74291a4b | 2572 | @item -g |
cd3bb277 | 2573 | @opindex g |
74291a4b | 2574 | Produce debugging information in the operating system's native format |
161d7b59 | 2575 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging |
74291a4b MM |
2576 | information. |
2577 | ||
630d3d5a | 2578 | On most systems that use stabs format, @option{-g} enables use of extra |
74291a4b MM |
2579 | debugging information that only GDB can use; this extra information |
2580 | makes debugging work better in GDB but will probably make other debuggers | |
2581 | crash or | |
2582 | refuse to read the program. If you want to control for certain whether | |
630d3d5a JM |
2583 | to generate the extra information, use @option{-gstabs+}, @option{-gstabs}, |
2584 | @option{-gxcoff+}, @option{-gxcoff}, @option{-gdwarf-1+}, or @option{-gdwarf-1} | |
74291a4b MM |
2585 | (see below). |
2586 | ||
630d3d5a JM |
2587 | Unlike most other C compilers, GCC allows you to use @option{-g} with |
2588 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
74291a4b MM |
2589 | produce surprising results: some variables you declared may not exist |
2590 | at all; flow of control may briefly move where you did not expect it; | |
2591 | some statements may not be executed because they compute constant | |
2592 | results or their values were already at hand; some statements may | |
2593 | execute in different places because they were moved out of loops. | |
2594 | ||
2595 | Nevertheless it proves possible to debug optimized output. This makes | |
2596 | it reasonable to use the optimizer for programs that might have bugs. | |
2597 | ||
0c2d1a2a | 2598 | The following options are useful when GCC is generated with the |
74291a4b MM |
2599 | capability for more than one debugging format. |
2600 | ||
2601 | @item -ggdb | |
cd3bb277 | 2602 | @opindex ggdb |
161d7b59 | 2603 | Produce debugging information for use by GDB@. This means to use the |
861bb6c1 JL |
2604 | most expressive format available (DWARF 2, stabs, or the native format |
2605 | if neither of those are supported), including GDB extensions if at all | |
2606 | possible. | |
74291a4b MM |
2607 | |
2608 | @item -gstabs | |
cd3bb277 | 2609 | @opindex gstabs |
74291a4b MM |
2610 | Produce debugging information in stabs format (if that is supported), |
2611 | without GDB extensions. This is the format used by DBX on most BSD | |
2612 | systems. On MIPS, Alpha and System V Release 4 systems this option | |
161d7b59 | 2613 | produces stabs debugging output which is not understood by DBX or SDB@. |
74291a4b MM |
2614 | On System V Release 4 systems this option requires the GNU assembler. |
2615 | ||
2616 | @item -gstabs+ | |
cd3bb277 | 2617 | @opindex gstabs+ |
74291a4b | 2618 | Produce debugging information in stabs format (if that is supported), |
161d7b59 | 2619 | using GNU extensions understood only by the GNU debugger (GDB)@. The |
74291a4b MM |
2620 | use of these extensions is likely to make other debuggers crash or |
2621 | refuse to read the program. | |
2622 | ||
2623 | @item -gcoff | |
cd3bb277 | 2624 | @opindex gcoff |
74291a4b MM |
2625 | Produce debugging information in COFF format (if that is supported). |
2626 | This is the format used by SDB on most System V systems prior to | |
2627 | System V Release 4. | |
2628 | ||
2629 | @item -gxcoff | |
cd3bb277 | 2630 | @opindex gxcoff |
74291a4b MM |
2631 | Produce debugging information in XCOFF format (if that is supported). |
2632 | This is the format used by the DBX debugger on IBM RS/6000 systems. | |
2633 | ||
2634 | @item -gxcoff+ | |
cd3bb277 | 2635 | @opindex gxcoff+ |
74291a4b | 2636 | Produce debugging information in XCOFF format (if that is supported), |
161d7b59 | 2637 | using GNU extensions understood only by the GNU debugger (GDB)@. The |
74291a4b MM |
2638 | use of these extensions is likely to make other debuggers crash or |
2639 | refuse to read the program, and may cause assemblers other than the GNU | |
2640 | assembler (GAS) to fail with an error. | |
2641 | ||
2642 | @item -gdwarf | |
cd3bb277 | 2643 | @opindex gdwarf |
861bb6c1 JL |
2644 | Produce debugging information in DWARF version 1 format (if that is |
2645 | supported). This is the format used by SDB on most System V Release 4 | |
2646 | systems. | |
74291a4b MM |
2647 | |
2648 | @item -gdwarf+ | |
cd3bb277 | 2649 | @opindex gdwarf+ |
861bb6c1 JL |
2650 | Produce debugging information in DWARF version 1 format (if that is |
2651 | supported), using GNU extensions understood only by the GNU debugger | |
161d7b59 | 2652 | (GDB)@. The use of these extensions is likely to make other debuggers |
861bb6c1 JL |
2653 | crash or refuse to read the program. |
2654 | ||
2655 | @item -gdwarf-2 | |
cd3bb277 | 2656 | @opindex gdwarf-2 |
861bb6c1 JL |
2657 | Produce debugging information in DWARF version 2 format (if that is |
2658 | supported). This is the format used by DBX on IRIX 6. | |
74291a4b MM |
2659 | |
2660 | @item -g@var{level} | |
2661 | @itemx -ggdb@var{level} | |
2662 | @itemx -gstabs@var{level} | |
2663 | @itemx -gcoff@var{level} | |
2664 | @itemx -gxcoff@var{level} | |
2665 | @itemx -gdwarf@var{level} | |
861bb6c1 | 2666 | @itemx -gdwarf-2@var{level} |
74291a4b MM |
2667 | Request debugging information and also use @var{level} to specify how |
2668 | much information. The default level is 2. | |
2669 | ||
2670 | Level 1 produces minimal information, enough for making backtraces in | |
2671 | parts of the program that you don't plan to debug. This includes | |
2672 | descriptions of functions and external variables, but no information | |
2673 | about local variables and no line numbers. | |
2674 | ||
2675 | Level 3 includes extra information, such as all the macro definitions | |
2676 | present in the program. Some debuggers support macro expansion when | |
630d3d5a | 2677 | you use @option{-g3}. |
74291a4b MM |
2678 | |
2679 | @cindex @code{prof} | |
2680 | @item -p | |
cd3bb277 | 2681 | @opindex p |
74291a4b MM |
2682 | Generate extra code to write profile information suitable for the |
2683 | analysis program @code{prof}. You must use this option when compiling | |
2684 | the source files you want data about, and you must also use it when | |
2685 | linking. | |
2686 | ||
2687 | @cindex @code{gprof} | |
2688 | @item -pg | |
cd3bb277 | 2689 | @opindex pg |
74291a4b MM |
2690 | Generate extra code to write profile information suitable for the |
2691 | analysis program @code{gprof}. You must use this option when compiling | |
2692 | the source files you want data about, and you must also use it when | |
2693 | linking. | |
2694 | ||
2695 | @cindex @code{tcov} | |
2696 | @item -a | |
cd3bb277 | 2697 | @opindex a |
74291a4b MM |
2698 | Generate extra code to write profile information for basic blocks, which will |
2699 | record the number of times each basic block is executed, the basic block start | |
630d3d5a | 2700 | address, and the function name containing the basic block. If @option{-g} is |
74291a4b MM |
2701 | used, the line number and filename of the start of the basic block will also be |
2702 | recorded. If not overridden by the machine description, the default action is | |
2703 | to append to the text file @file{bb.out}. | |
2704 | ||
2705 | This data could be analyzed by a program like @code{tcov}. Note, | |
2706 | however, that the format of the data is not what @code{tcov} expects. | |
2707 | Eventually GNU @code{gprof} should be extended to process this data. | |
2708 | ||
898f531b | 2709 | @item -Q |
cd3bb277 | 2710 | @opindex Q |
898f531b JL |
2711 | Makes the compiler print out each function name as it is compiled, and |
2712 | print some statistics about each pass when it finishes. | |
2713 | ||
1f0c3120 | 2714 | @item -ftime-report |
cd3bb277 | 2715 | @opindex ftime-report |
1f0c3120 JM |
2716 | Makes the compiler print some statistics about the time consumed by each |
2717 | pass when it finishes. | |
2718 | ||
2719 | @item -fmem-report | |
cd3bb277 | 2720 | @opindex fmem-report |
1f0c3120 JM |
2721 | Makes the compiler print some statistics about permanent memory |
2722 | allocation when it finishes. | |
2723 | ||
74291a4b | 2724 | @item -ax |
cd3bb277 | 2725 | @opindex ax |
74291a4b | 2726 | Generate extra code to profile basic blocks. Your executable will |
630d3d5a | 2727 | produce output that is a superset of that produced when @option{-a} is |
74291a4b MM |
2728 | used. Additional output is the source and target address of the basic |
2729 | blocks where a jump takes place, the number of times a jump is executed, | |
2730 | and (optionally) the complete sequence of basic blocks being executed. | |
2731 | The output is appended to file @file{bb.out}. | |
2732 | ||
2733 | You can examine different profiling aspects without recompilation. Your | |
956d6950 | 2734 | executable will read a list of function names from file @file{bb.in}. |
74291a4b MM |
2735 | Profiling starts when a function on the list is entered and stops when |
2736 | that invocation is exited. To exclude a function from profiling, prefix | |
c771326b | 2737 | its name with @samp{-}. If a function name is not unique, you can |
74291a4b MM |
2738 | disambiguate it by writing it in the form |
2739 | @samp{/path/filename.d:functionname}. Your executable will write the | |
2740 | available paths and filenames in file @file{bb.out}. | |
2741 | ||
2742 | Several function names have a special meaning: | |
2743 | @table @code | |
2744 | @item __bb_jumps__ | |
2745 | Write source, target and frequency of jumps to file @file{bb.out}. | |
2746 | @item __bb_hidecall__ | |
2747 | Exclude function calls from frequency count. | |
2748 | @item __bb_showret__ | |
2749 | Include function returns in frequency count. | |
2750 | @item __bb_trace__ | |
2751 | Write the sequence of basic blocks executed to file @file{bbtrace.gz}. | |
2752 | The file will be compressed using the program @samp{gzip}, which must | |
bedc7537 | 2753 | exist in your @env{PATH}. On systems without the @samp{popen} |
74291a4b MM |
2754 | function, the file will be named @file{bbtrace} and will not be |
2755 | compressed. @strong{Profiling for even a few seconds on these systems | |
2756 | will produce a very large file.} Note: @code{__bb_hidecall__} and | |
2757 | @code{__bb_showret__} will not affect the sequence written to | |
2758 | @file{bbtrace.gz}. | |
2759 | @end table | |
2760 | ||
2761 | Here's a short example using different profiling parameters | |
2762 | in file @file{bb.in}. Assume function @code{foo} consists of basic blocks | |
2763 | 1 and 2 and is called twice from block 3 of function @code{main}. After | |
2764 | the calls, block 3 transfers control to block 4 of @code{main}. | |
2765 | ||
2766 | With @code{__bb_trace__} and @code{main} contained in file @file{bb.in}, | |
2767 | the following sequence of blocks is written to file @file{bbtrace.gz}: | |
2768 | 0 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because | |
2769 | the return is to a point inside the block and not to the top. The | |
2770 | block address 0 always indicates, that control is transferred | |
2771 | to the trace from somewhere outside the observed functions. With | |
2772 | @samp{-foo} added to @file{bb.in}, the blocks of function | |
2773 | @code{foo} are removed from the trace, so only 0 3 4 remains. | |
2774 | ||
2775 | With @code{__bb_jumps__} and @code{main} contained in file @file{bb.in}, | |
2776 | jump frequencies will be written to file @file{bb.out}. The | |
2777 | frequencies are obtained by constructing a trace of blocks | |
2778 | and incrementing a counter for every neighbouring pair of blocks | |
2779 | in the trace. The trace 0 3 1 2 1 2 4 displays the following | |
2780 | frequencies: | |
2781 | ||
2782 | @example | |
2783 | Jump from block 0x0 to block 0x3 executed 1 time(s) | |
2784 | Jump from block 0x3 to block 0x1 executed 1 time(s) | |
2785 | Jump from block 0x1 to block 0x2 executed 2 time(s) | |
2786 | Jump from block 0x2 to block 0x1 executed 1 time(s) | |
2787 | Jump from block 0x2 to block 0x4 executed 1 time(s) | |
2788 | @end example | |
2789 | ||
2790 | With @code{__bb_hidecall__}, control transfer due to call instructions | |
2791 | is removed from the trace, that is the trace is cut into three parts: 0 | |
2792 | 3 4, 0 1 2 and 0 1 2. With @code{__bb_showret__}, control transfer due | |
2793 | to return instructions is added to the trace. The trace becomes: 0 3 1 | |
2794 | 2 3 1 2 3 4. Note, that this trace is not the same, as the sequence | |
2795 | written to @file{bbtrace.gz}. It is solely used for counting jump | |
2796 | frequencies. | |
2797 | ||
861bb6c1 | 2798 | @item -fprofile-arcs |
cd3bb277 | 2799 | @opindex fprofile-arcs |
861bb6c1 | 2800 | Instrument @dfn{arcs} during compilation. For each function of your |
0c2d1a2a | 2801 | program, GCC creates a program flow graph, then finds a spanning tree |
861bb6c1 JL |
2802 | for the graph. Only arcs that are not on the spanning tree have to be |
2803 | instrumented: the compiler adds code to count the number of times that these | |
2804 | arcs are executed. When an arc is the only exit or only entrance to a | |
2805 | block, the instrumentation code can be added to the block; otherwise, a | |
2806 | new basic block must be created to hold the instrumentation code. | |
2807 | ||
2808 | Since not every arc in the program must be instrumented, programs | |
2809 | compiled with this option run faster than programs compiled with | |
630d3d5a | 2810 | @option{-a}, which adds instrumentation code to every basic block in the |
861bb6c1 JL |
2811 | program. The tradeoff: since @code{gcov} does not have |
2812 | execution counts for all branches, it must start with the execution | |
2813 | counts for the instrumented branches, and then iterate over the program | |
2814 | flow graph until the entire graph has been solved. Hence, @code{gcov} | |
2815 | runs a little more slowly than a program which uses information from | |
630d3d5a | 2816 | @option{-a}. |
861bb6c1 | 2817 | |
630d3d5a | 2818 | @option{-fprofile-arcs} also makes it possible to estimate branch |
861bb6c1 JL |
2819 | probabilities, and to calculate basic block execution counts. In |
2820 | general, basic block execution counts do not give enough information to | |
2821 | estimate all branch probabilities. When the compiled program exits, it | |
2822 | saves the arc execution counts to a file called | |
2823 | @file{@var{sourcename}.da}. Use the compiler option | |
630d3d5a | 2824 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that |
861bb6c1 JL |
2825 | Control Optimization}) when recompiling, to optimize using estimated |
2826 | branch probabilities. | |
2827 | ||
2828 | @need 2000 | |
2829 | @item -ftest-coverage | |
cd3bb277 | 2830 | @opindex ftest-coverage |
861bb6c1 | 2831 | Create data files for the @code{gcov} code-coverage utility |
0c2d1a2a | 2832 | (@pxref{Gcov,, @code{gcov}: a GCC Test Coverage Program}). |
861bb6c1 JL |
2833 | The data file names begin with the name of your source file: |
2834 | ||
2642624b | 2835 | @table @gcctabopt |
861bb6c1 JL |
2836 | @item @var{sourcename}.bb |
2837 | A mapping from basic blocks to line numbers, which @code{gcov} uses to | |
2838 | associate basic block execution counts with line numbers. | |
2839 | ||
2840 | @item @var{sourcename}.bbg | |
2841 | A list of all arcs in the program flow graph. This allows @code{gcov} | |
2842 | to reconstruct the program flow graph, so that it can compute all basic | |
2843 | block and arc execution counts from the information in the | |
2844 | @code{@var{sourcename}.da} file (this last file is the output from | |
630d3d5a | 2845 | @option{-fprofile-arcs}). |
861bb6c1 JL |
2846 | @end table |
2847 | ||
74291a4b | 2848 | @item -d@var{letters} |
cd3bb277 | 2849 | @opindex d |
74291a4b MM |
2850 | Says to make debugging dumps during compilation at times specified by |
2851 | @var{letters}. This is used for debugging the compiler. The file names | |
375e2d5c | 2852 | for most of the dumps are made by appending a pass number and a word to |
02f52e19 | 2853 | the source file name (e.g. @file{foo.c.00.rtl} or @file{foo.c.01.sibling}). |
375e2d5c | 2854 | Here are the possible letters for use in @var{letters}, and their meanings: |
74291a4b MM |
2855 | |
2856 | @table @samp | |
375e2d5c | 2857 | @item A |
cd3bb277 | 2858 | @opindex dA |
375e2d5c | 2859 | Annotate the assembler output with miscellaneous debugging information. |
956d6950 | 2860 | @item b |
cd3bb277 | 2861 | @opindex db |
0b47e4c1 | 2862 | Dump after computing branch probabilities, to @file{@var{file}.14.bp}. |
48d9ade5 | 2863 | @item B |
cd3bb277 | 2864 | @opindex dB |
0b47e4c1 | 2865 | Dump after block reordering, to @file{@var{file}.28.bbro}. |
032713aa | 2866 | @item c |
cd3bb277 | 2867 | @opindex dc |
0b47e4c1 | 2868 | Dump after instruction combination, to the file @file{@var{file}.16.combine}. |
470fc13d | 2869 | @item C |
cd3bb277 | 2870 | @opindex dC |
0b47e4c1 | 2871 | Dump after the first if conversion, to the file @file{@var{file}.17.ce}. |
032713aa | 2872 | @item d |
cd3bb277 | 2873 | @opindex dd |
0b47e4c1 | 2874 | Dump after delayed branch scheduling, to @file{@var{file}.31.dbr}. |
032713aa | 2875 | @item D |
cd3bb277 | 2876 | @opindex dD |
f5963e61 JL |
2877 | Dump all macro definitions, at the end of preprocessing, in addition to |
2878 | normal output. | |
48d9ade5 | 2879 | @item e |
cd3bb277 | 2880 | @opindex de |
0826f1d8 | 2881 | Dump after SSA optimizations, to @file{@var{file}.04.ssa} and |
0b47e4c1 | 2882 | @file{@var{file}.07.ussa}. |
470fc13d | 2883 | @item E |
cd3bb277 | 2884 | @opindex dE |
0b47e4c1 | 2885 | Dump after the second if conversion, to @file{@var{file}.26.ce2}. |
74291a4b | 2886 | @item f |
cd3bb277 | 2887 | @opindex df |
0b47e4c1 | 2888 | Dump after life analysis, to @file{@var{file}.15.life}. |
48d9ade5 | 2889 | @item F |
cd3bb277 | 2890 | @opindex dF |
0b47e4c1 | 2891 | Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.09.addressof}. |
74291a4b | 2892 | @item g |
cd3bb277 | 2893 | @opindex dg |
0b47e4c1 | 2894 | Dump after global register allocation, to @file{@var{file}.21.greg}. |
0826f1d8 JL |
2895 | @item h |
2896 | @opindex dh | |
2897 | Dump after finalization of EH handling code, to @file{@var{file}.02.eh}. | |
2898 | @item o | |
8bb16620 | 2899 | @item o |
cd3bb277 | 2900 | @opindex do |
0b47e4c1 | 2901 | Dump after post-reload CSE and other optimizations, to @file{@var{file}.22.postreload}. |
02f52e19 | 2902 | @item G |
cd3bb277 | 2903 | @opindex dG |
0b47e4c1 | 2904 | Dump after GCSE, to @file{@var{file}.10.gcse}. |
48d9ade5 | 2905 | @item i |
cd3bb277 | 2906 | @opindex di |
48d9ade5 | 2907 | Dump after sibling call optimizations, to @file{@var{file}.01.sibling}. |
032713aa | 2908 | @item j |
cd3bb277 | 2909 | @opindex dj |
0826f1d8 | 2910 | Dump after the first jump optimization, to @file{@var{file}.03.jump}. |
74291a4b | 2911 | @item k |
cd3bb277 | 2912 | @opindex dk |
0b47e4c1 | 2913 | Dump after conversion from registers to stack, to @file{@var{file}.32.stack}. |
032713aa | 2914 | @item l |
cd3bb277 | 2915 | @opindex dl |
0b47e4c1 | 2916 | Dump after local register allocation, to @file{@var{file}.20.lreg}. |
032713aa | 2917 | @item L |
cd3bb277 | 2918 | @opindex dL |
0b47e4c1 | 2919 | Dump after loop optimization, to @file{@var{file}.11.loop}. |
032713aa | 2920 | @item M |
cd3bb277 | 2921 | @opindex dM |
032713aa | 2922 | Dump after performing the machine dependent reorganisation pass, to |
0b47e4c1 | 2923 | @file{@var{file}.30.mach}. |
48d9ade5 | 2924 | @item n |
cd3bb277 | 2925 | @opindex dn |
0b47e4c1 | 2926 | Dump after register renumbering, to @file{@var{file}.25.rnreg}. |
032713aa | 2927 | @item N |
cd3bb277 | 2928 | @opindex dN |
0b47e4c1 | 2929 | Dump after the register move pass, to @file{@var{file}.18.regmove}. |
032713aa | 2930 | @item r |
cd3bb277 | 2931 | @opindex dr |
375e2d5c | 2932 | Dump after RTL generation, to @file{@var{file}.00.rtl}. |
032713aa | 2933 | @item R |
cd3bb277 | 2934 | @opindex dR |
375e2d5c | 2935 | Dump after the second instruction scheduling pass, to |
0b47e4c1 | 2936 | @file{@var{file}.27.sched2}. |
032713aa | 2937 | @item s |
cd3bb277 | 2938 | @opindex ds |
032713aa | 2939 | Dump after CSE (including the jump optimization that sometimes follows |
0b47e4c1 | 2940 | CSE), to @file{@var{file}.08.cse}. |
032713aa | 2941 | @item S |
cd3bb277 | 2942 | @opindex dS |
375e2d5c | 2943 | Dump after the first instruction scheduling pass, to |
0b47e4c1 | 2944 | @file{@var{file}.19.sched}. |
032713aa | 2945 | @item t |
cd3bb277 | 2946 | @opindex dt |
032713aa | 2947 | Dump after the second CSE pass (including the jump optimization that |
0b47e4c1 | 2948 | sometimes follows CSE), to @file{@var{file}.12.cse2}. |
48d9ade5 | 2949 | @item w |
cd3bb277 | 2950 | @opindex dw |
0b47e4c1 | 2951 | Dump after the second flow pass, to @file{@var{file}.23.flow2}. |
470fc13d | 2952 | @item X |
cd3bb277 | 2953 | @opindex dX |
0b47e4c1 | 2954 | Dump after SSA aggressive dead code elimination, to @file{@var{file}.06.ssadce}. |
48d9ade5 | 2955 | @item z |
cd3bb277 | 2956 | @opindex dz |
0b47e4c1 | 2957 | Dump after the peephole pass, to @file{@var{file}.24.peephole2}. |
74291a4b | 2958 | @item a |
cd3bb277 | 2959 | @opindex da |
74291a4b MM |
2960 | Produce all the dumps listed above. |
2961 | @item m | |
cd3bb277 | 2962 | @opindex dm |
74291a4b MM |
2963 | Print statistics on memory usage, at the end of the run, to |
2964 | standard error. | |
2965 | @item p | |
cd3bb277 | 2966 | @opindex dp |
74291a4b | 2967 | Annotate the assembler output with a comment indicating which |
f20b5577 MM |
2968 | pattern and alternative was used. The length of each instruction is |
2969 | also printed. | |
2856c3e3 | 2970 | @item P |
cd3bb277 | 2971 | @opindex dP |
2856c3e3 | 2972 | Dump the RTL in the assembler output as a comment before each instruction. |
630d3d5a | 2973 | Also turns on @option{-dp} annotation. |
375e2d5c | 2974 | @item v |
cd3bb277 | 2975 | @opindex dv |
375e2d5c RH |
2976 | For each of the other indicated dump files (except for |
2977 | @file{@var{file}.00.rtl}), dump a representation of the control flow graph | |
b192711e | 2978 | suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}. |
62a1403d | 2979 | @item x |
cd3bb277 | 2980 | @opindex dx |
62a1403d AS |
2981 | Just generate RTL for a function instead of compiling it. Usually used |
2982 | with @samp{r}. | |
032713aa | 2983 | @item y |
cd3bb277 | 2984 | @opindex dy |
032713aa | 2985 | Dump debugging information during parsing, to standard error. |
74291a4b MM |
2986 | @end table |
2987 | ||
b707b450 | 2988 | @item -fdump-unnumbered |
cd3bb277 | 2989 | @opindex fdump-unnumbered |
695ac33f | 2990 | When doing debugging dumps (see @option{-d} option above), suppress instruction |
b707b450 | 2991 | numbers and line number note output. This makes it more feasible to |
b192711e | 2992 | use diff on debugging dumps for compiler invocations with different |
695ac33f | 2993 | options, in particular with and without @option{-g}. |
b707b450 | 2994 | |
aee96fe9 JM |
2995 | @item -fdump-translation-unit @r{(C and C++ only)} |
2996 | @itemx -fdump-translation-unit-@var{number} @r{(C and C++ only)} | |
cd3bb277 | 2997 | @opindex fdump-translation-unit |
f71f87f9 | 2998 | Dump a representation of the tree structure for the entire translation |
767094dd JM |
2999 | unit to a file. The file name is made by appending @file{.tu} to the |
3000 | source file name. If the @samp{-@var{number}} form is used, @var{number} | |
695ac33f | 3001 | controls the details of the dump as described for the @option{-fdump-tree} options. |
e76b4820 | 3002 | |
aee96fe9 JM |
3003 | @item -fdump-class-hierarchy @r{(C++ only)} |
3004 | @itemx -fdump-class-hierarchy-@var{number} @r{(C++ only)} | |
cd3bb277 | 3005 | @opindex fdump-class-hierarchy |
e76b4820 | 3006 | Dump a representation of each class's hierarchy and virtual function |
767094dd JM |
3007 | table layout to a file. The file name is made by appending @file{.class} |
3008 | to the source file name. If the @samp{-@var{number}} form is used, @var{number} | |
695ac33f | 3009 | controls the details of the dump as described for the @option{-fdump-tree} |
e76b4820 NS |
3010 | options. |
3011 | ||
aee96fe9 JM |
3012 | @item -fdump-ast-@var{switch} @r{(C++ only)} |
3013 | @itemx -fdump-ast-@var{switch}-@var{number} @r{(C++ only)} | |
cd3bb277 | 3014 | @opindex fdump-ast |
e76b4820 | 3015 | Control the dumping at various stages of processing the abstract syntax |
767094dd JM |
3016 | tree to a file. The file name is generated by appending a switch |
3017 | specific suffix to the source file name. If the @samp{-@var{number}} form is | |
e76b4820 | 3018 | used, @var{number} is a bit mask which controls the details of the |
767094dd | 3019 | dump. The following bits are meaningful (these are not set symbolically, |
e76b4820 | 3020 | as the primary function of these dumps is for debugging gcc itself): |
f71f87f9 | 3021 | |
e76b4820 NS |
3022 | @table @samp |
3023 | @item bit0 (1) | |
767094dd | 3024 | Print the address of each node. Usually this is not meaningful as it |
e76b4820 NS |
3025 | changes according to the environment and source file. |
3026 | @item bit1 (2) | |
3027 | Inhibit dumping of members of a scope or body of a function, unless they | |
3028 | are reachable by some other path. | |
3029 | @end table | |
3030 | ||
3031 | The following tree dumps are possible: | |
3032 | @table @samp | |
3033 | @item original | |
3034 | Dump before any tree based optimization, to @file{@var{file}.original}. | |
3035 | @item optimized | |
3036 | Dump after all tree based optimization, to @file{@var{file}.optimized}. | |
6be77748 NS |
3037 | @item inlined |
3038 | Dump after inlining within the body of the function, to | |
3039 | @file{@var{file}.inlined}. | |
e76b4820 | 3040 | @end table |
9965d119 | 3041 | |
74291a4b | 3042 | @item -fpretend-float |
cd3bb277 | 3043 | @opindex fpretend-float |
74291a4b MM |
3044 | When running a cross-compiler, pretend that the target machine uses the |
3045 | same floating point format as the host machine. This causes incorrect | |
3046 | output of the actual floating constants, but the actual instruction | |
0c2d1a2a | 3047 | sequence will probably be the same as GCC would make when running on |
74291a4b MM |
3048 | the target machine. |
3049 | ||
3050 | @item -save-temps | |
cd3bb277 | 3051 | @opindex save-temps |
74291a4b MM |
3052 | Store the usual ``temporary'' intermediate files permanently; place them |
3053 | in the current directory and name them based on the source file. Thus, | |
3054 | compiling @file{foo.c} with @samp{-c -save-temps} would produce files | |
f2ecb02d JM |
3055 | @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a |
3056 | preprocessed @file{foo.i} output file even though the compiler now | |
3057 | normally uses an integrated preprocessor. | |
74291a4b | 3058 | |
03c41c05 | 3059 | @item -time |
cd3bb277 | 3060 | @opindex time |
03c41c05 | 3061 | Report the CPU time taken by each subprocess in the compilation |
f2ecb02d JM |
3062 | sequence. For C source files, this is the compiler proper and assembler |
3063 | (plus the linker if linking is done). The output looks like this: | |
03c41c05 ZW |
3064 | |
3065 | @smallexample | |
03c41c05 ZW |
3066 | # cc1 0.12 0.01 |
3067 | # as 0.00 0.01 | |
3068 | @end smallexample | |
3069 | ||
3070 | The first number on each line is the ``user time,'' that is time spent | |
3071 | executing the program itself. The second number is ``system time,'' | |
3072 | time spent executing operating system routines on behalf of the program. | |
3073 | Both numbers are in seconds. | |
3074 | ||
74291a4b | 3075 | @item -print-file-name=@var{library} |
cd3bb277 | 3076 | @opindex print-file-name |
74291a4b MM |
3077 | Print the full absolute name of the library file @var{library} that |
3078 | would be used when linking---and don't do anything else. With this | |
0c2d1a2a | 3079 | option, GCC does not compile or link anything; it just prints the |
74291a4b MM |
3080 | file name. |
3081 | ||
b1018de6 AO |
3082 | @item -print-multi-directory |
3083 | @opindex print-multi-directory | |
3084 | Print the directory name corresponding to the multilib selected by any | |
3085 | other switches present in the command line. This directory is supposed | |
3086 | to exist in @env{GCC_EXEC_PREFIX}. | |
3087 | ||
3088 | @item -print-multi-lib | |
3089 | @opindex print-multi-lib | |
3090 | Print the mapping from multilib directory names to compiler switches | |
3091 | that enable them. The directory name is separated from the switches by | |
3092 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
3093 | @samp{-}, without spaces between multiple switches. This is supposed to | |
3094 | ease shell-processing. | |
3095 | ||
74291a4b | 3096 | @item -print-prog-name=@var{program} |
cd3bb277 | 3097 | @opindex print-prog-name |
630d3d5a | 3098 | Like @option{-print-file-name}, but searches for a program such as @samp{cpp}. |
74291a4b MM |
3099 | |
3100 | @item -print-libgcc-file-name | |
cd3bb277 | 3101 | @opindex print-libgcc-file-name |
630d3d5a | 3102 | Same as @option{-print-file-name=libgcc.a}. |
74291a4b | 3103 | |
630d3d5a | 3104 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} |
74291a4b MM |
3105 | but you do want to link with @file{libgcc.a}. You can do |
3106 | ||
3107 | @example | |
3108 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
3109 | @end example | |
3110 | ||
3111 | @item -print-search-dirs | |
cd3bb277 | 3112 | @opindex print-search-dirs |
74291a4b MM |
3113 | Print the name of the configured installation directory and a list of |
3114 | program and library directories gcc will search---and don't do anything else. | |
3115 | ||
3116 | This is useful when gcc prints the error message | |
3c0b7970 JM |
3117 | @samp{installation problem, cannot exec cpp0: No such file or directory}. |
3118 | To resolve this you either need to put @file{cpp0} and the other compiler | |
74291a4b | 3119 | components where gcc expects to find them, or you can set the environment |
bedc7537 | 3120 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. |
74291a4b MM |
3121 | Don't forget the trailing '/'. |
3122 | @xref{Environment Variables}. | |
1f0c3120 JM |
3123 | |
3124 | @item -dumpmachine | |
cd3bb277 | 3125 | @opindex dumpmachine |
1f0c3120 JM |
3126 | Print the compiler's target machine (for example, |
3127 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
3128 | ||
3129 | @item -dumpversion | |
cd3bb277 | 3130 | @opindex dumpversion |
1f0c3120 JM |
3131 | Print the compiler version (for example, @samp{3.0})---and don't do |
3132 | anything else. | |
3133 | ||
3134 | @item -dumpspecs | |
cd3bb277 | 3135 | @opindex dumpspecs |
1f0c3120 JM |
3136 | Print the compiler's built-in specs---and don't do anything else. (This |
3137 | is used when GCC itself is being built.) @xref{Spec Files}. | |
74291a4b MM |
3138 | @end table |
3139 | ||
3140 | @node Optimize Options | |
3141 | @section Options That Control Optimization | |
3142 | @cindex optimize options | |
3143 | @cindex options, optimization | |
3144 | ||
3145 | These options control various sorts of optimizations: | |
3146 | ||
2642624b | 3147 | @table @gcctabopt |
74291a4b MM |
3148 | @item -O |
3149 | @itemx -O1 | |
cd3bb277 JM |
3150 | @opindex O |
3151 | @opindex O1 | |
74291a4b MM |
3152 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
3153 | more memory for a large function. | |
3154 | ||
630d3d5a | 3155 | Without @option{-O}, the compiler's goal is to reduce the cost of |
74291a4b MM |
3156 | compilation and to make debugging produce the expected results. |
3157 | Statements are independent: if you stop the program with a breakpoint | |
3158 | between statements, you can then assign a new value to any variable or | |
3159 | change the program counter to any other statement in the function and | |
3160 | get exactly the results you would expect from the source code. | |
3161 | ||
630d3d5a | 3162 | Without @option{-O}, the compiler only allocates variables declared |
74291a4b | 3163 | @code{register} in registers. The resulting compiled code is a little |
630d3d5a | 3164 | worse than produced by PCC without @option{-O}. |
74291a4b | 3165 | |
630d3d5a | 3166 | With @option{-O}, the compiler tries to reduce code size and execution |
74291a4b MM |
3167 | time. |
3168 | ||
630d3d5a JM |
3169 | When you specify @option{-O}, the compiler turns on @option{-fthread-jumps} |
3170 | and @option{-fdefer-pop} on all machines. The compiler turns on | |
3171 | @option{-fdelayed-branch} on machines that have delay slots, and | |
3172 | @option{-fomit-frame-pointer} on machines that can support debugging even | |
74291a4b | 3173 | without a frame pointer. On some machines the compiler also turns |
bd819a4a | 3174 | on other flags. |
74291a4b MM |
3175 | |
3176 | @item -O2 | |
cd3bb277 | 3177 | @opindex O2 |
0c2d1a2a | 3178 | Optimize even more. GCC performs nearly all supported optimizations |
74291a4b | 3179 | that do not involve a space-speed tradeoff. The compiler does not |
630d3d5a JM |
3180 | perform loop unrolling or function inlining when you specify @option{-O2}. |
3181 | As compared to @option{-O}, this option increases both compilation time | |
74291a4b MM |
3182 | and the performance of the generated code. |
3183 | ||
630d3d5a | 3184 | @option{-O2} turns on all optional optimizations except for loop unrolling, |
2b2a8f1f | 3185 | function inlining, and register renaming. It also turns on the |
630d3d5a | 3186 | @option{-fforce-mem} option on all machines and frame pointer elimination |
2b2a8f1f | 3187 | on machines where doing so does not interfere with debugging. |
74291a4b | 3188 | |
081ca317 BL |
3189 | Please note the warning under @option{-fgcse} about |
3190 | invoking @option{-O2} on programs that use computed gotos. | |
3191 | ||
74291a4b | 3192 | @item -O3 |
cd3bb277 | 3193 | @opindex O3 |
630d3d5a JM |
3194 | Optimize yet more. @option{-O3} turns on all optimizations specified by |
3195 | @option{-O2} and also turns on the @option{-finline-functions} and | |
3196 | @option{-frename-registers} options. | |
74291a4b MM |
3197 | |
3198 | @item -O0 | |
cd3bb277 | 3199 | @opindex O0 |
74291a4b MM |
3200 | Do not optimize. |
3201 | ||
c6aded7c | 3202 | @item -Os |
cd3bb277 | 3203 | @opindex Os |
630d3d5a | 3204 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations that |
c6aded7c AG |
3205 | do not typically increase code size. It also performs further |
3206 | optimizations designed to reduce code size. | |
3207 | ||
630d3d5a | 3208 | If you use multiple @option{-O} options, with or without level numbers, |
74291a4b MM |
3209 | the last such option is the one that is effective. |
3210 | @end table | |
3211 | ||
630d3d5a | 3212 | Options of the form @option{-f@var{flag}} specify machine-independent |
74291a4b | 3213 | flags. Most flags have both positive and negative forms; the negative |
630d3d5a | 3214 | form of @option{-ffoo} would be @option{-fno-foo}. In the table below, |
74291a4b MM |
3215 | only one of the forms is listed---the one which is not the default. |
3216 | You can figure out the other form by either removing @samp{no-} or | |
3217 | adding it. | |
3218 | ||
2642624b | 3219 | @table @gcctabopt |
74291a4b | 3220 | @item -ffloat-store |
cd3bb277 | 3221 | @opindex ffloat-store |
74291a4b MM |
3222 | Do not store floating point variables in registers, and inhibit other |
3223 | options that might change whether a floating point value is taken from a | |
3224 | register or memory. | |
3225 | ||
3226 | @cindex floating point precision | |
3227 | This option prevents undesirable excess precision on machines such as | |
3228 | the 68000 where the floating registers (of the 68881) keep more | |
3229 | precision than a @code{double} is supposed to have. Similarly for the | |
3230 | x86 architecture. For most programs, the excess precision does only | |
3231 | good, but a few programs rely on the precise definition of IEEE floating | |
630d3d5a | 3232 | point. Use @option{-ffloat-store} for such programs, after modifying |
6fd74494 | 3233 | them to store all pertinent intermediate computations into variables. |
74291a4b MM |
3234 | |
3235 | @item -fno-default-inline | |
cd3bb277 | 3236 | @opindex fno-default-inline |
74291a4b MM |
3237 | Do not make member functions inline by default merely because they are |
3238 | defined inside the class scope (C++ only). Otherwise, when you specify | |
630d3d5a | 3239 | @w{@option{-O}}, member functions defined inside class scope are compiled |
74291a4b MM |
3240 | inline by default; i.e., you don't need to add @samp{inline} in front of |
3241 | the member function name. | |
3242 | ||
3243 | @item -fno-defer-pop | |
cd3bb277 | 3244 | @opindex fno-defer-pop |
74291a4b MM |
3245 | Always pop the arguments to each function call as soon as that function |
3246 | returns. For machines which must pop arguments after a function call, | |
3247 | the compiler normally lets arguments accumulate on the stack for several | |
3248 | function calls and pops them all at once. | |
3249 | ||
3250 | @item -fforce-mem | |
cd3bb277 | 3251 | @opindex fforce-mem |
74291a4b MM |
3252 | Force memory operands to be copied into registers before doing |
3253 | arithmetic on them. This produces better code by making all memory | |
3254 | references potential common subexpressions. When they are not common | |
3255 | subexpressions, instruction combination should eliminate the separate | |
630d3d5a | 3256 | register-load. The @option{-O2} option turns on this option. |
74291a4b MM |
3257 | |
3258 | @item -fforce-addr | |
cd3bb277 | 3259 | @opindex fforce-addr |
74291a4b MM |
3260 | Force memory address constants to be copied into registers before |
3261 | doing arithmetic on them. This may produce better code just as | |
630d3d5a | 3262 | @option{-fforce-mem} may. |
74291a4b MM |
3263 | |
3264 | @item -fomit-frame-pointer | |
cd3bb277 | 3265 | @opindex fomit-frame-pointer |
74291a4b MM |
3266 | Don't keep the frame pointer in a register for functions that |
3267 | don't need one. This avoids the instructions to save, set up and | |
3268 | restore frame pointers; it also makes an extra register available | |
3269 | in many functions. @strong{It also makes debugging impossible on | |
3270 | some machines.} | |
3271 | ||
3272 | @ifset INTERNALS | |
3273 | On some machines, such as the Vax, this flag has no effect, because | |
3274 | the standard calling sequence automatically handles the frame pointer | |
3275 | and nothing is saved by pretending it doesn't exist. The | |
3276 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
bd819a4a | 3277 | whether a target machine supports this flag. @xref{Registers}. |
74291a4b MM |
3278 | @end ifset |
3279 | @ifclear INTERNALS | |
3280 | On some machines, such as the Vax, this flag has no effect, because | |
3281 | the standard calling sequence automatically handles the frame pointer | |
3282 | and nothing is saved by pretending it doesn't exist. The | |
3283 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
3284 | whether a target machine supports this flag. @xref{Registers,,Register | |
bd819a4a | 3285 | Usage, gcc.info, Using and Porting GCC}. |
74291a4b MM |
3286 | @end ifclear |
3287 | ||
1aaef9c1 | 3288 | @item -foptimize-sibling-calls |
cd3bb277 | 3289 | @opindex foptimize-sibling-calls |
1aaef9c1 JH |
3290 | Optimize sibling and tail recursive calls. |
3291 | ||
91ce572a | 3292 | @item -ftrapv |
cd3bb277 | 3293 | @opindex ftrapv |
91ce572a CC |
3294 | This option generates traps for signed overflow on addition, subtraction, |
3295 | multiplication operations. | |
3296 | ||
74291a4b | 3297 | @item -fno-inline |
cd3bb277 | 3298 | @opindex fno-inline |
74291a4b MM |
3299 | Don't pay attention to the @code{inline} keyword. Normally this option |
3300 | is used to keep the compiler from expanding any functions inline. | |
3301 | Note that if you are not optimizing, no functions can be expanded inline. | |
3302 | ||
3303 | @item -finline-functions | |
cd3bb277 | 3304 | @opindex finline-functions |
74291a4b MM |
3305 | Integrate all simple functions into their callers. The compiler |
3306 | heuristically decides which functions are simple enough to be worth | |
3307 | integrating in this way. | |
3308 | ||
3309 | If all calls to a given function are integrated, and the function is | |
3310 | declared @code{static}, then the function is normally not output as | |
3311 | assembler code in its own right. | |
3312 | ||
efa3896a | 3313 | @item -finline-limit=@var{n} |
cd3bb277 | 3314 | @opindex finline-limit |
f9e814f1 TP |
3315 | By default, gcc limits the size of functions that can be inlined. This flag |
3316 | allows the control of this limit for functions that are explicitly marked as | |
02f52e19 AJ |
3317 | inline (ie marked with the inline keyword or defined within the class |
3318 | definition in c++). @var{n} is the size of functions that can be inlined in | |
f9e814f1 | 3319 | number of pseudo instructions (not counting parameter handling). The default |
aee96fe9 | 3320 | value of @var{n} is 10000. Increasing this value can result in more inlined code at |
f9e814f1 | 3321 | the cost of compilation time and memory consumption. Decreasing usually makes |
02f52e19 AJ |
3322 | the compilation faster and less code will be inlined (which presumably |
3323 | means slower programs). This option is particularly useful for programs that | |
aee96fe9 | 3324 | use inlining heavily such as those based on recursive templates with C++. |
f9e814f1 TP |
3325 | |
3326 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
3327 | abstract measurement of function's size. In no way, it represents a count | |
3328 | of assembly instructions and as such its exact meaning might change from one | |
3329 | release to an another. | |
3330 | ||
74291a4b | 3331 | @item -fkeep-inline-functions |
cd3bb277 | 3332 | @opindex fkeep-inline-functions |
74291a4b MM |
3333 | Even if all calls to a given function are integrated, and the function |
3334 | is declared @code{static}, nevertheless output a separate run-time | |
3335 | callable version of the function. This switch does not affect | |
3336 | @code{extern inline} functions. | |
3337 | ||
3338 | @item -fkeep-static-consts | |
cd3bb277 | 3339 | @opindex fkeep-static-consts |
74291a4b MM |
3340 | Emit variables declared @code{static const} when optimization isn't turned |
3341 | on, even if the variables aren't referenced. | |
3342 | ||
0c2d1a2a | 3343 | GCC enables this option by default. If you want to force the compiler to |
74291a4b | 3344 | check if the variable was referenced, regardless of whether or not |
630d3d5a | 3345 | optimization is turned on, use the @option{-fno-keep-static-consts} option. |
74291a4b MM |
3346 | |
3347 | @item -fno-function-cse | |
cd3bb277 | 3348 | @opindex fno-function-cse |
74291a4b MM |
3349 | Do not put function addresses in registers; make each instruction that |
3350 | calls a constant function contain the function's address explicitly. | |
3351 | ||
3352 | This option results in less efficient code, but some strange hacks | |
3353 | that alter the assembler output may be confused by the optimizations | |
3354 | performed when this option is not used. | |
3355 | ||
3356 | @item -ffast-math | |
cd3bb277 | 3357 | @opindex ffast-math |
630d3d5a JM |
3358 | Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, |
3359 | and @option{-fno-trapping-math}. | |
de6c5979 | 3360 | |
630d3d5a | 3361 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. |
74291a4b | 3362 | |
630d3d5a | 3363 | This option should never be turned on by any @option{-O} option since |
74291a4b | 3364 | it can result in incorrect output for programs which depend on |
c1030c7c | 3365 | an exact implementation of IEEE or ISO rules/specifications for |
74291a4b | 3366 | math functions. |
9605da8a BL |
3367 | |
3368 | @item -fno-math-errno | |
cd3bb277 | 3369 | @opindex fno-math-errno |
9605da8a BL |
3370 | Do not set ERRNO after calling math functions that are executed |
3371 | with a single instruction, e.g., sqrt. A program that relies on | |
3372 | IEEE exceptions for math error handling may want to use this flag | |
3373 | for speed while maintaining IEEE arithmetic compatibility. | |
3374 | ||
630d3d5a | 3375 | This option should never be turned on by any @option{-O} option since |
de6c5979 BL |
3376 | it can result in incorrect output for programs which depend on |
3377 | an exact implementation of IEEE or ISO rules/specifications for | |
3378 | math functions. | |
3379 | ||
630d3d5a JM |
3380 | The default is @option{-fmath-errno}. The @option{-ffast-math} option |
3381 | sets @option{-fno-math-errno}. | |
de6c5979 BL |
3382 | |
3383 | @item -funsafe-math-optimizations | |
cd3bb277 | 3384 | @opindex funsafe-math-optimizations |
de6c5979 BL |
3385 | Allow optimizations for floating-point arithmetic that (a) assume |
3386 | that arguments and results are valid and (b) may violate IEEE or | |
237b14f7 RH |
3387 | ANSI standards. When used at link-time, it may include libraries |
3388 | or startup files that change the default FPU control word or other | |
3389 | similar optimizations. | |
de6c5979 | 3390 | |
630d3d5a | 3391 | This option should never be turned on by any @option{-O} option since |
de6c5979 BL |
3392 | it can result in incorrect output for programs which depend on |
3393 | an exact implementation of IEEE or ISO rules/specifications for | |
3394 | math functions. | |
3395 | ||
630d3d5a JM |
3396 | The default is @option{-fno-unsafe-math-optimizations}. The |
3397 | @option{-ffast-math} option sets @option{-funsafe-math-optimizations}. | |
de6c5979 BL |
3398 | |
3399 | @item -fno-trapping-math | |
cd3bb277 | 3400 | @opindex fno-trapping-math |
de6c5979 BL |
3401 | Compile code assuming that floating-point operations cannot generate |
3402 | user-visible traps. Setting this option may allow faster code | |
3403 | if one relies on ``non-stop'' IEEE arithmetic, for example. | |
3404 | ||
630d3d5a | 3405 | This option should never be turned on by any @option{-O} option since |
de6c5979 BL |
3406 | it can result in incorrect output for programs which depend on |
3407 | an exact implementation of IEEE or ISO rules/specifications for | |
3408 | math functions. | |
3409 | ||
630d3d5a JM |
3410 | The default is @option{-ftrapping-math}. The @option{-ffast-math} |
3411 | option sets @option{-fno-trapping-math}. | |
74291a4b MM |
3412 | @end table |
3413 | ||
3414 | @c following causes underfulls.. they don't look great, but we deal. | |
3415 | @c --mew 26jan93 | |
630d3d5a JM |
3416 | The following options control specific optimizations. The @option{-O2} |
3417 | option turns on all of these optimizations except @option{-funroll-loops} | |
3418 | and @option{-funroll-all-loops}. On most machines, the @option{-O} option | |
3419 | turns on the @option{-fthread-jumps} and @option{-fdelayed-branch} options, | |
74291a4b MM |
3420 | but specific machines may handle it differently. |
3421 | ||
3422 | You can use the following flags in the rare cases when ``fine-tuning'' | |
3423 | of optimizations to be performed is desired. | |
3424 | ||
2642624b | 3425 | @table @gcctabopt |
74291a4b | 3426 | @item -fstrength-reduce |
cd3bb277 | 3427 | @opindex fstrength-reduce |
74291a4b MM |
3428 | Perform the optimizations of loop strength reduction and |
3429 | elimination of iteration variables. | |
3430 | ||
3431 | @item -fthread-jumps | |
cd3bb277 | 3432 | @opindex fthread-jumps |
74291a4b MM |
3433 | Perform optimizations where we check to see if a jump branches to a |
3434 | location where another comparison subsumed by the first is found. If | |
3435 | so, the first branch is redirected to either the destination of the | |
3436 | second branch or a point immediately following it, depending on whether | |
3437 | the condition is known to be true or false. | |
3438 | ||
3439 | @item -fcse-follow-jumps | |
cd3bb277 | 3440 | @opindex fcse-follow-jumps |
74291a4b MM |
3441 | In common subexpression elimination, scan through jump instructions |
3442 | when the target of the jump is not reached by any other path. For | |
3443 | example, when CSE encounters an @code{if} statement with an | |
3444 | @code{else} clause, CSE will follow the jump when the condition | |
3445 | tested is false. | |
3446 | ||
3447 | @item -fcse-skip-blocks | |
cd3bb277 | 3448 | @opindex fcse-skip-blocks |
630d3d5a | 3449 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
74291a4b MM |
3450 | follow jumps which conditionally skip over blocks. When CSE |
3451 | encounters a simple @code{if} statement with no else clause, | |
630d3d5a | 3452 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the |
74291a4b MM |
3453 | body of the @code{if}. |
3454 | ||
3455 | @item -frerun-cse-after-loop | |
cd3bb277 | 3456 | @opindex frerun-cse-after-loop |
74291a4b MM |
3457 | Re-run common subexpression elimination after loop optimizations has been |
3458 | performed. | |
3459 | ||
6d6d0fa0 | 3460 | @item -frerun-loop-opt |
cd3bb277 | 3461 | @opindex frerun-loop-opt |
6d6d0fa0 JL |
3462 | Run the loop optimizer twice. |
3463 | ||
7506f491 | 3464 | @item -fgcse |
cd3bb277 | 3465 | @opindex fgcse |
7506f491 DE |
3466 | Perform a global common subexpression elimination pass. |
3467 | This pass also performs global constant and copy propagation. | |
3468 | ||
081ca317 BL |
3469 | @emph{Note:} When compiling a program using computed gotos, a GCC |
3470 | extension, you may get better runtime performance if you disable | |
3471 | the global common subexpression elmination pass by adding | |
3472 | @option{-fno-gcse} to the command line. | |
3473 | ||
a13d4ebf | 3474 | @item -fgcse-lm |
cd3bb277 | 3475 | @opindex fgcse-lm |
695ac33f | 3476 | When @option{-fgcse-lm} is enabled, global common subexpression elimination will |
767094dd | 3477 | attempt to move loads which are only killed by stores into themselves. This |
a13d4ebf | 3478 | allows a loop containing a load/store sequence to be changed to a load outside |
02f52e19 | 3479 | the loop, and a copy/store within the loop. |
a13d4ebf AM |
3480 | |
3481 | @item -fgcse-sm | |
cd3bb277 | 3482 | @opindex fgcse-sm |
695ac33f | 3483 | When @option{-fgcse-sm} is enabled, A store motion pass is run after global common |
767094dd | 3484 | subexpression elimination. This pass will attempt to move stores out of loops. |
695ac33f | 3485 | When used in conjunction with @option{-fgcse-lm}, loops containing a load/store sequence |
a13d4ebf AM |
3486 | can be changed to a load before the loop and a store after the loop. |
3487 | ||
b6d24183 | 3488 | @item -fdelete-null-pointer-checks |
cd3bb277 | 3489 | @opindex fdelete-null-pointer-checks |
b6d24183 JL |
3490 | Use global dataflow analysis to identify and eliminate useless null |
3491 | pointer checks. Programs which rely on NULL pointer dereferences @emph{not} | |
3492 | halting the program may not work properly with this option. Use | |
aee96fe9 | 3493 | @option{-fno-delete-null-pointer-checks} to disable this optimizing for programs |
b6d24183 JL |
3494 | which depend on that behavior. |
3495 | ||
74291a4b | 3496 | @item -fexpensive-optimizations |
cd3bb277 | 3497 | @opindex fexpensive-optimizations |
74291a4b MM |
3498 | Perform a number of minor optimizations that are relatively expensive. |
3499 | ||
639726ba | 3500 | @item -foptimize-register-move |
59d40964 | 3501 | @itemx -fregmove |
cd3bb277 JM |
3502 | @opindex foptimize-register-move |
3503 | @opindex fregmove | |
9ec36da5 JL |
3504 | Attempt to reassign register numbers in move instructions and as |
3505 | operands of other simple instructions in order to maximize the amount of | |
56159047 | 3506 | register tying. This is especially helpful on machines with two-operand |
630d3d5a | 3507 | instructions. GCC enables this optimization by default with @option{-O2} |
9ec36da5 JL |
3508 | or higher. |
3509 | ||
bedc7537 | 3510 | Note @option{-fregmove} and @option{-foptimize-register-move} are the same |
9ec36da5 JL |
3511 | optimization. |
3512 | ||
74291a4b | 3513 | @item -fdelayed-branch |
cd3bb277 | 3514 | @opindex fdelayed-branch |
74291a4b MM |
3515 | If supported for the target machine, attempt to reorder instructions |
3516 | to exploit instruction slots available after delayed branch | |
3517 | instructions. | |
3518 | ||
3519 | @item -fschedule-insns | |
cd3bb277 | 3520 | @opindex fschedule-insns |
74291a4b MM |
3521 | If supported for the target machine, attempt to reorder instructions to |
3522 | eliminate execution stalls due to required data being unavailable. This | |
3523 | helps machines that have slow floating point or memory load instructions | |
3524 | by allowing other instructions to be issued until the result of the load | |
3525 | or floating point instruction is required. | |
3526 | ||
3527 | @item -fschedule-insns2 | |
cd3bb277 | 3528 | @opindex fschedule-insns2 |
630d3d5a | 3529 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
74291a4b MM |
3530 | instruction scheduling after register allocation has been done. This is |
3531 | especially useful on machines with a relatively small number of | |
3532 | registers and where memory load instructions take more than one cycle. | |
3533 | ||
3534 | @item -ffunction-sections | |
59d40964 | 3535 | @itemx -fdata-sections |
cd3bb277 JM |
3536 | @opindex ffunction-sections |
3537 | @opindex fdata-sections | |
7d0756fb CM |
3538 | Place each function or data item into its own section in the output |
3539 | file if the target supports arbitrary sections. The name of the | |
3540 | function or the name of the data item determines the section's name | |
3541 | in the output file. | |
74291a4b | 3542 | |
7d0756fb | 3543 | Use these options on systems where the linker can perform optimizations |
74291a4b MM |
3544 | to improve locality of reference in the instruction space. HPPA |
3545 | processors running HP-UX and Sparc processors running Solaris 2 have | |
3546 | linkers with such optimizations. Other systems using the ELF object format | |
3547 | as well as AIX may have these optimizations in the future. | |
3548 | ||
7d0756fb CM |
3549 | Only use these options when there are significant benefits from doing |
3550 | so. When you specify these options, the assembler and linker will | |
74291a4b MM |
3551 | create larger object and executable files and will also be slower. |
3552 | You will not be able to use @code{gprof} on all systems if you | |
3553 | specify this option and you may have problems with debugging if | |
630d3d5a | 3554 | you specify both this option and @option{-g}. |
74291a4b MM |
3555 | |
3556 | @item -fcaller-saves | |
cd3bb277 | 3557 | @opindex fcaller-saves |
74291a4b MM |
3558 | Enable values to be allocated in registers that will be clobbered by |
3559 | function calls, by emitting extra instructions to save and restore the | |
3560 | registers around such calls. Such allocation is done only when it | |
3561 | seems to result in better code than would otherwise be produced. | |
3562 | ||
81610a0d HPN |
3563 | This option is always enabled by default on certain machines, usually |
3564 | those which have no call-preserved registers to use instead. | |
3565 | ||
3566 | For all machines, optimization level 2 and higher enables this flag by | |
3567 | default. | |
74291a4b MM |
3568 | |
3569 | @item -funroll-loops | |
cd3bb277 | 3570 | @opindex funroll-loops |
74291a4b MM |
3571 | Perform the optimization of loop unrolling. This is only done for loops |
3572 | whose number of iterations can be determined at compile time or run time. | |
630d3d5a JM |
3573 | @option{-funroll-loops} implies both @option{-fstrength-reduce} and |
3574 | @option{-frerun-cse-after-loop}. | |
74291a4b MM |
3575 | |
3576 | @item -funroll-all-loops | |
cd3bb277 | 3577 | @opindex funroll-all-loops |
74291a4b | 3578 | Perform the optimization of loop unrolling. This is done for all loops |
630d3d5a JM |
3579 | and usually makes programs run more slowly. @option{-funroll-all-loops} |
3580 | implies @option{-fstrength-reduce} as well as @option{-frerun-cse-after-loop}. | |
74291a4b | 3581 | |
e5eb27e5 | 3582 | @item -fmove-all-movables |
cd3bb277 | 3583 | @opindex fmove-all-movables |
e5eb27e5 JL |
3584 | Forces all invariant computations in loops to be moved |
3585 | outside the loop. | |
3586 | ||
3587 | @item -freduce-all-givs | |
cd3bb277 | 3588 | @opindex freduce-all-givs |
e5eb27e5 JL |
3589 | Forces all general-induction variables in loops to be |
3590 | strength-reduced. | |
3591 | ||
3592 | @emph{Note:} When compiling programs written in Fortran, | |
630d3d5a | 3593 | @option{-fmove-all-movables} and @option{-freduce-all-givs} are enabled |
e5eb27e5 JL |
3594 | by default when you use the optimizer. |
3595 | ||
3596 | These options may generate better or worse code; results are highly | |
3597 | dependent on the structure of loops within the source code. | |
3598 | ||
3599 | These two options are intended to be removed someday, once | |
3600 | they have helped determine the efficacy of various | |
3601 | approaches to improving loop optimizations. | |
3602 | ||
2642624b | 3603 | Please let us (@w{@email{gcc@@gcc.gnu.org}} and @w{@email{fortran@@gnu.org}}) |
e5eb27e5 JL |
3604 | know how use of these options affects |
3605 | the performance of your production code. | |
3606 | We're very interested in code that runs @emph{slower} | |
3607 | when these options are @emph{enabled}. | |
3608 | ||
74291a4b | 3609 | @item -fno-peephole |
6cfc0341 | 3610 | @itemx -fno-peephole2 |
cd3bb277 | 3611 | @opindex fno-peephole |
6cfc0341 RH |
3612 | @opindex fno-peephole2 |
3613 | Disable any machine-specific peephole optimizations. The difference | |
630d3d5a | 3614 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they |
6cfc0341 RH |
3615 | are implemented in the compiler; some targets use one, some use the |
3616 | other, a few use both. | |
861bb6c1 JL |
3617 | |
3618 | @item -fbranch-probabilities | |
cd3bb277 | 3619 | @opindex fbranch-probabilities |
630d3d5a | 3620 | After running a program compiled with @option{-fprofile-arcs} |
861bb6c1 | 3621 | (@pxref{Debugging Options,, Options for Debugging Your Program or |
bedc7537 | 3622 | @command{gcc}}), you can compile it a second time using |
630d3d5a | 3623 | @option{-fbranch-probabilities}, to improve optimizations based on |
861bb6c1 JL |
3624 | guessing the path a branch might take. |
3625 | ||
3626 | @ifset INTERNALS | |
630d3d5a | 3627 | With @option{-fbranch-probabilities}, GCC puts a @samp{REG_EXEC_COUNT} |
861bb6c1 JL |
3628 | note on the first instruction of each basic block, and a |
3629 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
3630 | These can be used to improve optimization. Currently, they are only | |
3631 | used in one place: in @file{reorg.c}, instead of guessing which path a | |
3632 | branch is mostly to take, the @samp{REG_BR_PROB} values are used to | |
3633 | exactly determine which path is taken more often. | |
3634 | @end ifset | |
8c660648 | 3635 | |
454d0cc7 | 3636 | @item -fno-guess-branch-probability |
cd3bb277 | 3637 | @opindex fno-guess-branch-probability |
454d0cc7 | 3638 | Sometimes gcc will opt to guess branch probabilities when none are |
630d3d5a | 3639 | available from either profile directed feedback (@option{-fprofile-arcs}) |
2bab2366 | 3640 | or @samp{__builtin_expect}. In a hard real-time system, people don't |
454d0cc7 AH |
3641 | want different runs of the compiler to produce code that has different |
3642 | behavior; minimizing non-determinism is of paramount import. This | |
3643 | switch allows users to reduce non-determinism, possibly at the expense | |
3644 | of inferior optimization. | |
3645 | ||
41472af8 | 3646 | @item -fstrict-aliasing |
cd3bb277 | 3647 | @opindex fstrict-aliasing |
41472af8 MM |
3648 | Allows the compiler to assume the strictest aliasing rules applicable to |
3649 | the language being compiled. For C (and C++), this activates | |
3650 | optimizations based on the type of expressions. In particular, an | |
3651 | object of one type is assumed never to reside at the same address as an | |
3652 | object of a different type, unless the types are almost the same. For | |
3653 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
3654 | @code{void*} or a @code{double}. A character type may alias any other | |
02f52e19 | 3655 | type. |
41472af8 MM |
3656 | |
3657 | Pay special attention to code like this: | |
3658 | @example | |
02f52e19 | 3659 | union a_union @{ |
41472af8 MM |
3660 | int i; |
3661 | double d; | |
3662 | @}; | |
3663 | ||
3664 | int f() @{ | |
3665 | a_union t; | |
3666 | t.d = 3.0; | |
3667 | return t.i; | |
3668 | @} | |
3669 | @end example | |
3670 | The practice of reading from a different union member than the one most | |
3671 | recently written to (called ``type-punning'') is common. Even with | |
630d3d5a | 3672 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory |
41472af8 MM |
3673 | is accessed through the union type. So, the code above will work as |
3674 | expected. However, this code might not: | |
3675 | @example | |
02f52e19 | 3676 | int f() @{ |
41472af8 MM |
3677 | a_union t; |
3678 | int* ip; | |
3679 | t.d = 3.0; | |
3680 | ip = &t.i; | |
3681 | return *ip; | |
3682 | @} | |
3683 | @end example | |
3684 | ||
41472af8 MM |
3685 | @ifset INTERNALS |
3686 | Every language that wishes to perform language-specific alias analysis | |
3687 | should define a function that computes, given an @code{tree} | |
3688 | node, an alias set for the node. Nodes in different alias sets are not | |
3689 | allowed to alias. For an example, see the C front-end function | |
3690 | @code{c_get_alias_set}. | |
3691 | @end ifset | |
3692 | ||
efa3896a GK |
3693 | @item -falign-functions |
3694 | @itemx -falign-functions=@var{n} | |
cd3bb277 | 3695 | @opindex falign-functions |
efa3896a GK |
3696 | Align the start of functions to the next power-of-two greater than |
3697 | @var{n}, skipping up to @var{n} bytes. For instance, | |
630d3d5a JM |
3698 | @option{-falign-functions=32} aligns functions to the next 32-byte |
3699 | boundary, but @option{-falign-functions=24} would align to the next | |
efa3896a GK |
3700 | 32-byte boundary only if this can be done by skipping 23 bytes or less. |
3701 | ||
630d3d5a | 3702 | @option{-fno-align-functions} and @option{-falign-functions=1} are |
efa3896a GK |
3703 | equivalent and mean that functions will not be aligned. |
3704 | ||
3705 | Some assemblers only support this flag when @var{n} is a power of two; | |
3706 | in that case, it is rounded up. | |
3707 | ||
3708 | If @var{n} is not specified, use a machine-dependent default. | |
3709 | ||
3710 | @item -falign-labels | |
3711 | @itemx -falign-labels=@var{n} | |
cd3bb277 | 3712 | @opindex falign-labels |
efa3896a | 3713 | Align all branch targets to a power-of-two boundary, skipping up to |
630d3d5a | 3714 | @var{n} bytes like @option{-falign-functions}. This option can easily |
efa3896a GK |
3715 | make code slower, because it must insert dummy operations for when the |
3716 | branch target is reached in the usual flow of the code. | |
3717 | ||
630d3d5a | 3718 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and |
efa3896a GK |
3719 | are greater than this value, then their values are used instead. |
3720 | ||
3721 | If @var{n} is not specified, use a machine-dependent default which is | |
3722 | very likely to be @samp{1}, meaning no alignment. | |
3723 | ||
3724 | @item -falign-loops | |
3725 | @itemx -falign-loops=@var{n} | |
cd3bb277 | 3726 | @opindex falign-loops |
efa3896a | 3727 | Align loops to a power-of-two boundary, skipping up to @var{n} bytes |
630d3d5a | 3728 | like @option{-falign-functions}. The hope is that the loop will be |
efa3896a GK |
3729 | executed many times, which will make up for any execution of the dummy |
3730 | operations. | |
3731 | ||
3732 | If @var{n} is not specified, use a machine-dependent default. | |
3733 | ||
3734 | @item -falign-jumps | |
3735 | @itemx -falign-jumps=@var{n} | |
cd3bb277 | 3736 | @opindex falign-jumps |
efa3896a GK |
3737 | Align branch targets to a power-of-two boundary, for branch targets |
3738 | where the targets can only be reached by jumping, skipping up to @var{n} | |
630d3d5a | 3739 | bytes like @option{-falign-functions}. In this case, no dummy operations |
efa3896a GK |
3740 | need be executed. |
3741 | ||
3742 | If @var{n} is not specified, use a machine-dependent default. | |
3743 | ||
4bae0b47 | 3744 | @item -fssa |
cd3bb277 | 3745 | @opindex fssa |
4bae0b47 AS |
3746 | Perform optimizations in static single assignment form. Each function's |
3747 | flow graph is translated into SSA form, optimizations are performed, and | |
90ecce3e | 3748 | the flow graph is translated back from SSA form. Users should not |
b53978a3 JO |
3749 | specify this option, since it is not yet ready for production use. |
3750 | ||
0b47e4c1 JL |
3751 | @item -fssa-ccp |
3752 | @opindex fssa-ccp | |
3753 | Perform Sparse Conditional Constant Propagation in SSA form. Requires | |
3754 | @option{-fssa}. Like @option{-fssa}, this is an experimental feature. | |
3755 | ||
62d285ff JL |
3756 | @item -fssa-dce |
3757 | @opindex fssa-dce | |
3758 | Perform aggressive dead-code elimination in SSA form. Requires @option{-fssa}. | |
3759 | Like @option{-fssa}, this is an experimental feature. | |
4bae0b47 | 3760 | |
46d3a873 | 3761 | @item -fsingle-precision-constant |
cd3bb277 | 3762 | @opindex fsingle-precision-constant |
46d3a873 CC |
3763 | Treat floating point constant as single precision constant instead of |
3764 | implicitly converting it to double precision constant. | |
3765 | ||
2b2a8f1f | 3766 | @item -frename-registers |
cd3bb277 | 3767 | @opindex frename-registers |
c771326b | 3768 | Attempt to avoid false dependencies in scheduled code by making use |
2b2a8f1f RH |
3769 | of registers left over after register allocation. This optimization |
3770 | will most benefit processors with lots of registers. It can, however, | |
3771 | make debugging impossible, since variables will no longer stay in | |
3772 | a ``home register''. | |
3af64fd6 MM |
3773 | |
3774 | @item --param @var{name}=@var{value} | |
cd3bb277 | 3775 | @opindex param |
3af64fd6 MM |
3776 | In some places, GCC uses various constants to control the amount of |
3777 | optimization that is done. For example, GCC will not inline functions | |
3778 | that contain more that a certain number of instructions. You can | |
3779 | control some of these constants on the command-line using the | |
630d3d5a | 3780 | @option{--param} option. |
3af64fd6 MM |
3781 | |
3782 | In each case, the @var{value} is a integer. The allowable choices for | |
3783 | @var{name} are given in the following table: | |
3784 | ||
3785 | @table @gcctabopt | |
1c4c47db JO |
3786 | @item max-delay-slot-insn-search |
3787 | The maximum number of instructions to consider when looking for an | |
3788 | instruction to fill a delay slot. If more than this arbitrary number of | |
3789 | instructions is searched, the time savings from filling the delay slot | |
3790 | will be minimal so stop searching. Increasing values mean more | |
3791 | aggressive optimization, making the compile time increase with probably | |
3792 | small improvement in executable run time. | |
3793 | ||
3794 | @item max-delay-slot-live-search | |
3795 | When trying to fill delay slots, the maximum number of instructions to | |
3796 | consider when searching for a block with valid live register | |
3797 | information. Increasing this arbitrarily chosen value means more | |
3798 | aggressive optimization, increasing the compile time. This parameter | |
3799 | should be removed when the delay slot code is rewritten to maintain the | |
3800 | control-flow graph. | |
33d3b05b MM |
3801 | |
3802 | @item max-gcse-memory | |
3803 | The approximate maximum amount of memory that will be allocated in | |
3804 | order to perform the global common subexpression elimination | |
3805 | optimization. If more memory than specified is required, the | |
3806 | optimization will not be done. | |
3af64fd6 | 3807 | |
740f35a0 | 3808 | @item max-gcse-passes |
7dac2f89 | 3809 | The maximum number of passes of GCSE to run. |
740f35a0 | 3810 | |
4a121cc3 AM |
3811 | @item max-pending-list-length |
3812 | The maximum number of pending dependancies scheduling will allow | |
3813 | before flushing the current state and starting over. Large functions | |
3814 | with few branches or calls can create excessively large lists which | |
3815 | needlessly consume memory and resources. | |
3816 | ||
1c4c47db JO |
3817 | @item max-inline-insns |
3818 | If an function contains more than this many instructions, it | |
3819 | will not be inlined. This option is precisely equivalent to | |
630d3d5a | 3820 | @option{-finline-limit}. |
1c4c47db JO |
3821 | |
3822 | @end table | |
74291a4b MM |
3823 | @end table |
3824 | ||
3825 | @node Preprocessor Options | |
3826 | @section Options Controlling the Preprocessor | |
3827 | @cindex preprocessor options | |
3828 | @cindex options, preprocessor | |
3829 | ||
3830 | These options control the C preprocessor, which is run on each C source | |
3831 | file before actual compilation. | |
3832 | ||
630d3d5a JM |
3833 | If you use the @option{-E} option, nothing is done except preprocessing. |
3834 | Some of these options make sense only together with @option{-E} because | |
74291a4b MM |
3835 | they cause the preprocessor output to be unsuitable for actual |
3836 | compilation. | |
3837 | ||
2642624b | 3838 | @table @gcctabopt |
74291a4b | 3839 | @item -include @var{file} |
cd3bb277 | 3840 | @opindex include |
74291a4b | 3841 | Process @var{file} as input before processing the regular input file. |
630d3d5a JM |
3842 | In effect, the contents of @var{file} are compiled first. Any @option{-D} |
3843 | and @option{-U} options on the command line are always processed before | |
3844 | @option{-include @var{file}}, regardless of the order in which they are | |
3845 | written. All the @option{-include} and @option{-imacros} options are | |
74291a4b MM |
3846 | processed in the order in which they are written. |
3847 | ||
3848 | @item -imacros @var{file} | |
cd3bb277 | 3849 | @opindex imacros |
74291a4b MM |
3850 | Process @var{file} as input, discarding the resulting output, before |
3851 | processing the regular input file. Because the output generated from | |
630d3d5a | 3852 | @var{file} is discarded, the only effect of @option{-imacros @var{file}} |
74291a4b | 3853 | is to make the macros defined in @var{file} available for use in the |
630d3d5a | 3854 | main input. All the @option{-include} and @option{-imacros} options are |
e582248c | 3855 | processed in the order in which they are written. |
74291a4b MM |
3856 | |
3857 | @item -idirafter @var{dir} | |
cd3bb277 | 3858 | @opindex idirafter |
74291a4b MM |
3859 | @cindex second include path |
3860 | Add the directory @var{dir} to the second include path. The directories | |
3861 | on the second include path are searched when a header file is not found | |
3862 | in any of the directories in the main include path (the one that | |
630d3d5a | 3863 | @option{-I} adds to). |
74291a4b MM |
3864 | |
3865 | @item -iprefix @var{prefix} | |
cd3bb277 | 3866 | @opindex iprefix |
630d3d5a | 3867 | Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix} |
74291a4b MM |
3868 | options. |
3869 | ||
3870 | @item -iwithprefix @var{dir} | |
cd3bb277 | 3871 | @opindex iwithprefix |
74291a4b MM |
3872 | Add a directory to the second include path. The directory's name is |
3873 | made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was | |
630d3d5a | 3874 | specified previously with @option{-iprefix}. If you have not specified a |
74291a4b MM |
3875 | prefix yet, the directory containing the installed passes of the |
3876 | compiler is used as the default. | |
3877 | ||
3878 | @item -iwithprefixbefore @var{dir} | |
cd3bb277 | 3879 | @opindex iwithprefixbefore |
74291a4b MM |
3880 | Add a directory to the main include path. The directory's name is made |
3881 | by concatenating @var{prefix} and @var{dir}, as in the case of | |
630d3d5a | 3882 | @option{-iwithprefix}. |
74291a4b MM |
3883 | |
3884 | @item -isystem @var{dir} | |
cd3bb277 | 3885 | @opindex isystem |
74291a4b MM |
3886 | Add a directory to the beginning of the second include path, marking it |
3887 | as a system directory, so that it gets the same special treatment as | |
3888 | is applied to the standard system directories. | |
3889 | ||
3890 | @item -nostdinc | |
cd3bb277 | 3891 | @opindex nostdinc |
74291a4b | 3892 | Do not search the standard system directories for header files. Only |
630d3d5a | 3893 | the directories you have specified with @option{-I} options (and the |
74291a4b | 3894 | current directory, if appropriate) are searched. @xref{Directory |
630d3d5a | 3895 | Options}, for information on @option{-I}. |
74291a4b | 3896 | |
dfb5868d NS |
3897 | By using both @option{-nostdinc} and @option{-I-}, you can limit the include-file |
3898 | search path to only those directories you specify explicitly. | |
74291a4b | 3899 | |
e582248c | 3900 | @item -remap |
cd3bb277 | 3901 | @opindex remap |
e582248c NB |
3902 | When searching for a header file in a directory, remap file names if a |
3903 | file named @file{header.gcc} exists in that directory. This can be used | |
3904 | to work around limitations of file systems with file name restrictions. | |
3905 | The @file{header.gcc} file should contain a series of lines with two | |
3906 | tokens on each line: the first token is the name to map, and the second | |
3907 | token is the actual name to use. | |
3908 | ||
74291a4b | 3909 | @item -undef |
cd3bb277 | 3910 | @opindex undef |
74291a4b MM |
3911 | Do not predefine any nonstandard macros. (Including architecture flags). |
3912 | ||
3913 | @item -E | |
cd3bb277 | 3914 | @opindex E |
74291a4b MM |
3915 | Run only the C preprocessor. Preprocess all the C source files |
3916 | specified and output the results to standard output or to the | |
3917 | specified output file. | |
3918 | ||
3919 | @item -C | |
cd3bb277 | 3920 | @opindex C |
74291a4b | 3921 | Tell the preprocessor not to discard comments. Used with the |
630d3d5a | 3922 | @option{-E} option. |
74291a4b MM |
3923 | |
3924 | @item -P | |
cd3bb277 | 3925 | @opindex P |
74291a4b | 3926 | Tell the preprocessor not to generate @samp{#line} directives. |
630d3d5a | 3927 | Used with the @option{-E} option. |
74291a4b MM |
3928 | |
3929 | @cindex make | |
3930 | @cindex dependencies, make | |
3931 | @item -M | |
cd3bb277 | 3932 | @opindex M |
e582248c NB |
3933 | Instead of outputting the result of preprocessing, output a rule |
3934 | suitable for @code{make} describing the dependencies of the main source | |
3935 | file. The preprocessor outputs one @code{make} rule containing the | |
3936 | object file name for that source file, a colon, and the names of all the | |
48ce6bbb NS |
3937 | included files. Unless overridden explicitly, the object file name |
3938 | consists of the basename of the source file with any suffix replaced with | |
767094dd | 3939 | object file suffix. If there are many included files then the |
48ce6bbb | 3940 | rule is split into several lines using @samp{\}-newline. |
74291a4b | 3941 | |
630d3d5a | 3942 | @option{-M} implies @option{-E}. |
74291a4b | 3943 | |
e582248c | 3944 | @item -MM |
cd3bb277 | 3945 | @opindex MM |
630d3d5a | 3946 | Like @option{-M}, but mention only the files included with @samp{#include |
e582248c NB |
3947 | "@var{file}"}. System header files included with @samp{#include |
3948 | <@var{file}>} are omitted. | |
3949 | ||
7da723ef | 3950 | @item -MD |
cd3bb277 | 3951 | @opindex MD |
630d3d5a | 3952 | Like @option{-M} but the dependency information is written to a file |
7da723ef | 3953 | rather than stdout. @code{gcc} will use the same file name and |
695ac33f | 3954 | directory as the object file, but with the suffix @file{.d} instead. |
7da723ef | 3955 | |
630d3d5a JM |
3956 | This is in addition to compiling the main file as specified---@option{-MD} |
3957 | does not inhibit ordinary compilation the way @option{-M} does, | |
3958 | unless you also specify @option{-MG}. | |
7da723ef NB |
3959 | |
3960 | With Mach, you can use the utility @code{md} to merge multiple | |
3961 | dependency files into a single dependency file suitable for using with | |
3962 | the @samp{make} command. | |
3963 | ||
d396403a | 3964 | @item -MMD |
cd3bb277 | 3965 | @opindex MMD |
630d3d5a | 3966 | Like @option{-MD} except mention only user header files, not system |
7da723ef NB |
3967 | -header files. |
3968 | ||
e582248c | 3969 | @item -MF @var{file} |
cd3bb277 | 3970 | @opindex MF |
630d3d5a | 3971 | When used with @option{-M} or @option{-MM}, specifies a file to write the |
e582248c | 3972 | dependencies to. This allows the preprocessor to write the preprocessed |
630d3d5a | 3973 | file to stdout normally. If no @option{-MF} switch is given, CPP sends |
e582248c NB |
3974 | the rules to stdout and suppresses normal preprocessed output. |
3975 | ||
74291a4b | 3976 | Another way to specify output of a @code{make} rule is by setting |
bedc7537 | 3977 | the environment variable @env{DEPENDENCIES_OUTPUT} (@pxref{Environment |
74291a4b MM |
3978 | Variables}). |
3979 | ||
74291a4b | 3980 | @item -MG |
cd3bb277 | 3981 | @opindex MG |
630d3d5a | 3982 | When used with @option{-M} or @option{-MM}, @option{-MG} says to treat missing |
e582248c NB |
3983 | header files as generated files and assume they live in the same |
3984 | directory as the source file. It suppresses preprocessed output, as a | |
3985 | missing header file is ordinarily an error. | |
3986 | ||
3987 | This feature is used in automatic updating of makefiles. | |
3988 | ||
3989 | @item -MP | |
cd3bb277 | 3990 | @opindex MP |
e582248c NB |
3991 | This option instructs CPP to add a phony target for each dependency |
3992 | other than the main file, causing each to depend on nothing. These | |
3993 | dummy rules work around errors @code{make} gives if you remove header | |
3994 | files without updating the @code{Makefile} to match. | |
3995 | ||
3996 | This is typical output:- | |
3997 | ||
3998 | @smallexample | |
3999 | /tmp/test.o: /tmp/test.c /tmp/test.h | |
4000 | ||
4001 | /tmp/test.h: | |
4002 | @end smallexample | |
4003 | ||
4004 | @item -MQ @var{target} | |
4005 | @item -MT @var{target} | |
cd3bb277 JM |
4006 | @opindex MQ |
4007 | @opindex MT | |
e582248c NB |
4008 | By default CPP uses the main file name, including any path, and appends |
4009 | the object suffix, normally ``.o'', to it to obtain the name of the | |
630d3d5a | 4010 | target for dependency generation. With @option{-MT} you can specify a |
e582248c NB |
4011 | target yourself, overriding the default one. |
4012 | ||
4013 | If you want multiple targets, you can specify them as a single argument | |
630d3d5a | 4014 | to @option{-MT}, or use multiple @option{-MT} options. |
e582248c NB |
4015 | |
4016 | The targets you specify are output in the order they appear on the | |
630d3d5a JM |
4017 | command line. @option{-MQ} is identical to @option{-MT}, except that the |
4018 | target name is quoted for Make, but with @option{-MT} it isn't. For | |
4019 | example, @option{-MT '$(objpfx)foo.o'} gives | |
e582248c NB |
4020 | |
4021 | @smallexample | |
4022 | $(objpfx)foo.o: /tmp/foo.c | |
4023 | @end smallexample | |
4024 | ||
630d3d5a | 4025 | but @option{-MQ '$(objpfx)foo.o'} gives |
e582248c NB |
4026 | |
4027 | @smallexample | |
4028 | $$(objpfx)foo.o: /tmp/foo.c | |
4029 | @end smallexample | |
4030 | ||
4031 | The default target is automatically quoted, as if it were given with | |
630d3d5a | 4032 | @option{-MQ}. |
74291a4b MM |
4033 | |
4034 | @item -H | |
cd3bb277 | 4035 | @opindex H |
74291a4b MM |
4036 | Print the name of each header file used, in addition to other normal |
4037 | activities. | |
4038 | ||
4039 | @item -A@var{question}(@var{answer}) | |
cd3bb277 | 4040 | @opindex A |
74291a4b MM |
4041 | Assert the answer @var{answer} for @var{question}, in case it is tested |
4042 | with a preprocessing conditional such as @samp{#if | |
630d3d5a | 4043 | #@var{question}(@var{answer})}. @option{-A-} disables the standard |
74291a4b MM |
4044 | assertions that normally describe the target machine. |
4045 | ||
4046 | @item -D@var{macro} | |
cd3bb277 | 4047 | @opindex D |
74291a4b MM |
4048 | Define macro @var{macro} with the string @samp{1} as its definition. |
4049 | ||
4050 | @item -D@var{macro}=@var{defn} | |
630d3d5a JM |
4051 | Define macro @var{macro} as @var{defn}. All instances of @option{-D} on |
4052 | the command line are processed before any @option{-U} options. | |
74291a4b | 4053 | |
630d3d5a JM |
4054 | Any @option{-D} and @option{-U} options on the command line are processed in |
4055 | order, and always before @option{-imacros @var{file}}, regardless of the | |
e582248c NB |
4056 | order in which they are written. |
4057 | ||
74291a4b | 4058 | @item -U@var{macro} |
cd3bb277 | 4059 | @opindex U |
630d3d5a JM |
4060 | Undefine macro @var{macro}. @option{-U} options are evaluated after all |
4061 | @option{-D} options, but before any @option{-include} and @option{-imacros} | |
74291a4b MM |
4062 | options. |
4063 | ||
630d3d5a JM |
4064 | Any @option{-D} and @option{-U} options on the command line are processed in |
4065 | order, and always before @option{-imacros @var{file}}, regardless of the | |
e582248c NB |
4066 | order in which they are written. |
4067 | ||
74291a4b | 4068 | @item -dM |
cd3bb277 | 4069 | @opindex dM |
74291a4b | 4070 | Tell the preprocessor to output only a list of the macro definitions |
630d3d5a | 4071 | that are in effect at the end of preprocessing. Used with the @option{-E} |
74291a4b MM |
4072 | option. |
4073 | ||
4074 | @item -dD | |
cd3bb277 | 4075 | @opindex dD |
74291a4b MM |
4076 | Tell the preprocessing to pass all macro definitions into the output, in |
4077 | their proper sequence in the rest of the output. | |
4078 | ||
4079 | @item -dN | |
cd3bb277 | 4080 | @opindex dN |
630d3d5a | 4081 | Like @option{-dD} except that the macro arguments and contents are omitted. |
74291a4b MM |
4082 | Only @samp{#define @var{name}} is included in the output. |
4083 | ||
e582248c | 4084 | @item -dI |
cd3bb277 | 4085 | @opindex dI |
e582248c NB |
4086 | Output @samp{#include} directives in addition to the result of |
4087 | preprocessing. | |
4088 | ||
3bce8a01 NB |
4089 | @item -fpreprocessed |
4090 | @opindex fpreprocessed | |
4091 | Indicate to the preprocessor that the input file has already been | |
4092 | preprocessed. This suppresses things like macro expansion, trigraph | |
4093 | conversion, escaped newline splicing, and processing of most directives. | |
6d34c1c4 NB |
4094 | The preprocessor still recognizes and removes comments, so that you can |
4095 | pass a file preprocessed with @option{-C} to the compiler without | |
4096 | problems. In this mode the integrated preprocessor is little more than | |
4097 | a tokenizer for the front ends. | |
3bce8a01 | 4098 | |
630d3d5a | 4099 | @option{-fpreprocessed} is implicit if the input file has one of the |
6d34c1c4 NB |
4100 | extensions @samp{i}, @samp{ii} or @samp{mi}. These are the extensions |
4101 | that GCC uses for preprocessed files created by @option{-save-temps}. | |
3bce8a01 | 4102 | |
74291a4b | 4103 | @item -trigraphs |
cd3bb277 | 4104 | @opindex trigraphs |
e582248c NB |
4105 | Process ISO standard trigraph sequences. These are three-character |
4106 | sequences, all starting with @samp{??}, that are defined by ISO C to | |
4107 | stand for single characters. For example, @samp{??/} stands for | |
4108 | @samp{\}, so @samp{'??/n'} is a character constant for a newline. By | |
4109 | default, GCC ignores trigraphs, but in standard-conforming modes it | |
630d3d5a | 4110 | converts them. See the @option{-std} and @option{-ansi} options. |
e582248c NB |
4111 | |
4112 | The nine trigraph sequences are | |
4113 | @table @samp | |
4114 | @item ??( | |
aee96fe9 | 4115 | @expansion{} @samp{[} |
e582248c NB |
4116 | |
4117 | @item ??) | |
aee96fe9 | 4118 | @expansion{} @samp{]} |
e582248c NB |
4119 | |
4120 | @item ??< | |
aee96fe9 | 4121 | @expansion{} @samp{@{} |
e582248c NB |
4122 | |
4123 | @item ??> | |
aee96fe9 | 4124 | @expansion{} @samp{@}} |
e582248c NB |
4125 | |
4126 | @item ??= | |
aee96fe9 | 4127 | @expansion{} @samp{#} |
e582248c NB |
4128 | |
4129 | @item ??/ | |
aee96fe9 | 4130 | @expansion{} @samp{\} |
e582248c NB |
4131 | |
4132 | @item ??' | |
aee96fe9 | 4133 | @expansion{} @samp{^} |
e582248c NB |
4134 | |
4135 | @item ??! | |
aee96fe9 | 4136 | @expansion{} @samp{|} |
e582248c NB |
4137 | |
4138 | @item ??- | |
aee96fe9 | 4139 | @expansion{} @samp{~} |
e582248c NB |
4140 | |
4141 | @end table | |
4142 | ||
4143 | Trigraph support is not popular, so many compilers do not implement it | |
4144 | properly. Portable code should not rely on trigraphs being either | |
4145 | converted or ignored. | |
74291a4b | 4146 | |
aee96fe9 | 4147 | @item -Wp,@var{option} |
cd3bb277 | 4148 | @opindex Wp |
bedc7537 | 4149 | Pass @var{option} as an option to the preprocessor. If @var{option} |
74291a4b MM |
4150 | contains commas, it is split into multiple options at the commas. |
4151 | @end table | |
4152 | ||
4153 | @node Assembler Options | |
4154 | @section Passing Options to the Assembler | |
4155 | ||
4156 | @c prevent bad page break with this line | |
4157 | You can pass options to the assembler. | |
4158 | ||
2642624b | 4159 | @table @gcctabopt |
aee96fe9 | 4160 | @item -Wa,@var{option} |
cd3bb277 | 4161 | @opindex Wa |
74291a4b MM |
4162 | Pass @var{option} as an option to the assembler. If @var{option} |
4163 | contains commas, it is split into multiple options at the commas. | |
4164 | @end table | |
4165 | ||
4166 | @node Link Options | |
4167 | @section Options for Linking | |
4168 | @cindex link options | |
4169 | @cindex options, linking | |
4170 | ||
4171 | These options come into play when the compiler links object files into | |
4172 | an executable output file. They are meaningless if the compiler is | |
4173 | not doing a link step. | |
4174 | ||
2642624b | 4175 | @table @gcctabopt |
74291a4b MM |
4176 | @cindex file names |
4177 | @item @var{object-file-name} | |
4178 | A file name that does not end in a special recognized suffix is | |
4179 | considered to name an object file or library. (Object files are | |
4180 | distinguished from libraries by the linker according to the file | |
4181 | contents.) If linking is done, these object files are used as input | |
4182 | to the linker. | |
4183 | ||
4184 | @item -c | |
4185 | @itemx -S | |
4186 | @itemx -E | |
cd3bb277 JM |
4187 | @opindex c |
4188 | @opindex S | |
4189 | @opindex E | |
74291a4b MM |
4190 | If any of these options is used, then the linker is not run, and |
4191 | object file names should not be used as arguments. @xref{Overall | |
4192 | Options}. | |
4193 | ||
4194 | @cindex Libraries | |
4195 | @item -l@var{library} | |
4275c4c4 | 4196 | @itemx -l @var{library} |
cd3bb277 | 4197 | @opindex l |
4275c4c4 JS |
4198 | Search the library named @var{library} when linking. (The second |
4199 | alternative with the library as a separate argument is only for | |
4200 | POSIX compliance and is not recommended.) | |
74291a4b MM |
4201 | |
4202 | It makes a difference where in the command you write this option; the | |
4275c4c4 | 4203 | linker searches and processes libraries and object files in the order they |
74291a4b MM |
4204 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} |
4205 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
4206 | to functions in @samp{z}, those functions may not be loaded. | |
4207 | ||
4208 | The linker searches a standard list of directories for the library, | |
4209 | which is actually a file named @file{lib@var{library}.a}. The linker | |
4210 | then uses this file as if it had been specified precisely by name. | |
4211 | ||
4212 | The directories searched include several standard system directories | |
630d3d5a | 4213 | plus any that you specify with @option{-L}. |
74291a4b MM |
4214 | |
4215 | Normally the files found this way are library files---archive files | |
4216 | whose members are object files. The linker handles an archive file by | |
4217 | scanning through it for members which define symbols that have so far | |
4218 | been referenced but not defined. But if the file that is found is an | |
4219 | ordinary object file, it is linked in the usual fashion. The only | |
630d3d5a JM |
4220 | difference between using an @option{-l} option and specifying a file name |
4221 | is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a} | |
74291a4b MM |
4222 | and searches several directories. |
4223 | ||
4224 | @item -lobjc | |
cd3bb277 | 4225 | @opindex lobjc |
630d3d5a | 4226 | You need this special case of the @option{-l} option in order to |
2147b154 | 4227 | link an Objective-C program. |
74291a4b MM |
4228 | |
4229 | @item -nostartfiles | |
cd3bb277 | 4230 | @opindex nostartfiles |
74291a4b | 4231 | Do not use the standard system startup files when linking. |
bedc7537 NC |
4232 | The standard system libraries are used normally, unless @option{-nostdlib} |
4233 | or @option{-nodefaultlibs} is used. | |
74291a4b MM |
4234 | |
4235 | @item -nodefaultlibs | |
cd3bb277 | 4236 | @opindex nodefaultlibs |
74291a4b MM |
4237 | Do not use the standard system libraries when linking. |
4238 | Only the libraries you specify will be passed to the linker. | |
bedc7537 | 4239 | The standard startup files are used normally, unless @option{-nostartfiles} |
4754172c | 4240 | is used. The compiler may generate calls to memcmp, memset, and memcpy |
c1030c7c | 4241 | for System V (and ISO C) environments or to bcopy and bzero for |
4754172c CM |
4242 | BSD environments. These entries are usually resolved by entries in |
4243 | libc. These entry points should be supplied through some other | |
4244 | mechanism when this option is specified. | |
74291a4b MM |
4245 | |
4246 | @item -nostdlib | |
cd3bb277 | 4247 | @opindex nostdlib |
74291a4b MM |
4248 | Do not use the standard system startup files or libraries when linking. |
4249 | No startup files and only the libraries you specify will be passed to | |
767094dd | 4250 | the linker. The compiler may generate calls to memcmp, memset, and memcpy |
c1030c7c | 4251 | for System V (and ISO C) environments or to bcopy and bzero for |
4754172c CM |
4252 | BSD environments. These entries are usually resolved by entries in |
4253 | libc. These entry points should be supplied through some other | |
4254 | mechanism when this option is specified. | |
74291a4b | 4255 | |
630d3d5a JM |
4256 | @cindex @option{-lgcc}, use with @option{-nostdlib} |
4257 | @cindex @option{-nostdlib} and unresolved references | |
4258 | @cindex unresolved references and @option{-nostdlib} | |
4259 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
4260 | @cindex @option{-nodefaultlibs} and unresolved references | |
4261 | @cindex unresolved references and @option{-nodefaultlibs} | |
4262 | One of the standard libraries bypassed by @option{-nostdlib} and | |
4263 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
0c2d1a2a | 4264 | that GCC uses to overcome shortcomings of particular machines, or special |
74291a4b MM |
4265 | needs for some languages. |
4266 | @ifset INTERNALS | |
0c2d1a2a | 4267 | (@xref{Interface,,Interfacing to GCC Output}, for more discussion of |
74291a4b MM |
4268 | @file{libgcc.a}.) |
4269 | @end ifset | |
4270 | @ifclear INTERNALS | |
0c2d1a2a | 4271 | (@xref{Interface,,Interfacing to GCC Output,gcc.info,Porting GCC}, |
74291a4b MM |
4272 | for more discussion of @file{libgcc.a}.) |
4273 | @end ifclear | |
4274 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
630d3d5a JM |
4275 | other standard libraries. In other words, when you specify @option{-nostdlib} |
4276 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
0c2d1a2a | 4277 | This ensures that you have no unresolved references to internal GCC |
74291a4b | 4278 | library subroutines. (For example, @samp{__main}, used to ensure C++ |
bedc7537 | 4279 | constructors will be called; @pxref{Collect2,,@command{collect2}}.) |
74291a4b MM |
4280 | |
4281 | @item -s | |
cd3bb277 | 4282 | @opindex s |
74291a4b MM |
4283 | Remove all symbol table and relocation information from the executable. |
4284 | ||
4285 | @item -static | |
cd3bb277 | 4286 | @opindex static |
74291a4b MM |
4287 | On systems that support dynamic linking, this prevents linking with the shared |
4288 | libraries. On other systems, this option has no effect. | |
4289 | ||
4290 | @item -shared | |
cd3bb277 | 4291 | @opindex shared |
74291a4b | 4292 | Produce a shared object which can then be linked with other objects to |
1d3b0e2c | 4293 | form an executable. Not all systems support this option. For predictable |
02f52e19 | 4294 | results, you must also specify the same set of options that were used to |
630d3d5a | 4295 | generate code (@option{-fpic}, @option{-fPIC}, or model suboptions) |
2642624b | 4296 | when you specify this option.@footnote{On some systems, @samp{gcc -shared} |
767094dd | 4297 | needs to build supplementary stub code for constructors to work. On |
2642624b | 4298 | multi-libbed systems, @samp{gcc -shared} must select the correct support |
1d3b0e2c | 4299 | libraries to link against. Failing to supply the correct flags may lead |
767094dd | 4300 | to subtle defects. Supplying them in cases where they are not necessary |
1d3b0e2c | 4301 | is innocuous.} |
74291a4b | 4302 | |
9db0819e RH |
4303 | @item -shared-libgcc |
4304 | @itemx -static-libgcc | |
cd3bb277 JM |
4305 | @opindex shared-libgcc |
4306 | @opindex static-libgcc | |
9db0819e RH |
4307 | On systems that provide @file{libgcc} as a shared library, these options |
4308 | force the use of either the shared or static version respectively. | |
4309 | If no shared version of @file{libgcc} was built when the compiler was | |
4310 | configured, these options have no effect. | |
4311 | ||
4312 | There are several situations in which an application should use the | |
4313 | shared @file{libgcc} instead of the static version. The most common | |
4314 | of these is when the application wishes to throw and catch exceptions | |
4315 | across different shared libraries. In that case, each of the libraries | |
4316 | as well as the application itself should use the shared @file{libgcc}. | |
4317 | ||
630d3d5a JM |
4318 | Therefore, whenever you specify the @option{-shared} option, the GCC |
4319 | driver automatically adds @option{-shared-libgcc}, unless you explicitly | |
4320 | specify @option{-static-libgcc}. The G++ driver automatically adds | |
4321 | @option{-shared-libgcc} when you build a main executable as well because | |
049f6ec9 MM |
4322 | for C++ programs that is typically the right thing to do. |
4323 | (Exception-handling will not work reliably otherwise.) | |
4324 | ||
4325 | However, when linking a main executable written in C, you must | |
630d3d5a | 4326 | explicitly say @option{-shared-libgcc} if you want to use the shared |
049f6ec9 | 4327 | @file{libgcc}. |
9db0819e | 4328 | |
74291a4b | 4329 | @item -symbolic |
cd3bb277 | 4330 | @opindex symbolic |
74291a4b MM |
4331 | Bind references to global symbols when building a shared object. Warn |
4332 | about any unresolved references (unless overridden by the link editor | |
4333 | option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support | |
4334 | this option. | |
4335 | ||
4336 | @item -Xlinker @var{option} | |
cd3bb277 | 4337 | @opindex Xlinker |
74291a4b | 4338 | Pass @var{option} as an option to the linker. You can use this to |
0c2d1a2a | 4339 | supply system-specific linker options which GCC does not know how to |
74291a4b MM |
4340 | recognize. |
4341 | ||
4342 | If you want to pass an option that takes an argument, you must use | |
630d3d5a JM |
4343 | @option{-Xlinker} twice, once for the option and once for the argument. |
4344 | For example, to pass @option{-assert definitions}, you must write | |
74291a4b | 4345 | @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write |
630d3d5a | 4346 | @option{-Xlinker "-assert definitions"}, because this passes the entire |
74291a4b MM |
4347 | string as a single argument, which is not what the linker expects. |
4348 | ||
aee96fe9 | 4349 | @item -Wl,@var{option} |
cd3bb277 | 4350 | @opindex Wl |
74291a4b MM |
4351 | Pass @var{option} as an option to the linker. If @var{option} contains |
4352 | commas, it is split into multiple options at the commas. | |
4353 | ||
4354 | @item -u @var{symbol} | |
cd3bb277 | 4355 | @opindex u |
74291a4b | 4356 | Pretend the symbol @var{symbol} is undefined, to force linking of |
630d3d5a | 4357 | library modules to define it. You can use @option{-u} multiple times with |
74291a4b MM |
4358 | different symbols to force loading of additional library modules. |
4359 | @end table | |
4360 | ||
4361 | @node Directory Options | |
4362 | @section Options for Directory Search | |
4363 | @cindex directory options | |
4364 | @cindex options, directory search | |
4365 | @cindex search path | |
4366 | ||
4367 | These options specify directories to search for header files, for | |
4368 | libraries and for parts of the compiler: | |
4369 | ||
2642624b | 4370 | @table @gcctabopt |
74291a4b | 4371 | @item -I@var{dir} |
cd3bb277 | 4372 | @opindex I |
861bb6c1 JL |
4373 | Add the directory @var{dir} to the head of the list of directories to be |
4374 | searched for header files. This can be used to override a system header | |
4375 | file, substituting your own version, since these directories are | |
d0a5eb32 RK |
4376 | searched before the system header file directories. However, you should |
4377 | not use this option to add directories that contain vendor-supplied | |
767094dd | 4378 | system header files (use @option{-isystem} for that). If you use more than |
630d3d5a | 4379 | one @option{-I} option, the directories are scanned in left-to-right |
74291a4b MM |
4380 | order; the standard system directories come after. |
4381 | ||
dbead49c NS |
4382 | If a standard system include directory, or a directory specified with |
4383 | @option{-isystem}, is also specified with @option{-I}, it will be | |
4384 | searched only in the position requested by @option{-I}. Also, it will | |
4385 | not be considered a system include directory. If that directory really | |
4386 | does contain system headers, there is a good chance that they will | |
4387 | break. For instance, if GCC's installation procedure edited the headers | |
4388 | in @file{/usr/include} to fix bugs, @samp{-I/usr/include} will cause the | |
4389 | original, buggy headers to be found instead of the corrected ones. GCC | |
4390 | will issue a warning when a system include directory is hidden in this | |
4391 | way. | |
4392 | ||
74291a4b | 4393 | @item -I- |
cd3bb277 | 4394 | @opindex I- |
630d3d5a | 4395 | Any directories you specify with @option{-I} options before the @option{-I-} |
74291a4b MM |
4396 | option are searched only for the case of @samp{#include "@var{file}"}; |
4397 | they are not searched for @samp{#include <@var{file}>}. | |
4398 | ||
630d3d5a JM |
4399 | If additional directories are specified with @option{-I} options after |
4400 | the @option{-I-}, these directories are searched for all @samp{#include} | |
4401 | directives. (Ordinarily @emph{all} @option{-I} directories are used | |
74291a4b MM |
4402 | this way.) |
4403 | ||
630d3d5a | 4404 | In addition, the @option{-I-} option inhibits the use of the current |
74291a4b MM |
4405 | directory (where the current input file came from) as the first search |
4406 | directory for @samp{#include "@var{file}"}. There is no way to | |
630d3d5a | 4407 | override this effect of @option{-I-}. With @option{-I.} you can specify |
74291a4b MM |
4408 | searching the directory which was current when the compiler was |
4409 | invoked. That is not exactly the same as what the preprocessor does | |
4410 | by default, but it is often satisfactory. | |
4411 | ||
630d3d5a JM |
4412 | @option{-I-} does not inhibit the use of the standard system directories |
4413 | for header files. Thus, @option{-I-} and @option{-nostdinc} are | |
74291a4b MM |
4414 | independent. |
4415 | ||
4416 | @item -L@var{dir} | |
cd3bb277 | 4417 | @opindex L |
74291a4b | 4418 | Add directory @var{dir} to the list of directories to be searched |
630d3d5a | 4419 | for @option{-l}. |
74291a4b MM |
4420 | |
4421 | @item -B@var{prefix} | |
cd3bb277 | 4422 | @opindex B |
74291a4b MM |
4423 | This option specifies where to find the executables, libraries, |
4424 | include files, and data files of the compiler itself. | |
4425 | ||
4426 | The compiler driver program runs one or more of the subprograms | |
4427 | @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries | |
4428 | @var{prefix} as a prefix for each program it tries to run, both with and | |
4429 | without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}). | |
4430 | ||
4431 | For each subprogram to be run, the compiler driver first tries the | |
630d3d5a | 4432 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} |
74291a4b MM |
4433 | was not specified, the driver tries two standard prefixes, which are |
4434 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of | |
4435 | those results in a file name that is found, the unmodified program | |
4436 | name is searched for using the directories specified in your | |
bedc7537 | 4437 | @env{PATH} environment variable. |
74291a4b | 4438 | |
07804c3b NC |
4439 | The compiler will check to see if the path provided by the @option{-B} |
4440 | refers to a directory, and if necessary it will add a directory | |
4441 | separator character at the end of the path. | |
4442 | ||
630d3d5a | 4443 | @option{-B} prefixes that effectively specify directory names also apply |
74291a4b | 4444 | to libraries in the linker, because the compiler translates these |
630d3d5a | 4445 | options into @option{-L} options for the linker. They also apply to |
74291a4b | 4446 | includes files in the preprocessor, because the compiler translates these |
630d3d5a | 4447 | options into @option{-isystem} options for the preprocessor. In this case, |
74291a4b MM |
4448 | the compiler appends @samp{include} to the prefix. |
4449 | ||
4450 | The run-time support file @file{libgcc.a} can also be searched for using | |
630d3d5a | 4451 | the @option{-B} prefix, if needed. If it is not found there, the two |
74291a4b MM |
4452 | standard prefixes above are tried, and that is all. The file is left |
4453 | out of the link if it is not found by those means. | |
4454 | ||
630d3d5a | 4455 | Another way to specify a prefix much like the @option{-B} prefix is to use |
bedc7537 | 4456 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment |
74291a4b | 4457 | Variables}. |
861bb6c1 | 4458 | |
07804c3b | 4459 | As a special kludge, if the path provided by @option{-B} is |
bf4eebe0 NC |
4460 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to |
4461 | 9, then it will be replaced by @file{[dir/]include}. This is to help | |
7dac2f89 | 4462 | with boot-strapping the compiler. |
07804c3b | 4463 | |
861bb6c1 | 4464 | @item -specs=@var{file} |
cd3bb277 | 4465 | @opindex specs |
861bb6c1 JL |
4466 | Process @var{file} after the compiler reads in the standard @file{specs} |
4467 | file, in order to override the defaults that the @file{gcc} driver | |
4468 | program uses when determining what switches to pass to @file{cc1}, | |
4469 | @file{cc1plus}, @file{as}, @file{ld}, etc. More than one | |
630d3d5a | 4470 | @option{-specs=@var{file}} can be specified on the command line, and they |
861bb6c1 | 4471 | are processed in order, from left to right. |
74291a4b MM |
4472 | @end table |
4473 | ||
ee457005 JM |
4474 | @c man end |
4475 | ||
a743d340 NC |
4476 | @node Spec Files |
4477 | @section Specifying subprocesses and the switches to pass to them | |
4478 | @cindex Spec Files | |
bedc7537 | 4479 | @command{gcc} is a driver program. It performs its job by invoking a |
a743d340 NC |
4480 | sequence of other programs to do the work of compiling, assembling and |
4481 | linking. GCC interprets its command-line parameters and uses these to | |
4482 | deduce which programs it should invoke, and which command-line options | |
4483 | it ought to place on their command lines. This behaviour is controlled | |
4484 | by @dfn{spec strings}. In most cases there is one spec string for each | |
4485 | program that GCC can invoke, but a few programs have multiple spec | |
4486 | strings to control their behaviour. The spec strings built into GCC can | |
630d3d5a | 4487 | be overridden by using the @option{-specs=} command-line switch to specify |
a743d340 NC |
4488 | a spec file. |
4489 | ||
4490 | @dfn{Spec files} are plaintext files that are used to construct spec | |
4491 | strings. They consist of a sequence of directives separated by blank | |
4492 | lines. The type of directive is determined by the first non-whitespace | |
4493 | character on the line and it can be one of the following: | |
4494 | ||
4495 | @table @code | |
4496 | @item %@var{command} | |
4497 | Issues a @var{command} to the spec file processor. The commands that can | |
02f52e19 | 4498 | appear here are: |
a743d340 NC |
4499 | |
4500 | @table @code | |
4501 | @item %include <@var{file}> | |
4502 | @cindex %include | |
4503 | Search for @var{file} and insert its text at the current point in the | |
4504 | specs file. | |
4505 | ||
4506 | @item %include_noerr <@var{file}> | |
4507 | @cindex %include_noerr | |
4508 | Just like @samp{%include}, but do not generate an error message if the include | |
4509 | file cannot be found. | |
4510 | ||
4511 | @item %rename @var{old_name} @var{new_name} | |
4512 | @cindex %rename | |
4513 | Rename the spec string @var{old_name} to @var{new_name}. | |
4514 | ||
4515 | @end table | |
4516 | ||
4517 | @item *[@var{spec_name}]: | |
4518 | This tells the compiler to create, override or delete the named spec | |
4519 | string. All lines after this directive up to the next directive or | |
4520 | blank line are considered to be the text for the spec string. If this | |
4521 | results in an empty string then the spec will be deleted. (Or, if the | |
4522 | spec did not exist, then nothing will happened.) Otherwise, if the spec | |
4523 | does not currently exist a new spec will be created. If the spec does | |
4524 | exist then its contents will be overridden by the text of this | |
4525 | directive, unless the first character of that text is the @samp{+} | |
4526 | character, in which case the text will be appended to the spec. | |
4527 | ||
4528 | @item [@var{suffix}]: | |
4529 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
4530 | and up to the next directive or blank line are considered to make up the | |
02f52e19 | 4531 | spec string for the indicated suffix. When the compiler encounters an |
a743d340 NC |
4532 | input file with the named suffix, it will processes the spec string in |
4533 | order to work out how to compile that file. For example: | |
4534 | ||
4535 | @smallexample | |
4536 | .ZZ: | |
4537 | z-compile -input %i | |
4538 | @end smallexample | |
4539 | ||
4540 | This says that any input file whose name ends in @samp{.ZZ} should be | |
4541 | passed to the program @samp{z-compile}, which should be invoked with the | |
630d3d5a | 4542 | command-line switch @option{-input} and with the result of performing the |
a743d340 NC |
4543 | @samp{%i} substitution. (See below.) |
4544 | ||
4545 | As an alternative to providing a spec string, the text that follows a | |
4546 | suffix directive can be one of the following: | |
4547 | ||
4548 | @table @code | |
4549 | @item @@@var{language} | |
4550 | This says that the suffix is an alias for a known @var{language}. This is | |
bedc7537 | 4551 | similar to using the @option{-x} command-line switch to GCC to specify a |
a743d340 NC |
4552 | language explicitly. For example: |
4553 | ||
4554 | @smallexample | |
4555 | .ZZ: | |
4556 | @@c++ | |
4557 | @end smallexample | |
4558 | ||
4559 | Says that .ZZ files are, in fact, C++ source files. | |
4560 | ||
4561 | @item #@var{name} | |
4562 | This causes an error messages saying: | |
4563 | ||
4564 | @smallexample | |
4565 | @var{name} compiler not installed on this system. | |
4566 | @end smallexample | |
4567 | @end table | |
4568 | ||
4569 | GCC already has an extensive list of suffixes built into it. | |
4570 | This directive will add an entry to the end of the list of suffixes, but | |
4571 | since the list is searched from the end backwards, it is effectively | |
4572 | possible to override earlier entries using this technique. | |
4573 | ||
4574 | @end table | |
4575 | ||
4576 | GCC has the following spec strings built into it. Spec files can | |
4577 | override these strings or create their own. Note that individual | |
02f52e19 | 4578 | targets can also add their own spec strings to this list. |
a743d340 NC |
4579 | |
4580 | @smallexample | |
4581 | asm Options to pass to the assembler | |
4582 | asm_final Options to pass to the assembler post-processor | |
4583 | cpp Options to pass to the C preprocessor | |
4584 | cc1 Options to pass to the C compiler | |
4585 | cc1plus Options to pass to the C++ compiler | |
4586 | endfile Object files to include at the end of the link | |
4587 | link Options to pass to the linker | |
4588 | lib Libraries to include on the command line to the linker | |
4589 | libgcc Decides which GCC support library to pass to the linker | |
4590 | linker Sets the name of the linker | |
4591 | predefines Defines to be passed to the C preprocessor | |
310668e8 JM |
4592 | signed_char Defines to pass to CPP to say whether @code{char} is signed |
4593 | by default | |
a743d340 NC |
4594 | startfile Object files to include at the start of the link |
4595 | @end smallexample | |
4596 | ||
4597 | Here is a small example of a spec file: | |
4598 | ||
4599 | @smallexample | |
4600 | %rename lib old_lib | |
4601 | ||
4602 | *lib: | |
4603 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
4604 | @end smallexample | |
4605 | ||
4606 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
4607 | then overrides the previous definition of @samp{lib} with a new one. | |
4608 | The new definition adds in some extra command-line options before | |
4609 | including the text of the old definition. | |
4610 | ||
4611 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
4612 | corresponding program. In addition, the spec strings can contain | |
4613 | @samp{%}-prefixed sequences to substitute variable text or to | |
4614 | conditionally insert text into the command line. Using these constructs | |
4615 | it is possible to generate quite complex command lines. | |
4616 | ||
4617 | Here is a table of all defined @samp{%}-sequences for spec | |
4618 | strings. Note that spaces are not generated automatically around the | |
4619 | results of expanding these sequences. Therefore you can concatenate them | |
02f52e19 | 4620 | together or combine them with constant text in a single argument. |
a743d340 NC |
4621 | |
4622 | @table @code | |
4623 | @item %% | |
4624 | Substitute one @samp{%} into the program name or argument. | |
4625 | ||
4626 | @item %i | |
4627 | Substitute the name of the input file being processed. | |
4628 | ||
4629 | @item %b | |
4630 | Substitute the basename of the input file being processed. | |
4631 | This is the substring up to (and not including) the last period | |
4632 | and not including the directory. | |
4633 | ||
371e300b NC |
4634 | @item %B |
4635 | This is the same as @samp{%b}, but include the file suffix (text after | |
4636 | the last period). | |
4637 | ||
a743d340 NC |
4638 | @item %d |
4639 | Marks the argument containing or following the @samp{%d} as a | |
4640 | temporary file name, so that that file will be deleted if GCC exits | |
4641 | successfully. Unlike @samp{%g}, this contributes no text to the | |
02f52e19 | 4642 | argument. |
a743d340 NC |
4643 | |
4644 | @item %g@var{suffix} | |
4645 | Substitute a file name that has suffix @var{suffix} and is chosen | |
4646 | once per compilation, and mark the argument in the same way as | |
4647 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
02f52e19 | 4648 | name is now chosen in a way that is hard to predict even when previously |
695ac33f | 4649 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} |
a743d340 NC |
4650 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches |
4651 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
4652 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
4653 | was simply substituted with a file name chosen once per compilation, | |
4654 | without regard to any appended suffix (which was therefore treated | |
4655 | just like ordinary text), making such attacks more likely to succeed. | |
4656 | ||
4657 | @item %u@var{suffix} | |
4658 | Like @samp{%g}, but generates a new temporary file name even if | |
4659 | @samp{%u@var{suffix}} was already seen. | |
4660 | ||
4661 | @item %U@var{suffix} | |
4662 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
4663 | new one if there is no such last file name. In the absence of any | |
4664 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
695ac33f | 4665 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} |
a743d340 NC |
4666 | would involve the generation of two distinct file names, one |
4667 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
4668 | simply substituted with a file name chosen for the previous @samp{%u}, | |
4669 | without regard to any appended suffix. | |
4670 | ||
371e300b | 4671 | @item %j@var{SUFFIX} |
aee96fe9 | 4672 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is |
371e300b NC |
4673 | writable, and if save-temps is off; otherwise, substitute the name |
4674 | of a temporary file, just like @samp{%u}. This temporary file is not | |
4675 | meant for communication between processes, but rather as a junk | |
4676 | disposal mechanism. | |
4677 | ||
4678 | @item %.@var{SUFFIX} | |
4679 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
767094dd | 4680 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is |
371e300b NC |
4681 | terminated by the next space or %. |
4682 | ||
a743d340 NC |
4683 | @item %w |
4684 | Marks the argument containing or following the @samp{%w} as the | |
4685 | designated output file of this compilation. This puts the argument | |
4686 | into the sequence of arguments that @samp{%o} will substitute later. | |
4687 | ||
4688 | @item %o | |
4689 | Substitutes the names of all the output files, with spaces | |
4690 | automatically placed around them. You should write spaces | |
4691 | around the @samp{%o} as well or the results are undefined. | |
4692 | @samp{%o} is for use in the specs for running the linker. | |
4693 | Input files whose names have no recognized suffix are not compiled | |
4694 | at all, but they are included among the output files, so they will | |
4695 | be linked. | |
4696 | ||
4697 | @item %O | |
4698 | Substitutes the suffix for object files. Note that this is | |
4699 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
4700 | because of the need for those to form complete file names. The | |
4701 | handling is such that @samp{%O} is treated exactly as if it had already | |
4702 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
4703 | support additional @var{suffix} characters following @samp{%O} as they would | |
4704 | following, for example, @samp{.o}. | |
4705 | ||
4706 | @item %p | |
4707 | Substitutes the standard macro predefinitions for the | |
4708 | current target machine. Use this when running @code{cpp}. | |
4709 | ||
4710 | @item %P | |
4711 | Like @samp{%p}, but puts @samp{__} before and after the name of each | |
4712 | predefined macro, except for macros that start with @samp{__} or with | |
c1030c7c | 4713 | @samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO |
161d7b59 | 4714 | C@. |
a743d340 NC |
4715 | |
4716 | @item %I | |
aee96fe9 | 4717 | Substitute a @option{-iprefix} option made from @env{GCC_EXEC_PREFIX}. |
a743d340 NC |
4718 | |
4719 | @item %s | |
4720 | Current argument is the name of a library or startup file of some sort. | |
4721 | Search for that file in a standard list of directories and substitute | |
02f52e19 | 4722 | the full name found. |
a743d340 NC |
4723 | |
4724 | @item %e@var{str} | |
4725 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
4726 | Use this when inconsistent options are detected. | |
4727 | ||
4728 | @item %| | |
4729 | Output @samp{-} if the input for the current command is coming from a pipe. | |
4730 | ||
4731 | @item %(@var{name}) | |
4732 | Substitute the contents of spec string @var{name} at this point. | |
4733 | ||
4734 | @item %[@var{name}] | |
630d3d5a | 4735 | Like @samp{%(@dots{})} but put @samp{__} around @option{-D} arguments. |
a743d340 NC |
4736 | |
4737 | @item %x@{@var{option}@} | |
4738 | Accumulate an option for @samp{%X}. | |
4739 | ||
4740 | @item %X | |
630d3d5a | 4741 | Output the accumulated linker options specified by @option{-Wl} or a @samp{%x} |
a743d340 NC |
4742 | spec string. |
4743 | ||
4744 | @item %Y | |
630d3d5a | 4745 | Output the accumulated assembler options specified by @option{-Wa}. |
a743d340 NC |
4746 | |
4747 | @item %Z | |
630d3d5a | 4748 | Output the accumulated preprocessor options specified by @option{-Wp}. |
a743d340 NC |
4749 | |
4750 | @item %v1 | |
161d7b59 | 4751 | Substitute the major version number of GCC@. |
a743d340 NC |
4752 | (For version 2.9.5, this is 2.) |
4753 | ||
4754 | @item %v2 | |
161d7b59 | 4755 | Substitute the minor version number of GCC@. |
a743d340 NC |
4756 | (For version 2.9.5, this is 9.) |
4757 | ||
371e300b | 4758 | @item %v3 |
161d7b59 | 4759 | Substitute the patch level number of GCC@. |
371e300b NC |
4760 | (For version 2.9.5, this is 5.) |
4761 | ||
a743d340 NC |
4762 | @item %a |
4763 | Process the @code{asm} spec. This is used to compute the | |
4764 | switches to be passed to the assembler. | |
4765 | ||
4766 | @item %A | |
4767 | Process the @code{asm_final} spec. This is a spec string for | |
4768 | passing switches to an assembler post-processor, if such a program is | |
4769 | needed. | |
4770 | ||
4771 | @item %l | |
4772 | Process the @code{link} spec. This is the spec for computing the | |
4773 | command line passed to the linker. Typically it will make use of the | |
4774 | @samp{%L %G %S %D and %E} sequences. | |
4775 | ||
4776 | @item %D | |
630d3d5a | 4777 | Dump out a @option{-L} option for each directory that GCC believes might |
a743d340 | 4778 | contain startup files. If the target supports multilibs then the |
02f52e19 | 4779 | current multilib directory will be prepended to each of these paths. |
a743d340 | 4780 | |
371e300b | 4781 | @item %M |
c771326b | 4782 | Output the multilib directory with directory separators replaced with |
695ac33f JM |
4783 | @samp{_}. If multilib directories are not set, or the multilib directory is |
4784 | @file{.} then this option emits nothing. | |
371e300b | 4785 | |
a743d340 NC |
4786 | @item %L |
4787 | Process the @code{lib} spec. This is a spec string for deciding which | |
02f52e19 | 4788 | libraries should be included on the command line to the linker. |
a743d340 NC |
4789 | |
4790 | @item %G | |
4791 | Process the @code{libgcc} spec. This is a spec string for deciding | |
02f52e19 | 4792 | which GCC support library should be included on the command line to the linker. |
a743d340 NC |
4793 | |
4794 | @item %S | |
4795 | Process the @code{startfile} spec. This is a spec for deciding which | |
4796 | object files should be the first ones passed to the linker. Typically | |
02f52e19 | 4797 | this might be a file named @file{crt0.o}. |
a743d340 NC |
4798 | |
4799 | @item %E | |
4800 | Process the @code{endfile} spec. This is a spec string that specifies | |
02f52e19 | 4801 | the last object files that will be passed to the linker. |
a743d340 NC |
4802 | |
4803 | @item %C | |
4804 | Process the @code{cpp} spec. This is used to construct the arguments | |
4805 | to be passed to the C preprocessor. | |
4806 | ||
4807 | @item %c | |
4808 | Process the @code{signed_char} spec. This is intended to be used | |
02f52e19 | 4809 | to tell cpp whether a char is signed. It typically has the definition: |
a743d340 NC |
4810 | @smallexample |
4811 | %@{funsigned-char:-D__CHAR_UNSIGNED__@} | |
4812 | @end smallexample | |
4813 | ||
4814 | @item %1 | |
4815 | Process the @code{cc1} spec. This is used to construct the options to be | |
4816 | passed to the actual C compiler (@samp{cc1}). | |
4817 | ||
4818 | @item %2 | |
4819 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
4820 | passed to the actual C++ compiler (@samp{cc1plus}). | |
4821 | ||
4822 | @item %* | |
4823 | Substitute the variable part of a matched option. See below. | |
4824 | Note that each comma in the substituted string is replaced by | |
4825 | a single space. | |
4826 | ||
4827 | @item %@{@code{S}@} | |
161d7b59 | 4828 | Substitutes the @code{-S} switch, if that switch was given to GCC@. |
a743d340 NC |
4829 | If that switch was not specified, this substitutes nothing. Note that |
4830 | the leading dash is omitted when specifying this option, and it is | |
4831 | automatically inserted if the substitution is performed. Thus the spec | |
630d3d5a JM |
4832 | string @samp{%@{foo@}} would match the command-line option @option{-foo} |
4833 | and would output the command line option @option{-foo}. | |
a743d340 NC |
4834 | |
4835 | @item %W@{@code{S}@} | |
4836 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
02f52e19 | 4837 | deleted on failure. |
a743d340 NC |
4838 | |
4839 | @item %@{@code{S}*@} | |
4840 | Substitutes all the switches specified to GCC whose names start | |
4841 | with @code{-S}, but which also take an argument. This is used for | |
695ac33f | 4842 | switches like @option{-o}, @option{-D}, @option{-I}, etc. |
630d3d5a | 4843 | GCC considers @option{-o foo} as being |
a743d340 | 4844 | one switch whose names starts with @samp{o}. %@{o*@} would substitute this |
02f52e19 | 4845 | text, including the space. Thus two arguments would be generated. |
a743d340 NC |
4846 | |
4847 | @item %@{^@code{S}*@} | |
4848 | Like %@{@code{S}*@}, but don't put a blank between a switch and its | |
4849 | argument. Thus %@{^o*@} would only generate one argument, not two. | |
4850 | ||
371e300b NC |
4851 | @item %@{@code{S}*&@code{T}*@} |
4852 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
4853 | (the order of @code{S} and @code{T} in the spec is not significant). | |
4854 | There can be any number of ampersand-separated variables; for each the | |
4855 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
4856 | ||
d630442f | 4857 | @item %@{<@code{S}@} |
695ac33f | 4858 | Remove all occurrences of @code{-S} from the command line. Note---this |
d630442f | 4859 | command is position dependent. @samp{%} commands in the spec string |
50c57e7b | 4860 | before this option will see @code{-S}, @samp{%} commands in the spec |
d630442f NC |
4861 | string after this option will not. |
4862 | ||
a743d340 NC |
4863 | @item %@{@code{S}*:@code{X}@} |
4864 | Substitutes @code{X} if one or more switches whose names start with | |
161d7b59 | 4865 | @code{-S} are specified to GCC@. Note that the tail part of the |
e979f9e8 | 4866 | @code{-S} option (i.e.@: the part matched by the @samp{*}) will be substituted |
02f52e19 | 4867 | for each occurrence of @samp{%*} within @code{X}. |
a743d340 NC |
4868 | |
4869 | @item %@{@code{S}:@code{X}@} | |
161d7b59 | 4870 | Substitutes @code{X}, but only if the @samp{-S} switch was given to GCC@. |
a743d340 NC |
4871 | |
4872 | @item %@{!@code{S}:@code{X}@} | |
161d7b59 | 4873 | Substitutes @code{X}, but only if the @samp{-S} switch was @emph{not} given to GCC@. |
a743d340 NC |
4874 | |
4875 | @item %@{|@code{S}:@code{X}@} | |
4876 | Like %@{@code{S}:@code{X}@}, but if no @code{S} switch, substitute @samp{-}. | |
4877 | ||
4878 | @item %@{|!@code{S}:@code{X}@} | |
4879 | Like %@{!@code{S}:@code{X}@}, but if there is an @code{S} switch, substitute @samp{-}. | |
4880 | ||
4881 | @item %@{.@code{S}:@code{X}@} | |
4882 | Substitutes @code{X}, but only if processing a file with suffix @code{S}. | |
4883 | ||
4884 | @item %@{!.@code{S}:@code{X}@} | |
4885 | Substitutes @code{X}, but only if @emph{not} processing a file with suffix @code{S}. | |
4886 | ||
4887 | @item %@{@code{S}|@code{P}:@code{X}@} | |
161d7b59 | 4888 | Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC@. This may be |
a743d340 NC |
4889 | combined with @samp{!} and @samp{.} sequences as well, although they |
4890 | have a stronger binding than the @samp{|}. For example a spec string | |
4891 | like this: | |
4892 | ||
4893 | @smallexample | |
4894 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
4895 | @end smallexample | |
4896 | ||
4897 | will output the following command-line options from the following input | |
4898 | command-line options: | |
4899 | ||
4900 | @smallexample | |
4901 | fred.c -foo -baz | |
4902 | jim.d -bar -boggle | |
4903 | -d fred.c -foo -baz -boggle | |
4904 | -d jim.d -bar -baz -boggle | |
4905 | @end smallexample | |
4906 | ||
4907 | @end table | |
4908 | ||
4909 | The conditional text @code{X} in a %@{@code{S}:@code{X}@} or | |
4910 | %@{!@code{S}:@code{X}@} construct may contain other nested @samp{%} constructs | |
4911 | or spaces, or even newlines. They are processed as usual, as described | |
02f52e19 | 4912 | above. |
a743d340 | 4913 | |
695ac33f JM |
4914 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} |
4915 | switches are handled specifically in these | |
630d3d5a JM |
4916 | constructs. If another value of @option{-O} or the negated form of a @option{-f}, @option{-m}, or |
4917 | @option{-W} switch is found later in the command line, the earlier switch | |
a743d340 NC |
4918 | value is ignored, except with @{@code{S}*@} where @code{S} is just one |
4919 | letter, which passes all matching options. | |
4920 | ||
4921 | The character @samp{|} at the beginning of the predicate text is used to indicate | |
630d3d5a | 4922 | that a command should be piped to the following command, but only if @option{-pipe} |
a743d340 NC |
4923 | is specified. |
4924 | ||
4925 | It is built into GCC which switches take arguments and which do not. | |
4926 | (You might think it would be useful to generalize this to allow each | |
4927 | compiler's spec to say which switches take arguments. But this cannot | |
4928 | be done in a consistent fashion. GCC cannot even decide which input | |
4929 | files have been specified without knowing which switches take arguments, | |
4930 | and it must know which input files to compile in order to tell which | |
02f52e19 | 4931 | compilers to run). |
a743d340 | 4932 | |
630d3d5a | 4933 | GCC also knows implicitly that arguments starting in @option{-l} are to be |
a743d340 NC |
4934 | treated as compiler output files, and passed to the linker in their |
4935 | proper position among the other output files. | |
4936 | ||
ee457005 JM |
4937 | @c man begin OPTIONS |
4938 | ||
74291a4b MM |
4939 | @node Target Options |
4940 | @section Specifying Target Machine and Compiler Version | |
4941 | @cindex target options | |
4942 | @cindex cross compiling | |
4943 | @cindex specifying machine version | |
4944 | @cindex specifying compiler version and target machine | |
4945 | @cindex compiler version, specifying | |
4946 | @cindex target machine, specifying | |
4947 | ||
0c2d1a2a | 4948 | By default, GCC compiles code for the same type of machine that you |
74291a4b MM |
4949 | are using. However, it can also be installed as a cross-compiler, to |
4950 | compile for some other type of machine. In fact, several different | |
0c2d1a2a | 4951 | configurations of GCC, for different target machines, can be |
74291a4b | 4952 | installed side by side. Then you specify which one to use with the |
630d3d5a | 4953 | @option{-b} option. |
74291a4b | 4954 | |
0c2d1a2a | 4955 | In addition, older and newer versions of GCC can be installed side |
74291a4b MM |
4956 | by side. One of them (probably the newest) will be the default, but |
4957 | you may sometimes wish to use another. | |
4958 | ||
2642624b | 4959 | @table @gcctabopt |
74291a4b | 4960 | @item -b @var{machine} |
cd3bb277 | 4961 | @opindex b |
74291a4b | 4962 | The argument @var{machine} specifies the target machine for compilation. |
0c2d1a2a | 4963 | This is useful when you have installed GCC as a cross-compiler. |
74291a4b MM |
4964 | |
4965 | The value to use for @var{machine} is the same as was specified as the | |
0c2d1a2a | 4966 | machine type when configuring GCC as a cross-compiler. For |
74291a4b MM |
4967 | example, if a cross-compiler was configured with @samp{configure |
4968 | i386v}, meaning to compile for an 80386 running System V, then you | |
630d3d5a | 4969 | would specify @option{-b i386v} to run that cross compiler. |
74291a4b | 4970 | |
630d3d5a | 4971 | When you do not specify @option{-b}, it normally means to compile for |
74291a4b MM |
4972 | the same type of machine that you are using. |
4973 | ||
4974 | @item -V @var{version} | |
cd3bb277 | 4975 | @opindex V |
0c2d1a2a | 4976 | The argument @var{version} specifies which version of GCC to run. |
74291a4b | 4977 | This is useful when multiple versions are installed. For example, |
0c2d1a2a | 4978 | @var{version} might be @samp{2.0}, meaning to run GCC version 2.0. |
74291a4b | 4979 | |
630d3d5a | 4980 | The default version, when you do not specify @option{-V}, is the last |
0c2d1a2a | 4981 | version of GCC that you installed. |
74291a4b MM |
4982 | @end table |
4983 | ||
630d3d5a | 4984 | The @option{-b} and @option{-V} options actually work by controlling part of |
74291a4b | 4985 | the file name used for the executable files and libraries used for |
0c2d1a2a | 4986 | compilation. A given version of GCC, for a given target machine, is |
bd819a4a | 4987 | normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}. |
74291a4b | 4988 | |
630d3d5a | 4989 | Thus, sites can customize the effect of @option{-b} or @option{-V} either by |
74291a4b MM |
4990 | changing the names of these directories or adding alternate names (or |
4991 | symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the | |
630d3d5a JM |
4992 | file @file{80386} is a link to the file @file{i386v}, then @option{-b |
4993 | 80386} becomes an alias for @option{-b i386v}. | |
74291a4b | 4994 | |
630d3d5a | 4995 | In one respect, the @option{-b} or @option{-V} do not completely change |
bedc7537 | 4996 | to a different compiler: the top-level driver program @command{gcc} |
74291a4b MM |
4997 | that you originally invoked continues to run and invoke the other |
4998 | executables (preprocessor, compiler per se, assembler and linker) | |
4999 | that do the real work. However, since no real work is done in the | |
5000 | driver program, it usually does not matter that the driver program | |
8c7b74b9 JM |
5001 | in use is not the one for the specified target. It is common for the |
5002 | interface to the other executables to change incompatibly between | |
5003 | compiler versions, so unless the version specified is very close to that | |
630d3d5a JM |
5004 | of the driver (for example, @option{-V 3.0} with a driver program from GCC |
5005 | version 3.0.1), use of @option{-V} may not work; for example, using | |
5006 | @option{-V 2.95.2} will not work with a driver program from GCC 3.0. | |
74291a4b MM |
5007 | |
5008 | The only way that the driver program depends on the target machine is | |
5009 | in the parsing and handling of special machine-specific options. | |
5010 | However, this is controlled by a file which is found, along with the | |
5011 | other executables, in the directory for the specified version and | |
5012 | target machine. As a result, a single installed driver program adapts | |
8c7b74b9 JM |
5013 | to any specified target machine, and sufficiently similar compiler |
5014 | versions. | |
74291a4b MM |
5015 | |
5016 | The driver program executable does control one significant thing, | |
5017 | however: the default version and target machine. Therefore, you can | |
5018 | install different instances of the driver program, compiled for | |
5019 | different targets or versions, under different names. | |
5020 | ||
bedc7537 NC |
5021 | For example, if the driver for version 2.0 is installed as @command{ogcc} |
5022 | and that for version 2.1 is installed as @command{gcc}, then the command | |
5023 | @command{gcc} will use version 2.1 by default, while @command{ogcc} will use | |
74291a4b | 5024 | 2.0 by default. However, you can choose either version with either |
630d3d5a | 5025 | command with the @option{-V} option. |
74291a4b MM |
5026 | |
5027 | @node Submodel Options | |
5028 | @section Hardware Models and Configurations | |
5029 | @cindex submodel options | |
5030 | @cindex specifying hardware config | |
5031 | @cindex hardware models and configurations, specifying | |
5032 | @cindex machine dependent options | |
5033 | ||
630d3d5a | 5034 | Earlier we discussed the standard option @option{-b} which chooses among |
74291a4b | 5035 | different installed compilers for completely different target |
e979f9e8 | 5036 | machines, such as Vax vs.@: 68000 vs.@: 80386. |
74291a4b MM |
5037 | |
5038 | In addition, each of these target machine types can have its own | |
5039 | special options, starting with @samp{-m}, to choose among various | |
5040 | hardware models or configurations---for example, 68010 vs 68020, | |
5041 | floating coprocessor or none. A single installed version of the | |
5042 | compiler can compile for any model or configuration, according to the | |
5043 | options specified. | |
5044 | ||
5045 | Some configurations of the compiler also support additional special | |
5046 | options, usually for compatibility with other compilers on the same | |
5047 | platform. | |
5048 | ||
5049 | @ifset INTERNALS | |
5050 | These options are defined by the macro @code{TARGET_SWITCHES} in the | |
5051 | machine description. The default for the options is also defined by | |
5052 | that macro, which enables you to change the defaults. | |
5053 | @end ifset | |
5054 | ||
5055 | @menu | |
5056 | * M680x0 Options:: | |
2856c3e3 | 5057 | * M68hc1x Options:: |
74291a4b MM |
5058 | * VAX Options:: |
5059 | * SPARC Options:: | |
5060 | * Convex Options:: | |
5061 | * AMD29K Options:: | |
5062 | * ARM Options:: | |
ecff22ab | 5063 | * MN10200 Options:: |
6d6d0fa0 | 5064 | * MN10300 Options:: |
861bb6c1 | 5065 | * M32R/D Options:: |
74291a4b MM |
5066 | * M88K Options:: |
5067 | * RS/6000 and PowerPC Options:: | |
5068 | * RT Options:: | |
5069 | * MIPS Options:: | |
5070 | * i386 Options:: | |
5071 | * HPPA Options:: | |
5072 | * Intel 960 Options:: | |
5073 | * DEC Alpha Options:: | |
5074 | * Clipper Options:: | |
5075 | * H8/300 Options:: | |
5076 | * SH Options:: | |
5077 | * System V Options:: | |
282a61e6 | 5078 | * TMS320C3x/C4x Options:: |
f84271d9 | 5079 | * V850 Options:: |
56b2d7a7 | 5080 | * ARC Options:: |
83575957 | 5081 | * NS32K Options:: |
052a4b28 DC |
5082 | * AVR Options:: |
5083 | * MCore Options:: | |
df6194d4 | 5084 | * IA-64 Options:: |
e8ad90e5 | 5085 | * D30V Options:: |
74291a4b MM |
5086 | @end menu |
5087 | ||
5088 | @node M680x0 Options | |
5089 | @subsection M680x0 Options | |
5090 | @cindex M680x0 options | |
5091 | ||
5092 | These are the @samp{-m} options defined for the 68000 series. The default | |
5093 | values for these options depends on which style of 68000 was selected when | |
5094 | the compiler was configured; the defaults for the most common choices are | |
5095 | given below. | |
5096 | ||
2642624b | 5097 | @table @gcctabopt |
74291a4b MM |
5098 | @item -m68000 |
5099 | @itemx -mc68000 | |
cd3bb277 JM |
5100 | @opindex m68000 |
5101 | @opindex mc68000 | |
74291a4b MM |
5102 | Generate output for a 68000. This is the default |
5103 | when the compiler is configured for 68000-based systems. | |
5104 | ||
74cf1c6d RK |
5105 | Use this option for microcontrollers with a 68000 or EC000 core, |
5106 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
5107 | ||
74291a4b MM |
5108 | @item -m68020 |
5109 | @itemx -mc68020 | |
cd3bb277 JM |
5110 | @opindex m68020 |
5111 | @opindex mc68020 | |
74291a4b MM |
5112 | Generate output for a 68020. This is the default |
5113 | when the compiler is configured for 68020-based systems. | |
5114 | ||
5115 | @item -m68881 | |
cd3bb277 | 5116 | @opindex m68881 |
74291a4b | 5117 | Generate output containing 68881 instructions for floating point. |
630d3d5a | 5118 | This is the default for most 68020 systems unless @option{--nfp} was |
74291a4b MM |
5119 | specified when the compiler was configured. |
5120 | ||
5121 | @item -m68030 | |
cd3bb277 | 5122 | @opindex m68030 |
74291a4b MM |
5123 | Generate output for a 68030. This is the default when the compiler is |
5124 | configured for 68030-based systems. | |
5125 | ||
5126 | @item -m68040 | |
cd3bb277 | 5127 | @opindex m68040 |
74291a4b MM |
5128 | Generate output for a 68040. This is the default when the compiler is |
5129 | configured for 68040-based systems. | |
5130 | ||
5131 | This option inhibits the use of 68881/68882 instructions that have to be | |
74cf1c6d RK |
5132 | emulated by software on the 68040. Use this option if your 68040 does not |
5133 | have code to emulate those instructions. | |
74291a4b MM |
5134 | |
5135 | @item -m68060 | |
cd3bb277 | 5136 | @opindex m68060 |
74291a4b MM |
5137 | Generate output for a 68060. This is the default when the compiler is |
5138 | configured for 68060-based systems. | |
5139 | ||
5140 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
74cf1c6d RK |
5141 | have to be emulated by software on the 68060. Use this option if your 68060 |
5142 | does not have code to emulate those instructions. | |
5143 | ||
5144 | @item -mcpu32 | |
cd3bb277 | 5145 | @opindex mcpu32 |
767094dd | 5146 | Generate output for a CPU32. This is the default |
74cf1c6d RK |
5147 | when the compiler is configured for CPU32-based systems. |
5148 | ||
5149 | Use this option for microcontrollers with a | |
5150 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
5151 | 68336, 68340, 68341, 68349 and 68360. | |
74291a4b MM |
5152 | |
5153 | @item -m5200 | |
cd3bb277 | 5154 | @opindex m5200 |
695ac33f | 5155 | Generate output for a 520X ``coldfire'' family cpu. This is the default |
74291a4b MM |
5156 | when the compiler is configured for 520X-based systems. |
5157 | ||
02f52e19 | 5158 | Use this option for microcontroller with a 5200 core, including |
74cf1c6d RK |
5159 | the MCF5202, MCF5203, MCF5204 and MCF5202. |
5160 | ||
74291a4b MM |
5161 | |
5162 | @item -m68020-40 | |
cd3bb277 | 5163 | @opindex m68020-40 |
74291a4b MM |
5164 | Generate output for a 68040, without using any of the new instructions. |
5165 | This results in code which can run relatively efficiently on either a | |
5166 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
5167 | 68881 instructions that are emulated on the 68040. | |
5168 | ||
861bb6c1 | 5169 | @item -m68020-60 |
cd3bb277 | 5170 | @opindex m68020-60 |
861bb6c1 JL |
5171 | Generate output for a 68060, without using any of the new instructions. |
5172 | This results in code which can run relatively efficiently on either a | |
5173 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
5174 | 68881 instructions that are emulated on the 68060. | |
5175 | ||
74291a4b | 5176 | @item -mfpa |
cd3bb277 | 5177 | @opindex mfpa |
74291a4b MM |
5178 | Generate output containing Sun FPA instructions for floating point. |
5179 | ||
5180 | @item -msoft-float | |
cd3bb277 | 5181 | @opindex msoft-float |
74291a4b MM |
5182 | Generate output containing library calls for floating point. |
5183 | @strong{Warning:} the requisite libraries are not available for all m68k | |
5184 | targets. Normally the facilities of the machine's usual C compiler are | |
5185 | used, but this can't be done directly in cross-compilation. You must | |
5186 | make your own arrangements to provide suitable library functions for | |
5187 | cross-compilation. The embedded targets @samp{m68k-*-aout} and | |
5188 | @samp{m68k-*-coff} do provide software floating point support. | |
5189 | ||
5190 | @item -mshort | |
cd3bb277 | 5191 | @opindex mshort |
74291a4b MM |
5192 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
5193 | ||
5194 | @item -mnobitfield | |
cd3bb277 | 5195 | @opindex mnobitfield |
630d3d5a JM |
5196 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
5197 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
74291a4b MM |
5198 | |
5199 | @item -mbitfield | |
cd3bb277 | 5200 | @opindex mbitfield |
630d3d5a JM |
5201 | Do use the bit-field instructions. The @option{-m68020} option implies |
5202 | @option{-mbitfield}. This is the default if you use a configuration | |
74291a4b MM |
5203 | designed for a 68020. |
5204 | ||
5205 | @item -mrtd | |
cd3bb277 | 5206 | @opindex mrtd |
74291a4b MM |
5207 | Use a different function-calling convention, in which functions |
5208 | that take a fixed number of arguments return with the @code{rtd} | |
5209 | instruction, which pops their arguments while returning. This | |
5210 | saves one instruction in the caller since there is no need to pop | |
5211 | the arguments there. | |
5212 | ||
5213 | This calling convention is incompatible with the one normally | |
5214 | used on Unix, so you cannot use it if you need to call libraries | |
5215 | compiled with the Unix compiler. | |
5216 | ||
5217 | Also, you must provide function prototypes for all functions that | |
5218 | take variable numbers of arguments (including @code{printf}); | |
5219 | otherwise incorrect code will be generated for calls to those | |
5220 | functions. | |
5221 | ||
5222 | In addition, seriously incorrect code will result if you call a | |
5223 | function with too many arguments. (Normally, extra arguments are | |
5224 | harmlessly ignored.) | |
5225 | ||
5226 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
74cf1c6d | 5227 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. |
861bb6c1 JL |
5228 | |
5229 | @item -malign-int | |
5230 | @itemx -mno-align-int | |
cd3bb277 JM |
5231 | @opindex malign-int |
5232 | @opindex mno-align-int | |
02f52e19 | 5233 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
861bb6c1 | 5234 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit |
630d3d5a | 5235 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). |
861bb6c1 JL |
5236 | Aligning variables on 32-bit boundaries produces code that runs somewhat |
5237 | faster on processors with 32-bit busses at the expense of more memory. | |
5238 | ||
630d3d5a | 5239 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC will |
861bb6c1 JL |
5240 | align structures containing the above types differently than |
5241 | most published application binary interface specifications for the m68k. | |
5242 | ||
fb868474 | 5243 | @item -mpcrel |
cd3bb277 | 5244 | @opindex mpcrel |
fb868474 | 5245 | Use the pc-relative addressing mode of the 68000 directly, instead of |
695ac33f JM |
5246 | using a global offset table. At present, this option implies @option{-fpic}, |
5247 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
5248 | not presently supported with @option{-mpcrel}, though this could be supported for | |
fb868474 DL |
5249 | 68020 and higher processors. |
5250 | ||
b71733d5 GM |
5251 | @item -mno-strict-align |
5252 | @itemx -mstrict-align | |
cd3bb277 JM |
5253 | @opindex mno-strict-align |
5254 | @opindex mstrict-align | |
b71733d5 GM |
5255 | Do not (do) assume that unaligned memory references will be handled by |
5256 | the system. | |
5257 | ||
74291a4b MM |
5258 | @end table |
5259 | ||
2856c3e3 SC |
5260 | @node M68hc1x Options |
5261 | @subsection M68hc1x Options | |
5262 | @cindex M68hc1x options | |
5263 | ||
5264 | These are the @samp{-m} options defined for the 68hc11 and 68hc12 | |
02f52e19 | 5265 | microcontrollers. The default values for these options depends on |
2856c3e3 SC |
5266 | which style of microcontroller was selected when the compiler was configured; |
5267 | the defaults for the most common choices are given below. | |
5268 | ||
2642624b | 5269 | @table @gcctabopt |
2856c3e3 SC |
5270 | @item -m6811 |
5271 | @itemx -m68hc11 | |
cd3bb277 JM |
5272 | @opindex m6811 |
5273 | @opindex m68hc11 | |
2856c3e3 SC |
5274 | Generate output for a 68HC11. This is the default |
5275 | when the compiler is configured for 68HC11-based systems. | |
5276 | ||
5277 | @item -m6812 | |
5278 | @itemx -m68hc12 | |
cd3bb277 JM |
5279 | @opindex m6812 |
5280 | @opindex m68hc12 | |
2856c3e3 SC |
5281 | Generate output for a 68HC12. This is the default |
5282 | when the compiler is configured for 68HC12-based systems. | |
5283 | ||
5284 | @item -mauto-incdec | |
cd3bb277 | 5285 | @opindex mauto-incdec |
2856c3e3 SC |
5286 | Enable the use of 68HC12 pre and post auto-increment and auto-decrement |
5287 | addressing modes. | |
5288 | ||
5289 | @item -mshort | |
cd3bb277 | 5290 | @opindex mshort |
2856c3e3 SC |
5291 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
5292 | ||
5293 | @item -msoft-reg-count=@var{count} | |
cd3bb277 | 5294 | @opindex msoft-reg-count |
2856c3e3 SC |
5295 | Specify the number of pseudo-soft registers which are used for the |
5296 | code generation. The maximum number is 32. Using more pseudo-soft | |
5297 | register may or may not result in better code depending on the program. | |
5298 | The default is 4 for 68HC11 and 2 for 68HC12. | |
5299 | ||
5300 | @end table | |
5301 | ||
74291a4b MM |
5302 | @node VAX Options |
5303 | @subsection VAX Options | |
5304 | @cindex VAX options | |
5305 | ||
5306 | These @samp{-m} options are defined for the Vax: | |
5307 | ||
2642624b | 5308 | @table @gcctabopt |
74291a4b | 5309 | @item -munix |
cd3bb277 | 5310 | @opindex munix |
74291a4b MM |
5311 | Do not output certain jump instructions (@code{aobleq} and so on) |
5312 | that the Unix assembler for the Vax cannot handle across long | |
5313 | ranges. | |
5314 | ||
5315 | @item -mgnu | |
cd3bb277 | 5316 | @opindex mgnu |
74291a4b MM |
5317 | Do output those jump instructions, on the assumption that you |
5318 | will assemble with the GNU assembler. | |
5319 | ||
5320 | @item -mg | |
cd3bb277 | 5321 | @opindex mg |
74291a4b MM |
5322 | Output code for g-format floating point numbers instead of d-format. |
5323 | @end table | |
5324 | ||
5325 | @node SPARC Options | |
5326 | @subsection SPARC Options | |
5327 | @cindex SPARC options | |
5328 | ||
5329 | These @samp{-m} switches are supported on the SPARC: | |
5330 | ||
2642624b | 5331 | @table @gcctabopt |
74291a4b MM |
5332 | @item -mno-app-regs |
5333 | @itemx -mapp-regs | |
cd3bb277 JM |
5334 | @opindex mno-app-regs |
5335 | @opindex mapp-regs | |
630d3d5a | 5336 | Specify @option{-mapp-regs} to generate output using the global registers |
74291a4b MM |
5337 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. This |
5338 | is the default. | |
5339 | ||
5340 | To be fully SVR4 ABI compliant at the cost of some performance loss, | |
630d3d5a | 5341 | specify @option{-mno-app-regs}. You should compile libraries and system |
74291a4b MM |
5342 | software with this option. |
5343 | ||
5344 | @item -mfpu | |
5345 | @itemx -mhard-float | |
cd3bb277 JM |
5346 | @opindex mfpu |
5347 | @opindex mhard-float | |
74291a4b MM |
5348 | Generate output containing floating point instructions. This is the |
5349 | default. | |
5350 | ||
5351 | @item -mno-fpu | |
5352 | @itemx -msoft-float | |
cd3bb277 JM |
5353 | @opindex mno-fpu |
5354 | @opindex msoft-float | |
74291a4b MM |
5355 | Generate output containing library calls for floating point. |
5356 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
5357 | targets. Normally the facilities of the machine's usual C compiler are | |
5358 | used, but this cannot be done directly in cross-compilation. You must make | |
5359 | your own arrangements to provide suitable library functions for | |
5360 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
5361 | @samp{sparclite-*-*} do provide software floating point support. | |
5362 | ||
630d3d5a | 5363 | @option{-msoft-float} changes the calling convention in the output file; |
74291a4b MM |
5364 | therefore, it is only useful if you compile @emph{all} of a program with |
5365 | this option. In particular, you need to compile @file{libgcc.a}, the | |
630d3d5a | 5366 | library that comes with GCC, with @option{-msoft-float} in order for |
74291a4b MM |
5367 | this to work. |
5368 | ||
5369 | @item -mhard-quad-float | |
cd3bb277 | 5370 | @opindex mhard-quad-float |
74291a4b MM |
5371 | Generate output containing quad-word (long double) floating point |
5372 | instructions. | |
5373 | ||
5374 | @item -msoft-quad-float | |
cd3bb277 | 5375 | @opindex msoft-quad-float |
74291a4b MM |
5376 | Generate output containing library calls for quad-word (long double) |
5377 | floating point instructions. The functions called are those specified | |
161d7b59 | 5378 | in the SPARC ABI@. This is the default. |
74291a4b MM |
5379 | |
5380 | As of this writing, there are no sparc implementations that have hardware | |
5381 | support for the quad-word floating point instructions. They all invoke | |
5382 | a trap handler for one of these instructions, and then the trap handler | |
5383 | emulates the effect of the instruction. Because of the trap handler overhead, | |
5384 | this is much slower than calling the ABI library routines. Thus the | |
630d3d5a | 5385 | @option{-msoft-quad-float} option is the default. |
74291a4b MM |
5386 | |
5387 | @item -mno-epilogue | |
5388 | @itemx -mepilogue | |
cd3bb277 JM |
5389 | @opindex mno-epilogue |
5390 | @opindex mepilogue | |
630d3d5a | 5391 | With @option{-mepilogue} (the default), the compiler always emits code for |
74291a4b MM |
5392 | function exit at the end of each function. Any function exit in |
5393 | the middle of the function (such as a return statement in C) will | |
5394 | generate a jump to the exit code at the end of the function. | |
5395 | ||
630d3d5a | 5396 | With @option{-mno-epilogue}, the compiler tries to emit exit code inline |
74291a4b MM |
5397 | at every function exit. |
5398 | ||
5399 | @item -mno-flat | |
5400 | @itemx -mflat | |
cd3bb277 JM |
5401 | @opindex mno-flat |
5402 | @opindex mflat | |
630d3d5a | 5403 | With @option{-mflat}, the compiler does not generate save/restore instructions |
695ac33f | 5404 | and will use a ``flat'' or single register window calling convention. |
74291a4b MM |
5405 | This model uses %i7 as the frame pointer and is compatible with the normal |
5406 | register window model. Code from either may be intermixed. | |
aee96fe9 | 5407 | The local registers and the input registers (0--5) are still treated as |
695ac33f | 5408 | ``call saved'' registers and will be saved on the stack as necessary. |
74291a4b | 5409 | |
630d3d5a | 5410 | With @option{-mno-flat} (the default), the compiler emits save/restore |
74291a4b MM |
5411 | instructions (except for leaf functions) and is the normal mode of operation. |
5412 | ||
5413 | @item -mno-unaligned-doubles | |
5414 | @itemx -munaligned-doubles | |
cd3bb277 JM |
5415 | @opindex mno-unaligned-doubles |
5416 | @opindex munaligned-doubles | |
74291a4b MM |
5417 | Assume that doubles have 8 byte alignment. This is the default. |
5418 | ||
630d3d5a | 5419 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8 byte |
74291a4b MM |
5420 | alignment only if they are contained in another type, or if they have an |
5421 | absolute address. Otherwise, it assumes they have 4 byte alignment. | |
5422 | Specifying this option avoids some rare compatibility problems with code | |
5423 | generated by other compilers. It is not the default because it results | |
5424 | in a performance loss, especially for floating point code. | |
5425 | ||
c219ddf7 BK |
5426 | @item -mno-faster-structs |
5427 | @itemx -mfaster-structs | |
cd3bb277 JM |
5428 | @opindex mno-faster-structs |
5429 | @opindex mfaster-structs | |
630d3d5a | 5430 | With @option{-mfaster-structs}, the compiler assumes that structures |
c219ddf7 BK |
5431 | should have 8 byte alignment. This enables the use of pairs of |
5432 | @code{ldd} and @code{std} instructions for copies in structure | |
5433 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
5434 | However, the use of this changed alignment directly violates the Sparc | |
161d7b59 | 5435 | ABI@. Thus, it's intended only for use on targets where the developer |
c219ddf7 | 5436 | acknowledges that their resulting code will not be directly in line with |
161d7b59 | 5437 | the rules of the ABI@. |
c219ddf7 | 5438 | |
74291a4b MM |
5439 | @item -mv8 |
5440 | @itemx -msparclite | |
cd3bb277 JM |
5441 | @opindex mv8 |
5442 | @opindex msparclite | |
74291a4b MM |
5443 | These two options select variations on the SPARC architecture. |
5444 | ||
5445 | By default (unless specifically configured for the Fujitsu SPARClite), | |
5446 | GCC generates code for the v7 variant of the SPARC architecture. | |
5447 | ||
630d3d5a | 5448 | @option{-mv8} will give you SPARC v8 code. The only difference from v7 |
74291a4b MM |
5449 | code is that the compiler emits the integer multiply and integer |
5450 | divide instructions which exist in SPARC v8 but not in SPARC v7. | |
5451 | ||
630d3d5a | 5452 | @option{-msparclite} will give you SPARClite code. This adds the integer |
74291a4b MM |
5453 | multiply, integer divide step and scan (@code{ffs}) instructions which |
5454 | exist in SPARClite but not in SPARC v7. | |
5455 | ||
0c2d1a2a | 5456 | These options are deprecated and will be deleted in a future GCC release. |
630d3d5a | 5457 | They have been replaced with @option{-mcpu=xxx}. |
74291a4b MM |
5458 | |
5459 | @item -mcypress | |
5460 | @itemx -msupersparc | |
cd3bb277 JM |
5461 | @opindex mcypress |
5462 | @opindex msupersparc | |
74291a4b MM |
5463 | These two options select the processor for which the code is optimised. |
5464 | ||
630d3d5a | 5465 | With @option{-mcypress} (the default), the compiler optimizes code for the |
74291a4b MM |
5466 | Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series. |
5467 | This is also appropriate for the older SparcStation 1, 2, IPX etc. | |
5468 | ||
630d3d5a | 5469 | With @option{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as |
767094dd | 5470 | used in the SparcStation 10, 1000 and 2000 series. This flag also enables use |
74291a4b MM |
5471 | of the full SPARC v8 instruction set. |
5472 | ||
0c2d1a2a | 5473 | These options are deprecated and will be deleted in a future GCC release. |
630d3d5a | 5474 | They have been replaced with @option{-mcpu=xxx}. |
74291a4b MM |
5475 | |
5476 | @item -mcpu=@var{cpu_type} | |
cd3bb277 | 5477 | @opindex mcpu |
c0498f43 DE |
5478 | Set the instruction set, register set, and instruction scheduling parameters |
5479 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
5480 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite}, | |
ad6843d7 RH |
5481 | @samp{hypersparc}, @samp{sparclite86x}, @samp{f930}, @samp{f934}, |
5482 | @samp{sparclet}, @samp{tsc701}, @samp{v9}, and @samp{ultrasparc}. | |
c0498f43 DE |
5483 | |
5484 | Default instruction scheduling parameters are used for values that select | |
5485 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
5486 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
5487 | ||
5488 | Here is a list of each supported architecture and their supported | |
5489 | implementations. | |
5490 | ||
5491 | @smallexample | |
5492 | v7: cypress | |
ad6843d7 RH |
5493 | v8: supersparc, hypersparc |
5494 | sparclite: f930, f934, sparclite86x | |
c0498f43 DE |
5495 | sparclet: tsc701 |
5496 | v9: ultrasparc | |
5497 | @end smallexample | |
74291a4b MM |
5498 | |
5499 | @item -mtune=@var{cpu_type} | |
cd3bb277 | 5500 | @opindex mtune |
74291a4b | 5501 | Set the instruction scheduling parameters for machine type |
c0498f43 | 5502 | @var{cpu_type}, but do not set the instruction set or register set that the |
630d3d5a | 5503 | option @option{-mcpu=@var{cpu_type}} would. |
c0498f43 | 5504 | |
630d3d5a JM |
5505 | The same values for @option{-mcpu=@var{cpu_type}} are used for |
5506 | @option{-mtune=@var{cpu_type}}, though the only useful values are those that | |
c0498f43 | 5507 | select a particular cpu implementation: @samp{cypress}, @samp{supersparc}, |
ad6843d7 RH |
5508 | @samp{hypersparc}, @samp{f930}, @samp{f934}, @samp{sparclite86x}, |
5509 | @samp{tsc701}, @samp{ultrasparc}. | |
74291a4b MM |
5510 | |
5511 | @end table | |
5512 | ||
5513 | These @samp{-m} switches are supported in addition to the above | |
5514 | on the SPARCLET processor. | |
5515 | ||
2642624b | 5516 | @table @gcctabopt |
74291a4b | 5517 | @item -mlittle-endian |
cd3bb277 | 5518 | @opindex mlittle-endian |
74291a4b MM |
5519 | Generate code for a processor running in little-endian mode. |
5520 | ||
5521 | @item -mlive-g0 | |
cd3bb277 | 5522 | @opindex mlive-g0 |
74291a4b MM |
5523 | Treat register @code{%g0} as a normal register. |
5524 | GCC will continue to clobber it as necessary but will not assume | |
5525 | it always reads as 0. | |
5526 | ||
5527 | @item -mbroken-saverestore | |
cd3bb277 | 5528 | @opindex mbroken-saverestore |
74291a4b MM |
5529 | Generate code that does not use non-trivial forms of the @code{save} and |
5530 | @code{restore} instructions. Early versions of the SPARCLET processor do | |
5531 | not correctly handle @code{save} and @code{restore} instructions used with | |
5532 | arguments. They correctly handle them used without arguments. A @code{save} | |
5533 | instruction used without arguments increments the current window pointer | |
5534 | but does not allocate a new stack frame. It is assumed that the window | |
5535 | overflow trap handler will properly handle this case as will interrupt | |
5536 | handlers. | |
5537 | @end table | |
5538 | ||
5539 | These @samp{-m} switches are supported in addition to the above | |
02f52e19 | 5540 | on SPARC V9 processors in 64-bit environments. |
74291a4b | 5541 | |
2642624b | 5542 | @table @gcctabopt |
74291a4b | 5543 | @item -mlittle-endian |
cd3bb277 | 5544 | @opindex mlittle-endian |
74291a4b MM |
5545 | Generate code for a processor running in little-endian mode. |
5546 | ||
ded17aad DE |
5547 | @item -m32 |
5548 | @itemx -m64 | |
cd3bb277 JM |
5549 | @opindex m32 |
5550 | @opindex m64 | |
02f52e19 AJ |
5551 | Generate code for a 32-bit or 64-bit environment. |
5552 | The 32-bit environment sets int, long and pointer to 32 bits. | |
5553 | The 64-bit environment sets int to 32 bits and long and pointer | |
ded17aad DE |
5554 | to 64 bits. |
5555 | ||
5556 | @item -mcmodel=medlow | |
cd3bb277 | 5557 | @opindex mcmodel=medlow |
ded17aad DE |
5558 | Generate code for the Medium/Low code model: the program must be linked |
5559 | in the low 32 bits of the address space. Pointers are 64 bits. | |
5560 | Programs can be statically or dynamically linked. | |
5561 | ||
5562 | @item -mcmodel=medmid | |
cd3bb277 | 5563 | @opindex mcmodel=medmid |
ded17aad DE |
5564 | Generate code for the Medium/Middle code model: the program must be linked |
5565 | in the low 44 bits of the address space, the text segment must be less than | |
5566 | 2G bytes, and data segment must be within 2G of the text segment. | |
5567 | Pointers are 64 bits. | |
5568 | ||
5569 | @item -mcmodel=medany | |
cd3bb277 | 5570 | @opindex mcmodel=medany |
ded17aad DE |
5571 | Generate code for the Medium/Anywhere code model: the program may be linked |
5572 | anywhere in the address space, the text segment must be less than | |
5573 | 2G bytes, and data segment must be within 2G of the text segment. | |
5574 | Pointers are 64 bits. | |
5575 | ||
5576 | @item -mcmodel=embmedany | |
cd3bb277 | 5577 | @opindex mcmodel=embmedany |
ded17aad | 5578 | Generate code for the Medium/Anywhere code model for embedded systems: |
02f52e19 | 5579 | assume a 32-bit text and a 32-bit data segment, both starting anywhere |
ded17aad | 5580 | (determined at link time). Register %g4 points to the base of the |
02f52e19 | 5581 | data segment. Pointers are still 64 bits. |
ded17aad | 5582 | Programs are statically linked, PIC is not supported. |
74291a4b MM |
5583 | |
5584 | @item -mstack-bias | |
5585 | @itemx -mno-stack-bias | |
cd3bb277 JM |
5586 | @opindex mstack-bias |
5587 | @opindex mno-stack-bias | |
630d3d5a JM |
5588 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
5589 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
74291a4b MM |
5590 | when making stack frame references. |
5591 | Otherwise, assume no such offset is present. | |
5592 | @end table | |
5593 | ||
5594 | @node Convex Options | |
5595 | @subsection Convex Options | |
5596 | @cindex Convex options | |
5597 | ||
5598 | These @samp{-m} options are defined for Convex: | |
5599 | ||
2642624b | 5600 | @table @gcctabopt |
74291a4b | 5601 | @item -mc1 |
cd3bb277 | 5602 | @opindex mc1 |
74291a4b MM |
5603 | Generate output for C1. The code will run on any Convex machine. |
5604 | The preprocessor symbol @code{__convex__c1__} is defined. | |
5605 | ||
5606 | @item -mc2 | |
cd3bb277 | 5607 | @opindex mc2 |
74291a4b MM |
5608 | Generate output for C2. Uses instructions not available on C1. |
5609 | Scheduling and other optimizations are chosen for max performance on C2. | |
5610 | The preprocessor symbol @code{__convex_c2__} is defined. | |
5611 | ||
5612 | @item -mc32 | |
cd3bb277 | 5613 | @opindex mc32 |
74291a4b MM |
5614 | Generate output for C32xx. Uses instructions not available on C1. |
5615 | Scheduling and other optimizations are chosen for max performance on C32. | |
5616 | The preprocessor symbol @code{__convex_c32__} is defined. | |
5617 | ||
5618 | @item -mc34 | |
cd3bb277 | 5619 | @opindex mc34 |
74291a4b MM |
5620 | Generate output for C34xx. Uses instructions not available on C1. |
5621 | Scheduling and other optimizations are chosen for max performance on C34. | |
5622 | The preprocessor symbol @code{__convex_c34__} is defined. | |
5623 | ||
5624 | @item -mc38 | |
cd3bb277 | 5625 | @opindex mc38 |
74291a4b MM |
5626 | Generate output for C38xx. Uses instructions not available on C1. |
5627 | Scheduling and other optimizations are chosen for max performance on C38. | |
5628 | The preprocessor symbol @code{__convex_c38__} is defined. | |
5629 | ||
5630 | @item -margcount | |
cd3bb277 | 5631 | @opindex margcount |
74291a4b MM |
5632 | Generate code which puts an argument count in the word preceding each |
5633 | argument list. This is compatible with regular CC, and a few programs | |
5634 | may need the argument count word. GDB and other source-level debuggers | |
5635 | do not need it; this info is in the symbol table. | |
5636 | ||
5637 | @item -mnoargcount | |
cd3bb277 | 5638 | @opindex mnoargcount |
74291a4b MM |
5639 | Omit the argument count word. This is the default. |
5640 | ||
5641 | @item -mvolatile-cache | |
cd3bb277 | 5642 | @opindex mvolatile-cache |
74291a4b MM |
5643 | Allow volatile references to be cached. This is the default. |
5644 | ||
5645 | @item -mvolatile-nocache | |
cd3bb277 | 5646 | @opindex mvolatile-nocache |
74291a4b MM |
5647 | Volatile references bypass the data cache, going all the way to memory. |
5648 | This is only needed for multi-processor code that does not use standard | |
5649 | synchronization instructions. Making non-volatile references to volatile | |
5650 | locations will not necessarily work. | |
5651 | ||
5652 | @item -mlong32 | |
cd3bb277 | 5653 | @opindex mlong32 |
74291a4b MM |
5654 | Type long is 32 bits, the same as type int. This is the default. |
5655 | ||
5656 | @item -mlong64 | |
cd3bb277 | 5657 | @opindex mlong64 |
74291a4b MM |
5658 | Type long is 64 bits, the same as type long long. This option is useless, |
5659 | because no library support exists for it. | |
5660 | @end table | |
5661 | ||
5662 | @node AMD29K Options | |
5663 | @subsection AMD29K Options | |
5664 | @cindex AMD29K options | |
5665 | ||
5666 | These @samp{-m} options are defined for the AMD Am29000: | |
5667 | ||
2642624b | 5668 | @table @gcctabopt |
74291a4b | 5669 | @item -mdw |
cd3bb277 | 5670 | @opindex mdw |
74291a4b MM |
5671 | @cindex DW bit (29k) |
5672 | Generate code that assumes the @code{DW} bit is set, i.e., that byte and | |
5673 | halfword operations are directly supported by the hardware. This is the | |
5674 | default. | |
5675 | ||
5676 | @item -mndw | |
cd3bb277 | 5677 | @opindex mndw |
74291a4b MM |
5678 | Generate code that assumes the @code{DW} bit is not set. |
5679 | ||
5680 | @item -mbw | |
cd3bb277 | 5681 | @opindex mbw |
74291a4b MM |
5682 | @cindex byte writes (29k) |
5683 | Generate code that assumes the system supports byte and halfword write | |
5684 | operations. This is the default. | |
5685 | ||
5686 | @item -mnbw | |
cd3bb277 | 5687 | @opindex mnbw |
74291a4b | 5688 | Generate code that assumes the systems does not support byte and |
630d3d5a | 5689 | halfword write operations. @option{-mnbw} implies @option{-mndw}. |
74291a4b MM |
5690 | |
5691 | @item -msmall | |
cd3bb277 | 5692 | @opindex msmall |
74291a4b MM |
5693 | @cindex memory model (29k) |
5694 | Use a small memory model that assumes that all function addresses are | |
5695 | either within a single 256 KB segment or at an absolute address of less | |
5696 | than 256k. This allows the @code{call} instruction to be used instead | |
5697 | of a @code{const}, @code{consth}, @code{calli} sequence. | |
5698 | ||
5699 | @item -mnormal | |
cd3bb277 | 5700 | @opindex mnormal |
74291a4b MM |
5701 | Use the normal memory model: Generate @code{call} instructions only when |
5702 | calling functions in the same file and @code{calli} instructions | |
5703 | otherwise. This works if each file occupies less than 256 KB but allows | |
161d7b59 | 5704 | the entire executable to be larger than 256 KB@. This is the default. |
74291a4b MM |
5705 | |
5706 | @item -mlarge | |
cd3bb277 | 5707 | @opindex mlarge |
74291a4b MM |
5708 | Always use @code{calli} instructions. Specify this option if you expect |
5709 | a single file to compile into more than 256 KB of code. | |
5710 | ||
5711 | @item -m29050 | |
cd3bb277 | 5712 | @opindex m29050 |
74291a4b MM |
5713 | @cindex processor selection (29k) |
5714 | Generate code for the Am29050. | |
5715 | ||
5716 | @item -m29000 | |
cd3bb277 | 5717 | @opindex m29000 |
74291a4b MM |
5718 | Generate code for the Am29000. This is the default. |
5719 | ||
5720 | @item -mkernel-registers | |
cd3bb277 | 5721 | @opindex mkernel-registers |
74291a4b MM |
5722 | @cindex kernel and user registers (29k) |
5723 | Generate references to registers @code{gr64-gr95} instead of to | |
5724 | registers @code{gr96-gr127}. This option can be used when compiling | |
5725 | kernel code that wants a set of global registers disjoint from that used | |
5726 | by user-mode code. | |
5727 | ||
5728 | Note that when this option is used, register names in @samp{-f} flags | |
5729 | must use the normal, user-mode, names. | |
5730 | ||
5731 | @item -muser-registers | |
cd3bb277 | 5732 | @opindex muser-registers |
74291a4b MM |
5733 | Use the normal set of global registers, @code{gr96-gr127}. This is the |
5734 | default. | |
5735 | ||
5736 | @item -mstack-check | |
5737 | @itemx -mno-stack-check | |
cd3bb277 JM |
5738 | @opindex mstack-check |
5739 | @opindex mno-stack-check | |
74291a4b MM |
5740 | @cindex stack checks (29k) |
5741 | Insert (or do not insert) a call to @code{__msp_check} after each stack | |
5742 | adjustment. This is often used for kernel code. | |
5743 | ||
5744 | @item -mstorem-bug | |
5745 | @itemx -mno-storem-bug | |
cd3bb277 JM |
5746 | @opindex mstorem-bug |
5747 | @opindex mno-storem-bug | |
74291a4b | 5748 | @cindex storem bug (29k) |
630d3d5a | 5749 | @option{-mstorem-bug} handles 29k processors which cannot handle the |
74291a4b MM |
5750 | separation of a mtsrim insn and a storem instruction (most 29000 chips |
5751 | to date, but not the 29050). | |
5752 | ||
5753 | @item -mno-reuse-arg-regs | |
5754 | @itemx -mreuse-arg-regs | |
cd3bb277 JM |
5755 | @opindex mno-reuse-arg-regs |
5756 | @opindex mreuse-arg-regs | |
630d3d5a | 5757 | @option{-mno-reuse-arg-regs} tells the compiler to only use incoming argument |
74291a4b MM |
5758 | registers for copying out arguments. This helps detect calling a function |
5759 | with fewer arguments than it was declared with. | |
5760 | ||
861bb6c1 JL |
5761 | @item -mno-impure-text |
5762 | @itemx -mimpure-text | |
cd3bb277 JM |
5763 | @opindex mno-impure-text |
5764 | @opindex mimpure-text | |
630d3d5a JM |
5765 | @option{-mimpure-text}, used in addition to @option{-shared}, tells the compiler to |
5766 | not pass @option{-assert pure-text} to the linker when linking a shared object. | |
861bb6c1 | 5767 | |
74291a4b | 5768 | @item -msoft-float |
cd3bb277 | 5769 | @opindex msoft-float |
74291a4b | 5770 | Generate output containing library calls for floating point. |
161d7b59 | 5771 | @strong{Warning:} the requisite libraries are not part of GCC@. |
74291a4b MM |
5772 | Normally the facilities of the machine's usual C compiler are used, but |
5773 | this can't be done directly in cross-compilation. You must make your | |
5774 | own arrangements to provide suitable library functions for | |
5775 | cross-compilation. | |
4e8d7ddc JW |
5776 | |
5777 | @item -mno-multm | |
cd3bb277 | 5778 | @opindex mno-multm |
4e8d7ddc JW |
5779 | Do not generate multm or multmu instructions. This is useful for some embedded |
5780 | systems which do not have trap handlers for these instructions. | |
74291a4b MM |
5781 | @end table |
5782 | ||
5783 | @node ARM Options | |
5784 | @subsection ARM Options | |
5785 | @cindex ARM options | |
5786 | ||
5787 | These @samp{-m} options are defined for Advanced RISC Machines (ARM) | |
5788 | architectures: | |
5789 | ||
2642624b | 5790 | @table @gcctabopt |
74291a4b | 5791 | @item -mapcs-frame |
cd3bb277 | 5792 | @opindex mapcs-frame |
74291a4b MM |
5793 | Generate a stack frame that is compliant with the ARM Procedure Call |
5794 | Standard for all functions, even if this is not strictly necessary for | |
630d3d5a | 5795 | correct execution of the code. Specifying @option{-fomit-frame-pointer} |
157a620e | 5796 | with this option will cause the stack frames not to be generated for |
630d3d5a | 5797 | leaf functions. The default is @option{-mno-apcs-frame}. |
157a620e NC |
5798 | |
5799 | @item -mapcs | |
cd3bb277 | 5800 | @opindex mapcs |
630d3d5a | 5801 | This is a synonym for @option{-mapcs-frame}. |
74291a4b MM |
5802 | |
5803 | @item -mapcs-26 | |
cd3bb277 | 5804 | @opindex mapcs-26 |
74291a4b MM |
5805 | Generate code for a processor running with a 26-bit program counter, |
5806 | and conforming to the function calling standards for the APCS 26-bit | |
630d3d5a | 5807 | option. This option replaces the @option{-m2} and @option{-m3} options |
74291a4b MM |
5808 | of previous releases of the compiler. |
5809 | ||
5810 | @item -mapcs-32 | |
cd3bb277 | 5811 | @opindex mapcs-32 |
74291a4b MM |
5812 | Generate code for a processor running with a 32-bit program counter, |
5813 | and conforming to the function calling standards for the APCS 32-bit | |
630d3d5a | 5814 | option. This option replaces the @option{-m6} option of previous releases |
74291a4b MM |
5815 | of the compiler. |
5816 | ||
247f8561 PB |
5817 | @ignore |
5818 | @c not currently implemented | |
157a620e | 5819 | @item -mapcs-stack-check |
cd3bb277 | 5820 | @opindex mapcs-stack-check |
157a620e NC |
5821 | Generate code to check the amount of stack space available upon entry to |
5822 | every function (that actually uses some stack space). If there is | |
5823 | insufficient space available then either the function | |
5824 | @samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be | |
5825 | called, depending upon the amount of stack space required. The run time | |
5826 | system is required to provide these functions. The default is | |
630d3d5a | 5827 | @option{-mno-apcs-stack-check}, since this produces smaller code. |
157a620e | 5828 | |
247f8561 | 5829 | @c not currently implemented |
157a620e | 5830 | @item -mapcs-float |
cd3bb277 | 5831 | @opindex mapcs-float |
157a620e | 5832 | Pass floating point arguments using the float point registers. This is |
161d7b59 | 5833 | one of the variants of the APCS@. This option is recommended if the |
157a620e NC |
5834 | target hardware has a floating point unit or if a lot of floating point |
5835 | arithmetic is going to be performed by the code. The default is | |
630d3d5a JM |
5836 | @option{-mno-apcs-float}, since integer only code is slightly increased in |
5837 | size if @option{-mapcs-float} is used. | |
157a620e | 5838 | |
247f8561 | 5839 | @c not currently implemented |
157a620e | 5840 | @item -mapcs-reentrant |
cd3bb277 | 5841 | @opindex mapcs-reentrant |
247f8561 | 5842 | Generate reentrant, position independent code. The default is |
630d3d5a | 5843 | @option{-mno-apcs-reentrant}. |
247f8561 | 5844 | @end ignore |
157a620e NC |
5845 | |
5846 | @item -mthumb-interwork | |
cd3bb277 | 5847 | @opindex mthumb-interwork |
247f8561 | 5848 | Generate code which supports calling between the ARM and Thumb |
157a620e NC |
5849 | instruction sets. Without this option the two instruction sets cannot |
5850 | be reliably used inside one program. The default is | |
630d3d5a JM |
5851 | @option{-mno-thumb-interwork}, since slightly larger code is generated |
5852 | when @option{-mthumb-interwork} is specified. | |
157a620e NC |
5853 | |
5854 | @item -mno-sched-prolog | |
cd3bb277 | 5855 | @opindex mno-sched-prolog |
157a620e NC |
5856 | Prevent the reordering of instructions in the function prolog, or the |
5857 | merging of those instruction with the instructions in the function's | |
ed0e6530 PB |
5858 | body. This means that all functions will start with a recognizable set |
5859 | of instructions (or in fact one of a choice from a small set of | |
157a620e NC |
5860 | different function prologues), and this information can be used to |
5861 | locate the start if functions inside an executable piece of code. The | |
630d3d5a | 5862 | default is @option{-msched-prolog}. |
157a620e | 5863 | |
74291a4b | 5864 | @item -mhard-float |
cd3bb277 | 5865 | @opindex mhard-float |
74291a4b MM |
5866 | Generate output containing floating point instructions. This is the |
5867 | default. | |
5868 | ||
5869 | @item -msoft-float | |
cd3bb277 | 5870 | @opindex msoft-float |
74291a4b MM |
5871 | Generate output containing library calls for floating point. |
5872 | @strong{Warning:} the requisite libraries are not available for all ARM | |
5873 | targets. Normally the facilities of the machine's usual C compiler are | |
5874 | used, but this cannot be done directly in cross-compilation. You must make | |
5875 | your own arrangements to provide suitable library functions for | |
5876 | cross-compilation. | |
5877 | ||
630d3d5a | 5878 | @option{-msoft-float} changes the calling convention in the output file; |
74291a4b MM |
5879 | therefore, it is only useful if you compile @emph{all} of a program with |
5880 | this option. In particular, you need to compile @file{libgcc.a}, the | |
630d3d5a | 5881 | library that comes with GCC, with @option{-msoft-float} in order for |
74291a4b MM |
5882 | this to work. |
5883 | ||
5884 | @item -mlittle-endian | |
cd3bb277 | 5885 | @opindex mlittle-endian |
74291a4b MM |
5886 | Generate code for a processor running in little-endian mode. This is |
5887 | the default for all standard configurations. | |
5888 | ||
5889 | @item -mbig-endian | |
cd3bb277 | 5890 | @opindex mbig-endian |
74291a4b MM |
5891 | Generate code for a processor running in big-endian mode; the default is |
5892 | to compile code for a little-endian processor. | |
5893 | ||
5894 | @item -mwords-little-endian | |
cd3bb277 | 5895 | @opindex mwords-little-endian |
74291a4b MM |
5896 | This option only applies when generating code for big-endian processors. |
5897 | Generate code for a little-endian word order but a big-endian byte | |
5898 | order. That is, a byte order of the form @samp{32107654}. Note: this | |
5899 | option should only be used if you require compatibility with code for | |
5900 | big-endian ARM processors generated by versions of the compiler prior to | |
5901 | 2.8. | |
5902 | ||
5f1e6755 | 5903 | @item -malignment-traps |
cd3bb277 | 5904 | @opindex malignment-traps |
5f1e6755 NC |
5905 | Generate code that will not trap if the MMU has alignment traps enabled. |
5906 | On ARM architectures prior to ARMv4, there were no instructions to | |
5907 | access half-word objects stored in memory. However, when reading from | |
5908 | memory a feature of the ARM architecture allows a word load to be used, | |
5909 | even if the address is unaligned, and the processor core will rotate the | |
5910 | data as it is being loaded. This option tells the compiler that such | |
5911 | misaligned accesses will cause a MMU trap and that it should instead | |
5912 | synthesise the access as a series of byte accesses. The compiler can | |
5913 | still use word accesses to load half-word data if it knows that the | |
5914 | address is aligned to a word boundary. | |
5915 | ||
5916 | This option is ignored when compiling for ARM architecture 4 or later, | |
5917 | since these processors have instructions to directly access half-word | |
02f52e19 AJ |
5918 | objects in memory. |
5919 | ||
5f1e6755 | 5920 | @item -mno-alignment-traps |
cd3bb277 | 5921 | @opindex mno-alignment-traps |
5f1e6755 NC |
5922 | Generate code that assumes that the MMU will not trap unaligned |
5923 | accesses. This produces better code when the target instruction set | |
e979f9e8 | 5924 | does not have half-word memory operations (i.e.@: implementations prior to |
02f52e19 | 5925 | ARMv4). |
5f1e6755 NC |
5926 | |
5927 | Note that you cannot use this option to access unaligned word objects, | |
5928 | since the processor will only fetch one 32-bit aligned object from | |
02f52e19 | 5929 | memory. |
5f1e6755 | 5930 | |
695ac33f | 5931 | The default setting for most targets is @option{-mno-alignment-traps}, since |
5f1e6755 | 5932 | this produces better code when there are no half-word memory |
02f52e19 | 5933 | instructions available. |
5f1e6755 | 5934 | |
74291a4b | 5935 | @item -mshort-load-bytes |
247f8561 | 5936 | @itemx -mno-short-load-words |
cd3bb277 JM |
5937 | @opindex mshort-load-bytes |
5938 | @opindex mno-short-load-words | |
630d3d5a | 5939 | These are deprecated aliases for @option{-malignment-traps}. |
74291a4b MM |
5940 | |
5941 | @item -mno-short-load-bytes | |
247f8561 | 5942 | @itemx -mshort-load-words |
cd3bb277 JM |
5943 | @opindex mno-short-load-bytes |
5944 | @opindex mshort-load-words | |
630d3d5a | 5945 | This are deprecated aliases for @option{-mno-alignment-traps}. |
157a620e | 5946 | |
74291a4b | 5947 | @item -mbsd |
cd3bb277 | 5948 | @opindex mbsd |
161d7b59 | 5949 | This option only applies to RISC iX@. Emulate the native BSD-mode |
630d3d5a | 5950 | compiler. This is the default if @option{-ansi} is not specified. |
74291a4b MM |
5951 | |
5952 | @item -mxopen | |
cd3bb277 | 5953 | @opindex mxopen |
161d7b59 | 5954 | This option only applies to RISC iX@. Emulate the native X/Open-mode |
74291a4b MM |
5955 | compiler. |
5956 | ||
5957 | @item -mno-symrename | |
cd3bb277 | 5958 | @opindex mno-symrename |
161d7b59 | 5959 | This option only applies to RISC iX@. Do not run the assembler |
74291a4b MM |
5960 | post-processor, @samp{symrename}, after code has been assembled. |
5961 | Normally it is necessary to modify some of the standard symbols in | |
5962 | preparation for linking with the RISC iX C library; this option | |
5963 | suppresses this pass. The post-processor is never run when the | |
5964 | compiler is built for cross-compilation. | |
157a620e | 5965 | |
cd3bb277 JM |
5966 | @item -mcpu=@var{name} |
5967 | @opindex mcpu | |
157a620e | 5968 | This specifies the name of the target ARM processor. GCC uses this name |
247f8561 | 5969 | to determine what kind of instructions it can emit when generating |
aee96fe9 JM |
5970 | assembly code. Permissible names are: @samp{arm2}, @samp{arm250}, |
5971 | @samp{arm3}, @samp{arm6}, @samp{arm60}, @samp{arm600}, @samp{arm610}, | |
5972 | @samp{arm620}, @samp{arm7}, @samp{arm7m}, @samp{arm7d}, @samp{arm7dm}, | |
5973 | @samp{arm7di}, @samp{arm7dmi}, @samp{arm70}, @samp{arm700}, | |
5974 | @samp{arm700i}, @samp{arm710}, @samp{arm710c}, @samp{arm7100}, | |
5975 | @samp{arm7500}, @samp{arm7500fe}, @samp{arm7tdmi}, @samp{arm8}, | |
5976 | @samp{strongarm}, @samp{strongarm110}, @samp{strongarm1100}, | |
5977 | @samp{arm8}, @samp{arm810}, @samp{arm9}, @samp{arm9e}, @samp{arm920}, | |
5978 | @samp{arm920t}, @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, | |
5979 | @samp{arm1020t}, @samp{xscale}. | |
62b10bbc | 5980 | |
cd3bb277 JM |
5981 | @itemx -mtune=@var{name} |
5982 | @opindex mtune | |
630d3d5a | 5983 | This option is very similar to the @option{-mcpu=} option, except that |
62b10bbc NC |
5984 | instead of specifying the actual target processor type, and hence |
5985 | restricting which instructions can be used, it specifies that GCC should | |
5986 | tune the performance of the code as if the target were of the type | |
5987 | specified in this option, but still choosing the instructions that it | |
630d3d5a | 5988 | will generate based on the cpu specified by a @option{-mcpu=} option. |
247f8561 | 5989 | For some ARM implementations better performance can be obtained by using |
62b10bbc | 5990 | this option. |
157a620e | 5991 | |
cd3bb277 JM |
5992 | @item -march=@var{name} |
5993 | @opindex march | |
157a620e | 5994 | This specifies the name of the target ARM architecture. GCC uses this |
247f8561 | 5995 | name to determine what kind of instructions it can emit when generating |
157a620e | 5996 | assembly code. This option can be used in conjunction with or instead |
aee96fe9 JM |
5997 | of the @option{-mcpu=} option. Permissible names are: @samp{armv2}, |
5998 | @samp{armv2a}, @samp{armv3}, @samp{armv3m}, @samp{armv4}, @samp{armv4t}, | |
5999 | @samp{armv5}, @samp{armv5t}, @samp{armv5te}. | |
157a620e | 6000 | |
cd3bb277 JM |
6001 | @item -mfpe=@var{number} |
6002 | @itemx -mfp=@var{number} | |
6003 | @opindex mfpe | |
6004 | @opindex mfp | |
b192711e | 6005 | This specifies the version of the floating point emulation available on |
630d3d5a | 6006 | the target. Permissible values are 2 and 3. @option{-mfp=} is a synonym |
161d7b59 | 6007 | for @option{-mfpe=}, for compatibility with older versions of GCC@. |
157a620e | 6008 | |
cd3bb277 JM |
6009 | @item -mstructure-size-boundary=@var{n} |
6010 | @opindex mstructure-size-boundary | |
157a620e | 6011 | The size of all structures and unions will be rounded up to a multiple |
ed0e6530 | 6012 | of the number of bits set by this option. Permissible values are 8 and |
157a620e NC |
6013 | 32. The default value varies for different toolchains. For the COFF |
6014 | targeted toolchain the default value is 8. Specifying the larger number | |
ed0e6530 | 6015 | can produce faster, more efficient code, but can also increase the size |
157a620e NC |
6016 | of the program. The two values are potentially incompatible. Code |
6017 | compiled with one value cannot necessarily expect to work with code or | |
6018 | libraries compiled with the other value, if they exchange information | |
247f8561 | 6019 | using structures or unions. |
157a620e | 6020 | |
f5a1b0d2 | 6021 | @item -mabort-on-noreturn |
cd3bb277 | 6022 | @opindex mabort-on-noreturn |
247f8561 PB |
6023 | Generate a call to the function @code{abort} at the end of a |
6024 | @code{noreturn} function. It will be executed if the function tries to | |
6025 | return. | |
f5a1b0d2 | 6026 | |
c27ba912 DM |
6027 | @item -mlong-calls |
6028 | @itemx -mno-long-calls | |
cd3bb277 JM |
6029 | @opindex mlong-calls |
6030 | @opindex mno-long-calls | |
c27ba912 DM |
6031 | Tells the compiler to perform function calls by first loading the |
6032 | address of the function into a register and then performing a subroutine | |
6033 | call on this register. This switch is needed if the target function | |
6034 | will lie outside of the 64 megabyte addressing range of the offset based | |
02f52e19 | 6035 | version of subroutine call instruction. |
c27ba912 DM |
6036 | |
6037 | Even if this switch is enabled, not all function calls will be turned | |
6038 | into long calls. The heuristic is that static functions, functions | |
6039 | which have the @samp{short-call} attribute, functions that are inside | |
6040 | the scope of a @samp{#pragma no_long_calls} directive and functions whose | |
6041 | definitions have already been compiled within the current compilation | |
6042 | unit, will not be turned into long calls. The exception to this rule is | |
b192711e | 6043 | that weak function definitions, functions with the @samp{long-call} |
c27ba912 DM |
6044 | attribute or the @samp{section} attribute, and functions that are within |
6045 | the scope of a @samp{#pragma long_calls} directive, will always be | |
6046 | turned into long calls. | |
6047 | ||
6048 | This feature is not enabled by default. Specifying | |
630d3d5a | 6049 | @option{-mno-long-calls} will restore the default behaviour, as will |
c27ba912 DM |
6050 | placing the function calls within the scope of a @samp{#pragma |
6051 | long_calls_off} directive. Note these switches have no effect on how | |
6052 | the compiler generates code to handle function calls via function | |
02f52e19 | 6053 | pointers. |
c27ba912 | 6054 | |
62b10bbc | 6055 | @item -mnop-fun-dllimport |
cd3bb277 | 6056 | @opindex mnop-fun-dllimport |
aee96fe9 | 6057 | Disable support for the @code{dllimport} attribute. |
62b10bbc | 6058 | |
ed0e6530 | 6059 | @item -msingle-pic-base |
cd3bb277 | 6060 | @opindex msingle-pic-base |
ed0e6530 PB |
6061 | Treat the register used for PIC addressing as read-only, rather than |
6062 | loading it in the prologue for each function. The run-time system is | |
6063 | responsible for initialising this register with an appropriate value | |
6064 | before execution begins. | |
6065 | ||
cd3bb277 JM |
6066 | @item -mpic-register=@var{reg} |
6067 | @opindex mpic-register | |
ed0e6530 PB |
6068 | Specify the register to be used for PIC addressing. The default is R10 |
6069 | unless stack-checking is enabled, when R9 is used. | |
6070 | ||
247f8561 | 6071 | @item -mpoke-function-name |
cd3bb277 | 6072 | @opindex mpoke-function-name |
247f8561 PB |
6073 | Write the name of each function into the text section, directly |
6074 | preceding the function prologue. The generated code is similar to this: | |
74291a4b | 6075 | |
247f8561 PB |
6076 | @smallexample |
6077 | t0 | |
6078 | .ascii "arm_poke_function_name", 0 | |
6079 | .align | |
6080 | t1 | |
6081 | .word 0xff000000 + (t1 - t0) | |
6082 | arm_poke_function_name | |
6083 | mov ip, sp | |
6084 | stmfd sp!, @{fp, ip, lr, pc@} | |
6085 | sub fp, ip, #4 | |
6086 | @end smallexample | |
157a620e | 6087 | |
247f8561 PB |
6088 | When performing a stack backtrace, code can inspect the value of |
6089 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
6090 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
6091 | there is a function name embedded immediately preceding this location | |
6092 | and has length @code{((pc[-3]) & 0xff000000)}. | |
157a620e | 6093 | |
247f8561 | 6094 | @item -mthumb |
cd3bb277 | 6095 | @opindex mthumb |
247f8561 PB |
6096 | Generate code for the 16-bit Thumb instruction set. The default is to |
6097 | use the 32-bit ARM instruction set. | |
157a620e NC |
6098 | |
6099 | @item -mtpcs-frame | |
cd3bb277 | 6100 | @opindex mtpcs-frame |
157a620e NC |
6101 | Generate a stack frame that is compliant with the Thumb Procedure Call |
6102 | Standard for all non-leaf functions. (A leaf function is one that does | |
630d3d5a | 6103 | not call any other functions.) The default is @option{-mno-tpcs-frame}. |
157a620e NC |
6104 | |
6105 | @item -mtpcs-leaf-frame | |
cd3bb277 | 6106 | @opindex mtpcs-leaf-frame |
157a620e NC |
6107 | Generate a stack frame that is compliant with the Thumb Procedure Call |
6108 | Standard for all leaf functions. (A leaf function is one that does | |
630d3d5a | 6109 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. |
62b10bbc NC |
6110 | |
6111 | @item -mcallee-super-interworking | |
cd3bb277 | 6112 | @opindex mcallee-super-interworking |
62b10bbc NC |
6113 | Gives all externally visible functions in the file being compiled an ARM |
6114 | instruction set header which switches to Thumb mode before executing the | |
6115 | rest of the function. This allows these functions to be called from | |
6116 | non-interworking code. | |
6117 | ||
6118 | @item -mcaller-super-interworking | |
cd3bb277 | 6119 | @opindex mcaller-super-interworking |
62b10bbc NC |
6120 | Allows calls via function pointers (including virtual functions) to |
6121 | execute correctly regardless of whether the target code has been | |
6122 | compiled for interworking or not. There is a small overhead in the cost | |
4bdc1ac7 PB |
6123 | of executing a function pointer if this option is enabled. |
6124 | ||
157a620e NC |
6125 | @end table |
6126 | ||
ecff22ab JL |
6127 | @node MN10200 Options |
6128 | @subsection MN10200 Options | |
6129 | @cindex MN10200 options | |
630d3d5a | 6130 | These @option{-m} options are defined for Matsushita MN10200 architectures: |
2642624b | 6131 | @table @gcctabopt |
ecff22ab JL |
6132 | |
6133 | @item -mrelax | |
cd3bb277 | 6134 | @opindex mrelax |
ecff22ab JL |
6135 | Indicate to the linker that it should perform a relaxation optimization pass |
6136 | to shorten branches, calls and absolute memory addresses. This option only | |
6137 | has an effect when used on the command line for the final link step. | |
6138 | ||
02f52e19 | 6139 | This option makes symbolic debugging impossible. |
ecff22ab | 6140 | @end table |
157a620e | 6141 | |
6d6d0fa0 JL |
6142 | @node MN10300 Options |
6143 | @subsection MN10300 Options | |
6144 | @cindex MN10300 options | |
630d3d5a | 6145 | These @option{-m} options are defined for Matsushita MN10300 architectures: |
6d6d0fa0 | 6146 | |
2642624b | 6147 | @table @gcctabopt |
6d6d0fa0 | 6148 | @item -mmult-bug |
cd3bb277 | 6149 | @opindex mmult-bug |
6d6d0fa0 JL |
6150 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
6151 | processors. This is the default. | |
6152 | ||
6153 | @item -mno-mult-bug | |
cd3bb277 | 6154 | @opindex mno-mult-bug |
6d6d0fa0 JL |
6155 | Do not generate code to avoid bugs in the multiply instructions for the |
6156 | MN10300 processors. | |
ecff22ab | 6157 | |
705ac34f | 6158 | @item -mam33 |
cd3bb277 | 6159 | @opindex mam33 |
705ac34f JL |
6160 | Generate code which uses features specific to the AM33 processor. |
6161 | ||
6162 | @item -mno-am33 | |
cd3bb277 | 6163 | @opindex mno-am33 |
705ac34f JL |
6164 | Do not generate code which uses features specific to the AM33 processor. This |
6165 | is the default. | |
6166 | ||
c474f76b AO |
6167 | @item -mno-crt0 |
6168 | @opindex mno-crt0 | |
6169 | Do not link in the C run-time initialization object file. | |
6170 | ||
ecff22ab | 6171 | @item -mrelax |
cd3bb277 | 6172 | @opindex mrelax |
ecff22ab JL |
6173 | Indicate to the linker that it should perform a relaxation optimization pass |
6174 | to shorten branches, calls and absolute memory addresses. This option only | |
6175 | has an effect when used on the command line for the final link step. | |
6176 | ||
02f52e19 | 6177 | This option makes symbolic debugging impossible. |
6d6d0fa0 JL |
6178 | @end table |
6179 | ||
ecff22ab | 6180 | |
861bb6c1 JL |
6181 | @node M32R/D Options |
6182 | @subsection M32R/D Options | |
6183 | @cindex M32R/D options | |
6184 | ||
630d3d5a | 6185 | These @option{-m} options are defined for Mitsubishi M32R/D architectures: |
861bb6c1 | 6186 | |
2642624b | 6187 | @table @gcctabopt |
861bb6c1 | 6188 | @item -mcode-model=small |
cd3bb277 | 6189 | @opindex mcode-model=small |
861bb6c1 JL |
6190 | Assume all objects live in the lower 16MB of memory (so that their addresses |
6191 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
6192 | are reachable with the @code{bl} instruction. | |
6193 | This is the default. | |
6194 | ||
6195 | The addressability of a particular object can be set with the | |
6196 | @code{model} attribute. | |
6197 | ||
6198 | @item -mcode-model=medium | |
cd3bb277 | 6199 | @opindex mcode-model=medium |
02f52e19 | 6200 | Assume objects may be anywhere in the 32-bit address space (the compiler |
861bb6c1 JL |
6201 | will generate @code{seth/add3} instructions to load their addresses), and |
6202 | assume all subroutines are reachable with the @code{bl} instruction. | |
6203 | ||
6204 | @item -mcode-model=large | |
cd3bb277 | 6205 | @opindex mcode-model=large |
02f52e19 | 6206 | Assume objects may be anywhere in the 32-bit address space (the compiler |
861bb6c1 JL |
6207 | will generate @code{seth/add3} instructions to load their addresses), and |
6208 | assume subroutines may not be reachable with the @code{bl} instruction | |
6209 | (the compiler will generate the much slower @code{seth/add3/jl} | |
6210 | instruction sequence). | |
6211 | ||
6212 | @item -msdata=none | |
cd3bb277 | 6213 | @opindex msdata=none |
861bb6c1 JL |
6214 | Disable use of the small data area. Variables will be put into |
6215 | one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the | |
6216 | @code{section} attribute has been specified). | |
6217 | This is the default. | |
6218 | ||
6219 | The small data area consists of sections @samp{.sdata} and @samp{.sbss}. | |
6220 | Objects may be explicitly put in the small data area with the | |
6221 | @code{section} attribute using one of these sections. | |
6222 | ||
6223 | @item -msdata=sdata | |
cd3bb277 | 6224 | @opindex msdata=sdata |
861bb6c1 JL |
6225 | Put small global and static data in the small data area, but do not |
6226 | generate special code to reference them. | |
6227 | ||
6228 | @item -msdata=use | |
cd3bb277 | 6229 | @opindex msdata=use |
861bb6c1 JL |
6230 | Put small global and static data in the small data area, and generate |
6231 | special instructions to reference them. | |
6232 | ||
6233 | @item -G @var{num} | |
cd3bb277 | 6234 | @opindex G |
861bb6c1 JL |
6235 | @cindex smaller data references |
6236 | Put global and static objects less than or equal to @var{num} bytes | |
6237 | into the small data or bss sections instead of the normal data or bss | |
6238 | sections. The default value of @var{num} is 8. | |
630d3d5a | 6239 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} |
861bb6c1 JL |
6240 | for this option to have any effect. |
6241 | ||
630d3d5a | 6242 | All modules should be compiled with the same @option{-G @var{num}} value. |
861bb6c1 | 6243 | Compiling with different values of @var{num} may or may not work; if it |
695ac33f | 6244 | doesn't the linker will give an error message---incorrect code will not be |
861bb6c1 JL |
6245 | generated. |
6246 | ||
6247 | @end table | |
6248 | ||
74291a4b MM |
6249 | @node M88K Options |
6250 | @subsection M88K Options | |
6251 | @cindex M88k options | |
6252 | ||
6253 | These @samp{-m} options are defined for Motorola 88k architectures: | |
6254 | ||
2642624b | 6255 | @table @gcctabopt |
74291a4b | 6256 | @item -m88000 |
cd3bb277 | 6257 | @opindex m88000 |
74291a4b MM |
6258 | Generate code that works well on both the m88100 and the |
6259 | m88110. | |
6260 | ||
6261 | @item -m88100 | |
cd3bb277 | 6262 | @opindex m88100 |
74291a4b MM |
6263 | Generate code that works best for the m88100, but that also |
6264 | runs on the m88110. | |
6265 | ||
6266 | @item -m88110 | |
cd3bb277 | 6267 | @opindex m88110 |
74291a4b MM |
6268 | Generate code that works best for the m88110, and may not run |
6269 | on the m88100. | |
6270 | ||
6271 | @item -mbig-pic | |
cd3bb277 | 6272 | @opindex mbig-pic |
74291a4b | 6273 | Obsolete option to be removed from the next revision. |
630d3d5a | 6274 | Use @option{-fPIC}. |
74291a4b MM |
6275 | |
6276 | @item -midentify-revision | |
cd3bb277 | 6277 | @opindex midentify-revision |
74291a4b MM |
6278 | @cindex identifying source, compiler (88k) |
6279 | Include an @code{ident} directive in the assembler output recording the | |
6280 | source file name, compiler name and version, timestamp, and compilation | |
6281 | flags used. | |
6282 | ||
6283 | @item -mno-underscores | |
cd3bb277 | 6284 | @opindex mno-underscores |
74291a4b MM |
6285 | @cindex underscores, avoiding (88k) |
6286 | In assembler output, emit symbol names without adding an underscore | |
6287 | character at the beginning of each name. The default is to use an | |
6288 | underscore as prefix on each name. | |
6289 | ||
6290 | @item -mocs-debug-info | |
6291 | @itemx -mno-ocs-debug-info | |
cd3bb277 JM |
6292 | @opindex mocs-debug-info |
6293 | @opindex mno-ocs-debug-info | |
74291a4b MM |
6294 | @cindex OCS (88k) |
6295 | @cindex debugging, 88k OCS | |
6296 | Include (or omit) additional debugging information (about registers used | |
6297 | in each stack frame) as specified in the 88open Object Compatibility | |
161d7b59 | 6298 | Standard, ``OCS''@. This extra information allows debugging of code that |
74291a4b MM |
6299 | has had the frame pointer eliminated. The default for DG/UX, SVr4, and |
6300 | Delta 88 SVr3.2 is to include this information; other 88k configurations | |
6301 | omit this information by default. | |
6302 | ||
6303 | @item -mocs-frame-position | |
cd3bb277 | 6304 | @opindex mocs-frame-position |
74291a4b MM |
6305 | @cindex register positions in frame (88k) |
6306 | When emitting COFF debugging information for automatic variables and | |
6307 | parameters stored on the stack, use the offset from the canonical frame | |
6308 | address, which is the stack pointer (register 31) on entry to the | |
6309 | function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use | |
630d3d5a JM |
6310 | @option{-mocs-frame-position}; other 88k configurations have the default |
6311 | @option{-mno-ocs-frame-position}. | |
74291a4b MM |
6312 | |
6313 | @item -mno-ocs-frame-position | |
cd3bb277 | 6314 | @opindex mno-ocs-frame-position |
74291a4b MM |
6315 | @cindex register positions in frame (88k) |
6316 | When emitting COFF debugging information for automatic variables and | |
6317 | parameters stored on the stack, use the offset from the frame pointer | |
6318 | register (register 30). When this option is in effect, the frame | |
6319 | pointer is not eliminated when debugging information is selected by the | |
6320 | -g switch. | |
6321 | ||
6322 | @item -moptimize-arg-area | |
6323 | @itemx -mno-optimize-arg-area | |
cd3bb277 JM |
6324 | @opindex moptimize-arg-area |
6325 | @opindex mno-optimize-arg-area | |
74291a4b MM |
6326 | @cindex arguments in frame (88k) |
6327 | Control how function arguments are stored in stack frames. | |
630d3d5a | 6328 | @option{-moptimize-arg-area} saves space by optimizing them, but this |
74291a4b | 6329 | conflicts with the 88open specifications. The opposite alternative, |
630d3d5a | 6330 | @option{-mno-optimize-arg-area}, agrees with 88open standards. By default |
0c2d1a2a | 6331 | GCC does not optimize the argument area. |
74291a4b MM |
6332 | |
6333 | @item -mshort-data-@var{num} | |
cd3bb277 | 6334 | @opindex mshort-data |
74291a4b MM |
6335 | @cindex smaller data references (88k) |
6336 | @cindex r0-relative references (88k) | |
6337 | Generate smaller data references by making them relative to @code{r0}, | |
6338 | which allows loading a value using a single instruction (rather than the | |
6339 | usual two). You control which data references are affected by | |
6340 | specifying @var{num} with this option. For example, if you specify | |
630d3d5a | 6341 | @option{-mshort-data-512}, then the data references affected are those |
74291a4b | 6342 | involving displacements of less than 512 bytes. |
630d3d5a | 6343 | @option{-mshort-data-@var{num}} is not effective for @var{num} greater |
74291a4b MM |
6344 | than 64k. |
6345 | ||
6346 | @item -mserialize-volatile | |
cd3bb277 | 6347 | @opindex mserialize-volatile |
74291a4b | 6348 | @itemx -mno-serialize-volatile |
cd3bb277 | 6349 | @opindex mno-serialize-volatile |
74291a4b MM |
6350 | @cindex sequential consistency on 88k |
6351 | Do, or don't, generate code to guarantee sequential consistency | |
6352 | of volatile memory references. By default, consistency is | |
6353 | guaranteed. | |
6354 | ||
6355 | The order of memory references made by the MC88110 processor does | |
6356 | not always match the order of the instructions requesting those | |
6357 | references. In particular, a load instruction may execute before | |
6358 | a preceding store instruction. Such reordering violates | |
6359 | sequential consistency of volatile memory references, when there | |
6360 | are multiple processors. When consistency must be guaranteed, | |
f0523f02 | 6361 | GCC generates special instructions, as needed, to force |
74291a4b MM |
6362 | execution in the proper order. |
6363 | ||
6364 | The MC88100 processor does not reorder memory references and so | |
f0523f02 JM |
6365 | always provides sequential consistency. However, by default, GCC |
6366 | generates the special instructions to guarantee consistency | |
630d3d5a | 6367 | even when you use @option{-m88100}, so that the code may be run on an |
74291a4b | 6368 | MC88110 processor. If you intend to run your code only on the |
630d3d5a | 6369 | MC88100 processor, you may use @option{-mno-serialize-volatile}. |
74291a4b MM |
6370 | |
6371 | The extra code generated to guarantee consistency may affect the | |
6372 | performance of your application. If you know that you can safely | |
630d3d5a | 6373 | forgo this guarantee, you may use @option{-mno-serialize-volatile}. |
74291a4b MM |
6374 | |
6375 | @item -msvr4 | |
6376 | @itemx -msvr3 | |
cd3bb277 JM |
6377 | @opindex msvr4 |
6378 | @opindex msvr3 | |
74291a4b MM |
6379 | @cindex assembler syntax, 88k |
6380 | @cindex SVr4 | |
630d3d5a | 6381 | Turn on (@option{-msvr4}) or off (@option{-msvr3}) compiler extensions |
74291a4b MM |
6382 | related to System V release 4 (SVr4). This controls the following: |
6383 | ||
6384 | @enumerate | |
6385 | @item | |
6386 | Which variant of the assembler syntax to emit. | |
6387 | @item | |
630d3d5a | 6388 | @option{-msvr4} makes the C preprocessor recognize @samp{#pragma weak} |
74291a4b MM |
6389 | that is used on System V release 4. |
6390 | @item | |
630d3d5a | 6391 | @option{-msvr4} makes GCC issue additional declaration directives used in |
74291a4b MM |
6392 | SVr4. |
6393 | @end enumerate | |
6394 | ||
630d3d5a | 6395 | @option{-msvr4} is the default for the m88k-motorola-sysv4 and |
767094dd | 6396 | m88k-dg-dgux m88k configurations. @option{-msvr3} is the default for all |
74291a4b MM |
6397 | other m88k configurations. |
6398 | ||
6399 | @item -mversion-03.00 | |
cd3bb277 | 6400 | @opindex mversion-03.00 |
74291a4b MM |
6401 | This option is obsolete, and is ignored. |
6402 | @c ??? which asm syntax better for GAS? option there too? | |
6403 | ||
6404 | @item -mno-check-zero-division | |
6405 | @itemx -mcheck-zero-division | |
cd3bb277 JM |
6406 | @opindex mno-check-zero-division |
6407 | @opindex mcheck-zero-division | |
74291a4b MM |
6408 | @cindex zero division on 88k |
6409 | Do, or don't, generate code to guarantee that integer division by | |
6410 | zero will be detected. By default, detection is guaranteed. | |
6411 | ||
6412 | Some models of the MC88100 processor fail to trap upon integer | |
6413 | division by zero under certain conditions. By default, when | |
f0523f02 | 6414 | compiling code that might be run on such a processor, GCC |
74291a4b MM |
6415 | generates code that explicitly checks for zero-valued divisors |
6416 | and traps with exception number 503 when one is detected. Use of | |
6417 | mno-check-zero-division suppresses such checking for code | |
6418 | generated to run on an MC88100 processor. | |
6419 | ||
f0523f02 | 6420 | GCC assumes that the MC88110 processor correctly detects all |
630d3d5a JM |
6421 | instances of integer division by zero. When @option{-m88110} is |
6422 | specified, both @option{-mcheck-zero-division} and | |
6423 | @option{-mno-check-zero-division} are ignored, and no explicit checks for | |
74291a4b MM |
6424 | zero-valued divisors are generated. |
6425 | ||
6426 | @item -muse-div-instruction | |
cd3bb277 | 6427 | @opindex muse-div-instruction |
74291a4b MM |
6428 | @cindex divide instruction, 88k |
6429 | Use the div instruction for signed integer division on the | |
6430 | MC88100 processor. By default, the div instruction is not used. | |
6431 | ||
6432 | On the MC88100 processor the signed integer division instruction | |
6433 | div) traps to the operating system on a negative operand. The | |
6434 | operating system transparently completes the operation, but at a | |
6435 | large cost in execution time. By default, when compiling code | |
f0523f02 | 6436 | that might be run on an MC88100 processor, GCC emulates signed |
74291a4b MM |
6437 | integer division using the unsigned integer division instruction |
6438 | divu), thereby avoiding the large penalty of a trap to the | |
6439 | operating system. Such emulation has its own, smaller, execution | |
6440 | cost in both time and space. To the extent that your code's | |
6441 | important signed integer division operations are performed on two | |
6442 | nonnegative operands, it may be desirable to use the div | |
6443 | instruction directly. | |
6444 | ||
6445 | On the MC88110 processor the div instruction (also known as the | |
6446 | divs instruction) processes negative operands without trapping to | |
630d3d5a JM |
6447 | the operating system. When @option{-m88110} is specified, |
6448 | @option{-muse-div-instruction} is ignored, and the div instruction is used | |
74291a4b MM |
6449 | for signed integer division. |
6450 | ||
630d3d5a | 6451 | Note that the result of dividing @code{INT_MIN} by @minus{}1 is undefined. In |
74291a4b | 6452 | particular, the behavior of such a division with and without |
630d3d5a | 6453 | @option{-muse-div-instruction} may differ. |
74291a4b MM |
6454 | |
6455 | @item -mtrap-large-shift | |
6456 | @itemx -mhandle-large-shift | |
cd3bb277 JM |
6457 | @opindex mtrap-large-shift |
6458 | @opindex mhandle-large-shift | |
74291a4b MM |
6459 | @cindex bit shift overflow (88k) |
6460 | @cindex large bit shifts (88k) | |
6461 | Include code to detect bit-shifts of more than 31 bits; respectively, | |
0c2d1a2a | 6462 | trap such shifts or emit code to handle them properly. By default GCC |
74291a4b MM |
6463 | makes no special provision for large bit shifts. |
6464 | ||
6465 | @item -mwarn-passed-structs | |
cd3bb277 | 6466 | @opindex mwarn-passed-structs |
74291a4b MM |
6467 | @cindex structure passing (88k) |
6468 | Warn when a function passes a struct as an argument or result. | |
6469 | Structure-passing conventions have changed during the evolution of the C | |
6470 | language, and are often the source of portability problems. By default, | |
0c2d1a2a | 6471 | GCC issues no such warning. |
74291a4b MM |
6472 | @end table |
6473 | ||
6474 | @node RS/6000 and PowerPC Options | |
6475 | @subsection IBM RS/6000 and PowerPC Options | |
6476 | @cindex RS/6000 and PowerPC Options | |
6477 | @cindex IBM RS/6000 and PowerPC Options | |
6478 | ||
6479 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
2642624b | 6480 | @table @gcctabopt |
74291a4b MM |
6481 | @item -mpower |
6482 | @itemx -mno-power | |
6483 | @itemx -mpower2 | |
6484 | @itemx -mno-power2 | |
6485 | @itemx -mpowerpc | |
6486 | @itemx -mno-powerpc | |
6487 | @itemx -mpowerpc-gpopt | |
6488 | @itemx -mno-powerpc-gpopt | |
6489 | @itemx -mpowerpc-gfxopt | |
6490 | @itemx -mno-powerpc-gfxopt | |
7fe90e7b DE |
6491 | @itemx -mpowerpc64 |
6492 | @itemx -mno-powerpc64 | |
cd3bb277 JM |
6493 | @opindex mpower |
6494 | @opindex mno-power | |
6495 | @opindex mpower2 | |
6496 | @opindex mno-power2 | |
6497 | @opindex mpowerpc | |
6498 | @opindex mno-powerpc | |
6499 | @opindex mpowerpc-gpopt | |
6500 | @opindex mno-powerpc-gpopt | |
6501 | @opindex mpowerpc-gfxopt | |
6502 | @opindex mno-powerpc-gfxopt | |
6503 | @opindex mpowerpc64 | |
6504 | @opindex mno-powerpc64 | |
0c2d1a2a | 6505 | GCC supports two related instruction set architectures for the |
161d7b59 | 6506 | RS/6000 and PowerPC@. The @dfn{POWER} instruction set are those |
74291a4b MM |
6507 | instructions supported by the @samp{rios} chip set used in the original |
6508 | RS/6000 systems and the @dfn{PowerPC} instruction set is the | |
6509 | architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and | |
861bb6c1 | 6510 | the IBM 4xx microprocessors. |
74291a4b MM |
6511 | |
6512 | Neither architecture is a subset of the other. However there is a | |
6513 | large common subset of instructions supported by both. An MQ | |
6514 | register is included in processors supporting the POWER architecture. | |
6515 | ||
6516 | You use these options to specify which instructions are available on the | |
6517 | processor you are using. The default value of these options is | |
161d7b59 | 6518 | determined when configuring GCC@. Specifying the |
630d3d5a JM |
6519 | @option{-mcpu=@var{cpu_type}} overrides the specification of these |
6520 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
74291a4b MM |
6521 | rather than the options listed above. |
6522 | ||
630d3d5a | 6523 | The @option{-mpower} option allows GCC to generate instructions that |
74291a4b | 6524 | are found only in the POWER architecture and to use the MQ register. |
630d3d5a | 6525 | Specifying @option{-mpower2} implies @option{-power} and also allows GCC |
74291a4b MM |
6526 | to generate instructions that are present in the POWER2 architecture but |
6527 | not the original POWER architecture. | |
6528 | ||
630d3d5a | 6529 | The @option{-mpowerpc} option allows GCC to generate instructions that |
74291a4b | 6530 | are found only in the 32-bit subset of the PowerPC architecture. |
630d3d5a | 6531 | Specifying @option{-mpowerpc-gpopt} implies @option{-mpowerpc} and also allows |
0c2d1a2a | 6532 | GCC to use the optional PowerPC architecture instructions in the |
74291a4b | 6533 | General Purpose group, including floating-point square root. Specifying |
630d3d5a | 6534 | @option{-mpowerpc-gfxopt} implies @option{-mpowerpc} and also allows GCC to |
74291a4b MM |
6535 | use the optional PowerPC architecture instructions in the Graphics |
6536 | group, including floating-point select. | |
6537 | ||
630d3d5a | 6538 | The @option{-mpowerpc64} option allows GCC to generate the additional |
7fe90e7b | 6539 | 64-bit instructions that are found in the full PowerPC64 architecture |
0c2d1a2a | 6540 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to |
630d3d5a | 6541 | @option{-mno-powerpc64}. |
7fe90e7b | 6542 | |
630d3d5a | 6543 | If you specify both @option{-mno-power} and @option{-mno-powerpc}, GCC |
74291a4b MM |
6544 | will use only the instructions in the common subset of both |
6545 | architectures plus some special AIX common-mode calls, and will not use | |
630d3d5a | 6546 | the MQ register. Specifying both @option{-mpower} and @option{-mpowerpc} |
0c2d1a2a | 6547 | permits GCC to use any instruction from either architecture and to |
74291a4b MM |
6548 | allow use of the MQ register; specify this for the Motorola MPC601. |
6549 | ||
6550 | @item -mnew-mnemonics | |
6551 | @itemx -mold-mnemonics | |
cd3bb277 JM |
6552 | @opindex mnew-mnemonics |
6553 | @opindex mold-mnemonics | |
74291a4b | 6554 | Select which mnemonics to use in the generated assembler code. |
630d3d5a JM |
6555 | @option{-mnew-mnemonics} requests output that uses the assembler mnemonics |
6556 | defined for the PowerPC architecture, while @option{-mold-mnemonics} | |
74291a4b MM |
6557 | requests the assembler mnemonics defined for the POWER architecture. |
6558 | Instructions defined in only one architecture have only one mnemonic; | |
0c2d1a2a | 6559 | GCC uses that mnemonic irrespective of which of these options is |
74291a4b MM |
6560 | specified. |
6561 | ||
0c2d1a2a | 6562 | GCC defaults to the mnemonics appropriate for the architecture in |
630d3d5a | 6563 | use. Specifying @option{-mcpu=@var{cpu_type}} sometimes overrides the |
7fe90e7b | 6564 | value of these option. Unless you are building a cross-compiler, you |
630d3d5a JM |
6565 | should normally not specify either @option{-mnew-mnemonics} or |
6566 | @option{-mold-mnemonics}, but should instead accept the default. | |
74291a4b MM |
6567 | |
6568 | @item -mcpu=@var{cpu_type} | |
cd3bb277 | 6569 | @opindex mcpu |
74291a4b MM |
6570 | Set architecture type, register usage, choice of mnemonics, and |
6571 | instruction scheduling parameters for machine type @var{cpu_type}. | |
5f59ecb7 DE |
6572 | Supported values for @var{cpu_type} are @samp{rios}, @samp{rios1}, |
6573 | @samp{rsc}, @samp{rios2}, @samp{rs64a}, @samp{601}, @samp{602}, | |
6574 | @samp{603}, @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, | |
6575 | @samp{630}, @samp{740}, @samp{750}, @samp{power}, @samp{power2}, | |
6576 | @samp{powerpc}, @samp{403}, @samp{505}, @samp{801}, @samp{821}, | |
630d3d5a JM |
6577 | @samp{823}, and @samp{860} and @samp{common}. @option{-mcpu=power}, |
6578 | @option{-mcpu=power2}, @option{-mcpu=powerpc}, and @option{-mcpu=powerpc64} | |
5f59ecb7 DE |
6579 | specify generic POWER, POWER2, pure 32-bit PowerPC (i.e., not MPC601), |
6580 | and 64-bit PowerPC architecture machine types, with an appropriate, | |
bd819a4a | 6581 | generic processor model assumed for scheduling purposes. |
74291a4b | 6582 | |
02f52e19 | 6583 | Specifying any of the following options: |
630d3d5a JM |
6584 | @option{-mcpu=rios1}, @option{-mcpu=rios2}, @option{-mcpu=rsc}, |
6585 | @option{-mcpu=power}, or @option{-mcpu=power2} | |
6586 | enables the @option{-mpower} option and disables the @option{-mpowerpc} option; | |
6587 | @option{-mcpu=601} enables both the @option{-mpower} and @option{-mpowerpc} options. | |
6588 | All of @option{-mcpu=rs64a}, @option{-mcpu=602}, @option{-mcpu=603}, | |
6589 | @option{-mcpu=603e}, @option{-mcpu=604}, @option{-mcpu=620}, @option{-mcpu=630}, | |
6590 | @option{-mcpu=740}, and @option{-mcpu=750} | |
6591 | enable the @option{-mpowerpc} option and disable the @option{-mpower} option. | |
6592 | Exactly similarly, all of @option{-mcpu=403}, | |
6593 | @option{-mcpu=505}, @option{-mcpu=821}, @option{-mcpu=860} and @option{-mcpu=powerpc} | |
6594 | enable the @option{-mpowerpc} option and disable the @option{-mpower} option. | |
6595 | @option{-mcpu=common} disables both the | |
bd819a4a | 6596 | @option{-mpower} and @option{-mpowerpc} options. |
630d3d5a JM |
6597 | |
6598 | AIX versions 4 or greater selects @option{-mcpu=common} by default, so | |
5f59ecb7 | 6599 | that code will operate on all members of the RS/6000 POWER and PowerPC |
0c2d1a2a | 6600 | families. In that case, GCC will use only the instructions in the |
74291a4b | 6601 | common subset of both architectures plus some special AIX common-mode |
0c2d1a2a | 6602 | calls, and will not use the MQ register. GCC assumes a generic |
74291a4b MM |
6603 | processor model for scheduling purposes. |
6604 | ||
630d3d5a JM |
6605 | Specifying any of the options @option{-mcpu=rios1}, @option{-mcpu=rios2}, |
6606 | @option{-mcpu=rsc}, @option{-mcpu=power}, or @option{-mcpu=power2} also | |
6607 | disables the @samp{new-mnemonics} option. Specifying @option{-mcpu=601}, | |
6608 | @option{-mcpu=602}, @option{-mcpu=603}, @option{-mcpu=603e}, @option{-mcpu=604}, | |
6609 | @option{-mcpu=620}, @option{-mcpu=630}, @option{-mcpu=403}, @option{-mcpu=505}, | |
6610 | @option{-mcpu=821}, @option{-mcpu=860} or @option{-mcpu=powerpc} also enables | |
bd819a4a | 6611 | the @samp{new-mnemonics} option. |
74291a4b | 6612 | |
630d3d5a JM |
6613 | Specifying @option{-mcpu=403}, @option{-mcpu=821}, or @option{-mcpu=860} also |
6614 | enables the @option{-msoft-float} option. | |
74291a4b MM |
6615 | |
6616 | @item -mtune=@var{cpu_type} | |
cd3bb277 | 6617 | @opindex mtune |
74291a4b MM |
6618 | Set the instruction scheduling parameters for machine type |
6619 | @var{cpu_type}, but do not set the architecture type, register usage, | |
630d3d5a JM |
6620 | choice of mnemonics like @option{-mcpu=@var{cpu_type}} would. The same |
6621 | values for @var{cpu_type} are used for @option{-mtune=@var{cpu_type}} as | |
6622 | for @option{-mcpu=@var{cpu_type}}. The @option{-mtune=@var{cpu_type}} | |
6623 | option overrides the @option{-mcpu=@var{cpu_type}} option in terms of | |
74291a4b MM |
6624 | instruction scheduling parameters. |
6625 | ||
6626 | @item -mfull-toc | |
6627 | @itemx -mno-fp-in-toc | |
6628 | @itemx -mno-sum-in-toc | |
6629 | @itemx -mminimal-toc | |
cd3bb277 JM |
6630 | @opindex mfull-toc |
6631 | @opindex mno-fp-in-toc | |
6632 | @opindex mno-sum-in-toc | |
6633 | @opindex mminimal-toc | |
74291a4b | 6634 | Modify generation of the TOC (Table Of Contents), which is created for |
630d3d5a | 6635 | every executable file. The @option{-mfull-toc} option is selected by |
0c2d1a2a JB |
6636 | default. In that case, GCC will allocate at least one TOC entry for |
6637 | each unique non-automatic variable reference in your program. GCC | |
161d7b59 JM |
6638 | will also place floating-point constants in the TOC@. However, only |
6639 | 16,384 entries are available in the TOC@. | |
74291a4b MM |
6640 | |
6641 | If you receive a linker error message that saying you have overflowed | |
6642 | the available TOC space, you can reduce the amount of TOC space used | |
630d3d5a JM |
6643 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. |
6644 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
6645 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
74291a4b | 6646 | generate code to calculate the sum of an address and a constant at |
161d7b59 | 6647 | run-time instead of putting that sum into the TOC@. You may specify one |
0c2d1a2a | 6648 | or both of these options. Each causes GCC to produce very slightly |
74291a4b MM |
6649 | slower and larger code at the expense of conserving TOC space. |
6650 | ||
6651 | If you still run out of space in the TOC even when you specify both of | |
630d3d5a | 6652 | these options, specify @option{-mminimal-toc} instead. This option causes |
0c2d1a2a JB |
6653 | GCC to make only one TOC entry for every file. When you specify this |
6654 | option, GCC will produce code that is slower and larger but which | |
74291a4b | 6655 | uses extremely little TOC space. You may wish to use this option |
bd819a4a | 6656 | only on files that contain less frequently executed code. |
74291a4b | 6657 | |
fa06229f GK |
6658 | @item -maix64 |
6659 | @itemx -maix32 | |
cd3bb277 JM |
6660 | @opindex maix64 |
6661 | @opindex maix32 | |
fa06229f | 6662 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
7fe90e7b | 6663 | @code{long} type, and the infrastructure needed to support them. |
630d3d5a JM |
6664 | Specifying @option{-maix64} implies @option{-mpowerpc64} and |
6665 | @option{-mpowerpc}, while @option{-maix32} disables the 64-bit ABI and | |
6666 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
7fe90e7b | 6667 | |
74291a4b MM |
6668 | @item -mxl-call |
6669 | @itemx -mno-xl-call | |
cd3bb277 JM |
6670 | @opindex mxl-call |
6671 | @opindex mno-xl-call | |
74291a4b MM |
6672 | On AIX, pass floating-point arguments to prototyped functions beyond the |
6673 | register save area (RSA) on the stack in addition to argument FPRs. The | |
6674 | AIX calling convention was extended but not initially documented to | |
6675 | handle an obscure K&R C case of calling a function that takes the | |
6676 | address of its arguments with fewer arguments than declared. AIX XL | |
7fe90e7b DE |
6677 | compilers access floating point arguments which do not fit in the |
6678 | RSA from the stack when a subroutine is compiled without | |
74291a4b MM |
6679 | optimization. Because always storing floating-point arguments on the |
6680 | stack is inefficient and rarely needed, this option is not enabled by | |
6681 | default and only is necessary when calling subroutines compiled by AIX | |
6682 | XL compilers without optimization. | |
6683 | ||
861bb6c1 | 6684 | @item -mthreads |
cd3bb277 | 6685 | @opindex mthreads |
861bb6c1 JL |
6686 | Support @dfn{AIX Threads}. Link an application written to use |
6687 | @dfn{pthreads} with special libraries and startup code to enable the | |
6688 | application to run. | |
6689 | ||
6690 | @item -mpe | |
cd3bb277 | 6691 | @opindex mpe |
161d7b59 | 6692 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
861bb6c1 JL |
6693 | application written to use message passing with special startup code to |
6694 | enable the application to run. The system must have PE installed in the | |
6695 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
630d3d5a | 6696 | must be overridden with the @option{-specs=} option to specify the |
861bb6c1 | 6697 | appropriate directory location. The Parallel Environment does not |
630d3d5a | 6698 | support threads, so the @option{-mpe} option and the @option{-mthreads} |
861bb6c1 JL |
6699 | option are incompatible. |
6700 | ||
74291a4b MM |
6701 | @item -msoft-float |
6702 | @itemx -mhard-float | |
cd3bb277 JM |
6703 | @opindex msoft-float |
6704 | @opindex mhard-float | |
74291a4b MM |
6705 | Generate code that does not use (uses) the floating-point register set. |
6706 | Software floating point emulation is provided if you use the | |
630d3d5a | 6707 | @option{-msoft-float} option, and pass the option to GCC when linking. |
74291a4b MM |
6708 | |
6709 | @item -mmultiple | |
6710 | @itemx -mno-multiple | |
cd3bb277 JM |
6711 | @opindex mmultiple |
6712 | @opindex mno-multiple | |
74291a4b MM |
6713 | Generate code that uses (does not use) the load multiple word |
6714 | instructions and the store multiple word instructions. These | |
6715 | instructions are generated by default on POWER systems, and not | |
630d3d5a | 6716 | generated on PowerPC systems. Do not use @option{-mmultiple} on little |
74291a4b | 6717 | endian PowerPC systems, since those instructions do not work when the |
bef84347 VM |
6718 | processor is in little endian mode. The exceptions are PPC740 and |
6719 | PPC750 which permit the instructions usage in little endian mode. | |
74291a4b MM |
6720 | |
6721 | @item -mstring | |
6722 | @itemx -mno-string | |
cd3bb277 JM |
6723 | @opindex mstring |
6724 | @opindex mno-string | |
bef84347 VM |
6725 | Generate code that uses (does not use) the load string instructions |
6726 | and the store string word instructions to save multiple registers and | |
6727 | do small block moves. These instructions are generated by default on | |
6728 | POWER systems, and not generated on PowerPC systems. Do not use | |
630d3d5a | 6729 | @option{-mstring} on little endian PowerPC systems, since those |
bef84347 VM |
6730 | instructions do not work when the processor is in little endian mode. |
6731 | The exceptions are PPC740 and PPC750 which permit the instructions | |
6732 | usage in little endian mode. | |
74291a4b | 6733 | |
861bb6c1 JL |
6734 | @item -mupdate |
6735 | @itemx -mno-update | |
cd3bb277 JM |
6736 | @opindex mupdate |
6737 | @opindex mno-update | |
861bb6c1 JL |
6738 | Generate code that uses (does not use) the load or store instructions |
6739 | that update the base register to the address of the calculated memory | |
6740 | location. These instructions are generated by default. If you use | |
630d3d5a | 6741 | @option{-mno-update}, there is a small window between the time that the |
861bb6c1 JL |
6742 | stack pointer is updated and the address of the previous frame is |
6743 | stored, which means code that walks the stack frame across interrupts or | |
6744 | signals may get corrupted data. | |
6745 | ||
6746 | @item -mfused-madd | |
6747 | @itemx -mno-fused-madd | |
cd3bb277 JM |
6748 | @opindex mfused-madd |
6749 | @opindex mno-fused-madd | |
861bb6c1 JL |
6750 | Generate code that uses (does not use) the floating point multiply and |
6751 | accumulate instructions. These instructions are generated by default if | |
6752 | hardware floating is used. | |
6753 | ||
74291a4b MM |
6754 | @item -mno-bit-align |
6755 | @itemx -mbit-align | |
cd3bb277 JM |
6756 | @opindex mno-bit-align |
6757 | @opindex mbit-align | |
74291a4b | 6758 | On System V.4 and embedded PowerPC systems do not (do) force structures |
c771326b JM |
6759 | and unions that contain bit-fields to be aligned to the base type of the |
6760 | bit-field. | |
74291a4b MM |
6761 | |
6762 | For example, by default a structure containing nothing but 8 | |
c771326b | 6763 | @code{unsigned} bit-fields of length 1 would be aligned to a 4 byte |
630d3d5a | 6764 | boundary and have a size of 4 bytes. By using @option{-mno-bit-align}, |
74291a4b MM |
6765 | the structure would be aligned to a 1 byte boundary and be one byte in |
6766 | size. | |
6767 | ||
6768 | @item -mno-strict-align | |
6769 | @itemx -mstrict-align | |
cd3bb277 JM |
6770 | @opindex mno-strict-align |
6771 | @opindex mstrict-align | |
74291a4b MM |
6772 | On System V.4 and embedded PowerPC systems do not (do) assume that |
6773 | unaligned memory references will be handled by the system. | |
6774 | ||
6775 | @item -mrelocatable | |
6776 | @itemx -mno-relocatable | |
cd3bb277 JM |
6777 | @opindex mrelocatable |
6778 | @opindex mno-relocatable | |
74291a4b MM |
6779 | On embedded PowerPC systems generate code that allows (does not allow) |
6780 | the program to be relocated to a different address at runtime. If you | |
630d3d5a JM |
6781 | use @option{-mrelocatable} on any module, all objects linked together must |
6782 | be compiled with @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
74291a4b MM |
6783 | |
6784 | @item -mrelocatable-lib | |
6785 | @itemx -mno-relocatable-lib | |
cd3bb277 JM |
6786 | @opindex mrelocatable-lib |
6787 | @opindex mno-relocatable-lib | |
74291a4b MM |
6788 | On embedded PowerPC systems generate code that allows (does not allow) |
6789 | the program to be relocated to a different address at runtime. Modules | |
630d3d5a JM |
6790 | compiled with @option{-mrelocatable-lib} can be linked with either modules |
6791 | compiled without @option{-mrelocatable} and @option{-mrelocatable-lib} or | |
6792 | with modules compiled with the @option{-mrelocatable} options. | |
74291a4b MM |
6793 | |
6794 | @item -mno-toc | |
6795 | @itemx -mtoc | |
cd3bb277 JM |
6796 | @opindex mno-toc |
6797 | @opindex mtoc | |
74291a4b MM |
6798 | On System V.4 and embedded PowerPC systems do not (do) assume that |
6799 | register 2 contains a pointer to a global area pointing to the addresses | |
6800 | used in the program. | |
6801 | ||
74291a4b MM |
6802 | @item -mlittle |
6803 | @itemx -mlittle-endian | |
cd3bb277 JM |
6804 | @opindex mlittle |
6805 | @opindex mlittle-endian | |
74291a4b | 6806 | On System V.4 and embedded PowerPC systems compile code for the |
630d3d5a JM |
6807 | processor in little endian mode. The @option{-mlittle-endian} option is |
6808 | the same as @option{-mlittle}. | |
74291a4b MM |
6809 | |
6810 | @item -mbig | |
6811 | @itemx -mbig-endian | |
cd3bb277 JM |
6812 | @opindex mbig |
6813 | @opindex mbig-endian | |
74291a4b | 6814 | On System V.4 and embedded PowerPC systems compile code for the |
630d3d5a JM |
6815 | processor in big endian mode. The @option{-mbig-endian} option is |
6816 | the same as @option{-mbig}. | |
74291a4b MM |
6817 | |
6818 | @item -mcall-sysv | |
cd3bb277 | 6819 | @opindex mcall-sysv |
74291a4b MM |
6820 | On System V.4 and embedded PowerPC systems compile code using calling |
6821 | conventions that adheres to the March 1995 draft of the System V | |
6822 | Application Binary Interface, PowerPC processor supplement. This is the | |
6823 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
6824 | ||
6825 | @item -mcall-sysv-eabi | |
cd3bb277 | 6826 | @opindex mcall-sysv-eabi |
630d3d5a | 6827 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
74291a4b MM |
6828 | |
6829 | @item -mcall-sysv-noeabi | |
cd3bb277 | 6830 | @opindex mcall-sysv-noeabi |
630d3d5a | 6831 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
74291a4b MM |
6832 | |
6833 | @item -mcall-aix | |
cd3bb277 | 6834 | @opindex mcall-aix |
74291a4b | 6835 | On System V.4 and embedded PowerPC systems compile code using calling |
161d7b59 | 6836 | conventions that are similar to those used on AIX@. This is the |
74291a4b MM |
6837 | default if you configured GCC using @samp{powerpc-*-eabiaix}. |
6838 | ||
6839 | @item -mcall-solaris | |
cd3bb277 | 6840 | @opindex mcall-solaris |
74291a4b MM |
6841 | On System V.4 and embedded PowerPC systems compile code for the Solaris |
6842 | operating system. | |
6843 | ||
6844 | @item -mcall-linux | |
cd3bb277 | 6845 | @opindex mcall-linux |
861bb6c1 JL |
6846 | On System V.4 and embedded PowerPC systems compile code for the |
6847 | Linux-based GNU system. | |
74291a4b MM |
6848 | |
6849 | @item -mprototype | |
e9a25f70 | 6850 | @itemx -mno-prototype |
cd3bb277 JM |
6851 | @opindex mprototype |
6852 | @opindex mno-prototype | |
74291a4b MM |
6853 | On System V.4 and embedded PowerPC systems assume that all calls to |
6854 | variable argument functions are properly prototyped. Otherwise, the | |
6855 | compiler must insert an instruction before every non prototyped call to | |
6856 | set or clear bit 6 of the condition code register (@var{CR}) to | |
6857 | indicate whether floating point values were passed in the floating point | |
6858 | registers in case the function takes a variable arguments. With | |
630d3d5a | 6859 | @option{-mprototype}, only calls to prototyped variable argument functions |
74291a4b MM |
6860 | will set or clear the bit. |
6861 | ||
6862 | @item -msim | |
cd3bb277 | 6863 | @opindex msim |
74291a4b MM |
6864 | On embedded PowerPC systems, assume that the startup module is called |
6865 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
6866 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}. | |
6867 | configurations. | |
6868 | ||
6869 | @item -mmvme | |
cd3bb277 | 6870 | @opindex mmvme |
74291a4b | 6871 | On embedded PowerPC systems, assume that the startup module is called |
e9a25f70 JL |
6872 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and |
6873 | @file{libc.a}. | |
6874 | ||
6875 | @item -mads | |
cd3bb277 | 6876 | @opindex mads |
e9a25f70 JL |
6877 | On embedded PowerPC systems, assume that the startup module is called |
6878 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
6879 | @file{libc.a}. | |
6880 | ||
6881 | @item -myellowknife | |
cd3bb277 | 6882 | @opindex myellowknife |
e9a25f70 JL |
6883 | On embedded PowerPC systems, assume that the startup module is called |
6884 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
74291a4b MM |
6885 | @file{libc.a}. |
6886 | ||
bff46771 | 6887 | @item -mvxworks |
cd3bb277 | 6888 | @opindex mvxworks |
bff46771 GK |
6889 | On System V.4 and embedded PowerPC systems, specify that you are |
6890 | compiling for a VxWorks system. | |
6891 | ||
74291a4b | 6892 | @item -memb |
cd3bb277 | 6893 | @opindex memb |
74291a4b MM |
6894 | On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags |
6895 | header to indicate that @samp{eabi} extended relocations are used. | |
6896 | ||
6897 | @item -meabi | |
6898 | @itemx -mno-eabi | |
cd3bb277 JM |
6899 | @opindex meabi |
6900 | @opindex mno-eabi | |
74291a4b MM |
6901 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
6902 | Embedded Applications Binary Interface (eabi) which is a set of | |
bedc7537 | 6903 | modifications to the System V.4 specifications. Selecting @option{-meabi} |
74291a4b MM |
6904 | means that the stack is aligned to an 8 byte boundary, a function |
6905 | @code{__eabi} is called to from @code{main} to set up the eabi | |
630d3d5a | 6906 | environment, and the @option{-msdata} option can use both @code{r2} and |
74291a4b | 6907 | @code{r13} to point to two separate small data areas. Selecting |
bedc7537 | 6908 | @option{-mno-eabi} means that the stack is aligned to a 16 byte boundary, |
74291a4b | 6909 | do not call an initialization function from @code{main}, and the |
630d3d5a JM |
6910 | @option{-msdata} option will only use @code{r13} to point to a single |
6911 | small data area. The @option{-meabi} option is on by default if you | |
74291a4b MM |
6912 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. |
6913 | ||
6914 | @item -msdata=eabi | |
cd3bb277 | 6915 | @opindex msdata=eabi |
74291a4b MM |
6916 | On System V.4 and embedded PowerPC systems, put small initialized |
6917 | @code{const} global and static data in the @samp{.sdata2} section, which | |
6918 | is pointed to by register @code{r2}. Put small initialized | |
6919 | non-@code{const} global and static data in the @samp{.sdata} section, | |
6920 | which is pointed to by register @code{r13}. Put small uninitialized | |
6921 | global and static data in the @samp{.sbss} section, which is adjacent to | |
630d3d5a JM |
6922 | the @samp{.sdata} section. The @option{-msdata=eabi} option is |
6923 | incompatible with the @option{-mrelocatable} option. The | |
6924 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
74291a4b MM |
6925 | |
6926 | @item -msdata=sysv | |
cd3bb277 | 6927 | @opindex msdata=sysv |
74291a4b MM |
6928 | On System V.4 and embedded PowerPC systems, put small global and static |
6929 | data in the @samp{.sdata} section, which is pointed to by register | |
6930 | @code{r13}. Put small uninitialized global and static data in the | |
6931 | @samp{.sbss} section, which is adjacent to the @samp{.sdata} section. | |
630d3d5a JM |
6932 | The @option{-msdata=sysv} option is incompatible with the |
6933 | @option{-mrelocatable} option. | |
74291a4b MM |
6934 | |
6935 | @item -msdata=default | |
6936 | @itemx -msdata | |
cd3bb277 JM |
6937 | @opindex msdata=default |
6938 | @opindex msdata | |
630d3d5a JM |
6939 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
6940 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
6941 | same as @option{-msdata=sysv}. | |
74291a4b MM |
6942 | |
6943 | @item -msdata-data | |
cd3bb277 | 6944 | @opindex msdata-data |
74291a4b MM |
6945 | On System V.4 and embedded PowerPC systems, put small global and static |
6946 | data in the @samp{.sdata} section. Put small uninitialized global and | |
6947 | static data in the @samp{.sbss} section. Do not use register @code{r13} | |
6948 | to address small data however. This is the default behavior unless | |
630d3d5a | 6949 | other @option{-msdata} options are used. |
74291a4b MM |
6950 | |
6951 | @item -msdata=none | |
6952 | @itemx -mno-sdata | |
cd3bb277 JM |
6953 | @opindex msdata=none |
6954 | @opindex mno-sdata | |
74291a4b MM |
6955 | On embedded PowerPC systems, put all initialized global and static data |
6956 | in the @samp{.data} section, and all uninitialized data in the | |
6957 | @samp{.bss} section. | |
6958 | ||
6959 | @item -G @var{num} | |
cd3bb277 | 6960 | @opindex G |
74291a4b MM |
6961 | @cindex smaller data references (PowerPC) |
6962 | @cindex .sdata/.sdata2 references (PowerPC) | |
956d6950 | 6963 | On embedded PowerPC systems, put global and static items less than or |
74291a4b MM |
6964 | equal to @var{num} bytes into the small data or bss sections instead of |
6965 | the normal data or bss section. By default, @var{num} is 8. The | |
630d3d5a JM |
6966 | @option{-G @var{num}} switch is also passed to the linker. |
6967 | All modules should be compiled with the same @option{-G @var{num}} value. | |
74291a4b MM |
6968 | |
6969 | @item -mregnames | |
6970 | @itemx -mno-regnames | |
cd3bb277 JM |
6971 | @opindex mregnames |
6972 | @opindex mno-regnames | |
74291a4b MM |
6973 | On System V.4 and embedded PowerPC systems do (do not) emit register |
6974 | names in the assembly language output using symbolic forms. | |
f5a1b0d2 | 6975 | |
74291a4b | 6976 | @end table |
f5a1b0d2 | 6977 | |
74291a4b MM |
6978 | @node RT Options |
6979 | @subsection IBM RT Options | |
6980 | @cindex RT options | |
6981 | @cindex IBM RT options | |
6982 | ||
6983 | These @samp{-m} options are defined for the IBM RT PC: | |
6984 | ||
2642624b | 6985 | @table @gcctabopt |
74291a4b | 6986 | @item -min-line-mul |
cd3bb277 | 6987 | @opindex min-line-mul |
74291a4b MM |
6988 | Use an in-line code sequence for integer multiplies. This is the |
6989 | default. | |
6990 | ||
6991 | @item -mcall-lib-mul | |
cd3bb277 | 6992 | @opindex mcall-lib-mul |
74291a4b MM |
6993 | Call @code{lmul$$} for integer multiples. |
6994 | ||
6995 | @item -mfull-fp-blocks | |
cd3bb277 | 6996 | @opindex mfull-fp-blocks |
74291a4b | 6997 | Generate full-size floating point data blocks, including the minimum |
161d7b59 | 6998 | amount of scratch space recommended by IBM@. This is the default. |
74291a4b MM |
6999 | |
7000 | @item -mminimum-fp-blocks | |
cd3bb277 | 7001 | @opindex mminimum-fp-blocks |
74291a4b MM |
7002 | Do not include extra scratch space in floating point data blocks. This |
7003 | results in smaller code, but slower execution, since scratch space must | |
7004 | be allocated dynamically. | |
7005 | ||
7006 | @cindex @file{varargs.h} and RT PC | |
7007 | @cindex @file{stdarg.h} and RT PC | |
7008 | @item -mfp-arg-in-fpregs | |
cd3bb277 | 7009 | @opindex mfp-arg-in-fpregs |
74291a4b MM |
7010 | Use a calling sequence incompatible with the IBM calling convention in |
7011 | which floating point arguments are passed in floating point registers. | |
c771326b | 7012 | Note that @code{varargs.h} and @code{stdarg.h} will not work with |
74291a4b MM |
7013 | floating point operands if this option is specified. |
7014 | ||
7015 | @item -mfp-arg-in-gregs | |
cd3bb277 | 7016 | @opindex mfp-arg-in-gregs |
74291a4b MM |
7017 | Use the normal calling convention for floating point arguments. This is |
7018 | the default. | |
7019 | ||
7020 | @item -mhc-struct-return | |
cd3bb277 | 7021 | @opindex mhc-struct-return |
74291a4b MM |
7022 | Return structures of more than one word in memory, rather than in a |
7023 | register. This provides compatibility with the MetaWare HighC (hc) | |
630d3d5a | 7024 | compiler. Use the option @option{-fpcc-struct-return} for compatibility |
74291a4b MM |
7025 | with the Portable C Compiler (pcc). |
7026 | ||
7027 | @item -mnohc-struct-return | |
cd3bb277 | 7028 | @opindex mnohc-struct-return |
74291a4b MM |
7029 | Return some structures of more than one word in registers, when |
7030 | convenient. This is the default. For compatibility with the | |
630d3d5a JM |
7031 | IBM-supplied compilers, use the option @option{-fpcc-struct-return} or the |
7032 | option @option{-mhc-struct-return}. | |
74291a4b MM |
7033 | @end table |
7034 | ||
7035 | @node MIPS Options | |
7036 | @subsection MIPS Options | |
7037 | @cindex MIPS options | |
7038 | ||
7039 | These @samp{-m} options are defined for the MIPS family of computers: | |
7040 | ||
2642624b | 7041 | @table @gcctabopt |
7dac2f89 EC |
7042 | |
7043 | @item -march=@var{cpu-type} | |
7044 | @opindex march | |
7045 | Assume the defaults for the machine type @var{cpu-type} when generating | |
7046 | instructions. The choices for @var{cpu-type} are @samp{r2000}, @samp{r3000}, | |
7047 | @samp{r3900}, @samp{r4000}, @samp{r4100}, @samp{r4300}, @samp{r4400}, | |
7048 | @samp{r4600}, @samp{r4650}, @samp{r5000}, @samp{r6000}, @samp{r8000}, | |
7049 | and @samp{orion}. Additionally, the @samp{r2000}, @samp{r3000}, | |
7050 | @samp{r4000}, @samp{r5000}, and @samp{r6000} can be abbreviated as | |
7051 | @samp{r2k} (or @samp{r2K}), @samp{r3k}, etc. | |
7052 | ||
7053 | @item -mtune=@var{cpu-type} | |
7054 | @opindex mtune | |
630d3d5a JM |
7055 | Assume the defaults for the machine type @var{cpu-type} when scheduling |
7056 | instructions. The choices for @var{cpu-type} are @samp{r2000}, @samp{r3000}, | |
8b9243df JJ |
7057 | @samp{r3900}, @samp{r4000}, @samp{r4100}, @samp{r4300}, @samp{r4400}, |
7058 | @samp{r4600}, @samp{r4650}, @samp{r5000}, @samp{r6000}, @samp{r8000}, | |
7059 | and @samp{orion}. Additionally, the @samp{r2000}, @samp{r3000}, | |
7060 | @samp{r4000}, @samp{r5000}, and @samp{r6000} can be abbreviated as | |
7061 | @samp{r2k} (or @samp{r2K}), @samp{r3k}, etc. While picking a specific | |
630d3d5a | 7062 | @var{cpu-type} will schedule things appropriately for that particular |
8b9243df | 7063 | chip, the compiler will not generate any code that does not meet level 1 |
630d3d5a JM |
7064 | of the MIPS ISA (instruction set architecture) without a @option{-mipsX} |
7065 | or @option{-mabi} switch being used. | |
74291a4b | 7066 | |
7dac2f89 EC |
7067 | @item -mcpu=@var{cpu-type} |
7068 | @opindex mcpu | |
7069 | This is identical to specifying both @option{-march} and @option{-mtune}. | |
7070 | ||
74291a4b | 7071 | @item -mips1 |
cd3bb277 | 7072 | @opindex mips1 |
161d7b59 | 7073 | Issue instructions from level 1 of the MIPS ISA@. This is the default. |
630d3d5a | 7074 | @samp{r3000} is the default @var{cpu-type} at this ISA level. |
74291a4b MM |
7075 | |
7076 | @item -mips2 | |
cd3bb277 | 7077 | @opindex mips2 |
74291a4b | 7078 | Issue instructions from level 2 of the MIPS ISA (branch likely, square |
630d3d5a | 7079 | root instructions). @samp{r6000} is the default @var{cpu-type} at this |
74291a4b MM |
7080 | ISA level. |
7081 | ||
7082 | @item -mips3 | |
cd3bb277 | 7083 | @opindex mips3 |
02f52e19 | 7084 | Issue instructions from level 3 of the MIPS ISA (64-bit instructions). |
630d3d5a | 7085 | @samp{r4000} is the default @var{cpu-type} at this ISA level. |
74291a4b | 7086 | |
3398f47f | 7087 | @item -mips4 |
cd3bb277 | 7088 | @opindex mips4 |
8b9243df JJ |
7089 | Issue instructions from level 4 of the MIPS ISA (conditional move, |
7090 | prefetch, enhanced FPU instructions). @samp{r8000} is the default | |
630d3d5a | 7091 | @var{cpu-type} at this ISA level. |
3398f47f | 7092 | |
74291a4b | 7093 | @item -mfp32 |
cd3bb277 | 7094 | @opindex mfp32 |
74291a4b MM |
7095 | Assume that 32 32-bit floating point registers are available. This is |
7096 | the default. | |
7097 | ||
7098 | @item -mfp64 | |
cd3bb277 | 7099 | @opindex mfp64 |
74291a4b | 7100 | Assume that 32 64-bit floating point registers are available. This is |
630d3d5a | 7101 | the default when the @option{-mips3} option is used. |
74291a4b MM |
7102 | |
7103 | @item -mgp32 | |
cd3bb277 | 7104 | @opindex mgp32 |
74291a4b MM |
7105 | Assume that 32 32-bit general purpose registers are available. This is |
7106 | the default. | |
7107 | ||
7108 | @item -mgp64 | |
cd3bb277 | 7109 | @opindex mgp64 |
74291a4b | 7110 | Assume that 32 64-bit general purpose registers are available. This is |
630d3d5a | 7111 | the default when the @option{-mips3} option is used. |
74291a4b MM |
7112 | |
7113 | @item -mint64 | |
cd3bb277 | 7114 | @opindex mint64 |
630d3d5a | 7115 | Force int and long types to be 64 bits wide. See @option{-mlong32} for an |
3ce1ba83 | 7116 | explanation of the default, and the width of pointers. |
74291a4b MM |
7117 | |
7118 | @item -mlong64 | |
cd3bb277 | 7119 | @opindex mlong64 |
630d3d5a | 7120 | Force long types to be 64 bits wide. See @option{-mlong32} for an |
3ce1ba83 | 7121 | explanation of the default, and the width of pointers. |
fb1bf66d | 7122 | |
3ce1ba83 | 7123 | @item -mlong32 |
cd3bb277 | 7124 | @opindex mlong32 |
3ce1ba83 GRK |
7125 | Force long, int, and pointer types to be 32 bits wide. |
7126 | ||
630d3d5a | 7127 | If none of @option{-mlong32}, @option{-mlong64}, or @option{-mint64} are set, |
b192711e | 7128 | the size of ints, longs, and pointers depends on the ABI and ISA chosen. |
630d3d5a JM |
7129 | For @option{-mabi=32}, and @option{-mabi=n32}, ints and longs are 32 bits |
7130 | wide. For @option{-mabi=64}, ints are 32 bits, and longs are 64 bits wide. | |
7131 | For @option{-mabi=eabi} and either @option{-mips1} or @option{-mips2}, ints | |
7132 | and longs are 32 bits wide. For @option{-mabi=eabi} and higher ISAs, ints | |
3ce1ba83 GRK |
7133 | are 32 bits, and longs are 64 bits wide. The width of pointer types is |
7134 | the smaller of the width of longs or the width of general purpose | |
161d7b59 | 7135 | registers (which in turn depends on the ISA)@. |
74291a4b | 7136 | |
62a1403d | 7137 | @item -mabi=32 |
8b9243df | 7138 | @itemx -mabi=o64 |
3398f47f MM |
7139 | @itemx -mabi=n32 |
7140 | @itemx -mabi=64 | |
7141 | @itemx -mabi=eabi | |
cd3bb277 JM |
7142 | @opindex mabi=32 |
7143 | @opindex mabi=o64 | |
7144 | @opindex mabi=n32 | |
7145 | @opindex mabi=64 | |
7146 | @opindex mabi=eabi | |
161d7b59 | 7147 | Generate code for the indicated ABI@. The default instruction level is |
630d3d5a JM |
7148 | @option{-mips1} for @samp{32}, @option{-mips3} for @samp{n32}, and |
7149 | @option{-mips4} otherwise. Conversely, with @option{-mips1} or | |
7150 | @option{-mips2}, the default ABI is @samp{32}; otherwise, the default ABI | |
8b9243df | 7151 | is @samp{64}. |
3398f47f | 7152 | |
74291a4b | 7153 | @item -mmips-as |
cd3bb277 | 7154 | @opindex mmips-as |
74291a4b MM |
7155 | Generate code for the MIPS assembler, and invoke @file{mips-tfile} to |
7156 | add normal debug information. This is the default for all | |
7157 | platforms except for the OSF/1 reference platform, using the OSF/rose | |
630d3d5a | 7158 | object format. If the either of the @option{-gstabs} or @option{-gstabs+} |
74291a4b | 7159 | switches are used, the @file{mips-tfile} program will encapsulate the |
161d7b59 | 7160 | stabs within MIPS ECOFF@. |
74291a4b MM |
7161 | |
7162 | @item -mgas | |
cd3bb277 | 7163 | @opindex mgas |
74291a4b | 7164 | Generate code for the GNU assembler. This is the default on the OSF/1 |
861bb6c1 | 7165 | reference platform, using the OSF/rose object format. Also, this is |
630d3d5a | 7166 | the default if the configure option @option{--with-gnu-as} is used. |
861bb6c1 JL |
7167 | |
7168 | @item -msplit-addresses | |
7169 | @itemx -mno-split-addresses | |
cd3bb277 JM |
7170 | @opindex msplit-addresses |
7171 | @opindex mno-split-addresses | |
861bb6c1 | 7172 | Generate code to load the high and low parts of address constants separately. |
aee96fe9 | 7173 | This allows GCC to optimize away redundant loads of the high order |
861bb6c1 JL |
7174 | bits of addresses. This optimization requires GNU as and GNU ld. |
7175 | This optimization is enabled by default for some embedded targets where | |
7176 | GNU as and GNU ld are standard. | |
74291a4b MM |
7177 | |
7178 | @item -mrnames | |
7179 | @itemx -mno-rnames | |
cd3bb277 JM |
7180 | @opindex mrnames |
7181 | @opindex mno-rnames | |
630d3d5a | 7182 | The @option{-mrnames} switch says to output code using the MIPS software |
74291a4b MM |
7183 | names for the registers, instead of the hardware names (ie, @var{a0} |
7184 | instead of @var{$4}). The only known assembler that supports this option | |
7185 | is the Algorithmics assembler. | |
7186 | ||
7187 | @item -mgpopt | |
7188 | @itemx -mno-gpopt | |
cd3bb277 JM |
7189 | @opindex mgpopt |
7190 | @opindex mno-gpopt | |
630d3d5a | 7191 | The @option{-mgpopt} switch says to write all of the data declarations |
74291a4b MM |
7192 | before the instructions in the text section, this allows the MIPS |
7193 | assembler to generate one word memory references instead of using two | |
7194 | words for short global or static data items. This is on by default if | |
7195 | optimization is selected. | |
7196 | ||
7197 | @item -mstats | |
7198 | @itemx -mno-stats | |
cd3bb277 JM |
7199 | @opindex mstats |
7200 | @opindex mno-stats | |
630d3d5a | 7201 | For each non-inline function processed, the @option{-mstats} switch |
74291a4b MM |
7202 | causes the compiler to emit one line to the standard error file to |
7203 | print statistics about the program (number of registers saved, stack | |
7204 | size, etc.). | |
7205 | ||
7206 | @item -mmemcpy | |
7207 | @itemx -mno-memcpy | |
cd3bb277 JM |
7208 | @opindex mmemcpy |
7209 | @opindex mno-memcpy | |
630d3d5a | 7210 | The @option{-mmemcpy} switch makes all block moves call the appropriate |
74291a4b MM |
7211 | string function (@samp{memcpy} or @samp{bcopy}) instead of possibly |
7212 | generating inline code. | |
7213 | ||
7214 | @item -mmips-tfile | |
7215 | @itemx -mno-mips-tfile | |
cd3bb277 JM |
7216 | @opindex mmips-tfile |
7217 | @opindex mno-mips-tfile | |
630d3d5a | 7218 | The @option{-mno-mips-tfile} switch causes the compiler not |
74291a4b MM |
7219 | postprocess the object file with the @file{mips-tfile} program, |
7220 | after the MIPS assembler has generated it to add debug support. If | |
7221 | @file{mips-tfile} is not run, then no local variables will be | |
7222 | available to the debugger. In addition, @file{stage2} and | |
7223 | @file{stage3} objects will have the temporary file names passed to the | |
7224 | assembler embedded in the object file, which means the objects will | |
630d3d5a | 7225 | not compare the same. The @option{-mno-mips-tfile} switch should only |
74291a4b MM |
7226 | be used when there are bugs in the @file{mips-tfile} program that |
7227 | prevents compilation. | |
7228 | ||
7229 | @item -msoft-float | |
cd3bb277 | 7230 | @opindex msoft-float |
74291a4b | 7231 | Generate output containing library calls for floating point. |
161d7b59 | 7232 | @strong{Warning:} the requisite libraries are not part of GCC@. |
74291a4b MM |
7233 | Normally the facilities of the machine's usual C compiler are used, but |
7234 | this can't be done directly in cross-compilation. You must make your | |
7235 | own arrangements to provide suitable library functions for | |
7236 | cross-compilation. | |
7237 | ||
7238 | @item -mhard-float | |
cd3bb277 | 7239 | @opindex mhard-float |
74291a4b MM |
7240 | Generate output containing floating point instructions. This is the |
7241 | default if you use the unmodified sources. | |
7242 | ||
7243 | @item -mabicalls | |
7244 | @itemx -mno-abicalls | |
cd3bb277 JM |
7245 | @opindex mabicalls |
7246 | @opindex mno-abicalls | |
74291a4b MM |
7247 | Emit (or do not emit) the pseudo operations @samp{.abicalls}, |
7248 | @samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for | |
7249 | position independent code. | |
7250 | ||
7251 | @item -mlong-calls | |
7252 | @itemx -mno-long-calls | |
cd3bb277 JM |
7253 | @opindex mlong-calls |
7254 | @opindex mno-long-calls | |
74291a4b MM |
7255 | Do all calls with the @samp{JALR} instruction, which requires |
7256 | loading up a function's address into a register before the call. | |
7257 | You need to use this switch, if you call outside of the current | |
7258 | 512 megabyte segment to functions that are not through pointers. | |
7259 | ||
7260 | @item -mhalf-pic | |
7261 | @itemx -mno-half-pic | |
cd3bb277 JM |
7262 | @opindex mhalf-pic |
7263 | @opindex mno-half-pic | |
74291a4b MM |
7264 | Put pointers to extern references into the data section and load them |
7265 | up, rather than put the references in the text section. | |
7266 | ||
7267 | @item -membedded-pic | |
7268 | @itemx -mno-embedded-pic | |
cd3bb277 JM |
7269 | @opindex membedded-pic |
7270 | @opindex mno-embedded-pic | |
69fa83cf JW |
7271 | Generate PIC code suitable for some embedded systems. All calls are |
7272 | made using PC relative address, and all data is addressed using the $gp | |
7273 | register. No more than 65536 bytes of global data may be used. This | |
7274 | requires GNU as and GNU ld which do most of the work. This currently | |
161d7b59 | 7275 | only works on targets which use ECOFF; it does not work with ELF@. |
74291a4b MM |
7276 | |
7277 | @item -membedded-data | |
7278 | @itemx -mno-embedded-data | |
cd3bb277 JM |
7279 | @opindex membedded-data |
7280 | @opindex mno-embedded-data | |
74291a4b MM |
7281 | Allocate variables to the read-only data section first if possible, then |
7282 | next in the small data section if possible, otherwise in data. This gives | |
7283 | slightly slower code than the default, but reduces the amount of RAM required | |
7284 | when executing, and thus may be preferred for some embedded systems. | |
7285 | ||
919509ce DN |
7286 | @item -muninit-const-in-rodata |
7287 | @itemx -mno-uninit-const-in-rodata | |
cd3bb277 JM |
7288 | @opindex muninit-const-in-rodata |
7289 | @opindex mno-uninit-const-in-rodata | |
695ac33f | 7290 | When used together with @option{-membedded-data}, it will always store uninitialized |
919509ce | 7291 | const variables in the read-only data section. |
02f52e19 | 7292 | |
74291a4b MM |
7293 | @item -msingle-float |
7294 | @itemx -mdouble-float | |
cd3bb277 JM |
7295 | @opindex msingle-float |
7296 | @opindex mdouble-float | |
630d3d5a | 7297 | The @option{-msingle-float} switch tells gcc to assume that the floating |
74291a4b | 7298 | point coprocessor only supports single precision operations, as on the |
630d3d5a | 7299 | @samp{r4650} chip. The @option{-mdouble-float} switch permits gcc to use |
74291a4b MM |
7300 | double precision operations. This is the default. |
7301 | ||
7302 | @item -mmad | |
7303 | @itemx -mno-mad | |
cd3bb277 JM |
7304 | @opindex mmad |
7305 | @opindex mno-mad | |
74291a4b MM |
7306 | Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions, |
7307 | as on the @samp{r4650} chip. | |
7308 | ||
7309 | @item -m4650 | |
cd3bb277 | 7310 | @opindex m4650 |
630d3d5a JM |
7311 | Turns on @option{-msingle-float}, @option{-mmad}, and, at least for now, |
7312 | @option{-mcpu=r4650}. | |
74291a4b | 7313 | |
8b9243df JJ |
7314 | @item -mips16 |
7315 | @itemx -mno-mips16 | |
cd3bb277 JM |
7316 | @opindex mips16 |
7317 | @opindex mno-mips16 | |
8b9243df JJ |
7318 | Enable 16-bit instructions. |
7319 | ||
7320 | @item -mentry | |
cd3bb277 | 7321 | @opindex mentry |
8b9243df | 7322 | Use the entry and exit pseudo ops. This option can only be used with |
630d3d5a | 7323 | @option{-mips16}. |
8b9243df | 7324 | |
74291a4b | 7325 | @item -EL |
cd3bb277 | 7326 | @opindex EL |
74291a4b MM |
7327 | Compile code for the processor in little endian mode. |
7328 | The requisite libraries are assumed to exist. | |
7329 | ||
7330 | @item -EB | |
cd3bb277 | 7331 | @opindex EB |
74291a4b MM |
7332 | Compile code for the processor in big endian mode. |
7333 | The requisite libraries are assumed to exist. | |
7334 | ||
7335 | @item -G @var{num} | |
cd3bb277 | 7336 | @opindex G |
74291a4b MM |
7337 | @cindex smaller data references (MIPS) |
7338 | @cindex gp-relative references (MIPS) | |
7339 | Put global and static items less than or equal to @var{num} bytes into | |
7340 | the small data or bss sections instead of the normal data or bss | |
7341 | section. This allows the assembler to emit one word memory reference | |
7342 | instructions based on the global pointer (@var{gp} or @var{$28}), | |
7343 | instead of the normal two words used. By default, @var{num} is 8 when | |
7344 | the MIPS assembler is used, and 0 when the GNU assembler is used. The | |
630d3d5a JM |
7345 | @option{-G @var{num}} switch is also passed to the assembler and linker. |
7346 | All modules should be compiled with the same @option{-G @var{num}} | |
74291a4b MM |
7347 | value. |
7348 | ||
7349 | @item -nocpp | |
cd3bb277 | 7350 | @opindex nocpp |
9ec36da5 | 7351 | Tell the MIPS assembler to not run its preprocessor over user |
74291a4b | 7352 | assembler files (with a @samp{.s} suffix) when assembling them. |
63357d93 | 7353 | |
1e387156 | 7354 | @item -mfix7000 |
cd3bb277 | 7355 | @opindex mfix7000 |
1e387156 CM |
7356 | Pass an option to gas which will cause nops to be inserted if |
7357 | the read of the destination register of an mfhi or mflo instruction | |
7358 | occurs in the following two instructions. | |
7359 | ||
63357d93 | 7360 | @item -no-crt0 |
cd3bb277 | 7361 | @opindex no-crt0 |
63357d93 | 7362 | Do not include the default crt0. |
74291a4b MM |
7363 | @end table |
7364 | ||
7365 | @ifset INTERNALS | |
7366 | These options are defined by the macro | |
7367 | @code{TARGET_SWITCHES} in the machine description. The default for the | |
7368 | options is also defined by that macro, which enables you to change the | |
7369 | defaults. | |
7370 | @end ifset | |
7371 | ||
7372 | @node i386 Options | |
7373 | @subsection Intel 386 Options | |
7374 | @cindex i386 Options | |
7375 | @cindex Intel 386 Options | |
7376 | ||
7377 | These @samp{-m} options are defined for the i386 family of computers: | |
7378 | ||
2642624b | 7379 | @table @gcctabopt |
630d3d5a | 7380 | @item -mcpu=@var{cpu-type} |
cd3bb277 | 7381 | @opindex mcpu |
630d3d5a JM |
7382 | Assume the defaults for the machine type @var{cpu-type} when scheduling |
7383 | instructions. The choices for @var{cpu-type} are @samp{i386}, | |
9d86bffc | 7384 | @samp{i486}, @samp{i586}, @samp{i686}, @samp{pentium}, |
b4e89e2d | 7385 | @samp{pentiumpro}, @samp{pentium4}, @samp{k6}, and @samp{athlon} |
6f670fde | 7386 | |
630d3d5a | 7387 | While picking a specific @var{cpu-type} will schedule things appropriately |
6f670fde | 7388 | for that particular chip, the compiler will not generate any code that |
630d3d5a | 7389 | does not run on the i386 without the @option{-march=@var{cpu-type}} option |
7001ee2d | 7390 | being used. @samp{i586} is equivalent to @samp{pentium} and @samp{i686} |
6ca3ad1b | 7391 | is equivalent to @samp{pentiumpro}. @samp{k6} and @samp{athlon} are the |
b4e89e2d | 7392 | AMD chips as opposed to the Intel ones. |
a9f3e1a4 | 7393 | |
630d3d5a | 7394 | @item -march=@var{cpu-type} |
cd3bb277 | 7395 | @opindex march |
630d3d5a JM |
7396 | Generate instructions for the machine type @var{cpu-type}. The choices |
7397 | for @var{cpu-type} are the same as for @option{-mcpu}. Moreover, | |
7398 | specifying @option{-march=@var{cpu-type}} implies @option{-mcpu=@var{cpu-type}}. | |
a9f3e1a4 JL |
7399 | |
7400 | @item -m386 | |
7401 | @itemx -m486 | |
7402 | @itemx -mpentium | |
7403 | @itemx -mpentiumpro | |
cd3bb277 JM |
7404 | @opindex m386 |
7405 | @opindex m486 | |
7406 | @opindex mpentium | |
7407 | @opindex mpentiumpro | |
695ac33f | 7408 | Synonyms for @option{-mcpu=i386}, @option{-mcpu=i486}, @option{-mcpu=pentium}, and @option{-mcpu=pentiumpro} |
7001ee2d | 7409 | respectively. These synonyms are deprecated. |
74291a4b | 7410 | |
04e149ab | 7411 | @item -mintel-syntax |
cd3bb277 | 7412 | @opindex mintel-syntax |
04e149ab KC |
7413 | Emit assembly using Intel syntax opcodes instead of AT&T syntax. |
7414 | ||
74291a4b MM |
7415 | @item -mieee-fp |
7416 | @itemx -mno-ieee-fp | |
cd3bb277 JM |
7417 | @opindex mieee-fp |
7418 | @opindex mno-ieee-fp | |
74291a4b MM |
7419 | Control whether or not the compiler uses IEEE floating point |
7420 | comparisons. These handle correctly the case where the result of a | |
7421 | comparison is unordered. | |
7422 | ||
7423 | @item -msoft-float | |
cd3bb277 | 7424 | @opindex msoft-float |
74291a4b | 7425 | Generate output containing library calls for floating point. |
161d7b59 | 7426 | @strong{Warning:} the requisite libraries are not part of GCC@. |
74291a4b MM |
7427 | Normally the facilities of the machine's usual C compiler are used, but |
7428 | this can't be done directly in cross-compilation. You must make your | |
7429 | own arrangements to provide suitable library functions for | |
7430 | cross-compilation. | |
7431 | ||
7432 | On machines where a function returns floating point results in the 80387 | |
7433 | register stack, some floating point opcodes may be emitted even if | |
630d3d5a | 7434 | @option{-msoft-float} is used. |
74291a4b MM |
7435 | |
7436 | @item -mno-fp-ret-in-387 | |
cd3bb277 | 7437 | @opindex mno-fp-ret-in-387 |
74291a4b MM |
7438 | Do not use the FPU registers for return values of functions. |
7439 | ||
7440 | The usual calling convention has functions return values of types | |
7441 | @code{float} and @code{double} in an FPU register, even if there | |
161d7b59 JM |
7442 | is no FPU@. The idea is that the operating system should emulate |
7443 | an FPU@. | |
74291a4b | 7444 | |
630d3d5a | 7445 | The option @option{-mno-fp-ret-in-387} causes such values to be returned |
74291a4b MM |
7446 | in ordinary CPU registers instead. |
7447 | ||
7448 | @item -mno-fancy-math-387 | |
cd3bb277 | 7449 | @opindex mno-fancy-math-387 |
74291a4b MM |
7450 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
7451 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
161d7b59 | 7452 | generating those instructions. This option is the default on FreeBSD@. |
74291a4b | 7453 | As of revision 2.6.1, these instructions are not generated unless you |
630d3d5a | 7454 | also use the @option{-funsafe-math-optimizations} switch. |
74291a4b MM |
7455 | |
7456 | @item -malign-double | |
7457 | @itemx -mno-align-double | |
cd3bb277 JM |
7458 | @opindex malign-double |
7459 | @opindex mno-align-double | |
0c2d1a2a | 7460 | Control whether GCC aligns @code{double}, @code{long double}, and |
74291a4b MM |
7461 | @code{long long} variables on a two word boundary or a one word |
7462 | boundary. Aligning @code{double} variables on a two word boundary will | |
7463 | produce code that runs somewhat faster on a @samp{Pentium} at the | |
7464 | expense of more memory. | |
7465 | ||
2b589241 JH |
7466 | @item -m128bit-long-double |
7467 | @itemx -m128bit-long-double | |
cd3bb277 JM |
7468 | @opindex m128bit-long-double |
7469 | @opindex m128bit-long-double | |
2b589241 JH |
7470 | Control the size of @code{long double} type. i386 application binary interface |
7471 | specify the size to be 12 bytes, while modern architectures (Pentium and newer) | |
c771326b | 7472 | prefer @code{long double} aligned to 8 or 16 byte boundary. This is |
2b589241 JH |
7473 | impossible to reach with 12 byte long doubles in the array accesses. |
7474 | ||
630d3d5a | 7475 | @strong{Warning:} if you use the @option{-m128bit-long-double} switch, the |
2b589241 JH |
7476 | structures and arrays containing @code{long double} will change their size as |
7477 | well as function calling convention for function taking @code{long double} | |
02f52e19 | 7478 | will be modified. |
2b589241 JH |
7479 | |
7480 | @item -m96bit-long-double | |
7481 | @itemx -m96bit-long-double | |
cd3bb277 JM |
7482 | @opindex m96bit-long-double |
7483 | @opindex m96bit-long-double | |
0a75e5c3 | 7484 | Set the size of @code{long double} to 96 bits as required by the i386 |
2b589241 | 7485 | application binary interface. This is the default. |
74291a4b MM |
7486 | |
7487 | @item -msvr3-shlib | |
7488 | @itemx -mno-svr3-shlib | |
cd3bb277 JM |
7489 | @opindex msvr3-shlib |
7490 | @opindex mno-svr3-shlib | |
0c2d1a2a | 7491 | Control whether GCC places uninitialized locals into @code{bss} or |
630d3d5a | 7492 | @code{data}. @option{-msvr3-shlib} places these locals into @code{bss}. |
74291a4b MM |
7493 | These options are meaningful only on System V Release 3. |
7494 | ||
7495 | @item -mno-wide-multiply | |
7496 | @itemx -mwide-multiply | |
cd3bb277 JM |
7497 | @opindex mno-wide-multiply |
7498 | @opindex mwide-multiply | |
0c2d1a2a | 7499 | Control whether GCC uses the @code{mul} and @code{imul} that produce |
02f52e19 | 7500 | 64-bit results in @code{eax:edx} from 32-bit operands to do @code{long |
74291a4b MM |
7501 | long} multiplies and 32-bit division by constants. |
7502 | ||
7503 | @item -mrtd | |
cd3bb277 | 7504 | @opindex mrtd |
74291a4b MM |
7505 | Use a different function-calling convention, in which functions that |
7506 | take a fixed number of arguments return with the @code{ret} @var{num} | |
7507 | instruction, which pops their arguments while returning. This saves one | |
7508 | instruction in the caller since there is no need to pop the arguments | |
7509 | there. | |
7510 | ||
7511 | You can specify that an individual function is called with this calling | |
7512 | sequence with the function attribute @samp{stdcall}. You can also | |
630d3d5a | 7513 | override the @option{-mrtd} option by using the function attribute |
0b433de6 | 7514 | @samp{cdecl}. @xref{Function Attributes}. |
74291a4b MM |
7515 | |
7516 | @strong{Warning:} this calling convention is incompatible with the one | |
7517 | normally used on Unix, so you cannot use it if you need to call | |
7518 | libraries compiled with the Unix compiler. | |
7519 | ||
7520 | Also, you must provide function prototypes for all functions that | |
7521 | take variable numbers of arguments (including @code{printf}); | |
7522 | otherwise incorrect code will be generated for calls to those | |
7523 | functions. | |
7524 | ||
7525 | In addition, seriously incorrect code will result if you call a | |
7526 | function with too many arguments. (Normally, extra arguments are | |
7527 | harmlessly ignored.) | |
7528 | ||
74291a4b | 7529 | @item -mregparm=@var{num} |
cd3bb277 | 7530 | @opindex mregparm |
74291a4b MM |
7531 | Control how many registers are used to pass integer arguments. By |
7532 | default, no registers are used to pass arguments, and at most 3 | |
7533 | registers can be used. You can control this behavior for a specific | |
0b433de6 JL |
7534 | function by using the function attribute @samp{regparm}. |
7535 | @xref{Function Attributes}. | |
74291a4b MM |
7536 | |
7537 | @strong{Warning:} if you use this switch, and | |
7538 | @var{num} is nonzero, then you must build all modules with the same | |
7539 | value, including any libraries. This includes the system libraries and | |
7540 | startup modules. | |
7541 | ||
3af4bd89 | 7542 | @item -mpreferred-stack-boundary=@var{num} |
cd3bb277 | 7543 | @opindex mpreferred-stack-boundary |
3af4bd89 | 7544 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
630d3d5a | 7545 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, |
3af4bd89 JH |
7546 | the default is 4 (16 bytes or 128 bits). |
7547 | ||
7548 | The stack is required to be aligned on a 4 byte boundary. On Pentium | |
7549 | and PentiumPro, @code{double} and @code{long double} values should be | |
630d3d5a | 7550 | aligned to an 8 byte boundary (see @option{-malign-double}) or suffer |
3af4bd89 | 7551 | significant run time performance penalties. On Pentium III, the |
b192711e | 7552 | Streaming SIMD Extension (SSE) data type @code{__m128} suffers similar |
3af4bd89 JH |
7553 | penalties if it is not 16 byte aligned. |
7554 | ||
7555 | To ensure proper alignment of this values on the stack, the stack boundary | |
02f52e19 | 7556 | must be as aligned as that required by any value stored on the stack. |
3af4bd89 JH |
7557 | Further, every function must be generated such that it keeps the stack |
7558 | aligned. Thus calling a function compiled with a higher preferred | |
7559 | stack boundary from a function compiled with a lower preferred stack | |
7560 | boundary will most likely misalign the stack. It is recommended that | |
7561 | libraries that use callbacks always use the default setting. | |
7562 | ||
7563 | This extra alignment does consume extra stack space. Code that is sensitive | |
7564 | to stack space usage, such as embedded systems and operating system kernels, | |
7565 | may want to reduce the preferred alignment to | |
630d3d5a | 7566 | @option{-mpreferred-stack-boundary=2}. |
f22a97d2 | 7567 | |
f73ad30e | 7568 | @item -mpush-args |
cd3bb277 | 7569 | @opindex mpush-args |
767094dd | 7570 | Use PUSH operations to store outgoing parameters. This method is shorter |
f73ad30e | 7571 | and usually equally fast as method using SUB/MOV operations and is enabled |
767094dd | 7572 | by default. In some cases disabling it may improve performance because of |
f73ad30e JH |
7573 | improved scheduling and reduced dependencies. |
7574 | ||
7575 | @item -maccumulate-outgoing-args | |
cd3bb277 | 7576 | @opindex maccumulate-outgoing-args |
f73ad30e | 7577 | If enabled, the maximum amount of space required for outgoing arguments will be |
767094dd | 7578 | computed in the function prologue. This in faster on most modern CPUs |
b192711e | 7579 | because of reduced dependencies, improved scheduling and reduced stack usage |
f73ad30e | 7580 | when preferred stack boundary is not equal to 2. The drawback is a notable |
767094dd | 7581 | increase in code size. This switch implies @option{-mno-push-args}. |
f73ad30e | 7582 | |
f22a97d2 | 7583 | @item -mthreads |
cd3bb277 | 7584 | @opindex mthreads |
767094dd | 7585 | Support thread-safe exception handling on @samp{Mingw32}. Code that relies |
02f52e19 | 7586 | on thread-safe exception handling must compile and link all code with the |
767094dd | 7587 | @option{-mthreads} option. When compiling, @option{-mthreads} defines |
630d3d5a JM |
7588 | @option{-D_MT}; when linking, it links in a special thread helper library |
7589 | @option{-lmingwthrd} which cleans up per thread exception handling data. | |
79f05c19 JH |
7590 | |
7591 | @item -mno-align-stringops | |
cd3bb277 | 7592 | @opindex mno-align-stringops |
767094dd | 7593 | Do not align destination of inlined string operations. This switch reduces |
79f05c19 JH |
7594 | code size and improves performance in case the destination is already aligned, |
7595 | but gcc don't know about it. | |
7596 | ||
7597 | @item -minline-all-stringops | |
cd3bb277 | 7598 | @opindex minline-all-stringops |
79f05c19 | 7599 | By default GCC inlines string operations only when destination is known to be |
767094dd | 7600 | aligned at least to 4 byte boundary. This enables more inlining, increase code |
79f05c19 JH |
7601 | size, but may improve performance of code that depends on fast memcpy, strlen |
7602 | and memset for short lengths. | |
762e166b AJ |
7603 | |
7604 | @item -momit-leaf-frame-pointer | |
cd3bb277 | 7605 | @opindex momit-leaf-frame-pointer |
762e166b AJ |
7606 | Don't keep the frame pointer in a register for leaf functions. This |
7607 | avoids the instructions to save, set up and restore frame pointers and | |
7608 | makes an extra register available in leaf functions. The option | |
630d3d5a | 7609 | @option{-fomit-frame-pointer} removes the frame pointer for all functions |
762e166b | 7610 | which might make debugging harder. |
3af4bd89 JH |
7611 | @end table |
7612 | ||
74291a4b MM |
7613 | @node HPPA Options |
7614 | @subsection HPPA Options | |
7615 | @cindex HPPA Options | |
7616 | ||
7617 | These @samp{-m} options are defined for the HPPA family of computers: | |
7618 | ||
2642624b | 7619 | @table @gcctabopt |
630d3d5a | 7620 | @item -march=@var{architecture-type} |
cd3bb277 | 7621 | @opindex march |
ea3bfbfe | 7622 | Generate code for the specified architecture. The choices for |
630d3d5a | 7623 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA |
ea3bfbfe JQ |
7624 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to |
7625 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
7626 | architecture option for your machine. Code compiled for lower numbered | |
7627 | architectures will run on higher numbered architectures, but not the | |
7628 | other way around. | |
7629 | ||
7630 | PA 2.0 support currently requires gas snapshot 19990413 or later. The | |
7631 | next release of binutils (current is 2.9.1) will probably contain PA 2.0 | |
02f52e19 | 7632 | support. |
74291a4b | 7633 | |
ea3bfbfe | 7634 | @item -mpa-risc-1-0 |
62a1403d AS |
7635 | @itemx -mpa-risc-1-1 |
7636 | @itemx -mpa-risc-2-0 | |
cd3bb277 JM |
7637 | @opindex mpa-risc-1-0 |
7638 | @opindex mpa-risc-1-1 | |
7639 | @opindex mpa-risc-2-0 | |
695ac33f | 7640 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
74291a4b | 7641 | |
861bb6c1 | 7642 | @item -mbig-switch |
cd3bb277 | 7643 | @opindex mbig-switch |
861bb6c1 JL |
7644 | Generate code suitable for big switch tables. Use this option only if |
7645 | the assembler/linker complain about out of range branches within a switch | |
7646 | table. | |
7647 | ||
74291a4b | 7648 | @item -mjump-in-delay |
cd3bb277 | 7649 | @opindex mjump-in-delay |
74291a4b MM |
7650 | Fill delay slots of function calls with unconditional jump instructions |
7651 | by modifying the return pointer for the function call to be the target | |
7652 | of the conditional jump. | |
7653 | ||
7654 | @item -mdisable-fpregs | |
cd3bb277 | 7655 | @opindex mdisable-fpregs |
74291a4b MM |
7656 | Prevent floating point registers from being used in any manner. This is |
7657 | necessary for compiling kernels which perform lazy context switching of | |
7658 | floating point registers. If you use this option and attempt to perform | |
7659 | floating point operations, the compiler will abort. | |
7660 | ||
7661 | @item -mdisable-indexing | |
cd3bb277 | 7662 | @opindex mdisable-indexing |
74291a4b | 7663 | Prevent the compiler from using indexing address modes. This avoids some |
161d7b59 | 7664 | rather obscure problems when compiling MIG generated code under MACH@. |
74291a4b MM |
7665 | |
7666 | @item -mno-space-regs | |
cd3bb277 | 7667 | @opindex mno-space-regs |
74291a4b MM |
7668 | Generate code that assumes the target has no space registers. This allows |
7669 | GCC to generate faster indirect calls and use unscaled index address modes. | |
7670 | ||
7671 | Such code is suitable for level 0 PA systems and kernels. | |
7672 | ||
7673 | @item -mfast-indirect-calls | |
cd3bb277 | 7674 | @opindex mfast-indirect-calls |
74291a4b MM |
7675 | Generate code that assumes calls never cross space boundaries. This |
7676 | allows GCC to emit code which performs faster indirect calls. | |
7677 | ||
b192711e | 7678 | This option will not work in the presence of shared libraries or nested |
74291a4b MM |
7679 | functions. |
7680 | ||
74291a4b | 7681 | @item -mlong-load-store |
cd3bb277 | 7682 | @opindex mlong-load-store |
74291a4b MM |
7683 | Generate 3-instruction load and store sequences as sometimes required by |
7684 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
7685 | the HP compilers. | |
7686 | ||
7687 | @item -mportable-runtime | |
cd3bb277 | 7688 | @opindex mportable-runtime |
74291a4b MM |
7689 | Use the portable calling conventions proposed by HP for ELF systems. |
7690 | ||
7691 | @item -mgas | |
cd3bb277 | 7692 | @opindex mgas |
74291a4b MM |
7693 | Enable the use of assembler directives only GAS understands. |
7694 | ||
630d3d5a | 7695 | @item -mschedule=@var{cpu-type} |
cd3bb277 | 7696 | @opindex mschedule |
74291a4b | 7697 | Schedule code according to the constraints for the machine type |
630d3d5a | 7698 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} |
02f52e19 | 7699 | @samp{7100}, @samp{7100LC}, @samp{7200}, and @samp{8000}. Refer to |
732135bf JL |
7700 | @file{/usr/lib/sched.models} on an HP-UX system to determine the |
7701 | proper scheduling option for your machine. | |
74291a4b MM |
7702 | |
7703 | @item -mlinker-opt | |
cd3bb277 | 7704 | @opindex mlinker-opt |
74291a4b MM |
7705 | Enable the optimization pass in the HPUX linker. Note this makes symbolic |
7706 | debugging impossible. It also triggers a bug in the HPUX 8 and HPUX 9 linkers | |
7707 | in which they give bogus error messages when linking some programs. | |
7708 | ||
7709 | @item -msoft-float | |
cd3bb277 | 7710 | @opindex msoft-float |
74291a4b MM |
7711 | Generate output containing library calls for floating point. |
7712 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
7713 | targets. Normally the facilities of the machine's usual C compiler are | |
7714 | used, but this cannot be done directly in cross-compilation. You must make | |
7715 | your own arrangements to provide suitable library functions for | |
7716 | cross-compilation. The embedded target @samp{hppa1.1-*-pro} | |
7717 | does provide software floating point support. | |
7718 | ||
630d3d5a | 7719 | @option{-msoft-float} changes the calling convention in the output file; |
74291a4b MM |
7720 | therefore, it is only useful if you compile @emph{all} of a program with |
7721 | this option. In particular, you need to compile @file{libgcc.a}, the | |
630d3d5a | 7722 | library that comes with GCC, with @option{-msoft-float} in order for |
74291a4b MM |
7723 | this to work. |
7724 | @end table | |
7725 | ||
7726 | @node Intel 960 Options | |
7727 | @subsection Intel 960 Options | |
7728 | ||
7729 | These @samp{-m} options are defined for the Intel 960 implementations: | |
7730 | ||
2642624b | 7731 | @table @gcctabopt |
cd3bb277 JM |
7732 | @item -m@var{cpu-type} |
7733 | @opindex mka | |
7734 | @opindex mkb | |
7735 | @opindex mmc | |
7736 | @opindex mca | |
7737 | @opindex mcf | |
7738 | @opindex msa | |
7739 | @opindex msb | |
7740 | Assume the defaults for the machine type @var{cpu-type} for some of | |
74291a4b | 7741 | the other options, including instruction scheduling, floating point |
cd3bb277 | 7742 | support, and addressing modes. The choices for @var{cpu-type} are |
74291a4b MM |
7743 | @samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf}, |
7744 | @samp{sa}, and @samp{sb}. | |
7745 | The default is | |
7746 | @samp{kb}. | |
7747 | ||
7748 | @item -mnumerics | |
7749 | @itemx -msoft-float | |
cd3bb277 JM |
7750 | @opindex mnumerics |
7751 | @opindex msoft-float | |
630d3d5a JM |
7752 | The @option{-mnumerics} option indicates that the processor does support |
7753 | floating-point instructions. The @option{-msoft-float} option indicates | |
74291a4b MM |
7754 | that floating-point support should not be assumed. |
7755 | ||
7756 | @item -mleaf-procedures | |
7757 | @itemx -mno-leaf-procedures | |
cd3bb277 JM |
7758 | @opindex mleaf-procedures |
7759 | @opindex mno-leaf-procedures | |
74291a4b MM |
7760 | Do (or do not) attempt to alter leaf procedures to be callable with the |
7761 | @code{bal} instruction as well as @code{call}. This will result in more | |
7762 | efficient code for explicit calls when the @code{bal} instruction can be | |
7763 | substituted by the assembler or linker, but less efficient code in other | |
7764 | cases, such as calls via function pointers, or using a linker that doesn't | |
7765 | support this optimization. | |
7766 | ||
7767 | @item -mtail-call | |
7768 | @itemx -mno-tail-call | |
cd3bb277 JM |
7769 | @opindex mtail-call |
7770 | @opindex mno-tail-call | |
74291a4b MM |
7771 | Do (or do not) make additional attempts (beyond those of the |
7772 | machine-independent portions of the compiler) to optimize tail-recursive | |
7773 | calls into branches. You may not want to do this because the detection of | |
7774 | cases where this is not valid is not totally complete. The default is | |
630d3d5a | 7775 | @option{-mno-tail-call}. |
74291a4b MM |
7776 | |
7777 | @item -mcomplex-addr | |
7778 | @itemx -mno-complex-addr | |
cd3bb277 JM |
7779 | @opindex mcomplex-addr |
7780 | @opindex mno-complex-addr | |
74291a4b MM |
7781 | Assume (or do not assume) that the use of a complex addressing mode is a |
7782 | win on this implementation of the i960. Complex addressing modes may not | |
7783 | be worthwhile on the K-series, but they definitely are on the C-series. | |
630d3d5a | 7784 | The default is currently @option{-mcomplex-addr} for all processors except |
161d7b59 | 7785 | the CB and CC@. |
74291a4b MM |
7786 | |
7787 | @item -mcode-align | |
7788 | @itemx -mno-code-align | |
cd3bb277 JM |
7789 | @opindex mcode-align |
7790 | @opindex mno-code-align | |
74291a4b MM |
7791 | Align code to 8-byte boundaries for faster fetching (or don't bother). |
7792 | Currently turned on by default for C-series implementations only. | |
7793 | ||
7794 | @ignore | |
7795 | @item -mclean-linkage | |
7796 | @itemx -mno-clean-linkage | |
cd3bb277 JM |
7797 | @opindex mclean-linkage |
7798 | @opindex mno-clean-linkage | |
74291a4b MM |
7799 | These options are not fully implemented. |
7800 | @end ignore | |
7801 | ||
7802 | @item -mic-compat | |
7803 | @itemx -mic2.0-compat | |
7804 | @itemx -mic3.0-compat | |
cd3bb277 JM |
7805 | @opindex mic-compat |
7806 | @opindex mic2.0-compat | |
7807 | @opindex mic3.0-compat | |
74291a4b MM |
7808 | Enable compatibility with iC960 v2.0 or v3.0. |
7809 | ||
7810 | @item -masm-compat | |
7811 | @itemx -mintel-asm | |
cd3bb277 JM |
7812 | @opindex masm-compat |
7813 | @opindex mintel-asm | |
74291a4b MM |
7814 | Enable compatibility with the iC960 assembler. |
7815 | ||
7816 | @item -mstrict-align | |
7817 | @itemx -mno-strict-align | |
cd3bb277 JM |
7818 | @opindex mstrict-align |
7819 | @opindex mno-strict-align | |
74291a4b MM |
7820 | Do not permit (do permit) unaligned accesses. |
7821 | ||
7822 | @item -mold-align | |
cd3bb277 | 7823 | @opindex mold-align |
74291a4b | 7824 | Enable structure-alignment compatibility with Intel's gcc release version |
630d3d5a | 7825 | 1.3 (based on gcc 1.37). This option implies @option{-mstrict-align}. |
eaa4b44c VM |
7826 | |
7827 | @item -mlong-double-64 | |
cd3bb277 | 7828 | @opindex mlong-double-64 |
eaa4b44c VM |
7829 | Implement type @samp{long double} as 64-bit floating point numbers. |
7830 | Without the option @samp{long double} is implemented by 80-bit | |
7831 | floating point numbers. The only reason we have it because there is | |
7832 | no 128-bit @samp{long double} support in @samp{fp-bit.c} yet. So it | |
7833 | is only useful for people using soft-float targets. Otherwise, we | |
7834 | should recommend against use of it. | |
7835 | ||
74291a4b MM |
7836 | @end table |
7837 | ||
7838 | @node DEC Alpha Options | |
7839 | @subsection DEC Alpha Options | |
7840 | ||
7841 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
7842 | ||
2642624b | 7843 | @table @gcctabopt |
74291a4b MM |
7844 | @item -mno-soft-float |
7845 | @itemx -msoft-float | |
cd3bb277 JM |
7846 | @opindex mno-soft-float |
7847 | @opindex msoft-float | |
74291a4b | 7848 | Use (do not use) the hardware floating-point instructions for |
bedc7537 | 7849 | floating-point operations. When @option{-msoft-float} is specified, |
7857f134 | 7850 | functions in @file{libgcc.a} will be used to perform floating-point |
74291a4b MM |
7851 | operations. Unless they are replaced by routines that emulate the |
7852 | floating-point operations, or compiled in such a way as to call such | |
7853 | emulations routines, these routines will issue floating-point | |
7854 | operations. If you are compiling for an Alpha without floating-point | |
7855 | operations, you must ensure that the library is built so as not to call | |
7856 | them. | |
7857 | ||
7858 | Note that Alpha implementations without floating-point operations are | |
7859 | required to have floating-point registers. | |
7860 | ||
7861 | @item -mfp-reg | |
7862 | @itemx -mno-fp-regs | |
cd3bb277 JM |
7863 | @opindex mfp-reg |
7864 | @opindex mno-fp-regs | |
74291a4b | 7865 | Generate code that uses (does not use) the floating-point register set. |
bedc7537 | 7866 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point |
74291a4b MM |
7867 | register set is not used, floating point operands are passed in integer |
7868 | registers as if they were integers and floating-point results are passed | |
7869 | in $0 instead of $f0. This is a non-standard calling sequence, so any | |
7870 | function with a floating-point argument or return value called by code | |
bedc7537 | 7871 | compiled with @option{-mno-fp-regs} must also be compiled with that |
74291a4b MM |
7872 | option. |
7873 | ||
7874 | A typical use of this option is building a kernel that does not use, | |
7875 | and hence need not save and restore, any floating-point registers. | |
7876 | ||
7877 | @item -mieee | |
cd3bb277 | 7878 | @opindex mieee |
74291a4b MM |
7879 | The Alpha architecture implements floating-point hardware optimized for |
7880 | maximum performance. It is mostly compliant with the IEEE floating | |
7881 | point standard. However, for full compliance, software assistance is | |
7882 | required. This option generates code fully IEEE compliant code | |
630d3d5a | 7883 | @emph{except} that the @var{inexact-flag} is not maintained (see below). |
74291a4b | 7884 | If this option is turned on, the CPP macro @code{_IEEE_FP} is defined |
630d3d5a | 7885 | during compilation. The option is a shorthand for: @option{-D_IEEE_FP |
74291a4b MM |
7886 | -mfp-trap-mode=su -mtrap-precision=i -mieee-conformant}. The resulting |
7887 | code is less efficient but is able to correctly support denormalized | |
7888 | numbers and exceptional IEEE values such as not-a-number and plus/minus | |
7889 | infinity. Other Alpha compilers call this option | |
bedc7537 | 7890 | @option{-ieee_with_no_inexact}. |
74291a4b MM |
7891 | |
7892 | @item -mieee-with-inexact | |
cd3bb277 | 7893 | @opindex mieee-with-inexact |
74291a4b MM |
7894 | @c overfull hbox here --bob 22 jul96 |
7895 | @c original text between ignore ... end ignore | |
7896 | @ignore | |
630d3d5a JM |
7897 | This is like @option{-mieee} except the generated code also maintains the |
7898 | IEEE @var{inexact-flag}. Turning on this option causes the generated | |
74291a4b | 7899 | code to implement fully-compliant IEEE math. The option is a shorthand |
630d3d5a JM |
7900 | for @option{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus @option{-mieee-conformant}, |
7901 | @option{-mfp-trap-mode=sui}, and @option{-mtrap-precision=i}. On some Alpha | |
74291a4b MM |
7902 | implementations the resulting code may execute significantly slower than |
7903 | the code generated by default. Since there is very little code that | |
630d3d5a | 7904 | depends on the @var{inexact-flag}, you should normally not specify this |
74291a4b | 7905 | option. Other Alpha compilers call this option |
630d3d5a | 7906 | @option{-ieee_with_inexact}. |
74291a4b MM |
7907 | @end ignore |
7908 | @c changed paragraph | |
630d3d5a JM |
7909 | This is like @option{-mieee} except the generated code also maintains the |
7910 | IEEE @var{inexact-flag}. Turning on this option causes the generated | |
74291a4b | 7911 | code to implement fully-compliant IEEE math. The option is a shorthand |
630d3d5a JM |
7912 | for @option{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus the three following: |
7913 | @option{-mieee-conformant}, | |
7914 | @option{-mfp-trap-mode=sui}, | |
7915 | and @option{-mtrap-precision=i}. | |
74291a4b MM |
7916 | On some Alpha implementations the resulting code may execute |
7917 | significantly slower than the code generated by default. Since there | |
630d3d5a | 7918 | is very little code that depends on the @var{inexact-flag}, you should |
74291a4b | 7919 | normally not specify this option. Other Alpha compilers call this |
630d3d5a | 7920 | option @option{-ieee_with_inexact}. |
74291a4b MM |
7921 | @c end changes to prevent overfull hboxes |
7922 | ||
630d3d5a | 7923 | @item -mfp-trap-mode=@var{trap-mode} |
cd3bb277 | 7924 | @opindex mfp-trap-mode |
74291a4b | 7925 | This option controls what floating-point related traps are enabled. |
630d3d5a | 7926 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. |
74291a4b MM |
7927 | The trap mode can be set to one of four values: |
7928 | ||
7929 | @table @samp | |
7930 | @item n | |
7931 | This is the default (normal) setting. The only traps that are enabled | |
7932 | are the ones that cannot be disabled in software (e.g., division by zero | |
7933 | trap). | |
7934 | ||
7935 | @item u | |
7936 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
7937 | as well. | |
7938 | ||
7939 | @item su | |
7940 | Like @samp{su}, but the instructions are marked to be safe for software | |
7941 | completion (see Alpha architecture manual for details). | |
7942 | ||
7943 | @item sui | |
7944 | Like @samp{su}, but inexact traps are enabled as well. | |
7945 | @end table | |
7946 | ||
630d3d5a | 7947 | @item -mfp-rounding-mode=@var{rounding-mode} |
cd3bb277 | 7948 | @opindex mfp-rounding-mode |
74291a4b | 7949 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
630d3d5a | 7950 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one |
74291a4b MM |
7951 | of: |
7952 | ||
7953 | @table @samp | |
7954 | @item n | |
7955 | Normal IEEE rounding mode. Floating point numbers are rounded towards | |
7956 | the nearest machine number or towards the even machine number in case | |
7957 | of a tie. | |
7958 | ||
7959 | @item m | |
7960 | Round towards minus infinity. | |
7961 | ||
7962 | @item c | |
7963 | Chopped rounding mode. Floating point numbers are rounded towards zero. | |
7964 | ||
7965 | @item d | |
7966 | Dynamic rounding mode. A field in the floating point control register | |
7967 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
7968 | rounding mode in effect. The C library initializes this register for | |
7969 | rounding towards plus infinity. Thus, unless your program modifies the | |
ec4b2ecb CB |
7970 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. |
7971 | @end table | |
74291a4b | 7972 | |
630d3d5a | 7973 | @item -mtrap-precision=@var{trap-precision} |
cd3bb277 | 7974 | @opindex mtrap-precision |
74291a4b MM |
7975 | In the Alpha architecture, floating point traps are imprecise. This |
7976 | means without software assistance it is impossible to recover from a | |
7977 | floating trap and program execution normally needs to be terminated. | |
0c2d1a2a | 7978 | GCC can generate code that can assist operating system trap handlers |
74291a4b MM |
7979 | in determining the exact location that caused a floating point trap. |
7980 | Depending on the requirements of an application, different levels of | |
7981 | precisions can be selected: | |
7982 | ||
7983 | @table @samp | |
7984 | @item p | |
7985 | Program precision. This option is the default and means a trap handler | |
7986 | can only identify which program caused a floating point exception. | |
7987 | ||
7988 | @item f | |
7989 | Function precision. The trap handler can determine the function that | |
7990 | caused a floating point exception. | |
7991 | ||
7992 | @item i | |
7993 | Instruction precision. The trap handler can determine the exact | |
7994 | instruction that caused a floating point exception. | |
7995 | @end table | |
7996 | ||
7997 | Other Alpha compilers provide the equivalent options called | |
630d3d5a | 7998 | @option{-scope_safe} and @option{-resumption_safe}. |
74291a4b MM |
7999 | |
8000 | @item -mieee-conformant | |
cd3bb277 | 8001 | @opindex mieee-conformant |
74291a4b | 8002 | This option marks the generated code as IEEE conformant. You must not |
630d3d5a JM |
8003 | use this option unless you also specify @option{-mtrap-precision=i} and either |
8004 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
74291a4b MM |
8005 | is to emit the line @samp{.eflag 48} in the function prologue of the |
8006 | generated assembly file. Under DEC Unix, this has the effect that | |
8007 | IEEE-conformant math library routines will be linked in. | |
8008 | ||
8009 | @item -mbuild-constants | |
cd3bb277 | 8010 | @opindex mbuild-constants |
0c2d1a2a | 8011 | Normally GCC examines a 32- or 64-bit integer constant to |
74291a4b MM |
8012 | see if it can construct it from smaller constants in two or three |
8013 | instructions. If it cannot, it will output the constant as a literal and | |
956d6950 | 8014 | generate code to load it from the data segment at runtime. |
74291a4b | 8015 | |
0c2d1a2a | 8016 | Use this option to require GCC to construct @emph{all} integer constants |
74291a4b MM |
8017 | using code, even if it takes more instructions (the maximum is six). |
8018 | ||
8019 | You would typically use this option to build a shared library dynamic | |
8020 | loader. Itself a shared library, it must relocate itself in memory | |
8021 | before it can find the variables and constants in its own data segment. | |
956d6950 JL |
8022 | |
8023 | @item -malpha-as | |
8024 | @itemx -mgas | |
cd3bb277 JM |
8025 | @opindex malpha-as |
8026 | @opindex mgas | |
956d6950 | 8027 | Select whether to generate code to be assembled by the vendor-supplied |
630d3d5a | 8028 | assembler (@option{-malpha-as}) or by the GNU assembler @option{-mgas}. |
956d6950 JL |
8029 | |
8030 | @item -mbwx | |
8031 | @itemx -mno-bwx | |
8032 | @itemx -mcix | |
8033 | @itemx -mno-cix | |
8034 | @itemx -mmax | |
8035 | @itemx -mno-max | |
cd3bb277 JM |
8036 | @opindex mbwx |
8037 | @opindex mno-bwx | |
8038 | @opindex mcix | |
8039 | @opindex mno-cix | |
8040 | @opindex mmax | |
8041 | @opindex mno-max | |
0c2d1a2a | 8042 | Indicate whether GCC should generate code to use the optional BWX, |
956d6950 | 8043 | CIX, and MAX instruction sets. The default is to use the instruction sets |
630d3d5a | 8044 | supported by the CPU type specified via @option{-mcpu=} option or that |
0c2d1a2a | 8045 | of the CPU on which GCC was built if none was specified. |
956d6950 | 8046 | |
956d6950 | 8047 | @item -mcpu=@var{cpu_type} |
cd3bb277 | 8048 | @opindex mcpu |
956d6950 JL |
8049 | Set the instruction set, register set, and instruction scheduling |
8050 | parameters for machine type @var{cpu_type}. You can specify either the | |
0c2d1a2a | 8051 | @samp{EV} style name or the corresponding chip number. GCC |
956d6950 JL |
8052 | supports scheduling parameters for the EV4 and EV5 family of processors |
8053 | and will choose the default values for the instruction set from | |
8054 | the processor you specify. If you do not specify a processor type, | |
0c2d1a2a | 8055 | GCC will default to the processor on which the compiler was built. |
956d6950 JL |
8056 | |
8057 | Supported values for @var{cpu_type} are | |
8058 | ||
8059 | @table @samp | |
8060 | @item ev4 | |
8061 | @itemx 21064 | |
8062 | Schedules as an EV4 and has no instruction set extensions. | |
8063 | ||
8064 | @item ev5 | |
8065 | @itemx 21164 | |
8066 | Schedules as an EV5 and has no instruction set extensions. | |
8067 | ||
8068 | @item ev56 | |
8069 | @itemx 21164a | |
8070 | Schedules as an EV5 and supports the BWX extension. | |
8071 | ||
8072 | @item pca56 | |
4f69985c | 8073 | @itemx 21164pc |
956d6950 JL |
8074 | @itemx 21164PC |
8075 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
8076 | ||
8077 | @item ev6 | |
8078 | @itemx 21264 | |
8079 | Schedules as an EV5 (until Digital releases the scheduling parameters | |
8080 | for the EV6) and supports the BWX, CIX, and MAX extensions. | |
4f69985c RH |
8081 | @end table |
8082 | ||
8083 | @item -mmemory-latency=@var{time} | |
cd3bb277 | 8084 | @opindex mmemory-latency |
4f69985c RH |
8085 | Sets the latency the scheduler should assume for typical memory |
8086 | references as seen by the application. This number is highly | |
b192711e | 8087 | dependent on the memory access patterns used by the application |
4f69985c RH |
8088 | and the size of the external cache on the machine. |
8089 | ||
8090 | Valid options for @var{time} are | |
8091 | ||
8092 | @table @samp | |
8093 | @item @var{number} | |
8094 | A decimal number representing clock cycles. | |
8095 | ||
8096 | @item L1 | |
8097 | @itemx L2 | |
8098 | @itemx L3 | |
8099 | @itemx main | |
8100 | The compiler contains estimates of the number of clock cycles for | |
8101 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
8102 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
8103 | Note that L3 is only valid for EV5. | |
8104 | ||
956d6950 | 8105 | @end table |
74291a4b MM |
8106 | @end table |
8107 | ||
8108 | @node Clipper Options | |
8109 | @subsection Clipper Options | |
8110 | ||
8111 | These @samp{-m} options are defined for the Clipper implementations: | |
8112 | ||
2642624b | 8113 | @table @gcctabopt |
74291a4b | 8114 | @item -mc300 |
cd3bb277 | 8115 | @opindex mc300 |
767094dd | 8116 | Produce code for a C300 Clipper processor. This is the default. |
74291a4b | 8117 | |
62a1403d | 8118 | @item -mc400 |
cd3bb277 | 8119 | @opindex mc400 |
e979f9e8 | 8120 | Produce code for a C400 Clipper processor i.e.@: use floating point |
630d3d5a | 8121 | registers f8---f15. |
74291a4b MM |
8122 | @end table |
8123 | ||
8124 | @node H8/300 Options | |
8125 | @subsection H8/300 Options | |
8126 | ||
8127 | These @samp{-m} options are defined for the H8/300 implementations: | |
8128 | ||
2642624b | 8129 | @table @gcctabopt |
74291a4b | 8130 | @item -mrelax |
cd3bb277 | 8131 | @opindex mrelax |
74291a4b | 8132 | Shorten some address references at link time, when possible; uses the |
630d3d5a | 8133 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, |
74291a4b MM |
8134 | ld.info, Using ld}, for a fuller description. |
8135 | ||
8136 | @item -mh | |
cd3bb277 | 8137 | @opindex mh |
161d7b59 | 8138 | Generate code for the H8/300H@. |
74291a4b | 8139 | |
dcb9d1f0 | 8140 | @item -ms |
cd3bb277 | 8141 | @opindex ms |
161d7b59 | 8142 | Generate code for the H8/S@. |
dcb9d1f0 | 8143 | |
17f0f8fa | 8144 | @item -ms2600 |
cd3bb277 | 8145 | @opindex ms2600 |
695ac33f | 8146 | Generate code for the H8/S2600. This switch must be used with @option{-ms}. |
17f0f8fa | 8147 | |
74291a4b | 8148 | @item -mint32 |
cd3bb277 | 8149 | @opindex mint32 |
74291a4b MM |
8150 | Make @code{int} data 32 bits by default. |
8151 | ||
8152 | @item -malign-300 | |
cd3bb277 | 8153 | @opindex malign-300 |
2c54abce KH |
8154 | On the H8/300H and H8/S, use the same alignment rules as for the H8/300. |
8155 | The default for the H8/300H and H8/S is to align longs and floats on 4 | |
8156 | byte boundaries. | |
630d3d5a | 8157 | @option{-malign-300} causes them to be aligned on 2 byte boundaries. |
2c54abce | 8158 | This option has no effect on the H8/300. |
74291a4b MM |
8159 | @end table |
8160 | ||
8161 | @node SH Options | |
8162 | @subsection SH Options | |
8163 | ||
8164 | These @samp{-m} options are defined for the SH implementations: | |
8165 | ||
2642624b | 8166 | @table @gcctabopt |
74291a4b | 8167 | @item -m1 |
cd3bb277 | 8168 | @opindex m1 |
74291a4b MM |
8169 | Generate code for the SH1. |
8170 | ||
8171 | @item -m2 | |
cd3bb277 | 8172 | @opindex m2 |
74291a4b MM |
8173 | Generate code for the SH2. |
8174 | ||
8175 | @item -m3 | |
cd3bb277 | 8176 | @opindex m3 |
74291a4b MM |
8177 | Generate code for the SH3. |
8178 | ||
8179 | @item -m3e | |
cd3bb277 | 8180 | @opindex m3e |
74291a4b MM |
8181 | Generate code for the SH3e. |
8182 | ||
3cadd778 | 8183 | @item -m4-nofpu |
cd3bb277 | 8184 | @opindex m4-nofpu |
3cadd778 AO |
8185 | Generate code for the SH4 without a floating-point unit. |
8186 | ||
8187 | @item -m4-single-only | |
cd3bb277 | 8188 | @opindex m4-single-only |
3cadd778 | 8189 | Generate code for the SH4 with a floating-point unit that only |
c771326b | 8190 | supports single-precision arithmetic. |
3cadd778 AO |
8191 | |
8192 | @item -m4-single | |
cd3bb277 | 8193 | @opindex m4-single |
3cadd778 AO |
8194 | Generate code for the SH4 assuming the floating-point unit is in |
8195 | single-precision mode by default. | |
8196 | ||
8197 | @item -m4 | |
cd3bb277 | 8198 | @opindex m4 |
3cadd778 AO |
8199 | Generate code for the SH4. |
8200 | ||
74291a4b | 8201 | @item -mb |
cd3bb277 | 8202 | @opindex mb |
74291a4b MM |
8203 | Compile code for the processor in big endian mode. |
8204 | ||
8205 | @item -ml | |
cd3bb277 | 8206 | @opindex ml |
74291a4b MM |
8207 | Compile code for the processor in little endian mode. |
8208 | ||
3d5a0820 | 8209 | @item -mdalign |
cd3bb277 | 8210 | @opindex mdalign |
02f52e19 | 8211 | Align doubles at 64-bit boundaries. Note that this changes the calling |
3d5a0820 | 8212 | conventions, and thus some functions from the standard C library will |
695ac33f | 8213 | not work unless you recompile it first with @option{-mdalign}. |
3d5a0820 | 8214 | |
74291a4b | 8215 | @item -mrelax |
cd3bb277 | 8216 | @opindex mrelax |
74291a4b | 8217 | Shorten some address references at link time, when possible; uses the |
630d3d5a | 8218 | linker option @option{-relax}. |
3cadd778 AO |
8219 | |
8220 | @item -mbigtable | |
cd3bb277 | 8221 | @opindex mbigtable |
3cadd778 AO |
8222 | Use 32-bit offsets in @code{switch} tables. The default is to use |
8223 | 16-bit offsets. | |
8224 | ||
8225 | @item -mfmovd | |
cd3bb277 | 8226 | @opindex mfmovd |
3cadd778 AO |
8227 | Enable the use of the instruction @code{fmovd}. |
8228 | ||
8229 | @item -mhitachi | |
cd3bb277 | 8230 | @opindex mhitachi |
3cadd778 AO |
8231 | Comply with the calling conventions defined by Hitachi. |
8232 | ||
8233 | @item -mnomacsave | |
cd3bb277 | 8234 | @opindex mnomacsave |
3cadd778 | 8235 | Mark the @code{MAC} register as call-clobbered, even if |
bedc7537 | 8236 | @option{-mhitachi} is given. |
3cadd778 | 8237 | |
c474f76b AO |
8238 | @item -mieee |
8239 | @opindex mieee | |
8240 | Increase IEEE-compliance of floating-point code. | |
8241 | ||
3cadd778 | 8242 | @item -misize |
cd3bb277 | 8243 | @opindex misize |
3cadd778 AO |
8244 | Dump instruction size and location in the assembly code. |
8245 | ||
8246 | @item -mpadstruct | |
cd3bb277 | 8247 | @opindex mpadstruct |
3cadd778 | 8248 | This option is deprecated. It pads structures to multiple of 4 bytes, |
161d7b59 | 8249 | which is incompatible with the SH ABI@. |
3cadd778 AO |
8250 | |
8251 | @item -mspace | |
cd3bb277 | 8252 | @opindex mspace |
bedc7537 | 8253 | Optimize for space instead of speed. Implied by @option{-Os}. |
1a66cd67 AO |
8254 | |
8255 | @item -mprefergot | |
cd3bb277 | 8256 | @opindex mprefergot |
1a66cd67 AO |
8257 | When generating position-independent code, emit function calls using |
8258 | the Global Offset Table instead of the Procedure Linkage Table. | |
93ca1662 NY |
8259 | |
8260 | @item -musermode | |
cd3bb277 | 8261 | @opindex musermode |
93ca1662 NY |
8262 | Generate a library function call to invalidate instruction cache |
8263 | entries, after fixing up a trampoline. This library function call | |
8264 | doesn't assume it can write to the whole memory address space. This | |
8265 | is the default when the target is @code{sh-*-linux*}. | |
74291a4b MM |
8266 | @end table |
8267 | ||
8268 | @node System V Options | |
8269 | @subsection Options for System V | |
8270 | ||
8271 | These additional options are available on System V Release 4 for | |
8272 | compatibility with other compilers on those systems: | |
8273 | ||
2642624b | 8274 | @table @gcctabopt |
74291a4b | 8275 | @item -G |
cd3bb277 | 8276 | @opindex G |
74291a4b | 8277 | Create a shared object. |
630d3d5a | 8278 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. |
74291a4b MM |
8279 | |
8280 | @item -Qy | |
cd3bb277 | 8281 | @opindex Qy |
74291a4b MM |
8282 | Identify the versions of each tool used by the compiler, in a |
8283 | @code{.ident} assembler directive in the output. | |
8284 | ||
8285 | @item -Qn | |
cd3bb277 | 8286 | @opindex Qn |
74291a4b MM |
8287 | Refrain from adding @code{.ident} directives to the output file (this is |
8288 | the default). | |
8289 | ||
aee96fe9 | 8290 | @item -YP,@var{dirs} |
cd3bb277 | 8291 | @opindex YP |
74291a4b | 8292 | Search the directories @var{dirs}, and no others, for libraries |
630d3d5a | 8293 | specified with @option{-l}. |
74291a4b | 8294 | |
aee96fe9 | 8295 | @item -Ym,@var{dir} |
cd3bb277 | 8296 | @opindex Ym |
bedc7537 | 8297 | Look in the directory @var{dir} to find the M4 preprocessor. |
74291a4b MM |
8298 | The assembler uses this option. |
8299 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
8300 | @c the generic assembler that comes with Solaris takes just -Ym. | |
8301 | @end table | |
8302 | ||
282a61e6 MH |
8303 | @node TMS320C3x/C4x Options |
8304 | @subsection TMS320C3x/C4x Options | |
8305 | @cindex TMS320C3x/C4x Options | |
8306 | ||
8307 | These @samp{-m} options are defined for TMS320C3x/C4x implementations: | |
8308 | ||
2642624b | 8309 | @table @gcctabopt |
282a61e6 MH |
8310 | |
8311 | @item -mcpu=@var{cpu_type} | |
cd3bb277 | 8312 | @opindex mcpu |
282a61e6 MH |
8313 | Set the instruction set, register set, and instruction scheduling |
8314 | parameters for machine type @var{cpu_type}. Supported values for | |
8315 | @var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and | |
8316 | @samp{c44}. The default is @samp{c40} to generate code for the | |
8317 | TMS320C40. | |
8318 | ||
8319 | @item -mbig-memory | |
8320 | @item -mbig | |
8321 | @itemx -msmall-memory | |
8322 | @itemx -msmall | |
cd3bb277 JM |
8323 | @opindex mbig-memory |
8324 | @opindex mbig | |
8325 | @opindex msmall-memory | |
8326 | @opindex msmall | |
282a61e6 MH |
8327 | Generates code for the big or small memory model. The small memory |
8328 | model assumed that all data fits into one 64K word page. At run-time | |
8329 | the data page (DP) register must be set to point to the 64K page | |
8330 | containing the .bss and .data program sections. The big memory model is | |
8331 | the default and requires reloading of the DP register for every direct | |
8332 | memory access. | |
8333 | ||
8334 | @item -mbk | |
8335 | @itemx -mno-bk | |
cd3bb277 JM |
8336 | @opindex mbk |
8337 | @opindex mno-bk | |
282a61e6 | 8338 | Allow (disallow) allocation of general integer operands into the block |
161d7b59 | 8339 | count register BK@. |
282a61e6 MH |
8340 | |
8341 | @item -mdb | |
8342 | @itemx -mno-db | |
cd3bb277 JM |
8343 | @opindex mdb |
8344 | @opindex mno-db | |
282a61e6 MH |
8345 | Enable (disable) generation of code using decrement and branch, |
8346 | DBcond(D), instructions. This is enabled by default for the C4x. To be | |
8347 | on the safe side, this is disabled for the C3x, since the maximum | |
aee96fe9 JM |
8348 | iteration count on the C3x is @math{2^23 + 1} (but who iterates loops more than |
8349 | @math{2^23} times on the C3x?). Note that GCC will try to reverse a loop so | |
282a61e6 MH |
8350 | that it can utilise the decrement and branch instruction, but will give |
8351 | up if there is more than one memory reference in the loop. Thus a loop | |
8352 | where the loop counter is decremented can generate slightly more | |
8353 | efficient code, in cases where the RPTB instruction cannot be utilised. | |
8354 | ||
8355 | @item -mdp-isr-reload | |
8356 | @itemx -mparanoid | |
cd3bb277 JM |
8357 | @opindex mdp-isr-reload |
8358 | @opindex mparanoid | |
282a61e6 MH |
8359 | Force the DP register to be saved on entry to an interrupt service |
8360 | routine (ISR), reloaded to point to the data section, and restored on | |
161d7b59 | 8361 | exit from the ISR@. This should not be required unless someone has |
282a61e6 MH |
8362 | violated the small memory model by modifying the DP register, say within |
8363 | an object library. | |
8364 | ||
8365 | @item -mmpyi | |
8366 | @itemx -mno-mpyi | |
cd3bb277 JM |
8367 | @opindex mmpyi |
8368 | @opindex mno-mpyi | |
282a61e6 MH |
8369 | For the C3x use the 24-bit MPYI instruction for integer multiplies |
8370 | instead of a library call to guarantee 32-bit results. Note that if one | |
8371 | of the operands is a constant, then the multiplication will be performed | |
695ac33f | 8372 | using shifts and adds. If the @option{-mmpyi} option is not specified for the C3x, |
282a61e6 MH |
8373 | then squaring operations are performed inline instead of a library call. |
8374 | ||
8375 | @item -mfast-fix | |
8376 | @itemx -mno-fast-fix | |
cd3bb277 JM |
8377 | @opindex mfast-fix |
8378 | @opindex mno-fast-fix | |
282a61e6 MH |
8379 | The C3x/C4x FIX instruction to convert a floating point value to an |
8380 | integer value chooses the nearest integer less than or equal to the | |
8381 | floating point value rather than to the nearest integer. Thus if the | |
8382 | floating point number is negative, the result will be incorrectly | |
8383 | truncated an additional code is necessary to detect and correct this | |
8384 | case. This option can be used to disable generation of the additional | |
8385 | code required to correct the result. | |
8386 | ||
8387 | @item -mrptb | |
8388 | @itemx -mno-rptb | |
cd3bb277 JM |
8389 | @opindex mrptb |
8390 | @opindex mno-rptb | |
282a61e6 MH |
8391 | Enable (disable) generation of repeat block sequences using the RPTB |
8392 | instruction for zero overhead looping. The RPTB construct is only used | |
8393 | for innermost loops that do not call functions or jump across the loop | |
8394 | boundaries. There is no advantage having nested RPTB loops due to the | |
8395 | overhead required to save and restore the RC, RS, and RE registers. | |
695ac33f | 8396 | This is enabled by default with @option{-O2}. |
282a61e6 MH |
8397 | |
8398 | @item -mrpts=@var{count} | |
8399 | @itemx -mno-rpts | |
cd3bb277 JM |
8400 | @opindex mrpts |
8401 | @opindex mno-rpts | |
282a61e6 | 8402 | Enable (disable) the use of the single instruction repeat instruction |
161d7b59 | 8403 | RPTS@. If a repeat block contains a single instruction, and the loop |
282a61e6 | 8404 | count can be guaranteed to be less than the value @var{count}, GCC will |
161d7b59 | 8405 | emit a RPTS instruction instead of a RPTB@. If no value is specified, |
282a61e6 MH |
8406 | then a RPTS will be emitted even if the loop count cannot be determined |
8407 | at compile time. Note that the repeated instruction following RPTS does | |
8408 | not have to be reloaded from memory each iteration, thus freeing up the | |
b192711e | 8409 | CPU buses for operands. However, since interrupts are blocked by this |
282a61e6 MH |
8410 | instruction, it is disabled by default. |
8411 | ||
8412 | @item -mloop-unsigned | |
8413 | @itemx -mno-loop-unsigned | |
cd3bb277 JM |
8414 | @opindex mloop-unsigned |
8415 | @opindex mno-loop-unsigned | |
282a61e6 | 8416 | The maximum iteration count when using RPTS and RPTB (and DB on the C40) |
aee96fe9 | 8417 | is @math{2^31 + 1} since these instructions test if the iteration count is |
282a61e6 | 8418 | negative to terminate the loop. If the iteration count is unsigned |
aee96fe9 | 8419 | there is a possibility than the @math{2^31 + 1} maximum iteration count may be |
282a61e6 MH |
8420 | exceeded. This switch allows an unsigned iteration count. |
8421 | ||
8422 | @item -mti | |
cd3bb277 | 8423 | @opindex mti |
282a61e6 MH |
8424 | Try to emit an assembler syntax that the TI assembler (asm30) is happy |
8425 | with. This also enforces compatibility with the API employed by the TI | |
8426 | C3x C compiler. For example, long doubles are passed as structures | |
8427 | rather than in floating point registers. | |
8428 | ||
8429 | @item -mregparm | |
8430 | @itemx -mmemparm | |
cd3bb277 JM |
8431 | @opindex mregparm |
8432 | @opindex mmemparm | |
282a61e6 MH |
8433 | Generate code that uses registers (stack) for passing arguments to functions. |
8434 | By default, arguments are passed in registers where possible rather | |
8435 | than by pushing arguments on to the stack. | |
8436 | ||
8437 | @item -mparallel-insns | |
8438 | @itemx -mno-parallel-insns | |
cd3bb277 JM |
8439 | @opindex mparallel-insns |
8440 | @opindex mno-parallel-insns | |
282a61e6 | 8441 | Allow the generation of parallel instructions. This is enabled by |
695ac33f | 8442 | default with @option{-O2}. |
282a61e6 MH |
8443 | |
8444 | @item -mparallel-mpy | |
8445 | @itemx -mno-parallel-mpy | |
cd3bb277 JM |
8446 | @opindex mparallel-mpy |
8447 | @opindex mno-parallel-mpy | |
282a61e6 | 8448 | Allow the generation of MPY||ADD and MPY||SUB parallel instructions, |
695ac33f | 8449 | provided @option{-mparallel-insns} is also specified. These instructions have |
282a61e6 MH |
8450 | tight register constraints which can pessimize the code generation |
8451 | of large functions. | |
8452 | ||
8453 | @end table | |
8454 | ||
f84271d9 JL |
8455 | @node V850 Options |
8456 | @subsection V850 Options | |
8457 | @cindex V850 Options | |
8458 | ||
8459 | These @samp{-m} options are defined for V850 implementations: | |
8460 | ||
2642624b | 8461 | @table @gcctabopt |
f84271d9 JL |
8462 | @item -mlong-calls |
8463 | @itemx -mno-long-calls | |
cd3bb277 JM |
8464 | @opindex mlong-calls |
8465 | @opindex mno-long-calls | |
f84271d9 JL |
8466 | Treat all calls as being far away (near). If calls are assumed to be |
8467 | far away, the compiler will always load the functions address up into a | |
8468 | register, and call indirect through the pointer. | |
8469 | ||
8470 | @item -mno-ep | |
bd762873 | 8471 | @itemx -mep |
cd3bb277 JM |
8472 | @opindex mno-ep |
8473 | @opindex mep | |
f84271d9 JL |
8474 | Do not optimize (do optimize) basic blocks that use the same index |
8475 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
630d3d5a | 8476 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} |
f84271d9 JL |
8477 | option is on by default if you optimize. |
8478 | ||
8479 | @item -mno-prolog-function | |
8480 | @itemx -mprolog-function | |
cd3bb277 JM |
8481 | @opindex mno-prolog-function |
8482 | @opindex mprolog-function | |
f84271d9 JL |
8483 | Do not use (do use) external functions to save and restore registers at |
8484 | the prolog and epilog of a function. The external functions are slower, | |
8485 | but use less code space if more than one function saves the same number | |
630d3d5a | 8486 | of registers. The @option{-mprolog-function} option is on by default if |
f84271d9 JL |
8487 | you optimize. |
8488 | ||
8489 | @item -mspace | |
cd3bb277 | 8490 | @opindex mspace |
f84271d9 | 8491 | Try to make the code as small as possible. At present, this just turns |
630d3d5a | 8492 | on the @option{-mep} and @option{-mprolog-function} options. |
f84271d9 JL |
8493 | |
8494 | @item -mtda=@var{n} | |
cd3bb277 | 8495 | @opindex mtda |
f84271d9 JL |
8496 | Put static or global variables whose size is @var{n} bytes or less into |
8497 | the tiny data area that register @code{ep} points to. The tiny data | |
8498 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
8499 | ||
8500 | @item -msda=@var{n} | |
cd3bb277 | 8501 | @opindex msda |
f84271d9 JL |
8502 | Put static or global variables whose size is @var{n} bytes or less into |
8503 | the small data area that register @code{gp} points to. The small data | |
8504 | area can hold up to 64 kilobytes. | |
8505 | ||
8506 | @item -mzda=@var{n} | |
cd3bb277 | 8507 | @opindex mzda |
f84271d9 JL |
8508 | Put static or global variables whose size is @var{n} bytes or less into |
8509 | the first 32 kilobytes of memory. | |
02f52e19 | 8510 | |
48f0be1b | 8511 | @item -mv850 |
cd3bb277 | 8512 | @opindex mv850 |
48f0be1b SC |
8513 | Specify that the target processor is the V850. |
8514 | ||
e9a25f70 | 8515 | @item -mbig-switch |
cd3bb277 | 8516 | @opindex mbig-switch |
e9a25f70 JL |
8517 | Generate code suitable for big switch tables. Use this option only if |
8518 | the assembler/linker complain about out of range branches within a switch | |
8519 | table. | |
f84271d9 JL |
8520 | @end table |
8521 | ||
56b2d7a7 JL |
8522 | @node ARC Options |
8523 | @subsection ARC Options | |
8524 | @cindex ARC Options | |
8525 | ||
8526 | These options are defined for ARC implementations: | |
8527 | ||
2642624b | 8528 | @table @gcctabopt |
56b2d7a7 | 8529 | @item -EL |
cd3bb277 | 8530 | @opindex EL |
56b2d7a7 JL |
8531 | Compile code for little endian mode. This is the default. |
8532 | ||
8533 | @item -EB | |
cd3bb277 | 8534 | @opindex EB |
56b2d7a7 JL |
8535 | Compile code for big endian mode. |
8536 | ||
8537 | @item -mmangle-cpu | |
cd3bb277 | 8538 | @opindex mmangle-cpu |
56b2d7a7 JL |
8539 | Prepend the name of the cpu to all public symbol names. |
8540 | In multiple-processor systems, there are many ARC variants with different | |
8541 | instruction and register set characteristics. This flag prevents code | |
8542 | compiled for one cpu to be linked with code compiled for another. | |
695ac33f | 8543 | No facility exists for handling variants that are ``almost identical''. |
56b2d7a7 JL |
8544 | This is an all or nothing option. |
8545 | ||
8546 | @item -mcpu=@var{cpu} | |
cd3bb277 | 8547 | @opindex mcpu |
56b2d7a7 JL |
8548 | Compile code for ARC variant @var{cpu}. |
8549 | Which variants are supported depend on the configuration. | |
630d3d5a | 8550 | All variants support @option{-mcpu=base}, this is the default. |
56b2d7a7 | 8551 | |
630d3d5a JM |
8552 | @item -mtext=@var{text-section} |
8553 | @itemx -mdata=@var{data-section} | |
8554 | @itemx -mrodata=@var{readonly-data-section} | |
cd3bb277 JM |
8555 | @opindex mtext |
8556 | @opindex mdata | |
8557 | @opindex mrodata | |
630d3d5a JM |
8558 | Put functions, data, and readonly data in @var{text-section}, |
8559 | @var{data-section}, and @var{readonly-data-section} respectively | |
56b2d7a7 | 8560 | by default. This can be overridden with the @code{section} attribute. |
0b433de6 | 8561 | @xref{Variable Attributes}. |
56b2d7a7 JL |
8562 | |
8563 | @end table | |
8564 | ||
83575957 ID |
8565 | @node NS32K Options |
8566 | @subsection NS32K Options | |
8567 | @cindex NS32K options | |
8568 | ||
8569 | These are the @samp{-m} options defined for the 32000 series. The default | |
8570 | values for these options depends on which style of 32000 was selected when | |
8571 | the compiler was configured; the defaults for the most common choices are | |
8572 | given below. | |
8573 | ||
2642624b | 8574 | @table @gcctabopt |
83575957 ID |
8575 | @item -m32032 |
8576 | @itemx -m32032 | |
cd3bb277 JM |
8577 | @opindex m32032 |
8578 | @opindex m32032 | |
83575957 ID |
8579 | Generate output for a 32032. This is the default |
8580 | when the compiler is configured for 32032 and 32016 based systems. | |
8581 | ||
8582 | @item -m32332 | |
8583 | @itemx -m32332 | |
cd3bb277 JM |
8584 | @opindex m32332 |
8585 | @opindex m32332 | |
83575957 ID |
8586 | Generate output for a 32332. This is the default |
8587 | when the compiler is configured for 32332-based systems. | |
8588 | ||
8589 | @item -m32532 | |
8590 | @itemx -m32532 | |
cd3bb277 JM |
8591 | @opindex m32532 |
8592 | @opindex m32532 | |
83575957 ID |
8593 | Generate output for a 32532. This is the default |
8594 | when the compiler is configured for 32532-based systems. | |
8595 | ||
8596 | @item -m32081 | |
cd3bb277 | 8597 | @opindex m32081 |
83575957 ID |
8598 | Generate output containing 32081 instructions for floating point. |
8599 | This is the default for all systems. | |
8600 | ||
8601 | @item -m32381 | |
cd3bb277 | 8602 | @opindex m32381 |
83575957 | 8603 | Generate output containing 32381 instructions for floating point. This |
767094dd JM |
8604 | also implies @option{-m32081}. The 32381 is only compatible with the 32332 |
8605 | and 32532 cpus. This is the default for the pc532-netbsd configuration. | |
83575957 ID |
8606 | |
8607 | @item -mmulti-add | |
cd3bb277 | 8608 | @opindex mmulti-add |
83575957 | 8609 | Try and generate multiply-add floating point instructions @code{polyF} |
767094dd JM |
8610 | and @code{dotF}. This option is only available if the @option{-m32381} |
8611 | option is in effect. Using these instructions requires changes to to | |
83575957 ID |
8612 | register allocation which generally has a negative impact on |
8613 | performance. This option should only be enabled when compiling code | |
8614 | particularly likely to make heavy use of multiply-add instructions. | |
8615 | ||
8616 | @item -mnomulti-add | |
cd3bb277 | 8617 | @opindex mnomulti-add |
83575957 | 8618 | Do not try and generate multiply-add floating point instructions |
767094dd | 8619 | @code{polyF} and @code{dotF}. This is the default on all platforms. |
83575957 ID |
8620 | |
8621 | @item -msoft-float | |
cd3bb277 | 8622 | @opindex msoft-float |
83575957 ID |
8623 | Generate output containing library calls for floating point. |
8624 | @strong{Warning:} the requisite libraries may not be available. | |
8625 | ||
8626 | @item -mnobitfield | |
cd3bb277 | 8627 | @opindex mnobitfield |
767094dd JM |
8628 | Do not use the bit-field instructions. On some machines it is faster to |
8629 | use shifting and masking operations. This is the default for the pc532. | |
83575957 ID |
8630 | |
8631 | @item -mbitfield | |
cd3bb277 | 8632 | @opindex mbitfield |
767094dd | 8633 | Do use the bit-field instructions. This is the default for all platforms |
83575957 ID |
8634 | except the pc532. |
8635 | ||
8636 | @item -mrtd | |
cd3bb277 | 8637 | @opindex mrtd |
83575957 ID |
8638 | Use a different function-calling convention, in which functions |
8639 | that take a fixed number of arguments return pop their | |
8640 | arguments on return with the @code{ret} instruction. | |
8641 | ||
8642 | This calling convention is incompatible with the one normally | |
8643 | used on Unix, so you cannot use it if you need to call libraries | |
8644 | compiled with the Unix compiler. | |
8645 | ||
8646 | Also, you must provide function prototypes for all functions that | |
8647 | take variable numbers of arguments (including @code{printf}); | |
8648 | otherwise incorrect code will be generated for calls to those | |
8649 | functions. | |
8650 | ||
8651 | In addition, seriously incorrect code will result if you call a | |
8652 | function with too many arguments. (Normally, extra arguments are | |
8653 | harmlessly ignored.) | |
8654 | ||
8655 | This option takes its name from the 680x0 @code{rtd} instruction. | |
8656 | ||
8657 | ||
8658 | @item -mregparam | |
cd3bb277 | 8659 | @opindex mregparam |
83575957 ID |
8660 | Use a different function-calling convention where the first two arguments |
8661 | are passed in registers. | |
8662 | ||
8663 | This calling convention is incompatible with the one normally | |
8664 | used on Unix, so you cannot use it if you need to call libraries | |
8665 | compiled with the Unix compiler. | |
8666 | ||
8667 | @item -mnoregparam | |
cd3bb277 | 8668 | @opindex mnoregparam |
767094dd | 8669 | Do not pass any arguments in registers. This is the default for all |
83575957 ID |
8670 | targets. |
8671 | ||
8672 | @item -msb | |
cd3bb277 | 8673 | @opindex msb |
83575957 | 8674 | It is OK to use the sb as an index register which is always loaded with |
767094dd | 8675 | zero. This is the default for the pc532-netbsd target. |
83575957 ID |
8676 | |
8677 | @item -mnosb | |
cd3bb277 | 8678 | @opindex mnosb |
83575957 | 8679 | The sb register is not available for use or has not been initialized to |
767094dd JM |
8680 | zero by the run time system. This is the default for all targets except |
8681 | the pc532-netbsd. It is also implied whenever @option{-mhimem} or | |
630d3d5a | 8682 | @option{-fpic} is set. |
83575957 ID |
8683 | |
8684 | @item -mhimem | |
cd3bb277 | 8685 | @opindex mhimem |
161d7b59 | 8686 | Many ns32000 series addressing modes use displacements of up to 512MB@. |
83575957 | 8687 | If an address is above 512MB then displacements from zero can not be used. |
161d7b59 | 8688 | This option causes code to be generated which can be loaded above 512MB@. |
83575957 ID |
8689 | This may be useful for operating systems or ROM code. |
8690 | ||
8691 | @item -mnohimem | |
cd3bb277 | 8692 | @opindex mnohimem |
83575957 ID |
8693 | Assume code will be loaded in the first 512MB of virtual address space. |
8694 | This is the default for all platforms. | |
8695 | ||
8696 | ||
8697 | @end table | |
8698 | ||
052a4b28 DC |
8699 | @node AVR Options |
8700 | @subsection AVR Options | |
8701 | @cindex AVR Options | |
8702 | ||
8703 | These options are defined for AVR implementations: | |
8704 | ||
2642624b | 8705 | @table @gcctabopt |
052a4b28 | 8706 | @item -mmcu=@var{mcu} |
cd3bb277 | 8707 | @opindex mmcu |
3a69a7d5 MM |
8708 | Specify ATMEL AVR instruction set or MCU type. |
8709 | ||
8710 | Instruction set avr1 is for the minimal AVR core, not supported by the C | |
8711 | compiler, only for assembler programs (MCU types: at90s1200, attiny10, | |
8712 | attiny11, attiny12, attiny15, attiny28). | |
8713 | ||
8714 | Instruction set avr2 (default) is for the classic AVR core with up to | |
8715 | 8K program memory space (MCU types: at90s2313, at90s2323, attiny22, | |
8716 | at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515, | |
8717 | at90c8534, at90s8535). | |
8718 | ||
8719 | Instruction set avr3 is for the classic AVR core with up to 128K program | |
8720 | memory space (MCU types: atmega103, atmega603). | |
8721 | ||
8722 | Instruction set avr4 is for the enhanced AVR core with up to 8K program | |
8723 | memory space (MCU types: atmega83, atmega85). | |
8724 | ||
8725 | Instruction set avr5 is for the enhanced AVR core with up to 128K program | |
8726 | memory space (MCU types: atmega161, atmega163, atmega32, at94k). | |
052a4b28 DC |
8727 | |
8728 | @item -msize | |
cd3bb277 | 8729 | @opindex msize |
3a69a7d5 | 8730 | Output instruction sizes to the asm file. |
052a4b28 DC |
8731 | |
8732 | @item -minit-stack=@var{N} | |
cd3bb277 | 8733 | @opindex minit-stack |
3a69a7d5 | 8734 | Specify the initial stack address, which may be a symbol or numeric value, |
aee96fe9 | 8735 | @samp{__stack} is the default. |
052a4b28 DC |
8736 | |
8737 | @item -mno-interrupts | |
cd3bb277 | 8738 | @opindex mno-interrupts |
052a4b28 DC |
8739 | Generated code is not compatible with hardware interrupts. |
8740 | Code size will be smaller. | |
8741 | ||
8742 | @item -mcall-prologues | |
cd3bb277 | 8743 | @opindex mcall-prologues |
052a4b28 | 8744 | Functions prologues/epilogues expanded as call to appropriate |
767094dd | 8745 | subroutines. Code size will be smaller. |
3a69a7d5 MM |
8746 | |
8747 | @item -mno-tablejump | |
cd3bb277 | 8748 | @opindex mno-tablejump |
3a69a7d5 MM |
8749 | Do not generate tablejump insns which sometimes increase code size. |
8750 | ||
8751 | @item -mtiny-stack | |
cd3bb277 | 8752 | @opindex mtiny-stack |
3a69a7d5 | 8753 | Change only the low 8 bits of the stack pointer. |
052a4b28 DC |
8754 | @end table |
8755 | ||
789a3090 NC |
8756 | @node MCore Options |
8757 | @subsection MCore Options | |
8758 | @cindex MCore options | |
8759 | ||
8760 | These are the @samp{-m} options defined for the Motorola M*Core | |
02f52e19 | 8761 | processors. |
789a3090 | 8762 | |
2642624b | 8763 | @table @gcctabopt |
789a3090 NC |
8764 | |
8765 | @item -mhardlit | |
8766 | @itemx -mhardlit | |
8767 | @itemx -mno-hardlit | |
cd3bb277 JM |
8768 | @opindex mhardlit |
8769 | @opindex mhardlit | |
8770 | @opindex mno-hardlit | |
789a3090 NC |
8771 | Inline constants into the code stream if it can be done in two |
8772 | instructions or less. | |
8773 | ||
8774 | @item -mdiv | |
8775 | @itemx -mdiv | |
8776 | @itemx -mno-div | |
cd3bb277 JM |
8777 | @opindex mdiv |
8778 | @opindex mdiv | |
8779 | @opindex mno-div | |
789a3090 NC |
8780 | Use the divide instruction. (Enabled by default). |
8781 | ||
8782 | @item -mrelax-immediate | |
8783 | @itemx -mrelax-immediate | |
8784 | @itemx -mno-relax-immediate | |
cd3bb277 JM |
8785 | @opindex mrelax-immediate |
8786 | @opindex mrelax-immediate | |
8787 | @opindex mno-relax-immediate | |
b192711e | 8788 | Allow arbitrary sized immediates in bit operations. |
789a3090 NC |
8789 | |
8790 | @item -mwide-bitfields | |
8791 | @itemx -mwide-bitfields | |
8792 | @itemx -mno-wide-bitfields | |
cd3bb277 JM |
8793 | @opindex mwide-bitfields |
8794 | @opindex mwide-bitfields | |
8795 | @opindex mno-wide-bitfields | |
c771326b | 8796 | Always treat bit-fields as int-sized. |
789a3090 NC |
8797 | |
8798 | @item -m4byte-functions | |
8799 | @itemx -m4byte-functions | |
8800 | @itemx -mno-4byte-functions | |
cd3bb277 JM |
8801 | @opindex m4byte-functions |
8802 | @opindex m4byte-functions | |
8803 | @opindex mno-4byte-functions | |
b192711e | 8804 | Force all functions to be aligned to a four byte boundary. |
789a3090 NC |
8805 | |
8806 | @item -mcallgraph-data | |
8807 | @itemx -mcallgraph-data | |
8808 | @itemx -mno-callgraph-data | |
cd3bb277 JM |
8809 | @opindex mcallgraph-data |
8810 | @opindex mcallgraph-data | |
8811 | @opindex mno-callgraph-data | |
789a3090 NC |
8812 | Emit callgraph information. |
8813 | ||
8814 | @item -mslow-bytes | |
8815 | @itemx -mslow-bytes | |
8816 | @itemx -mno-slow-bytes | |
cd3bb277 JM |
8817 | @opindex mslow-bytes |
8818 | @opindex mslow-bytes | |
8819 | @opindex mno-slow-bytes | |
789a3090 NC |
8820 | Prefer word access when reading byte quantities. |
8821 | ||
8822 | @item -mlittle-endian | |
8823 | @itemx -mlittle-endian | |
8824 | @itemx -mbig-endian | |
cd3bb277 JM |
8825 | @opindex mlittle-endian |
8826 | @opindex mlittle-endian | |
8827 | @opindex mbig-endian | |
b192711e | 8828 | Generate code for a little endian target. |
789a3090 NC |
8829 | |
8830 | @item -m210 | |
8831 | @itemx -m210 | |
8832 | @itemx -m340 | |
cd3bb277 JM |
8833 | @opindex m210 |
8834 | @opindex m210 | |
8835 | @opindex m340 | |
789a3090 | 8836 | Generate code for the 210 processor. |
789a3090 | 8837 | @end table |
83575957 | 8838 | |
df6194d4 JW |
8839 | @node IA-64 Options |
8840 | @subsection IA-64 Options | |
8841 | @cindex IA-64 Options | |
8842 | ||
8843 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
8844 | ||
8845 | @table @gcctabopt | |
8846 | @item -mbig-endian | |
cd3bb277 | 8847 | @opindex mbig-endian |
161d7b59 | 8848 | Generate code for a big endian target. This is the default for HPUX@. |
df6194d4 JW |
8849 | |
8850 | @item -mlittle-endian | |
cd3bb277 | 8851 | @opindex mlittle-endian |
df6194d4 JW |
8852 | Generate code for a little endian target. This is the default for AIX5 |
8853 | and Linux. | |
8854 | ||
8855 | @item -mgnu-as | |
8856 | @itemx -mno-gnu-as | |
cd3bb277 JM |
8857 | @opindex mgnu-as |
8858 | @opindex mno-gnu-as | |
15d3a111 | 8859 | Generate (or don't) code for the GNU assembler. This is the default. |
630d3d5a | 8860 | @c Also, this is the default if the configure option @option{--with-gnu-as} |
15d3a111 | 8861 | @c is used. |
df6194d4 JW |
8862 | |
8863 | @item -mgnu-ld | |
8864 | @itemx -mno-gnu-ld | |
cd3bb277 JM |
8865 | @opindex mgnu-ld |
8866 | @opindex mno-gnu-ld | |
15d3a111 | 8867 | Generate (or don't) code for the GNU linker. This is the default. |
630d3d5a | 8868 | @c Also, this is the default if the configure option @option{--with-gnu-ld} |
15d3a111 | 8869 | @c is used. |
df6194d4 JW |
8870 | |
8871 | @item -mno-pic | |
cd3bb277 | 8872 | @opindex mno-pic |
15d3a111 | 8873 | Generate code that does not use a global pointer register. The result |
161d7b59 | 8874 | is not position independent code, and violates the IA-64 ABI@. |
df6194d4 JW |
8875 | |
8876 | @item -mvolatile-asm-stop | |
8877 | @itemx -mno-volatile-asm-stop | |
cd3bb277 JM |
8878 | @opindex mvolatile-asm-stop |
8879 | @opindex mno-volatile-asm-stop | |
15d3a111 JW |
8880 | Generate (or don't) a stop bit immediately before and after volatile asm |
8881 | statements. | |
df6194d4 JW |
8882 | |
8883 | @item -mb-step | |
cd3bb277 | 8884 | @opindex mb-step |
df6194d4 JW |
8885 | Generate code that works around Itanium B step errata. |
8886 | ||
8887 | @item -mregister-names | |
8888 | @itemx -mno-register-names | |
cd3bb277 JM |
8889 | @opindex mregister-names |
8890 | @opindex mno-register-names | |
15d3a111 JW |
8891 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
8892 | the stacked registers. This may make assembler output more readable. | |
df6194d4 JW |
8893 | |
8894 | @item -mno-sdata | |
8895 | @itemx -msdata | |
cd3bb277 JM |
8896 | @opindex mno-sdata |
8897 | @opindex msdata | |
15d3a111 JW |
8898 | Disable (or enable) optimizations that use the small data section. This may |
8899 | be useful for working around optimizer bugs. | |
df6194d4 JW |
8900 | |
8901 | @item -mconstant-gp | |
cd3bb277 | 8902 | @opindex mconstant-gp |
df6194d4 JW |
8903 | Generate code that uses a single constant global pointer value. This is |
8904 | useful when compiling kernel code. | |
8905 | ||
8906 | @item -mauto-pic | |
cd3bb277 | 8907 | @opindex mauto-pic |
630d3d5a | 8908 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
df6194d4 JW |
8909 | This is useful when compiling firmware code. |
8910 | ||
8911 | @item -minline-divide-min-latency | |
cd3bb277 | 8912 | @opindex minline-divide-min-latency |
df6194d4 JW |
8913 | Generate code for inline divides using the minimum latency algorithm. |
8914 | ||
8915 | @item -minline-divide-max-throughput | |
cd3bb277 | 8916 | @opindex minline-divide-max-throughput |
df6194d4 JW |
8917 | Generate code for inline divides using the maximum throughput algorithm. |
8918 | ||
8919 | @item -mno-dwarf2-asm | |
8920 | @itemx -mdwarf2-asm | |
cd3bb277 JM |
8921 | @opindex mno-dwarf2-asm |
8922 | @opindex mdwarf2-asm | |
15d3a111 JW |
8923 | Don't (or do) generate assembler code for the DWARF2 line number debugging |
8924 | info. This may be useful when not using the GNU assembler. | |
df6194d4 | 8925 | |
630d3d5a | 8926 | @item -mfixed-range=@var{register-range} |
cd3bb277 | 8927 | @opindex mfixed-range |
df6194d4 JW |
8928 | Generate code treating the given register range as fixed registers. |
8929 | A fixed register is one that the register allocator can not use. This is | |
8930 | useful when compiling kernel code. A register range is specified as | |
8931 | two registers separated by a dash. Multiple register ranges can be | |
8932 | specified separated by a comma. | |
8933 | @end table | |
8934 | ||
e8ad90e5 MM |
8935 | @node D30V Options |
8936 | @subsection D30V Options | |
8937 | @cindex D30V Options | |
8938 | ||
8939 | These @samp{-m} options are defined for D30V implementations: | |
8940 | ||
2642624b | 8941 | @table @gcctabopt |
e8ad90e5 | 8942 | @item -mextmem |
cd3bb277 | 8943 | @opindex mextmem |
e8ad90e5 MM |
8944 | Link the @samp{.text}, @samp{.data}, @samp{.bss}, @samp{.strings}, |
8945 | @samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections into external | |
8946 | memory, which starts at location @code{0x80000000}. | |
8947 | ||
8948 | @item -mextmemory | |
cd3bb277 | 8949 | @opindex mextmemory |
630d3d5a | 8950 | Same as the @option{-mextmem} switch. |
e8ad90e5 MM |
8951 | |
8952 | @item -monchip | |
cd3bb277 | 8953 | @opindex monchip |
e8ad90e5 MM |
8954 | Link the @samp{.text} section into onchip text memory, which starts at |
8955 | location @code{0x0}. Also link @samp{.data}, @samp{.bss}, | |
8956 | @samp{.strings}, @samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections | |
8957 | into onchip data memory, which starts at location @code{0x20000000}. | |
8958 | ||
8959 | @item -mno-asm-optimize | |
8960 | @itemx -masm-optimize | |
cd3bb277 JM |
8961 | @opindex mno-asm-optimize |
8962 | @opindex masm-optimize | |
630d3d5a JM |
8963 | Disable (enable) passing @option{-O} to the assembler when optimizing. |
8964 | The assembler uses the @option{-O} option to automatically parallelize | |
e8ad90e5 MM |
8965 | adjacent short instructions where possible. |
8966 | ||
8967 | @item -mbranch-cost=@var{n} | |
cd3bb277 | 8968 | @opindex mbranch-cost |
e8ad90e5 MM |
8969 | Increase the internal costs of branches to @var{n}. Higher costs means |
8970 | that the compiler will issue more instructions to avoid doing a branch. | |
8971 | The default is 2. | |
8972 | ||
8973 | @item -mcond-exec=@var{n} | |
cd3bb277 | 8974 | @opindex mcond-exec |
e8ad90e5 MM |
8975 | Specify the maximum number of conditionally executed instructions that |
8976 | replace a branch. The default is 4. | |
8977 | @end table | |
56b2d7a7 | 8978 | |
74291a4b MM |
8979 | @node Code Gen Options |
8980 | @section Options for Code Generation Conventions | |
8981 | @cindex code generation conventions | |
8982 | @cindex options, code generation | |
8983 | @cindex run-time options | |
8984 | ||
8985 | These machine-independent options control the interface conventions | |
8986 | used in code generation. | |
8987 | ||
8988 | Most of them have both positive and negative forms; the negative form | |
630d3d5a | 8989 | of @option{-ffoo} would be @option{-fno-foo}. In the table below, only |
74291a4b MM |
8990 | one of the forms is listed---the one which is not the default. You |
8991 | can figure out the other form by either removing @samp{no-} or adding | |
8992 | it. | |
8993 | ||
2642624b | 8994 | @table @gcctabopt |
956d6950 | 8995 | @item -fexceptions |
cd3bb277 | 8996 | @opindex fexceptions |
767094dd | 8997 | Enable exception handling. Generates extra code needed to propagate |
f0523f02 | 8998 | exceptions. For some targets, this implies GCC will generate frame |
c5c76735 JL |
8999 | unwind information for all functions, which can produce significant data |
9000 | size overhead, although it does not affect execution. If you do not | |
f0523f02 | 9001 | specify this option, GCC will enable it by default for languages like |
90ecce3e | 9002 | C++ which normally require exception handling, and disable it for |
c5c76735 JL |
9003 | languages like C that do not normally require it. However, you may need |
9004 | to enable this option when compiling C code that needs to interoperate | |
9005 | properly with exception handlers written in C++. You may also wish to | |
9006 | disable this option if you are compiling older C++ programs that don't | |
9007 | use exception handling. | |
956d6950 | 9008 | |
6cfc0341 RH |
9009 | @item -fnon-call-exceptions |
9010 | @opindex fnon-call-exceptions | |
9011 | Generate code that allows trapping instructions to throw exceptions. | |
9012 | Note that this requires platform-specific runtime support that does | |
9013 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
e979f9e8 | 9014 | instructions to throw exceptions, i.e.@: memory references or floating |
6cfc0341 RH |
9015 | point instructions. It does not allow exceptions to be thrown from |
9016 | arbitrary signal handlers such as @code{SIGALRM}. | |
9017 | ||
14a774a9 | 9018 | @item -funwind-tables |
cd3bb277 | 9019 | @opindex funwind-tables |
bedc7537 | 9020 | Similar to @option{-fexceptions}, except that it will just generate any needed |
14a774a9 RK |
9021 | static data, but will not affect the generated code in any other way. |
9022 | You will normally not enable this option; instead, a language processor | |
9023 | that needs this handling would enable it on your behalf. | |
9024 | ||
74291a4b | 9025 | @item -fpcc-struct-return |
cd3bb277 | 9026 | @opindex fpcc-struct-return |
74291a4b MM |
9027 | Return ``short'' @code{struct} and @code{union} values in memory like |
9028 | longer ones, rather than in registers. This convention is less | |
9029 | efficient, but it has the advantage of allowing intercallability between | |
0c2d1a2a | 9030 | GCC-compiled files and files compiled with other compilers. |
74291a4b MM |
9031 | |
9032 | The precise convention for returning structures in memory depends | |
9033 | on the target configuration macros. | |
9034 | ||
9035 | Short structures and unions are those whose size and alignment match | |
9036 | that of some integer type. | |
9037 | ||
9038 | @item -freg-struct-return | |
cd3bb277 | 9039 | @opindex freg-struct-return |
74291a4b MM |
9040 | Use the convention that @code{struct} and @code{union} values are |
9041 | returned in registers when possible. This is more efficient for small | |
630d3d5a | 9042 | structures than @option{-fpcc-struct-return}. |
74291a4b | 9043 | |
630d3d5a JM |
9044 | If you specify neither @option{-fpcc-struct-return} nor its contrary |
9045 | @option{-freg-struct-return}, GCC defaults to whichever convention is | |
0c2d1a2a | 9046 | standard for the target. If there is no standard convention, GCC |
630d3d5a | 9047 | defaults to @option{-fpcc-struct-return}, except on targets where GCC |
74291a4b MM |
9048 | is the principal compiler. In those cases, we can choose the standard, |
9049 | and we chose the more efficient register return alternative. | |
9050 | ||
9051 | @item -fshort-enums | |
cd3bb277 | 9052 | @opindex fshort-enums |
74291a4b MM |
9053 | Allocate to an @code{enum} type only as many bytes as it needs for the |
9054 | declared range of possible values. Specifically, the @code{enum} type | |
9055 | will be equivalent to the smallest integer type which has enough room. | |
9056 | ||
9057 | @item -fshort-double | |
cd3bb277 | 9058 | @opindex fshort-double |
74291a4b MM |
9059 | Use the same size for @code{double} as for @code{float}. |
9060 | ||
9061 | @item -fshared-data | |
cd3bb277 | 9062 | @opindex fshared-data |
74291a4b MM |
9063 | Requests that the data and non-@code{const} variables of this |
9064 | compilation be shared data rather than private data. The distinction | |
9065 | makes sense only on certain operating systems, where shared data is | |
9066 | shared between processes running the same program, while private data | |
9067 | exists in one copy per process. | |
9068 | ||
9069 | @item -fno-common | |
cd3bb277 | 9070 | @opindex fno-common |
90ecce3e | 9071 | In C, allocate even uninitialized global variables in the data section of the |
74291a4b MM |
9072 | object file, rather than generating them as common blocks. This has the |
9073 | effect that if the same variable is declared (without @code{extern}) in | |
9074 | two different compilations, you will get an error when you link them. | |
9075 | The only reason this might be useful is if you wish to verify that the | |
9076 | program will work on other systems which always work this way. | |
9077 | ||
9078 | @item -fno-ident | |
cd3bb277 | 9079 | @opindex fno-ident |
74291a4b MM |
9080 | Ignore the @samp{#ident} directive. |
9081 | ||
9082 | @item -fno-gnu-linker | |
cd3bb277 | 9083 | @opindex fno-gnu-linker |
74291a4b MM |
9084 | Do not output global initializations (such as C++ constructors and |
9085 | destructors) in the form used by the GNU linker (on systems where the GNU | |
9086 | linker is the standard method of handling them). Use this option when | |
9087 | you want to use a non-GNU linker, which also requires using the | |
bedc7537 NC |
9088 | @command{collect2} program to make sure the system linker includes |
9089 | constructors and destructors. (@command{collect2} is included in the GCC | |
9090 | distribution.) For systems which @emph{must} use @command{collect2}, the | |
9091 | compiler driver @command{gcc} is configured to do this automatically. | |
74291a4b MM |
9092 | |
9093 | @item -finhibit-size-directive | |
cd3bb277 | 9094 | @opindex finhibit-size-directive |
74291a4b MM |
9095 | Don't output a @code{.size} assembler directive, or anything else that |
9096 | would cause trouble if the function is split in the middle, and the | |
9097 | two halves are placed at locations far apart in memory. This option is | |
9098 | used when compiling @file{crtstuff.c}; you should not need to use it | |
9099 | for anything else. | |
9100 | ||
9101 | @item -fverbose-asm | |
cd3bb277 | 9102 | @opindex fverbose-asm |
74291a4b MM |
9103 | Put extra commentary information in the generated assembly code to |
9104 | make it more readable. This option is generally only of use to those | |
9105 | who actually need to read the generated assembly code (perhaps while | |
9106 | debugging the compiler itself). | |
9107 | ||
630d3d5a | 9108 | @option{-fno-verbose-asm}, the default, causes the |
74291a4b MM |
9109 | extra information to be omitted and is useful when comparing two assembler |
9110 | files. | |
9111 | ||
9112 | @item -fvolatile | |
cd3bb277 | 9113 | @opindex fvolatile |
74291a4b MM |
9114 | Consider all memory references through pointers to be volatile. |
9115 | ||
9116 | @item -fvolatile-global | |
cd3bb277 | 9117 | @opindex fvolatile-global |
74291a4b | 9118 | Consider all memory references to extern and global data items to |
0c2d1a2a | 9119 | be volatile. GCC does not consider static data items to be volatile |
ab87f8c8 JL |
9120 | because of this switch. |
9121 | ||
9122 | @item -fvolatile-static | |
cd3bb277 | 9123 | @opindex fvolatile-static |
ab87f8c8 | 9124 | Consider all memory references to static data to be volatile. |
74291a4b MM |
9125 | |
9126 | @item -fpic | |
cd3bb277 | 9127 | @opindex fpic |
74291a4b MM |
9128 | @cindex global offset table |
9129 | @cindex PIC | |
9130 | Generate position-independent code (PIC) suitable for use in a shared | |
9131 | library, if supported for the target machine. Such code accesses all | |
161d7b59 | 9132 | constant addresses through a global offset table (GOT)@. The dynamic |
861bb6c1 | 9133 | loader resolves the GOT entries when the program starts (the dynamic |
0c2d1a2a | 9134 | loader is not part of GCC; it is part of the operating system). If |
861bb6c1 JL |
9135 | the GOT size for the linked executable exceeds a machine-specific |
9136 | maximum size, you get an error message from the linker indicating that | |
630d3d5a | 9137 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} |
861bb6c1 JL |
9138 | instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k |
9139 | on the m68k and RS/6000. The 386 has no such limit.) | |
74291a4b MM |
9140 | |
9141 | Position-independent code requires special support, and therefore works | |
0c2d1a2a | 9142 | only on certain machines. For the 386, GCC supports PIC for System V |
74291a4b MM |
9143 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always |
9144 | position-independent. | |
9145 | ||
74291a4b | 9146 | @item -fPIC |
cd3bb277 | 9147 | @opindex fPIC |
74291a4b MM |
9148 | If supported for the target machine, emit position-independent code, |
9149 | suitable for dynamic linking and avoiding any limit on the size of the | |
9150 | global offset table. This option makes a difference on the m68k, m88k, | |
9151 | and the Sparc. | |
9152 | ||
9153 | Position-independent code requires special support, and therefore works | |
9154 | only on certain machines. | |
9155 | ||
9156 | @item -ffixed-@var{reg} | |
cd3bb277 | 9157 | @opindex ffixed |
74291a4b MM |
9158 | Treat the register named @var{reg} as a fixed register; generated code |
9159 | should never refer to it (except perhaps as a stack pointer, frame | |
9160 | pointer or in some other fixed role). | |
9161 | ||
9162 | @var{reg} must be the name of a register. The register names accepted | |
9163 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
9164 | macro in the machine description macro file. | |
9165 | ||
9166 | This flag does not have a negative form, because it specifies a | |
9167 | three-way choice. | |
9168 | ||
9169 | @item -fcall-used-@var{reg} | |
cd3bb277 | 9170 | @opindex fcall-used |
956d6950 | 9171 | Treat the register named @var{reg} as an allocable register that is |
74291a4b MM |
9172 | clobbered by function calls. It may be allocated for temporaries or |
9173 | variables that do not live across a call. Functions compiled this way | |
9174 | will not save and restore the register @var{reg}. | |
9175 | ||
cb2fdc84 GRK |
9176 | It is an error to used this flag with the frame pointer or stack pointer. |
9177 | Use of this flag for other registers that have fixed pervasive roles in | |
9178 | the machine's execution model will produce disastrous results. | |
74291a4b MM |
9179 | |
9180 | This flag does not have a negative form, because it specifies a | |
9181 | three-way choice. | |
9182 | ||
9183 | @item -fcall-saved-@var{reg} | |
cd3bb277 | 9184 | @opindex fcall-saved |
956d6950 | 9185 | Treat the register named @var{reg} as an allocable register saved by |
74291a4b MM |
9186 | functions. It may be allocated even for temporaries or variables that |
9187 | live across a call. Functions compiled this way will save and restore | |
9188 | the register @var{reg} if they use it. | |
9189 | ||
cb2fdc84 GRK |
9190 | It is an error to used this flag with the frame pointer or stack pointer. |
9191 | Use of this flag for other registers that have fixed pervasive roles in | |
9192 | the machine's execution model will produce disastrous results. | |
74291a4b MM |
9193 | |
9194 | A different sort of disaster will result from the use of this flag for | |
9195 | a register in which function values may be returned. | |
9196 | ||
9197 | This flag does not have a negative form, because it specifies a | |
9198 | three-way choice. | |
9199 | ||
9200 | @item -fpack-struct | |
cd3bb277 | 9201 | @opindex fpack-struct |
74291a4b MM |
9202 | Pack all structure members together without holes. Usually you would |
9203 | not want to use this option, since it makes the code suboptimal, and | |
9204 | the offsets of structure members won't agree with system libraries. | |
9205 | ||
861bb6c1 | 9206 | @item -fcheck-memory-usage |
cd3bb277 | 9207 | @opindex fcheck-memory-usage |
0c2d1a2a | 9208 | Generate extra code to check each memory access. GCC will generate |
861bb6c1 | 9209 | code that is suitable for a detector of bad memory accesses such as |
7d384cc0 | 9210 | @file{Checker}. |
861bb6c1 | 9211 | |
d3111037 CB |
9212 | Normally, you should compile all, or none, of your code with this option. |
9213 | ||
9214 | If you do mix code compiled with and without this option, | |
9215 | you must ensure that all code that has side effects | |
9216 | and that is called by code compiled with this option | |
9217 | is, itself, compiled with this option. | |
9218 | If you do not, you might get erroneous messages from the detector. | |
9219 | ||
861bb6c1 | 9220 | If you use functions from a library that have side-effects (such as |
d3111037 | 9221 | @code{read}), you might not be able to recompile the library and |
861bb6c1 | 9222 | specify this option. In that case, you can enable the |
630d3d5a | 9223 | @option{-fprefix-function-name} option, which requests GCC to encapsulate |
861bb6c1 | 9224 | your code and make other functions look as if they were compiled with |
630d3d5a | 9225 | @option{-fcheck-memory-usage}. This is done by calling ``stubs'', |
861bb6c1 | 9226 | which are provided by the detector. If you cannot find or build |
d3111037 | 9227 | stubs for every function you call, you might have to specify |
630d3d5a | 9228 | @option{-fcheck-memory-usage} without @option{-fprefix-function-name}. |
861bb6c1 | 9229 | |
7d384cc0 | 9230 | If you specify this option, you can not use the @code{asm} or |
f0523f02 JM |
9231 | @code{__asm__} keywords in functions with memory checking enabled. GCC |
9232 | cannot understand what the @code{asm} statement may do, and therefore | |
c5c76735 | 9233 | cannot generate the appropriate code, so it will reject it. However, if |
ee457005 | 9234 | you specify the function attribute @code{no_check_memory_usage} |
f0523f02 | 9235 | (@pxref{Function Attributes}), GCC will disable memory checking within a |
c5c76735 JL |
9236 | function; you may use @code{asm} statements inside such functions. You |
9237 | may have an inline expansion of a non-checked function within a checked | |
f0523f02 | 9238 | function; in that case GCC will not generate checks for the inlined |
c5c76735 JL |
9239 | function's memory accesses. |
9240 | ||
9241 | If you move your @code{asm} statements to non-checked inline functions | |
9242 | and they do access memory, you can add calls to the support code in your | |
7d384cc0 KR |
9243 | inline function, to indicate any reads, writes, or copies being done. |
9244 | These calls would be similar to those done in the stubs described above. | |
9245 | ||
861bb6c1 | 9246 | @item -fprefix-function-name |
cd3bb277 | 9247 | @opindex fprefix-function-name |
0c2d1a2a JB |
9248 | Request GCC to add a prefix to the symbols generated for function names. |
9249 | GCC adds a prefix to the names of functions defined as well as | |
861bb6c1 | 9250 | functions called. Code compiled with this option and code compiled |
d3111037 | 9251 | without the option can't be linked together, unless stubs are used. |
861bb6c1 | 9252 | |
630d3d5a | 9253 | If you compile the following code with @option{-fprefix-function-name} |
861bb6c1 JL |
9254 | @example |
9255 | extern void bar (int); | |
9256 | void | |
9257 | foo (int a) | |
9258 | @{ | |
9259 | return bar (a + 5); | |
861bb6c1 JL |
9260 | @} |
9261 | @end example | |
9262 | ||
9263 | @noindent | |
0c2d1a2a | 9264 | GCC will compile the code as if it was written: |
861bb6c1 JL |
9265 | @example |
9266 | extern void prefix_bar (int); | |
9267 | void | |
9268 | prefix_foo (int a) | |
9269 | @{ | |
9270 | return prefix_bar (a + 5); | |
9271 | @} | |
9272 | @end example | |
630d3d5a | 9273 | This option is designed to be used with @option{-fcheck-memory-usage}. |
861bb6c1 | 9274 | |
07417085 | 9275 | @item -finstrument-functions |
cd3bb277 | 9276 | @opindex finstrument-functions |
07417085 KR |
9277 | Generate instrumentation calls for entry and exit to functions. Just |
9278 | after function entry and just before function exit, the following | |
9279 | profiling functions will be called with the address of the current | |
9280 | function and its call site. (On some platforms, | |
9281 | @code{__builtin_return_address} does not work beyond the current | |
9282 | function, so the call site information may not be available to the | |
9283 | profiling functions otherwise.) | |
9284 | ||
9285 | @example | |
310668e8 JM |
9286 | void __cyg_profile_func_enter (void *this_fn, |
9287 | void *call_site); | |
9288 | void __cyg_profile_func_exit (void *this_fn, | |
9289 | void *call_site); | |
07417085 KR |
9290 | @end example |
9291 | ||
9292 | The first argument is the address of the start of the current function, | |
9293 | which may be looked up exactly in the symbol table. | |
9294 | ||
9295 | This instrumentation is also done for functions expanded inline in other | |
9296 | functions. The profiling calls will indicate where, conceptually, the | |
9297 | inline function is entered and exited. This means that addressable | |
9298 | versions of such functions must be available. If all your uses of a | |
9299 | function are expanded inline, this may mean an additional expansion of | |
9300 | code size. If you use @samp{extern inline} in your C code, an | |
9301 | addressable version of such functions must be provided. (This is | |
9302 | normally the case anyways, but if you get lucky and the optimizer always | |
9303 | expands the functions inline, you might have gotten away without | |
9304 | providing static copies.) | |
9305 | ||
9306 | A function may be given the attribute @code{no_instrument_function}, in | |
9307 | which case this instrumentation will not be done. This can be used, for | |
9308 | example, for the profiling functions listed above, high-priority | |
9309 | interrupt routines, and any functions from which the profiling functions | |
9310 | cannot safely be called (perhaps signal handlers, if the profiling | |
9311 | routines generate output or allocate memory). | |
9312 | ||
861bb6c1 | 9313 | @item -fstack-check |
cd3bb277 | 9314 | @opindex fstack-check |
861bb6c1 JL |
9315 | Generate code to verify that you do not go beyond the boundary of the |
9316 | stack. You should specify this flag if you are running in an | |
9317 | environment with multiple threads, but only rarely need to specify it in | |
9318 | a single-threaded environment since stack overflow is automatically | |
9319 | detected on nearly all systems if there is only one stack. | |
9320 | ||
a157febd GK |
9321 | Note that this switch does not actually cause checking to be done; the |
9322 | operating system must do that. The switch causes generation of code | |
9323 | to ensure that the operating system sees the stack being extended. | |
9324 | ||
9325 | @item -fstack-limit-register=@var{reg} | |
9326 | @itemx -fstack-limit-symbol=@var{sym} | |
9327 | @itemx -fno-stack-limit | |
cd3bb277 JM |
9328 | @opindex fstack-limit-register |
9329 | @opindex fstack-limit-symbol | |
9330 | @opindex fno-stack-limit | |
a157febd GK |
9331 | Generate code to ensure that the stack does not grow beyond a certain value, |
9332 | either the value of a register or the address of a symbol. If the stack | |
9333 | would grow beyond the value, a signal is raised. For most targets, | |
9334 | the signal is raised before the stack overruns the boundary, so | |
9335 | it is possible to catch the signal without taking special precautions. | |
9336 | ||
9337 | For instance, if the stack starts at address @samp{0x80000000} and grows | |
9338 | downwards you can use the flags | |
630d3d5a JM |
9339 | @samp{-fstack-limit-symbol=__stack_limit |
9340 | -Wl,--defsym,__stack_limit=0x7ffe0000} which will enforce a stack | |
161d7b59 | 9341 | limit of 128K@. |
a157febd | 9342 | |
e5eb27e5 JL |
9343 | @cindex aliasing of parameters |
9344 | @cindex parameters, aliased | |
9345 | @item -fargument-alias | |
04afd9d6 JL |
9346 | @itemx -fargument-noalias |
9347 | @itemx -fargument-noalias-global | |
cd3bb277 JM |
9348 | @opindex fargument-alias |
9349 | @opindex fargument-noalias | |
9350 | @opindex fargument-noalias-global | |
e5eb27e5 JL |
9351 | Specify the possible relationships among parameters and between |
9352 | parameters and global data. | |
9353 | ||
630d3d5a | 9354 | @option{-fargument-alias} specifies that arguments (parameters) may |
e5eb27e5 | 9355 | alias each other and may alias global storage. |
630d3d5a | 9356 | @option{-fargument-noalias} specifies that arguments do not alias |
e5eb27e5 | 9357 | each other, but may alias global storage. |
630d3d5a | 9358 | @option{-fargument-noalias-global} specifies that arguments do not |
e5eb27e5 JL |
9359 | alias each other and do not alias global storage. |
9360 | ||
9361 | Each language will automatically use whatever option is required by | |
9362 | the language standard. You should not need to use these options yourself. | |
19283265 RH |
9363 | |
9364 | @item -fleading-underscore | |
cd3bb277 | 9365 | @opindex fleading-underscore |
695ac33f | 9366 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
19283265 RH |
9367 | change the way C symbols are represented in the object file. One use |
9368 | is to help link with legacy assembly code. | |
9369 | ||
9370 | Be warned that you should know what you are doing when invoking this | |
9371 | option, and that not all targets provide complete support for it. | |
74291a4b MM |
9372 | @end table |
9373 | ||
ee457005 JM |
9374 | @c man end |
9375 | ||
74291a4b | 9376 | @node Environment Variables |
0c2d1a2a | 9377 | @section Environment Variables Affecting GCC |
74291a4b MM |
9378 | @cindex environment variables |
9379 | ||
ee457005 JM |
9380 | @c man begin ENVIRONMENT |
9381 | ||
0c2d1a2a JB |
9382 | This section describes several environment variables that affect how GCC |
9383 | operates. Some of them work by specifying directories or prefixes to use | |
767094dd | 9384 | when searching for various kinds of files. Some are used to specify other |
46103ab4 | 9385 | aspects of the compilation environment. |
74291a4b MM |
9386 | |
9387 | @ifclear INTERNALS | |
9388 | Note that you can also specify places to search using options such as | |
630d3d5a | 9389 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These |
74291a4b | 9390 | take precedence over places specified using environment variables, which |
161d7b59 | 9391 | in turn take precedence over those specified by the configuration of GCC@. |
0c2d1a2a | 9392 | |
74291a4b MM |
9393 | @end ifclear |
9394 | @ifset INTERNALS | |
9395 | Note that you can also specify places to search using options such as | |
630d3d5a | 9396 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These |
74291a4b | 9397 | take precedence over places specified using environment variables, which |
161d7b59 | 9398 | in turn take precedence over those specified by the configuration of GCC@. |
0c2d1a2a | 9399 | @xref{Driver}. |
74291a4b MM |
9400 | @end ifset |
9401 | ||
bedc7537 | 9402 | @table @env |
ab87f8c8 JL |
9403 | @item LANG |
9404 | @itemx LC_CTYPE | |
9405 | @c @itemx LC_COLLATE | |
9406 | @itemx LC_MESSAGES | |
9407 | @c @itemx LC_MONETARY | |
9408 | @c @itemx LC_NUMERIC | |
9409 | @c @itemx LC_TIME | |
9410 | @itemx LC_ALL | |
9411 | @findex LANG | |
9412 | @findex LC_CTYPE | |
9413 | @c @findex LC_COLLATE | |
9414 | @findex LC_MESSAGES | |
9415 | @c @findex LC_MONETARY | |
9416 | @c @findex LC_NUMERIC | |
9417 | @c @findex LC_TIME | |
9418 | @findex LC_ALL | |
9419 | @cindex locale | |
0c2d1a2a JB |
9420 | These environment variables control the way that GCC uses |
9421 | localization information that allow GCC to work with different | |
9422 | national conventions. GCC inspects the locale categories | |
bedc7537 | 9423 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do |
ab87f8c8 JL |
9424 | so. These locale categories can be set to any value supported by your |
9425 | installation. A typical value is @samp{en_UK} for English in the United | |
9426 | Kingdom. | |
9427 | ||
bedc7537 | 9428 | The @env{LC_CTYPE} environment variable specifies character |
0c2d1a2a | 9429 | classification. GCC uses it to determine the character boundaries in |
ab87f8c8 JL |
9430 | a string; this is needed for some multibyte encodings that contain quote |
9431 | and escape characters that would otherwise be interpreted as a string | |
9432 | end or escape. | |
9433 | ||
bedc7537 | 9434 | The @env{LC_MESSAGES} environment variable specifies the language to |
ab87f8c8 JL |
9435 | use in diagnostic messages. |
9436 | ||
bedc7537 NC |
9437 | If the @env{LC_ALL} environment variable is set, it overrides the value |
9438 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
9439 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
0c2d1a2a | 9440 | environment variable. If none of these variables are set, GCC |
ab87f8c8 JL |
9441 | defaults to traditional C English behavior. |
9442 | ||
74291a4b MM |
9443 | @item TMPDIR |
9444 | @findex TMPDIR | |
bedc7537 | 9445 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
0c2d1a2a | 9446 | files. GCC uses temporary files to hold the output of one stage of |
74291a4b MM |
9447 | compilation which is to be used as input to the next stage: for example, |
9448 | the output of the preprocessor, which is the input to the compiler | |
9449 | proper. | |
9450 | ||
9451 | @item GCC_EXEC_PREFIX | |
9452 | @findex GCC_EXEC_PREFIX | |
bedc7537 | 9453 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
74291a4b MM |
9454 | names of the subprograms executed by the compiler. No slash is added |
9455 | when this prefix is combined with the name of a subprogram, but you can | |
9456 | specify a prefix that ends with a slash if you wish. | |
9457 | ||
f0523f02 | 9458 | If @env{GCC_EXEC_PREFIX} is not set, GCC will attempt to figure out |
0deb20df TT |
9459 | an appropriate prefix to use based on the pathname it was invoked with. |
9460 | ||
0c2d1a2a | 9461 | If GCC cannot find the subprogram using the specified prefix, it |
74291a4b MM |
9462 | tries looking in the usual places for the subprogram. |
9463 | ||
bedc7537 | 9464 | The default value of @env{GCC_EXEC_PREFIX} is |
74291a4b MM |
9465 | @file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value |
9466 | of @code{prefix} when you ran the @file{configure} script. | |
9467 | ||
630d3d5a | 9468 | Other prefixes specified with @option{-B} take precedence over this prefix. |
74291a4b MM |
9469 | |
9470 | This prefix is also used for finding files such as @file{crt0.o} that are | |
9471 | used for linking. | |
9472 | ||
9473 | In addition, the prefix is used in an unusual way in finding the | |
9474 | directories to search for header files. For each of the standard | |
9475 | directories whose name normally begins with @samp{/usr/local/lib/gcc-lib} | |
bedc7537 | 9476 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries |
74291a4b | 9477 | replacing that beginning with the specified prefix to produce an |
630d3d5a | 9478 | alternate directory name. Thus, with @option{-Bfoo/}, GCC will search |
74291a4b MM |
9479 | @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}. |
9480 | These alternate directories are searched first; the standard directories | |
9481 | come next. | |
9482 | ||
9483 | @item COMPILER_PATH | |
9484 | @findex COMPILER_PATH | |
bedc7537 NC |
9485 | The value of @env{COMPILER_PATH} is a colon-separated list of |
9486 | directories, much like @env{PATH}. GCC tries the directories thus | |
74291a4b | 9487 | specified when searching for subprograms, if it can't find the |
bedc7537 | 9488 | subprograms using @env{GCC_EXEC_PREFIX}. |
74291a4b MM |
9489 | |
9490 | @item LIBRARY_PATH | |
9491 | @findex LIBRARY_PATH | |
bedc7537 NC |
9492 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
9493 | directories, much like @env{PATH}. When configured as a native compiler, | |
0c2d1a2a | 9494 | GCC tries the directories thus specified when searching for special |
bedc7537 | 9495 | linker files, if it can't find them using @env{GCC_EXEC_PREFIX}. Linking |
0c2d1a2a | 9496 | using GCC also uses these directories when searching for ordinary |
630d3d5a JM |
9497 | libraries for the @option{-l} option (but directories specified with |
9498 | @option{-L} come first). | |
74291a4b MM |
9499 | |
9500 | @item C_INCLUDE_PATH | |
9501 | @itemx CPLUS_INCLUDE_PATH | |
9502 | @itemx OBJC_INCLUDE_PATH | |
9503 | @findex C_INCLUDE_PATH | |
9504 | @findex CPLUS_INCLUDE_PATH | |
9505 | @findex OBJC_INCLUDE_PATH | |
9506 | @c @itemx OBJCPLUS_INCLUDE_PATH | |
9507 | These environment variables pertain to particular languages. Each | |
9508 | variable's value is a colon-separated list of directories, much like | |
bedc7537 | 9509 | @env{PATH}. When GCC searches for header files, it tries the |
74291a4b | 9510 | directories listed in the variable for the language you are using, after |
630d3d5a | 9511 | the directories specified with @option{-I} but before the standard header |
74291a4b MM |
9512 | file directories. |
9513 | ||
9514 | @item DEPENDENCIES_OUTPUT | |
9515 | @findex DEPENDENCIES_OUTPUT | |
9516 | @cindex dependencies for make as output | |
9517 | If this variable is set, its value specifies how to output dependencies | |
9518 | for Make based on the header files processed by the compiler. This | |
630d3d5a | 9519 | output looks much like the output from the @option{-M} option |
74291a4b MM |
9520 | (@pxref{Preprocessor Options}), but it goes to a separate file, and is |
9521 | in addition to the usual results of compilation. | |
9522 | ||
bedc7537 | 9523 | The value of @env{DEPENDENCIES_OUTPUT} can be just a file name, in |
74291a4b MM |
9524 | which case the Make rules are written to that file, guessing the target |
9525 | name from the source file name. Or the value can have the form | |
9526 | @samp{@var{file} @var{target}}, in which case the rules are written to | |
9527 | file @var{file} using @var{target} as the target name. | |
56f48ce9 DB |
9528 | |
9529 | @item LANG | |
9530 | @findex LANG | |
9531 | @cindex locale definition | |
767094dd | 9532 | This variable is used to pass locale information to the compiler. One way in |
56f48ce9 DB |
9533 | which this information is used is to determine the character set to be used |
9534 | when character literals, string literals and comments are parsed in C and C++. | |
9535 | When the compiler is configured to allow multibyte characters, | |
bedc7537 | 9536 | the following values for @env{LANG} are recognized: |
56f48ce9 | 9537 | |
2642624b | 9538 | @table @samp |
56f48ce9 DB |
9539 | @item C-JIS |
9540 | Recognize JIS characters. | |
9541 | @item C-SJIS | |
9542 | Recognize SJIS characters. | |
9543 | @item C-EUCJP | |
9544 | Recognize EUCJP characters. | |
9545 | @end table | |
9546 | ||
bedc7537 | 9547 | If @env{LANG} is not defined, or if it has some other value, then the |
56f48ce9 DB |
9548 | compiler will use mblen and mbtowc as defined by the default locale to |
9549 | recognize and translate multibyte characters. | |
74291a4b MM |
9550 | @end table |
9551 | ||
9d86bffc JM |
9552 | @c man end |
9553 | ||
74291a4b MM |
9554 | @node Running Protoize |
9555 | @section Running Protoize | |
9556 | ||
161d7b59 | 9557 | The program @code{protoize} is an optional part of GCC@. You can use |
c1030c7c | 9558 | it to add prototypes to a program, thus converting the program to ISO |
74291a4b MM |
9559 | C in one respect. The companion program @code{unprotoize} does the |
9560 | reverse: it removes argument types from any prototypes that are found. | |
9561 | ||
9562 | When you run these programs, you must specify a set of source files as | |
9563 | command line arguments. The conversion programs start out by compiling | |
9564 | these files to see what functions they define. The information gathered | |
9565 | about a file @var{foo} is saved in a file named @file{@var{foo}.X}. | |
9566 | ||
9567 | After scanning comes actual conversion. The specified files are all | |
9568 | eligible to be converted; any files they include (whether sources or | |
9569 | just headers) are eligible as well. | |
9570 | ||
9571 | But not all the eligible files are converted. By default, | |
9572 | @code{protoize} and @code{unprotoize} convert only source and header | |
9573 | files in the current directory. You can specify additional directories | |
630d3d5a | 9574 | whose files should be converted with the @option{-d @var{directory}} |
74291a4b | 9575 | option. You can also specify particular files to exclude with the |
630d3d5a | 9576 | @option{-x @var{file}} option. A file is converted if it is eligible, its |
74291a4b MM |
9577 | directory name matches one of the specified directory names, and its |
9578 | name within the directory has not been excluded. | |
9579 | ||
9580 | Basic conversion with @code{protoize} consists of rewriting most | |
9581 | function definitions and function declarations to specify the types of | |
9582 | the arguments. The only ones not rewritten are those for varargs | |
9583 | functions. | |
9584 | ||
9585 | @code{protoize} optionally inserts prototype declarations at the | |
9586 | beginning of the source file, to make them available for any calls that | |
9587 | precede the function's definition. Or it can insert prototype | |
9588 | declarations with block scope in the blocks where undeclared functions | |
9589 | are called. | |
9590 | ||
9591 | Basic conversion with @code{unprotoize} consists of rewriting most | |
9592 | function declarations to remove any argument types, and rewriting | |
c1030c7c | 9593 | function definitions to the old-style pre-ISO form. |
74291a4b MM |
9594 | |
9595 | Both conversion programs print a warning for any function declaration or | |
9596 | definition that they can't convert. You can suppress these warnings | |
630d3d5a | 9597 | with @option{-q}. |
74291a4b MM |
9598 | |
9599 | The output from @code{protoize} or @code{unprotoize} replaces the | |
9600 | original source file. The original file is renamed to a name ending | |
02f52e19 | 9601 | with @samp{.save} (for DOS, the saved filename ends in @samp{.sav} |
a7db8bbb MK |
9602 | without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav} |
9603 | for DOS) file already exists, then the source file is simply discarded. | |
74291a4b | 9604 | |
0c2d1a2a | 9605 | @code{protoize} and @code{unprotoize} both depend on GCC itself to |
74291a4b | 9606 | scan the program and collect information about the functions it uses. |
0c2d1a2a | 9607 | So neither of these programs will work until GCC is installed. |
74291a4b MM |
9608 | |
9609 | Here is a table of the options you can use with @code{protoize} and | |
9610 | @code{unprotoize}. Each option works with both programs unless | |
9611 | otherwise stated. | |
9612 | ||
9613 | @table @code | |
9614 | @item -B @var{directory} | |
9615 | Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the | |
9616 | usual directory (normally @file{/usr/local/lib}). This file contains | |
9617 | prototype information about standard system functions. This option | |
9618 | applies only to @code{protoize}. | |
9619 | ||
9620 | @item -c @var{compilation-options} | |
9621 | Use @var{compilation-options} as the options when running @code{gcc} to | |
630d3d5a | 9622 | produce the @samp{.X} files. The special option @option{-aux-info} is |
74291a4b MM |
9623 | always passed in addition, to tell @code{gcc} to write a @samp{.X} file. |
9624 | ||
9625 | Note that the compilation options must be given as a single argument to | |
9626 | @code{protoize} or @code{unprotoize}. If you want to specify several | |
9627 | @code{gcc} options, you must quote the entire set of compilation options | |
9628 | to make them a single word in the shell. | |
9629 | ||
9630 | There are certain @code{gcc} arguments that you cannot use, because they | |
630d3d5a JM |
9631 | would produce the wrong kind of output. These include @option{-g}, |
9632 | @option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in | |
74291a4b MM |
9633 | the @var{compilation-options}, they are ignored. |
9634 | ||
9635 | @item -C | |
a7db8bbb | 9636 | Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file |
02f52e19 | 9637 | systems) instead of @samp{.c}. This is convenient if you are converting |
ee77eda5 | 9638 | a C program to C++. This option applies only to @code{protoize}. |
74291a4b MM |
9639 | |
9640 | @item -g | |
9641 | Add explicit global declarations. This means inserting explicit | |
9642 | declarations at the beginning of each source file for each function | |
9643 | that is called in the file and was not declared. These declarations | |
9644 | precede the first function definition that contains a call to an | |
9645 | undeclared function. This option applies only to @code{protoize}. | |
9646 | ||
9647 | @item -i @var{string} | |
9648 | Indent old-style parameter declarations with the string @var{string}. | |
9649 | This option applies only to @code{protoize}. | |
9650 | ||
9651 | @code{unprotoize} converts prototyped function definitions to old-style | |
9652 | function definitions, where the arguments are declared between the | |
9653 | argument list and the initial @samp{@{}. By default, @code{unprotoize} | |
9654 | uses five spaces as the indentation. If you want to indent with just | |
630d3d5a | 9655 | one space instead, use @option{-i " "}. |
74291a4b MM |
9656 | |
9657 | @item -k | |
9658 | Keep the @samp{.X} files. Normally, they are deleted after conversion | |
9659 | is finished. | |
9660 | ||
9661 | @item -l | |
630d3d5a | 9662 | Add explicit local declarations. @code{protoize} with @option{-l} inserts |
74291a4b MM |
9663 | a prototype declaration for each function in each block which calls the |
9664 | function without any declaration. This option applies only to | |
9665 | @code{protoize}. | |
9666 | ||
9667 | @item -n | |
9668 | Make no real changes. This mode just prints information about the conversions | |
630d3d5a | 9669 | that would have been done without @option{-n}. |
74291a4b MM |
9670 | |
9671 | @item -N | |
9672 | Make no @samp{.save} files. The original files are simply deleted. | |
9673 | Use this option with caution. | |
9674 | ||
9675 | @item -p @var{program} | |
9676 | Use the program @var{program} as the compiler. Normally, the name | |
9677 | @file{gcc} is used. | |
9678 | ||
9679 | @item -q | |
9680 | Work quietly. Most warnings are suppressed. | |
9681 | ||
9682 | @item -v | |
630d3d5a | 9683 | Print the version number, just like @option{-v} for @code{gcc}. |
74291a4b MM |
9684 | @end table |
9685 | ||
9686 | If you need special compiler options to compile one of your program's | |
9687 | source files, then you should generate that file's @samp{.X} file | |
9688 | specially, by running @code{gcc} on that source file with the | |
630d3d5a | 9689 | appropriate options and the option @option{-aux-info}. Then run |
74291a4b MM |
9690 | @code{protoize} on the entire set of files. @code{protoize} will use |
9691 | the existing @samp{.X} file because it is newer than the source file. | |
9692 | For example: | |
9693 | ||
9694 | @example | |
b1018de6 | 9695 | gcc -Dfoo=bar file1.c -aux-info file1.X |
74291a4b MM |
9696 | protoize *.c |
9697 | @end example | |
9698 | ||
9699 | @noindent | |
9700 | You need to include the special files along with the rest in the | |
9701 | @code{protoize} command, even though their @samp{.X} files already | |
9702 | exist, because otherwise they won't get converted. | |
9703 | ||
9704 | @xref{Protoize Caveats}, for more information on how to use | |
9705 | @code{protoize} successfully. |