]>
Commit | Line | Data |
---|---|---|
861bb6c1 | 1 | @c Copyright (C) 1988,89,92,93,94,95,96,1997 Free Software Foundation, Inc. |
74291a4b MM |
2 | @c This is part of the GCC manual. |
3 | @c For copying conditions, see the file gcc.texi. | |
4 | ||
5 | @node Invoking GCC | |
6 | @chapter GNU CC Command Options | |
7 | @cindex GNU CC command options | |
8 | @cindex command options | |
9 | @cindex options, GNU CC command | |
10 | ||
11 | When you invoke GNU CC, it normally does preprocessing, compilation, | |
12 | assembly and linking. The ``overall options'' allow you to stop this | |
13 | process at an intermediate stage. For example, the @samp{-c} option | |
14 | says not to run the linker. Then the output consists of object files | |
15 | output by the assembler. | |
16 | ||
17 | Other options are passed on to one stage of processing. Some options | |
18 | control the preprocessor and others the compiler itself. Yet other | |
19 | options control the assembler and linker; most of these are not | |
20 | documented here, since you rarely need to use any of them. | |
21 | ||
22 | @cindex C compilation options | |
23 | Most of the command line options that you can use with GNU CC are useful | |
24 | for C programs; when an option is only useful with another language | |
25 | (usually C++), the explanation says so explicitly. If the description | |
26 | for a particular option does not mention a source language, you can use | |
27 | that option with all supported languages. | |
28 | ||
29 | @cindex C++ compilation options | |
30 | @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special | |
31 | options for compiling C++ programs. | |
32 | ||
33 | @cindex grouping options | |
34 | @cindex options, grouping | |
35 | The @code{gcc} program accepts options and file names as operands. Many | |
36 | options have multiletter names; therefore multiple single-letter options | |
37 | may @emph{not} be grouped: @samp{-dr} is very different from @w{@samp{-d | |
38 | -r}}. | |
39 | ||
40 | @cindex order of options | |
41 | @cindex options, order | |
42 | You can mix options and other arguments. For the most part, the order | |
43 | you use doesn't matter. Order does matter when you use several options | |
44 | of the same kind; for example, if you specify @samp{-L} more than once, | |
45 | the directories are searched in the order specified. | |
46 | ||
47 | Many options have long names starting with @samp{-f} or with | |
48 | @samp{-W}---for example, @samp{-fforce-mem}, | |
49 | @samp{-fstrength-reduce}, @samp{-Wformat} and so on. Most of | |
50 | these have both positive and negative forms; the negative form of | |
51 | @samp{-ffoo} would be @samp{-fno-foo}. This manual documents | |
52 | only one of these two forms, whichever one is not the default. | |
53 | ||
54 | @menu | |
55 | * Option Summary:: Brief list of all options, without explanations. | |
56 | * Overall Options:: Controlling the kind of output: | |
57 | an executable, object files, assembler files, | |
58 | or preprocessed source. | |
59 | * Invoking G++:: Compiling C++ programs. | |
60 | * C Dialect Options:: Controlling the variant of C language compiled. | |
61 | * C++ Dialect Options:: Variations on C++. | |
62 | * Warning Options:: How picky should the compiler be? | |
63 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
64 | * Optimize Options:: How much optimization? | |
65 | * Preprocessor Options:: Controlling header files and macro definitions. | |
66 | Also, getting dependency information for Make. | |
67 | * Assembler Options:: Passing options to the assembler. | |
68 | * Link Options:: Specifying libraries and so on. | |
69 | * Directory Options:: Where to find header files and libraries. | |
70 | Where to find the compiler executable files. | |
71 | * Target Options:: Running a cross-compiler, or an old version of GNU CC. | |
72 | * Submodel Options:: Specifying minor hardware or convention variations, | |
73 | such as 68010 vs 68020. | |
74 | * Code Gen Options:: Specifying conventions for function calls, data layout | |
75 | and register usage. | |
76 | * Environment Variables:: Env vars that affect GNU CC. | |
77 | * Running Protoize:: Automatically adding or removing function prototypes. | |
78 | @end menu | |
79 | ||
80 | @node Option Summary | |
81 | @section Option Summary | |
82 | ||
83 | Here is a summary of all the options, grouped by type. Explanations are | |
84 | in the following sections. | |
85 | ||
86 | @table @emph | |
87 | @item Overall Options | |
88 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
89 | @smallexample | |
90 | -c -S -E -o @var{file} -pipe -v -x @var{language} | |
91 | @end smallexample | |
92 | ||
93 | @item C Language Options | |
94 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
95 | @smallexample | |
861bb6c1 | 96 | -ansi -fallow-single-precision -fcond-mismatch -fno-asm |
8c81598d | 97 | -fno-builtin -ffreestanding -fhosted -fsigned-bitfields -fsigned-char |
74291a4b MM |
98 | -funsigned-bitfields -funsigned-char -fwritable-strings |
99 | -traditional -traditional-cpp -trigraphs | |
100 | @end smallexample | |
101 | ||
102 | @item C++ Language Options | |
103 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. | |
104 | @smallexample | |
105 | -fall-virtual -fdollars-in-identifiers -felide-constructors | |
8c81598d JM |
106 | -fenum-int-equiv -fexternal-templates -ffor-scope -fno-for-scope |
107 | -fhandle-signatures -fmemoize-lookups -fname-mangling-version-@var{n} | |
108 | -fno-default-inline -fno-gnu-keywords -fnonnull-objects -fguiding-decls | |
109 | -foperator-names -fstrict-prototype -fthis-is-variable | |
110 | -ftemplate-depth-@var{n} -nostdinc++ -traditional +e@var{n} | |
74291a4b MM |
111 | @end smallexample |
112 | ||
113 | @item Warning Options | |
114 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
115 | @smallexample | |
116 | -fsyntax-only -pedantic -pedantic-errors | |
117 | -w -W -Wall -Waggregate-return -Wbad-function-cast | |
8c81598d | 118 | -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment |
74291a4b MM |
119 | -Wconversion -Werror -Wformat |
120 | -Wid-clash-@var{len} -Wimplicit -Wimport -Winline | |
861bb6c1 | 121 | -Wlarger-than-@var{len} -Wmain -Wmissing-declarations |
74291a4b MM |
122 | -Wmissing-prototypes -Wnested-externs |
123 | -Wno-import -Woverloaded-virtual -Wparentheses | |
8c81598d JM |
124 | -Wpointer-arith -Wredundant-decls -Wreorder -Wreturn-type -Wshadow |
125 | -Wsign-compare -Wstrict-prototypes -Wswitch -Wsynth | |
74291a4b | 126 | -Wtemplate-debugging -Wtraditional -Wtrigraphs |
8c81598d | 127 | -Wundef -Wuninitialized -Wunused -Wwrite-strings |
74291a4b MM |
128 | @end smallexample |
129 | ||
130 | @item Debugging Options | |
131 | @xref{Debugging Options,,Options for Debugging Your Program or GCC}. | |
132 | @smallexample | |
133 | -a -ax -d@var{letters} -fpretend-float | |
861bb6c1 | 134 | -fprofile-arcs -ftest-coverage |
8c81598d | 135 | -g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 |
74291a4b MM |
136 | -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ |
137 | -p -pg -print-file-name=@var{library} -print-libgcc-file-name | |
138 | -print-prog-name=@var{program} -print-search-dirs -save-temps | |
139 | @end smallexample | |
140 | ||
141 | @item Optimization Options | |
142 | @xref{Optimize Options,,Options that Control Optimization}. | |
143 | @smallexample | |
861bb6c1 | 144 | -fbranch-probabilities |
74291a4b MM |
145 | -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks |
146 | -fdelayed-branch -fexpensive-optimizations | |
147 | -ffast-math -ffloat-store -fforce-addr -fforce-mem | |
8c81598d JM |
148 | -ffunction-sections -finline-functions |
149 | -fkeep-inline-functions -fno-default-inline | |
74291a4b | 150 | -fno-defer-pop -fno-function-cse |
8c660648 | 151 | -fno-inline -fno-peephole -fomit-frame-pointer -fregmove |
74291a4b MM |
152 | -frerun-cse-after-loop -fschedule-insns |
153 | -fschedule-insns2 -fstrength-reduce -fthread-jumps | |
154 | -funroll-all-loops -funroll-loops | |
e5eb27e5 | 155 | -fmove-all-movables -freduce-all-givs |
74291a4b MM |
156 | -O -O0 -O1 -O2 -O3 |
157 | @end smallexample | |
158 | ||
159 | @item Preprocessor Options | |
160 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
161 | @smallexample | |
162 | -A@var{question}(@var{answer}) -C -dD -dM -dN | |
163 | -D@var{macro}@r{[}=@var{defn}@r{]} -E -H | |
164 | -idirafter @var{dir} | |
165 | -include @var{file} -imacros @var{file} | |
166 | -iprefix @var{file} -iwithprefix @var{dir} | |
167 | -iwithprefixbefore @var{dir} -isystem @var{dir} | |
168 | -M -MD -MM -MMD -MG -nostdinc -P -trigraphs | |
169 | -undef -U@var{macro} -Wp,@var{option} | |
170 | @end smallexample | |
171 | ||
172 | @item Assembler Option | |
173 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
174 | @smallexample | |
175 | -Wa,@var{option} | |
176 | @end smallexample | |
177 | ||
178 | @item Linker Options | |
179 | @xref{Link Options,,Options for Linking}. | |
180 | @smallexample | |
181 | @var{object-file-name} -l@var{library} | |
182 | -nostartfiles -nodefaultlibs -nostdlib | |
183 | -s -static -shared -symbolic | |
184 | -Wl,@var{option} -Xlinker @var{option} | |
185 | -u @var{symbol} | |
186 | @end smallexample | |
187 | ||
188 | @item Directory Options | |
189 | @xref{Directory Options,,Options for Directory Search}. | |
190 | @smallexample | |
8c81598d | 191 | -B@var{prefix} -I@var{dir} -I- -L@var{dir} -specs=@var{file} |
74291a4b MM |
192 | @end smallexample |
193 | ||
194 | @item Target Options | |
195 | @c I wrote this xref this way to avoid overfull hbox. -- rms | |
196 | @xref{Target Options}. | |
197 | @smallexample | |
198 | -b @var{machine} -V @var{version} | |
199 | @end smallexample | |
200 | ||
201 | @item Machine Dependent Options | |
202 | @xref{Submodel Options,,Hardware Models and Configurations}. | |
203 | @smallexample | |
204 | @emph{M680x0 Options} | |
8c81598d JM |
205 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 |
206 | -m68060 -m5200 -m68881 -mbitfield -mc68000 -mc68020 -mfpa | |
861bb6c1 | 207 | -mnobitfield -mrtd -mshort -msoft-float -malign-int |
74291a4b MM |
208 | |
209 | @emph{VAX Options} | |
210 | -mg -mgnu -munix | |
211 | ||
212 | @emph{SPARC Options} | |
213 | -mcpu=@var{cpu type} | |
214 | -mtune=@var{cpu type} | |
6d4312dd DE |
215 | -malign-jumps=@var{num} -malign-loops=@var{num} |
216 | -malign-functions=@var{num} | |
74291a4b MM |
217 | -mapp-regs -mbroken-saverestore -mcypress -mepilogue |
218 | -mflat -mfpu -mfullany -mhard-float -mhard-quad-float | |
219 | -mimpure-text -mint32 -mint64 -mlive-g0 | |
220 | -mlong32 -mlong64 -mmedlow -mmedany | |
221 | -mno-app-regs -mno-epilogue | |
222 | -mno-flat -mno-fpu -mno-impure-text | |
223 | -mno-stack-bias -mno-unaligned-doubles | |
224 | -msoft-float -msoft-quad-float -msparclite -mstack-bias | |
225 | -msupersparc -munaligned-doubles -mv8 | |
226 | ||
227 | @emph{Convex Options} | |
228 | -mc1 -mc2 -mc32 -mc34 -mc38 | |
229 | -margcount -mnoargcount | |
230 | -mlong32 -mlong64 | |
231 | -mvolatile-cache -mvolatile-nocache | |
232 | ||
233 | @emph{AMD29K Options} | |
234 | -m29000 -m29050 -mbw -mnbw -mdw -mndw | |
235 | -mlarge -mnormal -msmall | |
236 | -mkernel-registers -mno-reuse-arg-regs | |
237 | -mno-stack-check -mno-storem-bug | |
238 | -mreuse-arg-regs -msoft-float -mstack-check | |
239 | -mstorem-bug -muser-registers | |
240 | ||
241 | @emph{ARM Options} | |
8c81598d JM |
242 | -mapcs-frame -mapcs-26 -mapcs-32 |
243 | -mlittle-endian -mbig-endian -mwords-little-endian | |
244 | -mshort-load-bytes -mno-short-load-bytes | |
245 | -msoft-float -mhard-float | |
246 | -mbsd -mxopen -mno-symrename | |
74291a4b | 247 | |
861bb6c1 JL |
248 | @emph{M32R/D Options} |
249 | -mcode-model=@var{model type} -msdata=@var{sdata type} | |
250 | -G @var{num} | |
251 | ||
74291a4b MM |
252 | @emph{M88K Options} |
253 | -m88000 -m88100 -m88110 -mbig-pic | |
254 | -mcheck-zero-division -mhandle-large-shift | |
255 | -midentify-revision -mno-check-zero-division | |
256 | -mno-ocs-debug-info -mno-ocs-frame-position | |
257 | -mno-optimize-arg-area -mno-serialize-volatile | |
258 | -mno-underscores -mocs-debug-info | |
259 | -mocs-frame-position -moptimize-arg-area | |
260 | -mserialize-volatile -mshort-data-@var{num} -msvr3 | |
261 | -msvr4 -mtrap-large-shift -muse-div-instruction | |
262 | -mversion-03.00 -mwarn-passed-structs | |
263 | ||
264 | @emph{RS/6000 and PowerPC Options} | |
8c81598d JM |
265 | -mcpu=@var{cpu type} |
266 | -mtune=@var{cpu type} | |
74291a4b MM |
267 | -mpower -mno-power -mpower2 -mno-power2 |
268 | -mpowerpc -mno-powerpc | |
269 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
270 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
271 | -mnew-mnemonics -mno-new-mnemonics | |
272 | -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc | |
861bb6c1 | 273 | -mxl-call -mno-xl-call -mthreads -mpe |
74291a4b | 274 | -msoft-float -mhard-float -mmultiple -mno-multiple |
861bb6c1 JL |
275 | -mstring -mno-string -mupdate -mno-update |
276 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
74291a4b MM |
277 | -mstrict-align -mno-strict-align -mrelocatable |
278 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
279 | -mtoc -mno-toc -mtraceback -mno-traceback | |
280 | -mlittle -mlittle-endian -mbig -mbig-endian | |
281 | -mcall-aix -mcall-sysv -mprototype -mno-prototype | |
282 | -msim -mmvme -memb -msdata -msdata=@var{opt} -G @var{num} | |
283 | ||
284 | @emph{RT Options} | |
285 | -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs | |
286 | -mfull-fp-blocks -mhc-struct-return -min-line-mul | |
287 | -mminimum-fp-blocks -mnohc-struct-return | |
288 | ||
289 | @emph{MIPS Options} | |
8c81598d | 290 | -mabicalls -mcpu=@var{cpu type} -membedded-data |
74291a4b | 291 | -membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64 |
8c81598d JM |
292 | -mgpopt -mhalf-pic -mhard-float -mint64 -mips1 |
293 | -mips2 -mips3 -mlong64 -mlong-calls -mmemcpy | |
74291a4b MM |
294 | -mmips-as -mmips-tfile -mno-abicalls |
295 | -mno-embedded-data -mno-embedded-pic | |
296 | -mno-gpopt -mno-long-calls | |
297 | -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats | |
8c81598d JM |
298 | -mrnames -msoft-float |
299 | -m4650 -msingle-float -mmad | |
74291a4b MM |
300 | -mstats -EL -EB -G @var{num} -nocpp |
301 | ||
302 | @emph{i386 Options} | |
8c81598d | 303 | -m486 -m386 -mieee-fp -mno-fancy-math-387 |
74291a4b | 304 | -mno-fp-ret-in-387 -msoft-float -msvr3-shlib |
8c81598d JM |
305 | -mno-wide-multiply -mrtd -malign-double |
306 | -mreg-alloc=@var{list} -mregparm=@var{num} | |
307 | -malign-jumps=@var{num} -malign-loops=@var{num} | |
74291a4b MM |
308 | -malign-functions=@var{num} |
309 | ||
310 | @emph{HPPA Options} | |
8c81598d JM |
311 | -mbig-switch -mdisable-fpregs -mdisable-indexing -mfast-indirect-calls |
312 | -mgas -mjump-in-delay -mlong-load-store -mno-big-switch -mno-disable-fpregs | |
313 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
74291a4b MM |
314 | -mno-jump-in-delay |
315 | -mno-long-load-store | |
316 | -mno-portable-runtime -mno-soft-float -mno-space -mno-space-regs -msoft-float | |
317 | -mpa-risc-1-0 -mpa-risc-1-1 -mportable-runtime | |
8c81598d | 318 | -mschedule=@var{list} -mspace -mspace-regs |
74291a4b MM |
319 | |
320 | @emph{Intel 960 Options} | |
321 | -m@var{cpu type} -masm-compat -mclean-linkage | |
322 | -mcode-align -mcomplex-addr -mleaf-procedures | |
323 | -mic-compat -mic2.0-compat -mic3.0-compat | |
324 | -mintel-asm -mno-clean-linkage -mno-code-align | |
325 | -mno-complex-addr -mno-leaf-procedures | |
326 | -mno-old-align -mno-strict-align -mno-tail-call | |
327 | -mnumerics -mold-align -msoft-float -mstrict-align | |
328 | -mtail-call | |
329 | ||
330 | @emph{DEC Alpha Options} | |
331 | -mfp-regs -mno-fp-regs | |
8c81598d JM |
332 | -mno-soft-float -msoft-float |
333 | -mieee -mieee-with-inexact -mieee-conformant | |
334 | -mfp-trap-mode -mfp-rounding-mode -mtrap-precision | |
74291a4b MM |
335 | -mbuild-constants |
336 | ||
337 | @emph{Clipper Options} | |
8c81598d | 338 | -mc300 -mc400 |
74291a4b MM |
339 | |
340 | @emph{H8/300 Options} | |
dcb9d1f0 | 341 | -mrelax -mh -ms -mint32 -malign-300 |
74291a4b MM |
342 | |
343 | @emph{SH Options} | |
344 | -m1 -m2 -m3 -m3e -mb -ml -mrelax | |
345 | ||
346 | @emph{System V Options} | |
347 | -Qy -Qn -YP,@var{paths} -Ym,@var{dir} | |
74291a4b | 348 | |
f84271d9 JL |
349 | @emph{V850 Options} |
350 | -mlong-calls -mno-long-calls -mep -mno-ep | |
351 | -mprolog-function -mno-prolog-function -mspace | |
352 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
48f0be1b | 353 | -mv850 |
f84271d9 JL |
354 | @end smallexample |
355 | ||
74291a4b MM |
356 | @item Code Generation Options |
357 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
358 | @smallexample | |
359 | -fcall-saved-@var{reg} -fcall-used-@var{reg} | |
360 | -ffixed-@var{reg} -finhibit-size-directive | |
861bb6c1 | 361 | -fcheck-memory-usage -fprefix-function-name |
74291a4b MM |
362 | -fno-common -fno-ident -fno-gnu-linker |
363 | -fpcc-struct-return -fpic -fPIC | |
364 | -freg-struct-return -fshared-data -fshort-enums | |
365 | -fshort-double -fvolatile -fvolatile-global | |
861bb6c1 | 366 | -fverbose-asm -fpack-struct -fstack-check +e0 +e1 |
e5eb27e5 JL |
367 | -fargument-alias -fargument-noalias |
368 | -fargument-noalias-global | |
74291a4b MM |
369 | @end smallexample |
370 | @end table | |
371 | ||
372 | @menu | |
373 | * Overall Options:: Controlling the kind of output: | |
374 | an executable, object files, assembler files, | |
375 | or preprocessed source. | |
376 | * C Dialect Options:: Controlling the variant of C language compiled. | |
377 | * C++ Dialect Options:: Variations on C++. | |
378 | * Warning Options:: How picky should the compiler be? | |
379 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
380 | * Optimize Options:: How much optimization? | |
381 | * Preprocessor Options:: Controlling header files and macro definitions. | |
382 | Also, getting dependency information for Make. | |
383 | * Assembler Options:: Passing options to the assembler. | |
384 | * Link Options:: Specifying libraries and so on. | |
385 | * Directory Options:: Where to find header files and libraries. | |
386 | Where to find the compiler executable files. | |
387 | * Target Options:: Running a cross-compiler, or an old version of GNU CC. | |
388 | @end menu | |
389 | ||
390 | @node Overall Options | |
391 | @section Options Controlling the Kind of Output | |
392 | ||
393 | Compilation can involve up to four stages: preprocessing, compilation | |
394 | proper, assembly and linking, always in that order. The first three | |
395 | stages apply to an individual source file, and end by producing an | |
396 | object file; linking combines all the object files (those newly | |
397 | compiled, and those specified as input) into an executable file. | |
398 | ||
399 | @cindex file name suffix | |
400 | For any given input file, the file name suffix determines what kind of | |
401 | compilation is done: | |
402 | ||
403 | @table @code | |
404 | @item @var{file}.c | |
405 | C source code which must be preprocessed. | |
406 | ||
407 | @item @var{file}.i | |
408 | C source code which should not be preprocessed. | |
409 | ||
410 | @item @var{file}.ii | |
411 | C++ source code which should not be preprocessed. | |
412 | ||
413 | @item @var{file}.m | |
414 | Objective-C source code. Note that you must link with the library | |
415 | @file{libobjc.a} to make an Objective-C program work. | |
416 | ||
417 | @item @var{file}.h | |
418 | C header file (not to be compiled or linked). | |
419 | ||
420 | @item @var{file}.cc | |
421 | @itemx @var{file}.cxx | |
422 | @itemx @var{file}.cpp | |
423 | @itemx @var{file}.C | |
424 | C++ source code which must be preprocessed. Note that in @samp{.cxx}, | |
425 | the last two letters must both be literally @samp{x}. Likewise, | |
426 | @samp{.C} refers to a literal capital C. | |
427 | ||
428 | @item @var{file}.s | |
429 | Assembler code. | |
430 | ||
431 | @item @var{file}.S | |
432 | Assembler code which must be preprocessed. | |
433 | ||
434 | @item @var{other} | |
435 | An object file to be fed straight into linking. | |
436 | Any file name with no recognized suffix is treated this way. | |
437 | @end table | |
438 | ||
439 | You can specify the input language explicitly with the @samp{-x} option: | |
440 | ||
441 | @table @code | |
442 | @item -x @var{language} | |
443 | Specify explicitly the @var{language} for the following input files | |
444 | (rather than letting the compiler choose a default based on the file | |
445 | name suffix). This option applies to all following input files until | |
446 | the next @samp{-x} option. Possible values for @var{language} are: | |
447 | @example | |
448 | c objective-c c++ | |
449 | c-header cpp-output c++-cpp-output | |
450 | assembler assembler-with-cpp | |
451 | @end example | |
452 | ||
453 | @item -x none | |
454 | Turn off any specification of a language, so that subsequent files are | |
455 | handled according to their file name suffixes (as they are if @samp{-x} | |
456 | has not been used at all). | |
457 | @end table | |
458 | ||
459 | If you only want some of the stages of compilation, you can use | |
460 | @samp{-x} (or filename suffixes) to tell @code{gcc} where to start, and | |
461 | one of the options @samp{-c}, @samp{-S}, or @samp{-E} to say where | |
462 | @code{gcc} is to stop. Note that some combinations (for example, | |
463 | @samp{-x cpp-output -E} instruct @code{gcc} to do nothing at all. | |
464 | ||
465 | @table @code | |
466 | @item -c | |
467 | Compile or assemble the source files, but do not link. The linking | |
468 | stage simply is not done. The ultimate output is in the form of an | |
469 | object file for each source file. | |
470 | ||
471 | By default, the object file name for a source file is made by replacing | |
472 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
473 | ||
474 | Unrecognized input files, not requiring compilation or assembly, are | |
475 | ignored. | |
476 | ||
477 | @item -S | |
478 | Stop after the stage of compilation proper; do not assemble. The output | |
479 | is in the form of an assembler code file for each non-assembler input | |
480 | file specified. | |
481 | ||
482 | By default, the assembler file name for a source file is made by | |
483 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
484 | ||
485 | Input files that don't require compilation are ignored. | |
486 | ||
487 | @item -E | |
488 | Stop after the preprocessing stage; do not run the compiler proper. The | |
489 | output is in the form of preprocessed source code, which is sent to the | |
490 | standard output. | |
491 | ||
492 | Input files which don't require preprocessing are ignored. | |
493 | ||
494 | @cindex output file option | |
495 | @item -o @var{file} | |
496 | Place output in file @var{file}. This applies regardless to whatever | |
497 | sort of output is being produced, whether it be an executable file, | |
498 | an object file, an assembler file or preprocessed C code. | |
499 | ||
500 | Since only one output file can be specified, it does not make sense to | |
501 | use @samp{-o} when compiling more than one input file, unless you are | |
502 | producing an executable file as output. | |
503 | ||
504 | If @samp{-o} is not specified, the default is to put an executable file | |
505 | in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in | |
506 | @file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and | |
507 | all preprocessed C source on standard output.@refill | |
508 | ||
509 | @item -v | |
510 | Print (on standard error output) the commands executed to run the stages | |
511 | of compilation. Also print the version number of the compiler driver | |
512 | program and of the preprocessor and the compiler proper. | |
513 | ||
514 | @item -pipe | |
515 | Use pipes rather than temporary files for communication between the | |
516 | various stages of compilation. This fails to work on some systems where | |
517 | the assembler is unable to read from a pipe; but the GNU assembler has | |
518 | no trouble. | |
519 | @end table | |
520 | ||
521 | @node Invoking G++ | |
522 | @section Compiling C++ Programs | |
523 | ||
524 | @cindex suffixes for C++ source | |
525 | @cindex C++ source file suffixes | |
526 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
527 | @samp{.cc}, @samp{cpp}, or @samp{.cxx}; preprocessed C++ files use the | |
528 | suffix @samp{.ii}. GNU CC recognizes files with these names and | |
529 | compiles them as C++ programs even if you call the compiler the same way | |
530 | as for compiling C programs (usually with the name @code{gcc}). | |
531 | ||
532 | @findex g++ | |
533 | @findex c++ | |
534 | However, C++ programs often require class libraries as well as a | |
535 | compiler that understands the C++ language---and under some | |
536 | circumstances, you might want to compile programs from standard input, | |
537 | or otherwise without a suffix that flags them as C++ programs. | |
538 | @code{g++} is a program that calls GNU CC with the default language | |
539 | set to C++, and automatically specifies linking against the GNU class | |
540 | library libg++. | |
541 | @cindex @code{g++ 1.@var{xx}} | |
542 | @cindex @code{g++}, separate compiler | |
543 | @cindex @code{g++} older version | |
544 | @footnote{Prior to release 2 of the compiler, | |
545 | there was a separate @code{g++} compiler. That version was based on GNU | |
546 | CC, but not integrated with it. Versions of @code{g++} with a | |
547 | @samp{1.@var{xx}} version number---for example, @code{g++} version 1.37 | |
548 | or 1.42---are much less reliable than the versions integrated with GCC | |
549 | 2. Moreover, combining G++ @samp{1.@var{xx}} with a version 2 GCC will | |
550 | simply not work.} On many systems, the script @code{g++} is also | |
551 | installed with the name @code{c++}. | |
552 | ||
553 | @cindex invoking @code{g++} | |
554 | When you compile C++ programs, you may specify many of the same | |
555 | command-line options that you use for compiling programs in any | |
556 | language; or command-line options meaningful for C and related | |
557 | languages; or options that are meaningful only for C++ programs. | |
558 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
559 | explanations of options for languages related to C. | |
560 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
561 | explanations of options that are meaningful only for C++ programs. | |
562 | ||
563 | @node C Dialect Options | |
564 | @section Options Controlling C Dialect | |
565 | @cindex dialect options | |
566 | @cindex language dialect options | |
567 | @cindex options, dialect | |
568 | ||
569 | The following options control the dialect of C (or languages derived | |
570 | from C, such as C++ and Objective C) that the compiler accepts: | |
571 | ||
572 | @table @code | |
573 | @cindex ANSI support | |
574 | @item -ansi | |
575 | Support all ANSI standard C programs. | |
576 | ||
577 | This turns off certain features of GNU C that are incompatible with ANSI | |
578 | C, such as the @code{asm}, @code{inline} and @code{typeof} keywords, and | |
579 | predefined macros such as @code{unix} and @code{vax} that identify the | |
580 | type of system you are using. It also enables the undesirable and | |
861bb6c1 JL |
581 | rarely used ANSI trigraph feature, and it disables recognition of C++ |
582 | style @samp{//} comments. | |
74291a4b MM |
583 | |
584 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
585 | @code{__inline__} and @code{__typeof__} continue to work despite | |
586 | @samp{-ansi}. You would not want to use them in an ANSI C program, of | |
587 | course, but it is useful to put them in header files that might be included | |
588 | in compilations done with @samp{-ansi}. Alternate predefined macros | |
589 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
590 | without @samp{-ansi}. | |
591 | ||
592 | The @samp{-ansi} option does not cause non-ANSI programs to be | |
593 | rejected gratuitously. For that, @samp{-pedantic} is required in | |
594 | addition to @samp{-ansi}. @xref{Warning Options}. | |
595 | ||
596 | The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi} | |
597 | option is used. Some header files may notice this macro and refrain | |
598 | from declaring certain functions or defining certain macros that the | |
599 | ANSI standard doesn't call for; this is to avoid interfering with any | |
600 | programs that might use these names for other things. | |
601 | ||
602 | The functions @code{alloca}, @code{abort}, @code{exit}, and | |
603 | @code{_exit} are not builtin functions when @samp{-ansi} is used. | |
604 | ||
605 | @item -fno-asm | |
606 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a | |
607 | keyword, so that code can use these words as identifiers. You can use | |
608 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
609 | instead. @samp{-ansi} implies @samp{-fno-asm}. | |
610 | ||
611 | In C++, this switch only affects the @code{typeof} keyword, since | |
612 | @code{asm} and @code{inline} are standard keywords. You may want to | |
613 | use the @samp{-fno-gnu-keywords} flag instead, as it also disables the | |
614 | other, C++-specific, extension keywords such as @code{headof}. | |
615 | ||
616 | @item -fno-builtin | |
617 | @cindex builtin functions | |
618 | @findex abort | |
619 | @findex abs | |
620 | @findex alloca | |
621 | @findex cos | |
622 | @findex exit | |
623 | @findex fabs | |
624 | @findex ffs | |
625 | @findex labs | |
626 | @findex memcmp | |
627 | @findex memcpy | |
628 | @findex sin | |
629 | @findex sqrt | |
630 | @findex strcmp | |
631 | @findex strcpy | |
632 | @findex strlen | |
633 | Don't recognize builtin functions that do not begin with two leading | |
634 | underscores. Currently, the functions affected include @code{abort}, | |
635 | @code{abs}, @code{alloca}, @code{cos}, @code{exit}, @code{fabs}, | |
636 | @code{ffs}, @code{labs}, @code{memcmp}, @code{memcpy}, @code{sin}, | |
637 | @code{sqrt}, @code{strcmp}, @code{strcpy}, and @code{strlen}. | |
638 | ||
639 | GCC normally generates special code to handle certain builtin functions | |
640 | more efficiently; for instance, calls to @code{alloca} may become single | |
641 | instructions that adjust the stack directly, and calls to @code{memcpy} | |
642 | may become inline copy loops. The resulting code is often both smaller | |
643 | and faster, but since the function calls no longer appear as such, you | |
644 | cannot set a breakpoint on those calls, nor can you change the behavior | |
645 | of the functions by linking with a different library. | |
646 | ||
647 | The @samp{-ansi} option prevents @code{alloca} and @code{ffs} from being | |
648 | builtin functions, since these functions do not have an ANSI standard | |
649 | meaning. | |
650 | ||
861bb6c1 JL |
651 | @item -fhosted |
652 | @cindex hosted environment | |
653 | ||
654 | Assert that compilation takes place in a hosted environment. This implies | |
655 | @samp{-fbuiltin}. A hosted environment is one in which the | |
656 | entire standard library is available, and in which @code{main} has a return | |
657 | type of @code{int}. Examples are nearly everything except a kernel. | |
658 | This is equivalent to @samp{-fno-freestanding}. | |
659 | ||
660 | @item -ffreestanding | |
661 | @cindex hosted environment | |
662 | ||
663 | Assert that compilation takes place in a freestanding environment. This | |
664 | implies @samp{-fno-builtin}. A freestanding environment | |
665 | is one in which the standard library may not exist, and program startup may | |
666 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
667 | This is equivalent to @samp{-fno-hosted}. | |
668 | ||
74291a4b MM |
669 | @item -trigraphs |
670 | Support ANSI C trigraphs. You don't want to know about this | |
671 | brain-damage. The @samp{-ansi} option implies @samp{-trigraphs}. | |
672 | ||
673 | @cindex traditional C language | |
674 | @cindex C language, traditional | |
675 | @item -traditional | |
676 | Attempt to support some aspects of traditional C compilers. | |
677 | Specifically: | |
678 | ||
679 | @itemize @bullet | |
680 | @item | |
681 | All @code{extern} declarations take effect globally even if they | |
682 | are written inside of a function definition. This includes implicit | |
683 | declarations of functions. | |
684 | ||
685 | @item | |
686 | The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const} | |
687 | and @code{volatile} are not recognized. (You can still use the | |
688 | alternative keywords such as @code{__typeof__}, @code{__inline__}, and | |
689 | so on.) | |
690 | ||
691 | @item | |
692 | Comparisons between pointers and integers are always allowed. | |
693 | ||
694 | @item | |
695 | Integer types @code{unsigned short} and @code{unsigned char} promote | |
696 | to @code{unsigned int}. | |
697 | ||
698 | @item | |
699 | Out-of-range floating point literals are not an error. | |
700 | ||
701 | @item | |
702 | Certain constructs which ANSI regards as a single invalid preprocessing | |
703 | number, such as @samp{0xe-0xd}, are treated as expressions instead. | |
704 | ||
705 | @item | |
706 | String ``constants'' are not necessarily constant; they are stored in | |
707 | writable space, and identical looking constants are allocated | |
708 | separately. (This is the same as the effect of | |
709 | @samp{-fwritable-strings}.) | |
710 | ||
711 | @cindex @code{longjmp} and automatic variables | |
712 | @item | |
713 | All automatic variables not declared @code{register} are preserved by | |
714 | @code{longjmp}. Ordinarily, GNU C follows ANSI C: automatic variables | |
715 | not declared @code{volatile} may be clobbered. | |
716 | ||
717 | @item | |
718 | @kindex \x | |
719 | @kindex \a | |
720 | @cindex escape sequences, traditional | |
721 | The character escape sequences @samp{\x} and @samp{\a} evaluate as the | |
722 | literal characters @samp{x} and @samp{a} respectively. Without | |
723 | @w{@samp{-traditional}}, @samp{\x} is a prefix for the hexadecimal | |
724 | representation of a character, and @samp{\a} produces a bell. | |
725 | ||
726 | @item | |
727 | In C++ programs, assignment to @code{this} is permitted with | |
728 | @samp{-traditional}. (The option @samp{-fthis-is-variable} also has | |
729 | this effect.) | |
730 | @end itemize | |
731 | ||
732 | You may wish to use @samp{-fno-builtin} as well as @samp{-traditional} | |
733 | if your program uses names that are normally GNU C builtin functions for | |
734 | other purposes of its own. | |
735 | ||
736 | You cannot use @samp{-traditional} if you include any header files that | |
737 | rely on ANSI C features. Some vendors are starting to ship systems with | |
738 | ANSI C header files and you cannot use @samp{-traditional} on such | |
739 | systems to compile files that include any system headers. | |
740 | ||
741 | The @samp{-traditional} option also enables the @samp{-traditional-cpp} | |
742 | option, which is described next. | |
743 | ||
744 | @item -traditional-cpp | |
745 | Attempt to support some aspects of traditional C preprocessors. | |
746 | Specifically: | |
747 | ||
748 | @itemize @bullet | |
749 | @item | |
750 | Comments convert to nothing at all, rather than to a space. This allows | |
751 | traditional token concatenation. | |
752 | ||
753 | @item | |
754 | In a preprocessing directive, the @samp{#} symbol must appear as the first | |
755 | character of a line. | |
756 | ||
757 | @item | |
758 | Macro arguments are recognized within string constants in a macro | |
759 | definition (and their values are stringified, though without additional | |
760 | quote marks, when they appear in such a context). The preprocessor | |
761 | always considers a string constant to end at a newline. | |
762 | ||
763 | @item | |
764 | @cindex detecting @w{@samp{-traditional}} | |
765 | The predefined macro @code{__STDC__} is not defined when you use | |
766 | @samp{-traditional}, but @code{__GNUC__} is (since the GNU extensions | |
767 | which @code{__GNUC__} indicates are not affected by | |
768 | @samp{-traditional}). If you need to write header files that work | |
769 | differently depending on whether @samp{-traditional} is in use, by | |
770 | testing both of these predefined macros you can distinguish four | |
771 | situations: GNU C, traditional GNU C, other ANSI C compilers, and other | |
772 | old C compilers. The predefined macro @code{__STDC_VERSION__} is also | |
773 | not defined when you use @samp{-traditional}. @xref{Standard | |
774 | Predefined,,Standard Predefined Macros,cpp.info,The C Preprocessor}, | |
775 | for more discussion of these and other predefined macros. | |
776 | ||
777 | @item | |
778 | @cindex string constants vs newline | |
779 | @cindex newline vs string constants | |
780 | The preprocessor considers a string constant to end at a newline (unless | |
781 | the newline is escaped with @samp{\}). (Without @w{@samp{-traditional}}, | |
782 | string constants can contain the newline character as typed.) | |
783 | @end itemize | |
784 | ||
785 | @item -fcond-mismatch | |
786 | Allow conditional expressions with mismatched types in the second and | |
787 | third arguments. The value of such an expression is void. | |
788 | ||
789 | @item -funsigned-char | |
790 | Let the type @code{char} be unsigned, like @code{unsigned char}. | |
791 | ||
792 | Each kind of machine has a default for what @code{char} should | |
793 | be. It is either like @code{unsigned char} by default or like | |
794 | @code{signed char} by default. | |
795 | ||
796 | Ideally, a portable program should always use @code{signed char} or | |
797 | @code{unsigned char} when it depends on the signedness of an object. | |
798 | But many programs have been written to use plain @code{char} and | |
799 | expect it to be signed, or expect it to be unsigned, depending on the | |
800 | machines they were written for. This option, and its inverse, let you | |
801 | make such a program work with the opposite default. | |
802 | ||
803 | The type @code{char} is always a distinct type from each of | |
804 | @code{signed char} or @code{unsigned char}, even though its behavior | |
805 | is always just like one of those two. | |
806 | ||
807 | @item -fsigned-char | |
808 | Let the type @code{char} be signed, like @code{signed char}. | |
809 | ||
810 | Note that this is equivalent to @samp{-fno-unsigned-char}, which is | |
811 | the negative form of @samp{-funsigned-char}. Likewise, the option | |
812 | @samp{-fno-signed-char} is equivalent to @samp{-funsigned-char}. | |
813 | ||
814 | You may wish to use @samp{-fno-builtin} as well as @samp{-traditional} | |
815 | if your program uses names that are normally GNU C builtin functions for | |
816 | other purposes of its own. | |
817 | ||
818 | You cannot use @samp{-traditional} if you include any header files that | |
819 | rely on ANSI C features. Some vendors are starting to ship systems with | |
820 | ANSI C header files and you cannot use @samp{-traditional} on such | |
821 | systems to compile files that include any system headers. | |
822 | ||
823 | @item -fsigned-bitfields | |
824 | @itemx -funsigned-bitfields | |
825 | @itemx -fno-signed-bitfields | |
826 | @itemx -fno-unsigned-bitfields | |
827 | These options control whether a bitfield is signed or unsigned, when the | |
828 | declaration does not use either @code{signed} or @code{unsigned}. By | |
829 | default, such a bitfield is signed, because this is consistent: the | |
830 | basic integer types such as @code{int} are signed types. | |
831 | ||
832 | However, when @samp{-traditional} is used, bitfields are all unsigned | |
833 | no matter what. | |
834 | ||
835 | @item -fwritable-strings | |
836 | Store string constants in the writable data segment and don't uniquize | |
837 | them. This is for compatibility with old programs which assume they can | |
838 | write into string constants. The option @samp{-traditional} also has | |
839 | this effect. | |
840 | ||
841 | Writing into string constants is a very bad idea; ``constants'' should | |
842 | be constant. | |
843 | ||
844 | @item -fallow-single-precision | |
845 | Do not promote single precision math operations to double precision, | |
846 | even when compiling with @samp{-traditional}. | |
847 | ||
848 | Traditional K&R C promotes all floating point operations to double | |
849 | precision, regardless of the sizes of the operands. On the | |
850 | architecture for which you are compiling, single precision may be faster | |
851 | than double precision. If you must use @samp{-traditional}, but want | |
852 | to use single precision operations when the operands are single | |
853 | precision, use this option. This option has no effect when compiling | |
854 | with ANSI or GNU C conventions (the default). | |
855 | ||
856 | @end table | |
857 | ||
858 | @node C++ Dialect Options | |
859 | @section Options Controlling C++ Dialect | |
860 | ||
861 | @cindex compiler options, C++ | |
862 | @cindex C++ options, command line | |
863 | @cindex options, C++ | |
864 | This section describes the command-line options that are only meaningful | |
865 | for C++ programs; but you can also use most of the GNU compiler options | |
866 | regardless of what language your program is in. For example, you | |
867 | might compile a file @code{firstClass.C} like this: | |
868 | ||
869 | @example | |
870 | g++ -g -felide-constructors -O -c firstClass.C | |
871 | @end example | |
872 | ||
873 | @noindent | |
874 | In this example, only @samp{-felide-constructors} is an option meant | |
875 | only for C++ programs; you can use the other options with any | |
876 | language supported by GNU CC. | |
877 | ||
878 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
879 | ||
880 | @table @code | |
881 | @item -fno-access-control | |
882 | Turn off all access checking. This switch is mainly useful for working | |
883 | around bugs in the access control code. | |
884 | ||
885 | @item -fall-virtual | |
886 | Treat all possible member functions as virtual, implicitly. | |
887 | All member functions (except for constructor functions and @code{new} or | |
888 | @code{delete} member operators) are treated as virtual functions of the | |
889 | class where they appear. | |
890 | ||
891 | This does not mean that all calls to these member functions will be made | |
892 | through the internal table of virtual functions. Under some | |
893 | circumstances, the compiler can determine that a call to a given virtual | |
894 | function can be made directly; in these cases the calls are direct in | |
895 | any case. | |
896 | ||
897 | @item -fcheck-new | |
898 | Check that the pointer returned by @code{operator new} is non-null | |
899 | before attempting to modify the storage allocated. The current Working | |
900 | Paper requires that @code{operator new} never return a null pointer, so | |
901 | this check is normally unnecessary. | |
902 | ||
903 | @item -fconserve-space | |
904 | Put uninitialized or runtime-initialized global variables into the | |
905 | common segment, as C does. This saves space in the executable at the | |
906 | cost of not diagnosing duplicate definitions. If you compile with this | |
907 | flag and your program mysteriously crashes after @code{main()} has | |
908 | completed, you may have an object that is being destroyed twice because | |
909 | two definitions were merged. | |
910 | ||
911 | @item -fdollars-in-identifiers | |
912 | Accept @samp{$} in identifiers. You can also explicitly prohibit use of | |
eb795509 RK |
913 | @samp{$} with the option @samp{-fno-dollars-in-identifiers}. (GNU C allows |
914 | @samp{$} by default on most target systems, but there are a few exceptions.) | |
74291a4b MM |
915 | Traditional C allowed the character @samp{$} to form part of |
916 | identifiers. However, ANSI C and C++ forbid @samp{$} in identifiers. | |
917 | ||
918 | @item -fenum-int-equiv | |
919 | Anachronistically permit implicit conversion of @code{int} to | |
920 | enumeration types. Current C++ allows conversion of @code{enum} to | |
921 | @code{int}, but not the other way around. | |
922 | ||
923 | @item -fexternal-templates | |
924 | Cause template instantiations to obey @samp{#pragma interface} and | |
925 | @samp{implementation}; template instances are emitted or not according | |
926 | to the location of the template definition. @xref{Template | |
927 | Instantiation}, for more information. | |
928 | ||
37f6b6bf MM |
929 | This option is deprecated. |
930 | ||
74291a4b MM |
931 | @item -falt-external-templates |
932 | Similar to -fexternal-templates, but template instances are emitted or | |
933 | not according to the place where they are first instantiated. | |
934 | @xref{Template Instantiation}, for more information. | |
935 | ||
37f6b6bf MM |
936 | This option is deprecated. |
937 | ||
74291a4b | 938 | @item -ffor-scope |
8c81598d | 939 | @itemx -fno-for-scope |
74291a4b MM |
940 | If -ffor-scope is specified, the scope of variables declared in |
941 | a @i{for-init-statement} is limited to the @samp{for} loop itself, | |
942 | as specified by the draft C++ standard. | |
943 | If -fno-for-scope is specified, the scope of variables declared in | |
944 | a @i{for-init-statement} extends to the end of the enclosing scope, | |
945 | as was the case in old versions of gcc, and other (traditional) | |
946 | implementations of C++. | |
947 | ||
948 | The default if neither flag is given to follow the standard, | |
949 | but to allow and give a warning for old-style code that would | |
950 | otherwise be invalid, or have different behavior. | |
951 | ||
952 | @item -fno-gnu-keywords | |
953 | Do not recognize @code{classof}, @code{headof}, @code{signature}, | |
954 | @code{sigof} or @code{typeof} as a keyword, so that code can use these | |
955 | words as identifiers. You can use the keywords @code{__classof__}, | |
956 | @code{__headof__}, @code{__signature__}, @code{__sigof__}, and | |
957 | @code{__typeof__} instead. @samp{-ansi} implies | |
958 | @samp{-fno-gnu-keywords}. | |
959 | ||
37f6b6bf MM |
960 | @item -fguiding-decls |
961 | Treat a function declaration with the same type as a potential function | |
962 | template instantiation as though it declares that instantiation, not a | |
963 | normal function. If a definition is given for the function later in the | |
964 | translation unit (or another translation unit if the target supports | |
965 | weak symbols), that definition will be used; otherwise the template will | |
966 | be instantiated. This behavior reflects the C++ language prior to | |
967 | September 1996, when guiding declarations were removed. | |
968 | ||
969 | This option implies @samp{-fname-mangling-version-0}, and will not work | |
970 | with other name mangling versions. | |
971 | ||
74291a4b MM |
972 | @item -fno-implicit-templates |
973 | Never emit code for templates which are instantiated implicitly (i.e. by | |
974 | use); only emit code for explicit instantiations. @xref{Template | |
975 | Instantiation}, for more information. | |
976 | ||
977 | @item -fhandle-signatures | |
978 | Recognize the @code{signature} and @code{sigof} keywords for specifying | |
979 | abstract types. The default (@samp{-fno-handle-signatures}) is not to | |
980 | recognize them. @xref{C++ Signatures, Type Abstraction using | |
981 | Signatures}. | |
982 | ||
983 | @item -fhuge-objects | |
984 | Support virtual function calls for objects that exceed the size | |
985 | representable by a @samp{short int}. Users should not use this flag by | |
986 | default; if you need to use it, the compiler will tell you so. If you | |
987 | compile any of your code with this flag, you must compile @emph{all} of | |
988 | your code with this flag (including libg++, if you use it). | |
989 | ||
990 | This flag is not useful when compiling with -fvtable-thunks. | |
991 | ||
992 | @item -fno-implement-inlines | |
993 | To save space, do not emit out-of-line copies of inline functions | |
994 | controlled by @samp{#pragma implementation}. This will cause linker | |
995 | errors if these functions are not inlined everywhere they are called. | |
996 | ||
997 | @item -fmemoize-lookups | |
998 | @itemx -fsave-memoized | |
999 | Use heuristics to compile faster. These heuristics are not enabled by | |
1000 | default, since they are only effective for certain input files. Other | |
1001 | input files compile more slowly. | |
1002 | ||
1003 | The first time the compiler must build a call to a member function (or | |
1004 | reference to a data member), it must (1) determine whether the class | |
1005 | implements member functions of that name; (2) resolve which member | |
1006 | function to call (which involves figuring out what sorts of type | |
1007 | conversions need to be made); and (3) check the visibility of the member | |
1008 | function to the caller. All of this adds up to slower compilation. | |
1009 | Normally, the second time a call is made to that member function (or | |
1010 | reference to that data member), it must go through the same lengthy | |
1011 | process again. This means that code like this: | |
1012 | ||
1013 | @smallexample | |
1014 | cout << "This " << p << " has " << n << " legs.\n"; | |
1015 | @end smallexample | |
1016 | ||
1017 | @noindent | |
1018 | makes six passes through all three steps. By using a software cache, a | |
1019 | ``hit'' significantly reduces this cost. Unfortunately, using the cache | |
1020 | introduces another layer of mechanisms which must be implemented, and so | |
1021 | incurs its own overhead. @samp{-fmemoize-lookups} enables the software | |
1022 | cache. | |
1023 | ||
1024 | Because access privileges (visibility) to members and member functions | |
1025 | may differ from one function context to the next, G++ may need to flush | |
1026 | the cache. With the @samp{-fmemoize-lookups} flag, the cache is flushed | |
1027 | after every function that is compiled. The @samp{-fsave-memoized} flag | |
1028 | enables the same software cache, but when the compiler determines that | |
1029 | the context of the last function compiled would yield the same access | |
1030 | privileges of the next function to compile, it preserves the cache. | |
1031 | This is most helpful when defining many member functions for the same | |
1032 | class: with the exception of member functions which are friends of other | |
1033 | classes, each member function has exactly the same access privileges as | |
1034 | every other, and the cache need not be flushed. | |
1035 | ||
1036 | The code that implements these flags has rotted; you should probably | |
1037 | avoid using them. | |
1038 | ||
1039 | @item -fstrict-prototype | |
1040 | Within an @samp{extern "C"} linkage specification, treat a function | |
1041 | declaration with no arguments, such as @samp{int foo ();}, as declaring | |
1042 | the function to take no arguments. Normally, such a declaration means | |
1043 | that the function @code{foo} can take any combination of arguments, as | |
1044 | in C. @samp{-pedantic} implies @samp{-fstrict-prototype} unless | |
1045 | overridden with @samp{-fno-strict-prototype}. | |
1046 | ||
1047 | This flag no longer affects declarations with C++ linkage. | |
1048 | ||
37f6b6bf MM |
1049 | @item -fname-mangling-version-@var{n} |
1050 | Control the way in which names are mangled. Version 0 is compatible | |
1051 | with versions of g++ before 2.8. Version 1 is the default. Version 1 | |
1052 | will allow correct mangling of function templates. For example, | |
1053 | version 0 mangling does not mangle foo<int, double> and foo<int, char> | |
1054 | given this declaration: | |
1055 | ||
1056 | @example | |
1057 | template <class T, class U> void foo(T t); | |
1058 | @end example | |
1059 | ||
74291a4b MM |
1060 | @item -fno-nonnull-objects |
1061 | Don't assume that a reference is initialized to refer to a valid object. | |
1062 | Although the current C++ Working Paper prohibits null references, some | |
1063 | old code may rely on them, and you can use @samp{-fno-nonnull-objects} | |
1064 | to turn on checking. | |
1065 | ||
1066 | At the moment, the compiler only does this checking for conversions to | |
1067 | virtual base classes. | |
1068 | ||
1069 | @item -foperator-names | |
1070 | Recognize the operator name keywords @code{and}, @code{bitand}, | |
1071 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
1072 | synonyms for the symbols they refer to. @samp{-ansi} implies | |
1073 | @samp{-foperator-names}. | |
1074 | ||
8c81598d JM |
1075 | @item -frepo |
1076 | Enable automatic template instantiation. This option also implies | |
1077 | @samp{-fno-implicit-templates}. @xref{Template Instantiation}, for more | |
1078 | information. | |
1079 | ||
74291a4b MM |
1080 | @item -fthis-is-variable |
1081 | Permit assignment to @code{this}. The incorporation of user-defined | |
1082 | free store management into C++ has made assignment to @samp{this} an | |
1083 | anachronism. Therefore, by default it is invalid to assign to | |
1084 | @code{this} within a class member function; that is, GNU C++ treats | |
1085 | @samp{this} in a member function of class @code{X} as a non-lvalue of | |
1086 | type @samp{X *}. However, for backwards compatibility, you can make it | |
1087 | valid with @samp{-fthis-is-variable}. | |
1088 | ||
1089 | @item -fvtable-thunks | |
1090 | Use @samp{thunks} to implement the virtual function dispatch table | |
1091 | (@samp{vtable}). The traditional (cfront-style) approach to | |
1092 | implementing vtables was to store a pointer to the function and two | |
1093 | offsets for adjusting the @samp{this} pointer at the call site. Newer | |
1094 | implementations store a single pointer to a @samp{thunk} function which | |
1095 | does any necessary adjustment and then calls the target function. | |
1096 | ||
1097 | This option also enables a heuristic for controlling emission of | |
1098 | vtables; if a class has any non-inline virtual functions, the vtable | |
1099 | will be emitted in the translation unit containing the first one of | |
1100 | those. | |
1101 | ||
861bb6c1 JL |
1102 | @item -ftemplate-depth-@var{n} |
1103 | Set the maximum instantiation depth for template classes to @var{n}. | |
1104 | A limit on the template instantiation depth is needed to detect | |
1105 | endless recursions during template class instantiation. ANSI/ISO C++ | |
1106 | conforming programs must not rely on a maximum depth greater than 17. | |
1107 | ||
74291a4b MM |
1108 | @item -nostdinc++ |
1109 | Do not search for header files in the standard directories specific to | |
1110 | C++, but do still search the other standard directories. (This option | |
1111 | is used when building libg++.) | |
1112 | ||
1113 | @item -traditional | |
1114 | For C++ programs (in addition to the effects that apply to both C and | |
1115 | C++), this has the same effect as @samp{-fthis-is-variable}. | |
1116 | @xref{C Dialect Options,, Options Controlling C Dialect}. | |
1117 | @end table | |
1118 | ||
1119 | In addition, these optimization, warning, and code generation options | |
1120 | have meanings only for C++ programs: | |
1121 | ||
1122 | @table @code | |
1123 | @item -fno-default-inline | |
1124 | Do not assume @samp{inline} for functions defined inside a class scope. | |
1125 | @xref{Optimize Options,,Options That Control Optimization}. | |
1126 | ||
1127 | @item -Woverloaded-virtual | |
1128 | @itemx -Wtemplate-debugging | |
1129 | Warnings that apply only to C++ programs. @xref{Warning | |
1130 | Options,,Options to Request or Suppress Warnings}. | |
1131 | ||
861bb6c1 JL |
1132 | @item -Weffc++ |
1133 | Warn about violation of some style rules from Effective C++ by Scott Myers. | |
1134 | ||
74291a4b MM |
1135 | @item +e@var{n} |
1136 | Control how virtual function definitions are used, in a fashion | |
1137 | compatible with @code{cfront} 1.x. @xref{Code Gen Options,,Options for | |
1138 | Code Generation Conventions}. | |
1139 | @end table | |
1140 | ||
1141 | @node Warning Options | |
1142 | @section Options to Request or Suppress Warnings | |
1143 | @cindex options to control warnings | |
1144 | @cindex warning messages | |
1145 | @cindex messages, warning | |
1146 | @cindex suppressing warnings | |
1147 | ||
1148 | Warnings are diagnostic messages that report constructions which | |
1149 | are not inherently erroneous but which are risky or suggest there | |
1150 | may have been an error. | |
1151 | ||
1152 | You can request many specific warnings with options beginning @samp{-W}, | |
1153 | for example @samp{-Wimplicit} to request warnings on implicit | |
1154 | declarations. Each of these specific warning options also has a | |
1155 | negative form beginning @samp{-Wno-} to turn off warnings; | |
1156 | for example, @samp{-Wno-implicit}. This manual lists only one of the | |
1157 | two forms, whichever is not the default. | |
1158 | ||
1159 | These options control the amount and kinds of warnings produced by GNU | |
1160 | CC: | |
1161 | ||
1162 | @table @code | |
1163 | @cindex syntax checking | |
1164 | @item -fsyntax-only | |
1165 | Check the code for syntax errors, but don't do anything beyond that. | |
1166 | ||
1167 | @item -pedantic | |
1168 | Issue all the warnings demanded by strict ANSI standard C; reject | |
1169 | all programs that use forbidden extensions. | |
1170 | ||
1171 | Valid ANSI standard C programs should compile properly with or without | |
1172 | this option (though a rare few will require @samp{-ansi}). However, | |
1173 | without this option, certain GNU extensions and traditional C features | |
1174 | are supported as well. With this option, they are rejected. | |
1175 | ||
1176 | @samp{-pedantic} does not cause warning messages for use of the | |
1177 | alternate keywords whose names begin and end with @samp{__}. Pedantic | |
1178 | warnings are also disabled in the expression that follows | |
1179 | @code{__extension__}. However, only system header files should use | |
1180 | these escape routes; application programs should avoid them. | |
1181 | @xref{Alternate Keywords}. | |
1182 | ||
1183 | This option is not intended to be @i{useful}; it exists only to satisfy | |
1184 | pedants who would otherwise claim that GNU CC fails to support the ANSI | |
1185 | standard. | |
1186 | ||
1187 | Some users try to use @samp{-pedantic} to check programs for strict ANSI | |
1188 | C conformance. They soon find that it does not do quite what they want: | |
1189 | it finds some non-ANSI practices, but not all---only those for which | |
1190 | ANSI C @emph{requires} a diagnostic. | |
1191 | ||
1192 | A feature to report any failure to conform to ANSI C might be useful in | |
1193 | some instances, but would require considerable additional work and would | |
1194 | be quite different from @samp{-pedantic}. We recommend, rather, that | |
1195 | users take advantage of the extensions of GNU C and disregard the | |
1196 | limitations of other compilers. Aside from certain supercomputers and | |
1197 | obsolete small machines, there is less and less reason ever to use any | |
1198 | other C compiler other than for bootstrapping GNU CC. | |
1199 | ||
1200 | @item -pedantic-errors | |
1201 | Like @samp{-pedantic}, except that errors are produced rather than | |
1202 | warnings. | |
1203 | ||
1204 | @item -w | |
1205 | Inhibit all warning messages. | |
1206 | ||
1207 | @item -Wno-import | |
1208 | Inhibit warning messages about the use of @samp{#import}. | |
1209 | ||
1210 | @item -Wchar-subscripts | |
1211 | Warn if an array subscript has type @code{char}. This is a common cause | |
1212 | of error, as programmers often forget that this type is signed on some | |
1213 | machines. | |
1214 | ||
1215 | @item -Wcomment | |
1216 | Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*} | |
1217 | comment, or whenever a Backslash-Newline appears in a @samp{//} comment. | |
1218 | ||
1219 | @item -Wformat | |
1220 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that | |
1221 | the arguments supplied have types appropriate to the format string | |
1222 | specified. | |
1223 | ||
1224 | @item -Wimplicit | |
861bb6c1 JL |
1225 | Warn whenever a function or parameter is implicitly declared, |
1226 | or when a type implicitly defaults to @code{int}. | |
1227 | ||
1228 | @item -Wmain | |
1229 | Warn if the type of @samp{main} is suspicious. @samp{main} should be a | |
1230 | function with external linkage, returning int, taking either zero | |
1231 | arguments, two, or three arguments of appropriate types. | |
1232 | ||
74291a4b MM |
1233 | @item -Wparentheses |
1234 | Warn if parentheses are omitted in certain contexts, such | |
1235 | as when there is an assignment in a context where a truth value | |
1236 | is expected, or when operators are nested whose precedence people | |
1237 | often get confused about. | |
1238 | ||
1239 | @item -Wreturn-type | |
1240 | Warn whenever a function is defined with a return-type that defaults | |
1241 | to @code{int}. Also warn about any @code{return} statement with no | |
1242 | return-value in a function whose return-type is not @code{void}. | |
1243 | ||
1244 | @item -Wswitch | |
1245 | Warn whenever a @code{switch} statement has an index of enumeral type | |
1246 | and lacks a @code{case} for one or more of the named codes of that | |
1247 | enumeration. (The presence of a @code{default} label prevents this | |
1248 | warning.) @code{case} labels outside the enumeration range also | |
1249 | provoke warnings when this option is used. | |
1250 | ||
1251 | @item -Wtrigraphs | |
1252 | Warn if any trigraphs are encountered (assuming they are enabled). | |
1253 | ||
1254 | @item -Wunused | |
1255 | Warn whenever a variable is unused aside from its declaration, | |
1256 | whenever a function is declared static but never defined, whenever a | |
1257 | label is declared but not used, and whenever a statement computes a | |
1258 | result that is explicitly not used. | |
1259 | ||
1260 | To suppress this warning for an expression, simply cast it to void. For | |
1261 | unused variables and parameters, use the @samp{unused} attribute | |
1262 | (@pxref{Variable Attributes}). | |
1263 | ||
1264 | @item -Wuninitialized | |
1265 | An automatic variable is used without first being initialized. | |
1266 | ||
1267 | These warnings are possible only in optimizing compilation, | |
1268 | because they require data flow information that is computed only | |
1269 | when optimizing. If you don't specify @samp{-O}, you simply won't | |
1270 | get these warnings. | |
1271 | ||
1272 | These warnings occur only for variables that are candidates for | |
1273 | register allocation. Therefore, they do not occur for a variable that | |
1274 | is declared @code{volatile}, or whose address is taken, or whose size | |
1275 | is other than 1, 2, 4 or 8 bytes. Also, they do not occur for | |
1276 | structures, unions or arrays, even when they are in registers. | |
1277 | ||
1278 | Note that there may be no warning about a variable that is used only | |
1279 | to compute a value that itself is never used, because such | |
1280 | computations may be deleted by data flow analysis before the warnings | |
1281 | are printed. | |
1282 | ||
1283 | These warnings are made optional because GNU CC is not smart | |
1284 | enough to see all the reasons why the code might be correct | |
1285 | despite appearing to have an error. Here is one example of how | |
1286 | this can happen: | |
1287 | ||
1288 | @smallexample | |
1289 | @{ | |
1290 | int x; | |
1291 | switch (y) | |
1292 | @{ | |
1293 | case 1: x = 1; | |
1294 | break; | |
1295 | case 2: x = 4; | |
1296 | break; | |
1297 | case 3: x = 5; | |
1298 | @} | |
1299 | foo (x); | |
1300 | @} | |
1301 | @end smallexample | |
1302 | ||
1303 | @noindent | |
1304 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
1305 | always initialized, but GNU CC doesn't know this. Here is | |
1306 | another common case: | |
1307 | ||
1308 | @smallexample | |
1309 | @{ | |
1310 | int save_y; | |
1311 | if (change_y) save_y = y, y = new_y; | |
1312 | @dots{} | |
1313 | if (change_y) y = save_y; | |
1314 | @} | |
1315 | @end smallexample | |
1316 | ||
1317 | @noindent | |
1318 | This has no bug because @code{save_y} is used only if it is set. | |
1319 | ||
1320 | Some spurious warnings can be avoided if you declare all the functions | |
1321 | you use that never return as @code{noreturn}. @xref{Function | |
1322 | Attributes}. | |
1323 | ||
1324 | @item -Wreorder (C++ only) | |
1325 | @cindex reordering, warning | |
1326 | @cindex warning for reordering of member initializers | |
1327 | Warn when the order of member initializers given in the code does not | |
1328 | match the order in which they must be executed. For instance: | |
1329 | ||
1330 | @smallexample | |
1331 | struct A @{ | |
1332 | int i; | |
1333 | int j; | |
1334 | A(): j (0), i (1) @{ @} | |
1335 | @}; | |
1336 | @end smallexample | |
1337 | ||
1338 | Here the compiler will warn that the member initializers for @samp{i} | |
1339 | and @samp{j} will be rearranged to match the declaration order of the | |
1340 | members. | |
1341 | ||
1342 | @item -Wsign-compare | |
1343 | @cindex warning for comparison of signed and unsigned values | |
1344 | @cindex comparison of signed and unsigned values, warning | |
1345 | @cindex signed and unsigned values, comparison warning | |
1346 | Warn when a comparison between signed and unsigned values could produce | |
1347 | an incorrect result when the signed value is converted to unsigned. | |
1348 | ||
1349 | @item -Wtemplate-debugging | |
1350 | @cindex template debugging | |
1351 | When using templates in a C++ program, warn if debugging is not yet | |
1352 | fully available (C++ only). | |
1353 | ||
1354 | @item -Wall | |
1355 | All of the above @samp{-W} options combined. This enables all the | |
1356 | warnings about constructions that some users consider questionable, and | |
1357 | that are easy to avoid (or modify to prevent the warning), even in | |
1358 | conjunction with macros. | |
1359 | @end table | |
1360 | ||
1361 | The following @samp{-W@dots{}} options are not implied by @samp{-Wall}. | |
1362 | Some of them warn about constructions that users generally do not | |
1363 | consider questionable, but which occasionally you might wish to check | |
1364 | for; others warn about constructions that are necessary or hard to avoid | |
1365 | in some cases, and there is no simple way to modify the code to suppress | |
1366 | the warning. | |
1367 | ||
1368 | @table @code | |
1369 | @item -W | |
1370 | Print extra warning messages for these events: | |
1371 | ||
1372 | @itemize @bullet | |
1373 | @cindex @code{longjmp} warnings | |
1374 | @item | |
1375 | A nonvolatile automatic variable might be changed by a call to | |
1376 | @code{longjmp}. These warnings as well are possible only in | |
1377 | optimizing compilation. | |
1378 | ||
1379 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
1380 | where @code{longjmp} will be called; in fact, a signal handler could | |
1381 | call it at any point in the code. As a result, you may get a warning | |
1382 | even when there is in fact no problem because @code{longjmp} cannot | |
1383 | in fact be called at the place which would cause a problem. | |
1384 | ||
1385 | @item | |
1386 | A function can return either with or without a value. (Falling | |
1387 | off the end of the function body is considered returning without | |
1388 | a value.) For example, this function would evoke such a | |
1389 | warning: | |
1390 | ||
1391 | @smallexample | |
1392 | @group | |
1393 | foo (a) | |
1394 | @{ | |
1395 | if (a > 0) | |
1396 | return a; | |
1397 | @} | |
1398 | @end group | |
1399 | @end smallexample | |
1400 | ||
1401 | @item | |
1402 | An expression-statement or the left-hand side of a comma expression | |
1403 | contains no side effects. | |
1404 | To suppress the warning, cast the unused expression to void. | |
1405 | For example, an expression such as @samp{x[i,j]} will cause a warning, | |
1406 | but @samp{x[(void)i,j]} will not. | |
1407 | ||
1408 | @item | |
1409 | An unsigned value is compared against zero with @samp{<} or @samp{<=}. | |
1410 | ||
1411 | @item | |
1412 | A comparison like @samp{x<=y<=z} appears; this is equivalent to | |
1413 | @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from | |
1414 | that of ordinary mathematical notation. | |
1415 | ||
1416 | @item | |
1417 | Storage-class specifiers like @code{static} are not the first things in | |
1418 | a declaration. According to the C Standard, this usage is obsolescent. | |
1419 | ||
1420 | @item | |
1421 | If @samp{-Wall} or @samp{-Wunused} is also specified, warn about unused | |
1422 | arguments. | |
1423 | ||
1424 | @item | |
1425 | An aggregate has a partly bracketed initializer. | |
1426 | For example, the following code would evoke such a warning, | |
1427 | because braces are missing around the initializer for @code{x.h}: | |
1428 | ||
1429 | @smallexample | |
1430 | struct s @{ int f, g; @}; | |
1431 | struct t @{ struct s h; int i; @}; | |
1432 | struct t x = @{ 1, 2, 3 @}; | |
1433 | @end smallexample | |
1434 | @end itemize | |
1435 | ||
1436 | @item -Wtraditional | |
1437 | Warn about certain constructs that behave differently in traditional and | |
1438 | ANSI C. | |
1439 | ||
1440 | @itemize @bullet | |
1441 | @item | |
1442 | Macro arguments occurring within string constants in the macro body. | |
1443 | These would substitute the argument in traditional C, but are part of | |
1444 | the constant in ANSI C. | |
1445 | ||
1446 | @item | |
1447 | A function declared external in one block and then used after the end of | |
1448 | the block. | |
1449 | ||
1450 | @item | |
1451 | A @code{switch} statement has an operand of type @code{long}. | |
1452 | @end itemize | |
1453 | ||
861bb6c1 JL |
1454 | @item -Wundef |
1455 | Warn if an undefined identifier is evaluated in an @samp{#if} directive. | |
1456 | ||
74291a4b MM |
1457 | @item -Wshadow |
1458 | Warn whenever a local variable shadows another local variable. | |
1459 | ||
1460 | @item -Wid-clash-@var{len} | |
1461 | Warn whenever two distinct identifiers match in the first @var{len} | |
1462 | characters. This may help you prepare a program that will compile | |
1463 | with certain obsolete, brain-damaged compilers. | |
1464 | ||
1465 | @item -Wlarger-than-@var{len} | |
1466 | Warn whenever an object of larger than @var{len} bytes is defined. | |
1467 | ||
1468 | @item -Wpointer-arith | |
1469 | Warn about anything that depends on the ``size of'' a function type or | |
1470 | of @code{void}. GNU C assigns these types a size of 1, for | |
1471 | convenience in calculations with @code{void *} pointers and pointers | |
1472 | to functions. | |
1473 | ||
1474 | @item -Wbad-function-cast | |
1475 | Warn whenever a function call is cast to a non-matching type. | |
1476 | For example, warn if @code{int malloc()} is cast to @code{anything *}. | |
1477 | ||
1478 | @item -Wcast-qual | |
1479 | Warn whenever a pointer is cast so as to remove a type qualifier from | |
1480 | the target type. For example, warn if a @code{const char *} is cast | |
1481 | to an ordinary @code{char *}. | |
1482 | ||
1483 | @item -Wcast-align | |
1484 | Warn whenever a pointer is cast such that the required alignment of the | |
1485 | target is increased. For example, warn if a @code{char *} is cast to | |
1486 | an @code{int *} on machines where integers can only be accessed at | |
1487 | two- or four-byte boundaries. | |
1488 | ||
1489 | @item -Wwrite-strings | |
1490 | Give string constants the type @code{const char[@var{length}]} so that | |
1491 | copying the address of one into a non-@code{const} @code{char *} | |
1492 | pointer will get a warning. These warnings will help you find at | |
1493 | compile time code that can try to write into a string constant, but | |
1494 | only if you have been very careful about using @code{const} in | |
1495 | declarations and prototypes. Otherwise, it will just be a nuisance; | |
1496 | this is why we did not make @samp{-Wall} request these warnings. | |
1497 | ||
1498 | @item -Wconversion | |
1499 | Warn if a prototype causes a type conversion that is different from what | |
1500 | would happen to the same argument in the absence of a prototype. This | |
1501 | includes conversions of fixed point to floating and vice versa, and | |
1502 | conversions changing the width or signedness of a fixed point argument | |
1503 | except when the same as the default promotion. | |
1504 | ||
1505 | Also, warn if a negative integer constant expression is implicitly | |
1506 | converted to an unsigned type. For example, warn about the assignment | |
1507 | @code{x = -1} if @code{x} is unsigned. But do not warn about explicit | |
1508 | casts like @code{(unsigned) -1}. | |
1509 | ||
1510 | @item -Waggregate-return | |
1511 | Warn if any functions that return structures or unions are defined or | |
1512 | called. (In languages where you can return an array, this also elicits | |
1513 | a warning.) | |
1514 | ||
1515 | @item -Wstrict-prototypes | |
1516 | Warn if a function is declared or defined without specifying the | |
1517 | argument types. (An old-style function definition is permitted without | |
1518 | a warning if preceded by a declaration which specifies the argument | |
1519 | types.) | |
1520 | ||
1521 | @item -Wmissing-prototypes | |
1522 | Warn if a global function is defined without a previous prototype | |
1523 | declaration. This warning is issued even if the definition itself | |
1524 | provides a prototype. The aim is to detect global functions that fail | |
1525 | to be declared in header files. | |
1526 | ||
1527 | @item -Wmissing-declarations | |
1528 | Warn if a global function is defined without a previous declaration. | |
1529 | Do so even if the definition itself provides a prototype. | |
1530 | Use this option to detect global functions that are not declared in | |
1531 | header files. | |
1532 | ||
1533 | @item -Wredundant-decls | |
1534 | Warn if anything is declared more than once in the same scope, even in | |
1535 | cases where multiple declaration is valid and changes nothing. | |
1536 | ||
1537 | @item -Wnested-externs | |
1538 | Warn if an @code{extern} declaration is encountered within an function. | |
1539 | ||
1540 | @item -Winline | |
1541 | Warn if a function can not be inlined, and either it was declared as inline, | |
1542 | or else the @samp{-finline-functions} option was given. | |
1543 | ||
1544 | @item -Woverloaded-virtual | |
1545 | @cindex overloaded virtual fn, warning | |
1546 | @cindex warning for overloaded virtual fn | |
1547 | Warn when a derived class function declaration may be an error in | |
1548 | defining a virtual function (C++ only). In a derived class, the | |
1549 | definitions of virtual functions must match the type signature of a | |
1550 | virtual function declared in the base class. With this option, the | |
1551 | compiler warns when you define a function with the same name as a | |
1552 | virtual function, but with a type signature that does not match any | |
1553 | declarations from the base class. | |
1554 | ||
1555 | @item -Wsynth (C++ only) | |
1556 | @cindex warning for synthesized methods | |
1557 | @cindex synthesized methods, warning | |
1558 | Warn when g++'s synthesis behavior does not match that of cfront. For | |
1559 | instance: | |
1560 | ||
1561 | @smallexample | |
1562 | struct A @{ | |
1563 | operator int (); | |
1564 | A& operator = (int); | |
1565 | @}; | |
1566 | ||
1567 | main () | |
1568 | @{ | |
1569 | A a,b; | |
1570 | a = b; | |
1571 | @} | |
1572 | @end smallexample | |
1573 | ||
1574 | In this example, g++ will synthesize a default @samp{A& operator = | |
1575 | (const A&);}, while cfront will use the user-defined @samp{operator =}. | |
1576 | ||
1577 | @item -Werror | |
1578 | Make all warnings into errors. | |
1579 | @end table | |
1580 | ||
1581 | @node Debugging Options | |
1582 | @section Options for Debugging Your Program or GNU CC | |
1583 | @cindex options, debugging | |
1584 | @cindex debugging information options | |
1585 | ||
1586 | GNU CC has various special options that are used for debugging | |
1587 | either your program or GCC: | |
1588 | ||
1589 | @table @code | |
1590 | @item -g | |
1591 | Produce debugging information in the operating system's native format | |
1592 | (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging | |
1593 | information. | |
1594 | ||
1595 | On most systems that use stabs format, @samp{-g} enables use of extra | |
1596 | debugging information that only GDB can use; this extra information | |
1597 | makes debugging work better in GDB but will probably make other debuggers | |
1598 | crash or | |
1599 | refuse to read the program. If you want to control for certain whether | |
1600 | to generate the extra information, use @samp{-gstabs+}, @samp{-gstabs}, | |
861bb6c1 | 1601 | @samp{-gxcoff+}, @samp{-gxcoff}, @samp{-gdwarf-1+}, or @samp{-gdwarf-1} |
74291a4b MM |
1602 | (see below). |
1603 | ||
1604 | Unlike most other C compilers, GNU CC allows you to use @samp{-g} with | |
1605 | @samp{-O}. The shortcuts taken by optimized code may occasionally | |
1606 | produce surprising results: some variables you declared may not exist | |
1607 | at all; flow of control may briefly move where you did not expect it; | |
1608 | some statements may not be executed because they compute constant | |
1609 | results or their values were already at hand; some statements may | |
1610 | execute in different places because they were moved out of loops. | |
1611 | ||
1612 | Nevertheless it proves possible to debug optimized output. This makes | |
1613 | it reasonable to use the optimizer for programs that might have bugs. | |
1614 | ||
1615 | The following options are useful when GNU CC is generated with the | |
1616 | capability for more than one debugging format. | |
1617 | ||
1618 | @item -ggdb | |
861bb6c1 JL |
1619 | Produce debugging information for use by GDB. This means to use the |
1620 | most expressive format available (DWARF 2, stabs, or the native format | |
1621 | if neither of those are supported), including GDB extensions if at all | |
1622 | possible. | |
74291a4b MM |
1623 | |
1624 | @item -gstabs | |
1625 | Produce debugging information in stabs format (if that is supported), | |
1626 | without GDB extensions. This is the format used by DBX on most BSD | |
1627 | systems. On MIPS, Alpha and System V Release 4 systems this option | |
1628 | produces stabs debugging output which is not understood by DBX or SDB. | |
1629 | On System V Release 4 systems this option requires the GNU assembler. | |
1630 | ||
1631 | @item -gstabs+ | |
1632 | Produce debugging information in stabs format (if that is supported), | |
1633 | using GNU extensions understood only by the GNU debugger (GDB). The | |
1634 | use of these extensions is likely to make other debuggers crash or | |
1635 | refuse to read the program. | |
1636 | ||
1637 | @item -gcoff | |
1638 | Produce debugging information in COFF format (if that is supported). | |
1639 | This is the format used by SDB on most System V systems prior to | |
1640 | System V Release 4. | |
1641 | ||
1642 | @item -gxcoff | |
1643 | Produce debugging information in XCOFF format (if that is supported). | |
1644 | This is the format used by the DBX debugger on IBM RS/6000 systems. | |
1645 | ||
1646 | @item -gxcoff+ | |
1647 | Produce debugging information in XCOFF format (if that is supported), | |
1648 | using GNU extensions understood only by the GNU debugger (GDB). The | |
1649 | use of these extensions is likely to make other debuggers crash or | |
1650 | refuse to read the program, and may cause assemblers other than the GNU | |
1651 | assembler (GAS) to fail with an error. | |
1652 | ||
1653 | @item -gdwarf | |
861bb6c1 JL |
1654 | Produce debugging information in DWARF version 1 format (if that is |
1655 | supported). This is the format used by SDB on most System V Release 4 | |
1656 | systems. | |
74291a4b MM |
1657 | |
1658 | @item -gdwarf+ | |
861bb6c1 JL |
1659 | Produce debugging information in DWARF version 1 format (if that is |
1660 | supported), using GNU extensions understood only by the GNU debugger | |
1661 | (GDB). The use of these extensions is likely to make other debuggers | |
1662 | crash or refuse to read the program. | |
1663 | ||
1664 | @item -gdwarf-2 | |
1665 | Produce debugging information in DWARF version 2 format (if that is | |
1666 | supported). This is the format used by DBX on IRIX 6. | |
74291a4b MM |
1667 | |
1668 | @item -g@var{level} | |
1669 | @itemx -ggdb@var{level} | |
1670 | @itemx -gstabs@var{level} | |
1671 | @itemx -gcoff@var{level} | |
1672 | @itemx -gxcoff@var{level} | |
1673 | @itemx -gdwarf@var{level} | |
861bb6c1 | 1674 | @itemx -gdwarf-2@var{level} |
74291a4b MM |
1675 | Request debugging information and also use @var{level} to specify how |
1676 | much information. The default level is 2. | |
1677 | ||
1678 | Level 1 produces minimal information, enough for making backtraces in | |
1679 | parts of the program that you don't plan to debug. This includes | |
1680 | descriptions of functions and external variables, but no information | |
1681 | about local variables and no line numbers. | |
1682 | ||
1683 | Level 3 includes extra information, such as all the macro definitions | |
1684 | present in the program. Some debuggers support macro expansion when | |
1685 | you use @samp{-g3}. | |
1686 | ||
1687 | @cindex @code{prof} | |
1688 | @item -p | |
1689 | Generate extra code to write profile information suitable for the | |
1690 | analysis program @code{prof}. You must use this option when compiling | |
1691 | the source files you want data about, and you must also use it when | |
1692 | linking. | |
1693 | ||
1694 | @cindex @code{gprof} | |
1695 | @item -pg | |
1696 | Generate extra code to write profile information suitable for the | |
1697 | analysis program @code{gprof}. You must use this option when compiling | |
1698 | the source files you want data about, and you must also use it when | |
1699 | linking. | |
1700 | ||
1701 | @cindex @code{tcov} | |
1702 | @item -a | |
1703 | Generate extra code to write profile information for basic blocks, which will | |
1704 | record the number of times each basic block is executed, the basic block start | |
1705 | address, and the function name containing the basic block. If @samp{-g} is | |
1706 | used, the line number and filename of the start of the basic block will also be | |
1707 | recorded. If not overridden by the machine description, the default action is | |
1708 | to append to the text file @file{bb.out}. | |
1709 | ||
1710 | This data could be analyzed by a program like @code{tcov}. Note, | |
1711 | however, that the format of the data is not what @code{tcov} expects. | |
1712 | Eventually GNU @code{gprof} should be extended to process this data. | |
1713 | ||
1714 | @item -ax | |
1715 | Generate extra code to profile basic blocks. Your executable will | |
1716 | produce output that is a superset of that produced when @samp{-a} is | |
1717 | used. Additional output is the source and target address of the basic | |
1718 | blocks where a jump takes place, the number of times a jump is executed, | |
1719 | and (optionally) the complete sequence of basic blocks being executed. | |
1720 | The output is appended to file @file{bb.out}. | |
1721 | ||
1722 | You can examine different profiling aspects without recompilation. Your | |
1723 | execuable will read a list of function names from file @file{bb.in}. | |
1724 | Profiling starts when a function on the list is entered and stops when | |
1725 | that invocation is exited. To exclude a function from profiling, prefix | |
1726 | its name with `-'. If a function name is not unique, you can | |
1727 | disambiguate it by writing it in the form | |
1728 | @samp{/path/filename.d:functionname}. Your executable will write the | |
1729 | available paths and filenames in file @file{bb.out}. | |
1730 | ||
1731 | Several function names have a special meaning: | |
1732 | @table @code | |
1733 | @item __bb_jumps__ | |
1734 | Write source, target and frequency of jumps to file @file{bb.out}. | |
1735 | @item __bb_hidecall__ | |
1736 | Exclude function calls from frequency count. | |
1737 | @item __bb_showret__ | |
1738 | Include function returns in frequency count. | |
1739 | @item __bb_trace__ | |
1740 | Write the sequence of basic blocks executed to file @file{bbtrace.gz}. | |
1741 | The file will be compressed using the program @samp{gzip}, which must | |
1742 | exist in your @code{PATH}. On systems without the @samp{popen} | |
1743 | function, the file will be named @file{bbtrace} and will not be | |
1744 | compressed. @strong{Profiling for even a few seconds on these systems | |
1745 | will produce a very large file.} Note: @code{__bb_hidecall__} and | |
1746 | @code{__bb_showret__} will not affect the sequence written to | |
1747 | @file{bbtrace.gz}. | |
1748 | @end table | |
1749 | ||
1750 | Here's a short example using different profiling parameters | |
1751 | in file @file{bb.in}. Assume function @code{foo} consists of basic blocks | |
1752 | 1 and 2 and is called twice from block 3 of function @code{main}. After | |
1753 | the calls, block 3 transfers control to block 4 of @code{main}. | |
1754 | ||
1755 | With @code{__bb_trace__} and @code{main} contained in file @file{bb.in}, | |
1756 | the following sequence of blocks is written to file @file{bbtrace.gz}: | |
1757 | 0 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because | |
1758 | the return is to a point inside the block and not to the top. The | |
1759 | block address 0 always indicates, that control is transferred | |
1760 | to the trace from somewhere outside the observed functions. With | |
1761 | @samp{-foo} added to @file{bb.in}, the blocks of function | |
1762 | @code{foo} are removed from the trace, so only 0 3 4 remains. | |
1763 | ||
1764 | With @code{__bb_jumps__} and @code{main} contained in file @file{bb.in}, | |
1765 | jump frequencies will be written to file @file{bb.out}. The | |
1766 | frequencies are obtained by constructing a trace of blocks | |
1767 | and incrementing a counter for every neighbouring pair of blocks | |
1768 | in the trace. The trace 0 3 1 2 1 2 4 displays the following | |
1769 | frequencies: | |
1770 | ||
1771 | @example | |
1772 | Jump from block 0x0 to block 0x3 executed 1 time(s) | |
1773 | Jump from block 0x3 to block 0x1 executed 1 time(s) | |
1774 | Jump from block 0x1 to block 0x2 executed 2 time(s) | |
1775 | Jump from block 0x2 to block 0x1 executed 1 time(s) | |
1776 | Jump from block 0x2 to block 0x4 executed 1 time(s) | |
1777 | @end example | |
1778 | ||
1779 | With @code{__bb_hidecall__}, control transfer due to call instructions | |
1780 | is removed from the trace, that is the trace is cut into three parts: 0 | |
1781 | 3 4, 0 1 2 and 0 1 2. With @code{__bb_showret__}, control transfer due | |
1782 | to return instructions is added to the trace. The trace becomes: 0 3 1 | |
1783 | 2 3 1 2 3 4. Note, that this trace is not the same, as the sequence | |
1784 | written to @file{bbtrace.gz}. It is solely used for counting jump | |
1785 | frequencies. | |
1786 | ||
861bb6c1 JL |
1787 | @item -fprofile-arcs |
1788 | Instrument @dfn{arcs} during compilation. For each function of your | |
1789 | program, GNU CC creates a program flow graph, then finds a spanning tree | |
1790 | for the graph. Only arcs that are not on the spanning tree have to be | |
1791 | instrumented: the compiler adds code to count the number of times that these | |
1792 | arcs are executed. When an arc is the only exit or only entrance to a | |
1793 | block, the instrumentation code can be added to the block; otherwise, a | |
1794 | new basic block must be created to hold the instrumentation code. | |
1795 | ||
1796 | Since not every arc in the program must be instrumented, programs | |
1797 | compiled with this option run faster than programs compiled with | |
1798 | @samp{-a}, which adds instrumentation code to every basic block in the | |
1799 | program. The tradeoff: since @code{gcov} does not have | |
1800 | execution counts for all branches, it must start with the execution | |
1801 | counts for the instrumented branches, and then iterate over the program | |
1802 | flow graph until the entire graph has been solved. Hence, @code{gcov} | |
1803 | runs a little more slowly than a program which uses information from | |
1804 | @samp{-a}. | |
1805 | ||
1806 | @samp{-fprofile-arcs} also makes it possible to estimate branch | |
1807 | probabilities, and to calculate basic block execution counts. In | |
1808 | general, basic block execution counts do not give enough information to | |
1809 | estimate all branch probabilities. When the compiled program exits, it | |
1810 | saves the arc execution counts to a file called | |
1811 | @file{@var{sourcename}.da}. Use the compiler option | |
1812 | @samp{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
1813 | Control Optimization}) when recompiling, to optimize using estimated | |
1814 | branch probabilities. | |
1815 | ||
1816 | @need 2000 | |
1817 | @item -ftest-coverage | |
1818 | Create data files for the @code{gcov} code-coverage utility | |
1819 | (@pxref{Gcov,, @code{gcov}: a GNU CC Test Coverage Program}). | |
1820 | The data file names begin with the name of your source file: | |
1821 | ||
1822 | @table @code | |
1823 | @item @var{sourcename}.bb | |
1824 | A mapping from basic blocks to line numbers, which @code{gcov} uses to | |
1825 | associate basic block execution counts with line numbers. | |
1826 | ||
1827 | @item @var{sourcename}.bbg | |
1828 | A list of all arcs in the program flow graph. This allows @code{gcov} | |
1829 | to reconstruct the program flow graph, so that it can compute all basic | |
1830 | block and arc execution counts from the information in the | |
1831 | @code{@var{sourcename}.da} file (this last file is the output from | |
1832 | @samp{-fprofile-arcs}). | |
1833 | @end table | |
1834 | ||
74291a4b MM |
1835 | @item -d@var{letters} |
1836 | Says to make debugging dumps during compilation at times specified by | |
1837 | @var{letters}. This is used for debugging the compiler. The file names | |
1838 | for most of the dumps are made by appending a word to the source file | |
1839 | name (e.g. @file{foo.c.rtl} or @file{foo.c.jump}). Here are the | |
1840 | possible letters for use in @var{letters}, and their meanings: | |
1841 | ||
1842 | @table @samp | |
1843 | @item M | |
1844 | Dump all macro definitions, at the end of preprocessing, and write no | |
1845 | output. | |
1846 | @item N | |
1847 | Dump all macro names, at the end of preprocessing. | |
1848 | @item D | |
1849 | Dump all macro definitions, at the end of preprocessing, in addition to | |
1850 | normal output. | |
1851 | @item y | |
1852 | Dump debugging information during parsing, to standard error. | |
1853 | @item r | |
1854 | Dump after RTL generation, to @file{@var{file}.rtl}. | |
1855 | @item x | |
1856 | Just generate RTL for a function instead of compiling it. Usually used | |
1857 | with @samp{r}. | |
1858 | @item j | |
1859 | Dump after first jump optimization, to @file{@var{file}.jump}. | |
1860 | @item s | |
1861 | Dump after CSE (including the jump optimization that sometimes | |
1862 | follows CSE), to @file{@var{file}.cse}. | |
1863 | @item L | |
1864 | Dump after loop optimization, to @file{@var{file}.loop}. | |
1865 | @item t | |
1866 | Dump after the second CSE pass (including the jump optimization that | |
1867 | sometimes follows CSE), to @file{@var{file}.cse2}. | |
1868 | @item f | |
1869 | Dump after flow analysis, to @file{@var{file}.flow}. | |
1870 | @item c | |
1871 | Dump after instruction combination, to the file | |
1872 | @file{@var{file}.combine}. | |
1873 | @item S | |
1874 | Dump after the first instruction scheduling pass, to | |
1875 | @file{@var{file}.sched}. | |
1876 | @item l | |
1877 | Dump after local register allocation, to | |
1878 | @file{@var{file}.lreg}. | |
1879 | @item g | |
1880 | Dump after global register allocation, to | |
1881 | @file{@var{file}.greg}. | |
1882 | @item R | |
1883 | Dump after the second instruction scheduling pass, to | |
1884 | @file{@var{file}.sched2}. | |
1885 | @item J | |
1886 | Dump after last jump optimization, to @file{@var{file}.jump2}. | |
1887 | @item d | |
1888 | Dump after delayed branch scheduling, to @file{@var{file}.dbr}. | |
1889 | @item k | |
1890 | Dump after conversion from registers to stack, to @file{@var{file}.stack}. | |
1891 | @item a | |
1892 | Produce all the dumps listed above. | |
1893 | @item m | |
1894 | Print statistics on memory usage, at the end of the run, to | |
1895 | standard error. | |
1896 | @item p | |
1897 | Annotate the assembler output with a comment indicating which | |
1898 | pattern and alternative was used. | |
1899 | @item A | |
1900 | Annotate the assembler output with miscellaneous debugging information. | |
1901 | @end table | |
1902 | ||
1903 | @item -fpretend-float | |
1904 | When running a cross-compiler, pretend that the target machine uses the | |
1905 | same floating point format as the host machine. This causes incorrect | |
1906 | output of the actual floating constants, but the actual instruction | |
1907 | sequence will probably be the same as GNU CC would make when running on | |
1908 | the target machine. | |
1909 | ||
1910 | @item -save-temps | |
1911 | Store the usual ``temporary'' intermediate files permanently; place them | |
1912 | in the current directory and name them based on the source file. Thus, | |
1913 | compiling @file{foo.c} with @samp{-c -save-temps} would produce files | |
1914 | @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. | |
1915 | ||
1916 | @item -print-file-name=@var{library} | |
1917 | Print the full absolute name of the library file @var{library} that | |
1918 | would be used when linking---and don't do anything else. With this | |
1919 | option, GNU CC does not compile or link anything; it just prints the | |
1920 | file name. | |
1921 | ||
1922 | @item -print-prog-name=@var{program} | |
1923 | Like @samp{-print-file-name}, but searches for a program such as @samp{cpp}. | |
1924 | ||
1925 | @item -print-libgcc-file-name | |
1926 | Same as @samp{-print-file-name=libgcc.a}. | |
1927 | ||
1928 | This is useful when you use @samp{-nostdlib} or @samp{-nodefaultlibs} | |
1929 | but you do want to link with @file{libgcc.a}. You can do | |
1930 | ||
1931 | @example | |
1932 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
1933 | @end example | |
1934 | ||
1935 | @item -print-search-dirs | |
1936 | Print the name of the configured installation directory and a list of | |
1937 | program and library directories gcc will search---and don't do anything else. | |
1938 | ||
1939 | This is useful when gcc prints the error message | |
1940 | @samp{installation problem, cannot exec cpp: No such file or directory}. | |
1941 | To resolve this you either need to put @file{cpp} and the other compiler | |
1942 | components where gcc expects to find them, or you can set the environment | |
1943 | variable @code{GCC_EXEC_PREFIX} to the directory where you installed them. | |
1944 | Don't forget the trailing '/'. | |
1945 | @xref{Environment Variables}. | |
1946 | @end table | |
1947 | ||
1948 | @node Optimize Options | |
1949 | @section Options That Control Optimization | |
1950 | @cindex optimize options | |
1951 | @cindex options, optimization | |
1952 | ||
1953 | These options control various sorts of optimizations: | |
1954 | ||
1955 | @table @code | |
1956 | @item -O | |
1957 | @itemx -O1 | |
1958 | Optimize. Optimizing compilation takes somewhat more time, and a lot | |
1959 | more memory for a large function. | |
1960 | ||
1961 | Without @samp{-O}, the compiler's goal is to reduce the cost of | |
1962 | compilation and to make debugging produce the expected results. | |
1963 | Statements are independent: if you stop the program with a breakpoint | |
1964 | between statements, you can then assign a new value to any variable or | |
1965 | change the program counter to any other statement in the function and | |
1966 | get exactly the results you would expect from the source code. | |
1967 | ||
1968 | Without @samp{-O}, the compiler only allocates variables declared | |
1969 | @code{register} in registers. The resulting compiled code is a little | |
1970 | worse than produced by PCC without @samp{-O}. | |
1971 | ||
1972 | With @samp{-O}, the compiler tries to reduce code size and execution | |
1973 | time. | |
1974 | ||
1975 | When you specify @samp{-O}, the compiler turns on @samp{-fthread-jumps} | |
1976 | and @samp{-fdefer-pop} on all machines. The compiler turns on | |
1977 | @samp{-fdelayed-branch} on machines that have delay slots, and | |
1978 | @samp{-fomit-frame-pointer} on machines that can support debugging even | |
1979 | without a frame pointer. On some machines the compiler also turns | |
1980 | on other flags.@refill | |
1981 | ||
1982 | @item -O2 | |
1983 | Optimize even more. GNU CC performs nearly all supported optimizations | |
1984 | that do not involve a space-speed tradeoff. The compiler does not | |
1985 | perform loop unrolling or function inlining when you specify @samp{-O2}. | |
1986 | As compared to @samp{-O}, this option increases both compilation time | |
1987 | and the performance of the generated code. | |
1988 | ||
1989 | @samp{-O2} turns on all optional optimizations except for loop unrolling | |
1990 | and function inlining. It also turns on the @samp{-fforce-mem} option | |
1991 | on all machines and frame pointer elimination on machines where doing so | |
1992 | does not interfere with debugging. | |
1993 | ||
1994 | @item -O3 | |
1995 | Optimize yet more. @samp{-O3} turns on all optimizations specified by | |
1996 | @samp{-O2} and also turns on the @samp{inline-functions} option. | |
1997 | ||
1998 | @item -O0 | |
1999 | Do not optimize. | |
2000 | ||
2001 | If you use multiple @samp{-O} options, with or without level numbers, | |
2002 | the last such option is the one that is effective. | |
2003 | @end table | |
2004 | ||
2005 | Options of the form @samp{-f@var{flag}} specify machine-independent | |
2006 | flags. Most flags have both positive and negative forms; the negative | |
2007 | form of @samp{-ffoo} would be @samp{-fno-foo}. In the table below, | |
2008 | only one of the forms is listed---the one which is not the default. | |
2009 | You can figure out the other form by either removing @samp{no-} or | |
2010 | adding it. | |
2011 | ||
2012 | @table @code | |
2013 | @item -ffloat-store | |
2014 | Do not store floating point variables in registers, and inhibit other | |
2015 | options that might change whether a floating point value is taken from a | |
2016 | register or memory. | |
2017 | ||
2018 | @cindex floating point precision | |
2019 | This option prevents undesirable excess precision on machines such as | |
2020 | the 68000 where the floating registers (of the 68881) keep more | |
2021 | precision than a @code{double} is supposed to have. Similarly for the | |
2022 | x86 architecture. For most programs, the excess precision does only | |
2023 | good, but a few programs rely on the precise definition of IEEE floating | |
2024 | point. Use @samp{-ffloat-store} for such programs. | |
2025 | ||
2026 | @item -fno-default-inline | |
2027 | Do not make member functions inline by default merely because they are | |
2028 | defined inside the class scope (C++ only). Otherwise, when you specify | |
2029 | @w{@samp{-O}}, member functions defined inside class scope are compiled | |
2030 | inline by default; i.e., you don't need to add @samp{inline} in front of | |
2031 | the member function name. | |
2032 | ||
2033 | @item -fno-defer-pop | |
2034 | Always pop the arguments to each function call as soon as that function | |
2035 | returns. For machines which must pop arguments after a function call, | |
2036 | the compiler normally lets arguments accumulate on the stack for several | |
2037 | function calls and pops them all at once. | |
2038 | ||
2039 | @item -fforce-mem | |
2040 | Force memory operands to be copied into registers before doing | |
2041 | arithmetic on them. This produces better code by making all memory | |
2042 | references potential common subexpressions. When they are not common | |
2043 | subexpressions, instruction combination should eliminate the separate | |
2044 | register-load. The @samp{-O2} option turns on this option. | |
2045 | ||
2046 | @item -fforce-addr | |
2047 | Force memory address constants to be copied into registers before | |
2048 | doing arithmetic on them. This may produce better code just as | |
2049 | @samp{-fforce-mem} may. | |
2050 | ||
2051 | @item -fomit-frame-pointer | |
2052 | Don't keep the frame pointer in a register for functions that | |
2053 | don't need one. This avoids the instructions to save, set up and | |
2054 | restore frame pointers; it also makes an extra register available | |
2055 | in many functions. @strong{It also makes debugging impossible on | |
2056 | some machines.} | |
2057 | ||
2058 | @ifset INTERNALS | |
2059 | On some machines, such as the Vax, this flag has no effect, because | |
2060 | the standard calling sequence automatically handles the frame pointer | |
2061 | and nothing is saved by pretending it doesn't exist. The | |
2062 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
2063 | whether a target machine supports this flag. @xref{Registers}.@refill | |
2064 | @end ifset | |
2065 | @ifclear INTERNALS | |
2066 | On some machines, such as the Vax, this flag has no effect, because | |
2067 | the standard calling sequence automatically handles the frame pointer | |
2068 | and nothing is saved by pretending it doesn't exist. The | |
2069 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
2070 | whether a target machine supports this flag. @xref{Registers,,Register | |
2071 | Usage, gcc.info, Using and Porting GCC}.@refill | |
2072 | @end ifclear | |
2073 | ||
2074 | @item -fno-inline | |
2075 | Don't pay attention to the @code{inline} keyword. Normally this option | |
2076 | is used to keep the compiler from expanding any functions inline. | |
2077 | Note that if you are not optimizing, no functions can be expanded inline. | |
2078 | ||
2079 | @item -finline-functions | |
2080 | Integrate all simple functions into their callers. The compiler | |
2081 | heuristically decides which functions are simple enough to be worth | |
2082 | integrating in this way. | |
2083 | ||
2084 | If all calls to a given function are integrated, and the function is | |
2085 | declared @code{static}, then the function is normally not output as | |
2086 | assembler code in its own right. | |
2087 | ||
2088 | @item -fkeep-inline-functions | |
2089 | Even if all calls to a given function are integrated, and the function | |
2090 | is declared @code{static}, nevertheless output a separate run-time | |
2091 | callable version of the function. This switch does not affect | |
2092 | @code{extern inline} functions. | |
2093 | ||
2094 | @item -fkeep-static-consts | |
2095 | Emit variables declared @code{static const} when optimization isn't turned | |
2096 | on, even if the variables aren't referenced. | |
2097 | ||
2098 | GNU CC enables this option by default. If you want to force the compiler to | |
2099 | check if the variable was referenced, regardless of whether or not | |
2100 | optimization is turned on, use the @samp{-fno-keep-static-consts} option. | |
2101 | ||
2102 | @item -fno-function-cse | |
2103 | Do not put function addresses in registers; make each instruction that | |
2104 | calls a constant function contain the function's address explicitly. | |
2105 | ||
2106 | This option results in less efficient code, but some strange hacks | |
2107 | that alter the assembler output may be confused by the optimizations | |
2108 | performed when this option is not used. | |
2109 | ||
2110 | @item -ffast-math | |
2111 | This option allows GCC to violate some ANSI or IEEE rules and/or | |
2112 | specifications in the interest of optimizing code for speed. For | |
2113 | example, it allows the compiler to assume arguments to the @code{sqrt} | |
2114 | function are non-negative numbers and that no floating-point values | |
2115 | are NaNs. | |
2116 | ||
2117 | This option should never be turned on by any @samp{-O} option since | |
2118 | it can result in incorrect output for programs which depend on | |
2119 | an exact implementation of IEEE or ANSI rules/specifications for | |
2120 | math functions. | |
2121 | @end table | |
2122 | ||
2123 | @c following causes underfulls.. they don't look great, but we deal. | |
2124 | @c --mew 26jan93 | |
2125 | The following options control specific optimizations. The @samp{-O2} | |
2126 | option turns on all of these optimizations except @samp{-funroll-loops} | |
2127 | and @samp{-funroll-all-loops}. On most machines, the @samp{-O} option | |
2128 | turns on the @samp{-fthread-jumps} and @samp{-fdelayed-branch} options, | |
2129 | but specific machines may handle it differently. | |
2130 | ||
2131 | You can use the following flags in the rare cases when ``fine-tuning'' | |
2132 | of optimizations to be performed is desired. | |
2133 | ||
2134 | @table @code | |
2135 | @item -fstrength-reduce | |
2136 | Perform the optimizations of loop strength reduction and | |
2137 | elimination of iteration variables. | |
2138 | ||
2139 | @item -fthread-jumps | |
2140 | Perform optimizations where we check to see if a jump branches to a | |
2141 | location where another comparison subsumed by the first is found. If | |
2142 | so, the first branch is redirected to either the destination of the | |
2143 | second branch or a point immediately following it, depending on whether | |
2144 | the condition is known to be true or false. | |
2145 | ||
2146 | @item -fcse-follow-jumps | |
2147 | In common subexpression elimination, scan through jump instructions | |
2148 | when the target of the jump is not reached by any other path. For | |
2149 | example, when CSE encounters an @code{if} statement with an | |
2150 | @code{else} clause, CSE will follow the jump when the condition | |
2151 | tested is false. | |
2152 | ||
2153 | @item -fcse-skip-blocks | |
2154 | This is similar to @samp{-fcse-follow-jumps}, but causes CSE to | |
2155 | follow jumps which conditionally skip over blocks. When CSE | |
2156 | encounters a simple @code{if} statement with no else clause, | |
2157 | @samp{-fcse-skip-blocks} causes CSE to follow the jump around the | |
2158 | body of the @code{if}. | |
2159 | ||
2160 | @item -frerun-cse-after-loop | |
2161 | Re-run common subexpression elimination after loop optimizations has been | |
2162 | performed. | |
2163 | ||
2164 | @item -fexpensive-optimizations | |
2165 | Perform a number of minor optimizations that are relatively expensive. | |
2166 | ||
2167 | @item -fdelayed-branch | |
2168 | If supported for the target machine, attempt to reorder instructions | |
2169 | to exploit instruction slots available after delayed branch | |
2170 | instructions. | |
2171 | ||
2172 | @item -fschedule-insns | |
2173 | If supported for the target machine, attempt to reorder instructions to | |
2174 | eliminate execution stalls due to required data being unavailable. This | |
2175 | helps machines that have slow floating point or memory load instructions | |
2176 | by allowing other instructions to be issued until the result of the load | |
2177 | or floating point instruction is required. | |
2178 | ||
2179 | @item -fschedule-insns2 | |
2180 | Similar to @samp{-fschedule-insns}, but requests an additional pass of | |
2181 | instruction scheduling after register allocation has been done. This is | |
2182 | especially useful on machines with a relatively small number of | |
2183 | registers and where memory load instructions take more than one cycle. | |
2184 | ||
2185 | @item -ffunction-sections | |
2186 | Place each function into its own section in the output file if the | |
2187 | target supports arbitrary sections. The function's name determines | |
2188 | the section's name in the output file. | |
2189 | ||
2190 | Use this option on systems where the linker can perform optimizations | |
2191 | to improve locality of reference in the instruction space. HPPA | |
2192 | processors running HP-UX and Sparc processors running Solaris 2 have | |
2193 | linkers with such optimizations. Other systems using the ELF object format | |
2194 | as well as AIX may have these optimizations in the future. | |
2195 | ||
2196 | Only use this option when there are significant benefits from doing | |
2197 | so. When you specify this option, the assembler and linker will | |
2198 | create larger object and executable files and will also be slower. | |
2199 | You will not be able to use @code{gprof} on all systems if you | |
2200 | specify this option and you may have problems with debugging if | |
2201 | you specify both this option and @samp{-g}. | |
2202 | ||
2203 | @item -fcaller-saves | |
2204 | Enable values to be allocated in registers that will be clobbered by | |
2205 | function calls, by emitting extra instructions to save and restore the | |
2206 | registers around such calls. Such allocation is done only when it | |
2207 | seems to result in better code than would otherwise be produced. | |
2208 | ||
2209 | This option is enabled by default on certain machines, usually those | |
2210 | which have no call-preserved registers to use instead. | |
2211 | ||
2212 | @item -funroll-loops | |
2213 | Perform the optimization of loop unrolling. This is only done for loops | |
2214 | whose number of iterations can be determined at compile time or run time. | |
2215 | @samp{-funroll-loop} implies both @samp{-fstrength-reduce} and | |
2216 | @samp{-frerun-cse-after-loop}. | |
2217 | ||
2218 | @item -funroll-all-loops | |
2219 | Perform the optimization of loop unrolling. This is done for all loops | |
2220 | and usually makes programs run more slowly. @samp{-funroll-all-loops} | |
2221 | implies @samp{-fstrength-reduce} as well as @samp{-frerun-cse-after-loop}. | |
2222 | ||
e5eb27e5 JL |
2223 | @item -fmove-all-movables |
2224 | Forces all invariant computations in loops to be moved | |
2225 | outside the loop. | |
2226 | ||
2227 | @item -freduce-all-givs | |
2228 | Forces all general-induction variables in loops to be | |
2229 | strength-reduced. | |
2230 | ||
2231 | @emph{Note:} When compiling programs written in Fortran, | |
2232 | @samp{-fmove-all-moveables} and @samp{-freduce-all-givs} are enabled | |
2233 | by default when you use the optimizer. | |
2234 | ||
2235 | These options may generate better or worse code; results are highly | |
2236 | dependent on the structure of loops within the source code. | |
2237 | ||
2238 | These two options are intended to be removed someday, once | |
2239 | they have helped determine the efficacy of various | |
2240 | approaches to improving loop optimizations. | |
2241 | ||
ec83e9d3 | 2242 | Please let us (@code{egcs@@cygnus.com} and @code{fortran@@gnu.ai.mit.edu}) |
e5eb27e5 JL |
2243 | know how use of these options affects |
2244 | the performance of your production code. | |
2245 | We're very interested in code that runs @emph{slower} | |
2246 | when these options are @emph{enabled}. | |
2247 | ||
74291a4b MM |
2248 | @item -fno-peephole |
2249 | Disable any machine-specific peephole optimizations. | |
861bb6c1 JL |
2250 | |
2251 | @item -fbranch-probabilities | |
2252 | After running a program compiled with @samp{-fprofile-arcs} | |
2253 | (@pxref{Debugging Options,, Options for Debugging Your Program or | |
2254 | @code{gcc}}), you can compile it a second time using | |
2255 | @samp{-fbranch-probabilities}, to improve optimizations based on | |
2256 | guessing the path a branch might take. | |
2257 | ||
2258 | @ifset INTERNALS | |
2259 | With @samp{-fbranch-probabilities}, GNU CC puts a @samp{REG_EXEC_COUNT} | |
2260 | note on the first instruction of each basic block, and a | |
2261 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
2262 | These can be used to improve optimization. Currently, they are only | |
2263 | used in one place: in @file{reorg.c}, instead of guessing which path a | |
2264 | branch is mostly to take, the @samp{REG_BR_PROB} values are used to | |
2265 | exactly determine which path is taken more often. | |
2266 | @end ifset | |
8c660648 JL |
2267 | |
2268 | @item -fregmove | |
2269 | Some machines only support 2 operands per instruction. On such | |
2270 | machines, GNU CC might have to do extra copies. The @samp{-fregmove} | |
2271 | option overrides the default for the machine to do the copy before | |
2272 | register allocation. | |
74291a4b MM |
2273 | @end table |
2274 | ||
2275 | @node Preprocessor Options | |
2276 | @section Options Controlling the Preprocessor | |
2277 | @cindex preprocessor options | |
2278 | @cindex options, preprocessor | |
2279 | ||
2280 | These options control the C preprocessor, which is run on each C source | |
2281 | file before actual compilation. | |
2282 | ||
2283 | If you use the @samp{-E} option, nothing is done except preprocessing. | |
2284 | Some of these options make sense only together with @samp{-E} because | |
2285 | they cause the preprocessor output to be unsuitable for actual | |
2286 | compilation. | |
2287 | ||
2288 | @table @code | |
2289 | @item -include @var{file} | |
2290 | Process @var{file} as input before processing the regular input file. | |
2291 | In effect, the contents of @var{file} are compiled first. Any @samp{-D} | |
2292 | and @samp{-U} options on the command line are always processed before | |
2293 | @samp{-include @var{file}}, regardless of the order in which they are | |
2294 | written. All the @samp{-include} and @samp{-imacros} options are | |
2295 | processed in the order in which they are written. | |
2296 | ||
2297 | @item -imacros @var{file} | |
2298 | Process @var{file} as input, discarding the resulting output, before | |
2299 | processing the regular input file. Because the output generated from | |
2300 | @var{file} is discarded, the only effect of @samp{-imacros @var{file}} | |
2301 | is to make the macros defined in @var{file} available for use in the | |
2302 | main input. | |
2303 | ||
2304 | Any @samp{-D} and @samp{-U} options on the command line are always | |
2305 | processed before @samp{-imacros @var{file}}, regardless of the order in | |
2306 | which they are written. All the @samp{-include} and @samp{-imacros} | |
2307 | options are processed in the order in which they are written. | |
2308 | ||
2309 | @item -idirafter @var{dir} | |
2310 | @cindex second include path | |
2311 | Add the directory @var{dir} to the second include path. The directories | |
2312 | on the second include path are searched when a header file is not found | |
2313 | in any of the directories in the main include path (the one that | |
2314 | @samp{-I} adds to). | |
2315 | ||
2316 | @item -iprefix @var{prefix} | |
2317 | Specify @var{prefix} as the prefix for subsequent @samp{-iwithprefix} | |
2318 | options. | |
2319 | ||
2320 | @item -iwithprefix @var{dir} | |
2321 | Add a directory to the second include path. The directory's name is | |
2322 | made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was | |
2323 | specified previously with @samp{-iprefix}. If you have not specified a | |
2324 | prefix yet, the directory containing the installed passes of the | |
2325 | compiler is used as the default. | |
2326 | ||
2327 | @item -iwithprefixbefore @var{dir} | |
2328 | Add a directory to the main include path. The directory's name is made | |
2329 | by concatenating @var{prefix} and @var{dir}, as in the case of | |
2330 | @samp{-iwithprefix}. | |
2331 | ||
2332 | @item -isystem @var{dir} | |
2333 | Add a directory to the beginning of the second include path, marking it | |
2334 | as a system directory, so that it gets the same special treatment as | |
2335 | is applied to the standard system directories. | |
2336 | ||
2337 | @item -nostdinc | |
2338 | Do not search the standard system directories for header files. Only | |
2339 | the directories you have specified with @samp{-I} options (and the | |
2340 | current directory, if appropriate) are searched. @xref{Directory | |
2341 | Options}, for information on @samp{-I}. | |
2342 | ||
2343 | By using both @samp{-nostdinc} and @samp{-I-}, you can limit the include-file | |
2344 | search path to only those directories you specify explicitly. | |
2345 | ||
2346 | @item -undef | |
2347 | Do not predefine any nonstandard macros. (Including architecture flags). | |
2348 | ||
2349 | @item -E | |
2350 | Run only the C preprocessor. Preprocess all the C source files | |
2351 | specified and output the results to standard output or to the | |
2352 | specified output file. | |
2353 | ||
2354 | @item -C | |
2355 | Tell the preprocessor not to discard comments. Used with the | |
2356 | @samp{-E} option. | |
2357 | ||
2358 | @item -P | |
2359 | Tell the preprocessor not to generate @samp{#line} directives. | |
2360 | Used with the @samp{-E} option. | |
2361 | ||
2362 | @cindex make | |
2363 | @cindex dependencies, make | |
2364 | @item -M | |
2365 | Tell the preprocessor to output a rule suitable for @code{make} | |
2366 | describing the dependencies of each object file. For each source file, | |
2367 | the preprocessor outputs one @code{make}-rule whose target is the object | |
2368 | file name for that source file and whose dependencies are all the | |
2369 | @code{#include} header files it uses. This rule may be a single line or | |
2370 | may be continued with @samp{\}-newline if it is long. The list of rules | |
2371 | is printed on standard output instead of the preprocessed C program. | |
2372 | ||
2373 | @samp{-M} implies @samp{-E}. | |
2374 | ||
2375 | Another way to specify output of a @code{make} rule is by setting | |
2376 | the environment variable @code{DEPENDENCIES_OUTPUT} (@pxref{Environment | |
2377 | Variables}). | |
2378 | ||
2379 | @item -MM | |
2380 | Like @samp{-M} but the output mentions only the user header files | |
2381 | included with @samp{#include "@var{file}"}. System header files | |
2382 | included with @samp{#include <@var{file}>} are omitted. | |
2383 | ||
2384 | @item -MD | |
2385 | Like @samp{-M} but the dependency information is written to a file made by | |
2386 | replacing ".c" with ".d" at the end of the input file names. | |
2387 | This is in addition to compiling the file as specified---@samp{-MD} does | |
2388 | not inhibit ordinary compilation the way @samp{-M} does. | |
2389 | ||
2390 | In Mach, you can use the utility @code{md} to merge multiple dependency | |
2391 | files into a single dependency file suitable for using with the @samp{make} | |
2392 | command. | |
2393 | ||
2394 | @item -MMD | |
2395 | Like @samp{-MD} except mention only user header files, not system | |
2396 | header files. | |
2397 | ||
2398 | @item -MG | |
2399 | Treat missing header files as generated files and assume they live in the | |
2400 | same directory as the source file. If you specify @samp{-MG}, you | |
2401 | must also specify either @samp{-M} or @samp{-MM}. @samp{-MG} is not | |
2402 | supported with @samp{-MD} or @samp{-MMD}. | |
2403 | ||
2404 | @item -H | |
2405 | Print the name of each header file used, in addition to other normal | |
2406 | activities. | |
2407 | ||
2408 | @item -A@var{question}(@var{answer}) | |
2409 | Assert the answer @var{answer} for @var{question}, in case it is tested | |
2410 | with a preprocessing conditional such as @samp{#if | |
2411 | #@var{question}(@var{answer})}. @samp{-A-} disables the standard | |
2412 | assertions that normally describe the target machine. | |
2413 | ||
2414 | @item -D@var{macro} | |
2415 | Define macro @var{macro} with the string @samp{1} as its definition. | |
2416 | ||
2417 | @item -D@var{macro}=@var{defn} | |
2418 | Define macro @var{macro} as @var{defn}. All instances of @samp{-D} on | |
2419 | the command line are processed before any @samp{-U} options. | |
2420 | ||
2421 | @item -U@var{macro} | |
2422 | Undefine macro @var{macro}. @samp{-U} options are evaluated after all | |
2423 | @samp{-D} options, but before any @samp{-include} and @samp{-imacros} | |
2424 | options. | |
2425 | ||
2426 | @item -dM | |
2427 | Tell the preprocessor to output only a list of the macro definitions | |
2428 | that are in effect at the end of preprocessing. Used with the @samp{-E} | |
2429 | option. | |
2430 | ||
2431 | @item -dD | |
2432 | Tell the preprocessing to pass all macro definitions into the output, in | |
2433 | their proper sequence in the rest of the output. | |
2434 | ||
2435 | @item -dN | |
2436 | Like @samp{-dD} except that the macro arguments and contents are omitted. | |
2437 | Only @samp{#define @var{name}} is included in the output. | |
2438 | ||
2439 | @item -trigraphs | |
2440 | Support ANSI C trigraphs. The @samp{-ansi} option also has this effect. | |
2441 | ||
2442 | @item -Wp,@var{option} | |
2443 | Pass @var{option} as an option to the preprocessor. If @var{option} | |
2444 | contains commas, it is split into multiple options at the commas. | |
2445 | @end table | |
2446 | ||
2447 | @node Assembler Options | |
2448 | @section Passing Options to the Assembler | |
2449 | ||
2450 | @c prevent bad page break with this line | |
2451 | You can pass options to the assembler. | |
2452 | ||
2453 | @table @code | |
2454 | @item -Wa,@var{option} | |
2455 | Pass @var{option} as an option to the assembler. If @var{option} | |
2456 | contains commas, it is split into multiple options at the commas. | |
2457 | @end table | |
2458 | ||
2459 | @node Link Options | |
2460 | @section Options for Linking | |
2461 | @cindex link options | |
2462 | @cindex options, linking | |
2463 | ||
2464 | These options come into play when the compiler links object files into | |
2465 | an executable output file. They are meaningless if the compiler is | |
2466 | not doing a link step. | |
2467 | ||
2468 | @table @code | |
2469 | @cindex file names | |
2470 | @item @var{object-file-name} | |
2471 | A file name that does not end in a special recognized suffix is | |
2472 | considered to name an object file or library. (Object files are | |
2473 | distinguished from libraries by the linker according to the file | |
2474 | contents.) If linking is done, these object files are used as input | |
2475 | to the linker. | |
2476 | ||
2477 | @item -c | |
2478 | @itemx -S | |
2479 | @itemx -E | |
2480 | If any of these options is used, then the linker is not run, and | |
2481 | object file names should not be used as arguments. @xref{Overall | |
2482 | Options}. | |
2483 | ||
2484 | @cindex Libraries | |
2485 | @item -l@var{library} | |
2486 | Search the library named @var{library} when linking. | |
2487 | ||
2488 | It makes a difference where in the command you write this option; the | |
2489 | linker searches processes libraries and object files in the order they | |
2490 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
2491 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
2492 | to functions in @samp{z}, those functions may not be loaded. | |
2493 | ||
2494 | The linker searches a standard list of directories for the library, | |
2495 | which is actually a file named @file{lib@var{library}.a}. The linker | |
2496 | then uses this file as if it had been specified precisely by name. | |
2497 | ||
2498 | The directories searched include several standard system directories | |
2499 | plus any that you specify with @samp{-L}. | |
2500 | ||
2501 | Normally the files found this way are library files---archive files | |
2502 | whose members are object files. The linker handles an archive file by | |
2503 | scanning through it for members which define symbols that have so far | |
2504 | been referenced but not defined. But if the file that is found is an | |
2505 | ordinary object file, it is linked in the usual fashion. The only | |
2506 | difference between using an @samp{-l} option and specifying a file name | |
2507 | is that @samp{-l} surrounds @var{library} with @samp{lib} and @samp{.a} | |
2508 | and searches several directories. | |
2509 | ||
2510 | @item -lobjc | |
2511 | You need this special case of the @samp{-l} option in order to | |
2512 | link an Objective C program. | |
2513 | ||
2514 | @item -nostartfiles | |
2515 | Do not use the standard system startup files when linking. | |
2516 | The standard system libraries are used normally, unless @code{-nostdlib} | |
2517 | or @code{-nodefaultlibs} is used. | |
2518 | ||
2519 | @item -nodefaultlibs | |
2520 | Do not use the standard system libraries when linking. | |
2521 | Only the libraries you specify will be passed to the linker. | |
2522 | The standard startup files are used normally, unless @code{-nostartfiles} | |
2523 | is used. | |
2524 | ||
2525 | @item -nostdlib | |
2526 | Do not use the standard system startup files or libraries when linking. | |
2527 | No startup files and only the libraries you specify will be passed to | |
2528 | the linker. | |
2529 | ||
2530 | @cindex @code{-lgcc}, use with @code{-nostdlib} | |
2531 | @cindex @code{-nostdlib} and unresolved references | |
2532 | @cindex unresolved references and @code{-nostdlib} | |
2533 | @cindex @code{-lgcc}, use with @code{-nodefaultlibs} | |
2534 | @cindex @code{-nodefaultlibs} and unresolved references | |
2535 | @cindex unresolved references and @code{-nodefaultlibs} | |
2536 | One of the standard libraries bypassed by @samp{-nostdlib} and | |
2537 | @samp{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
2538 | that GNU CC uses to overcome shortcomings of particular machines, or special | |
2539 | needs for some languages. | |
2540 | @ifset INTERNALS | |
2541 | (@xref{Interface,,Interfacing to GNU CC Output}, for more discussion of | |
2542 | @file{libgcc.a}.) | |
2543 | @end ifset | |
2544 | @ifclear INTERNALS | |
2545 | (@xref{Interface,,Interfacing to GNU CC Output,gcc.info,Porting GNU CC}, | |
2546 | for more discussion of @file{libgcc.a}.) | |
2547 | @end ifclear | |
2548 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
2549 | other standard libraries. In other words, when you specify @samp{-nostdlib} | |
2550 | or @samp{-nodefaultlibs} you should usually specify @samp{-lgcc} as well. | |
2551 | This ensures that you have no unresolved references to internal GNU CC | |
2552 | library subroutines. (For example, @samp{__main}, used to ensure C++ | |
2553 | constructors will be called; @pxref{Collect2,,@code{collect2}}.) | |
2554 | ||
2555 | @item -s | |
2556 | Remove all symbol table and relocation information from the executable. | |
2557 | ||
2558 | @item -static | |
2559 | On systems that support dynamic linking, this prevents linking with the shared | |
2560 | libraries. On other systems, this option has no effect. | |
2561 | ||
2562 | @item -shared | |
2563 | Produce a shared object which can then be linked with other objects to | |
2564 | form an executable. Not all systems support this option. You must | |
2565 | also specify @samp{-fpic} or @samp{-fPIC} on some systems when | |
2566 | you specify this option. | |
2567 | ||
2568 | @item -symbolic | |
2569 | Bind references to global symbols when building a shared object. Warn | |
2570 | about any unresolved references (unless overridden by the link editor | |
2571 | option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support | |
2572 | this option. | |
2573 | ||
2574 | @item -Xlinker @var{option} | |
2575 | Pass @var{option} as an option to the linker. You can use this to | |
2576 | supply system-specific linker options which GNU CC does not know how to | |
2577 | recognize. | |
2578 | ||
2579 | If you want to pass an option that takes an argument, you must use | |
2580 | @samp{-Xlinker} twice, once for the option and once for the argument. | |
2581 | For example, to pass @samp{-assert definitions}, you must write | |
2582 | @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
2583 | @samp{-Xlinker "-assert definitions"}, because this passes the entire | |
2584 | string as a single argument, which is not what the linker expects. | |
2585 | ||
2586 | @item -Wl,@var{option} | |
2587 | Pass @var{option} as an option to the linker. If @var{option} contains | |
2588 | commas, it is split into multiple options at the commas. | |
2589 | ||
2590 | @item -u @var{symbol} | |
2591 | Pretend the symbol @var{symbol} is undefined, to force linking of | |
2592 | library modules to define it. You can use @samp{-u} multiple times with | |
2593 | different symbols to force loading of additional library modules. | |
2594 | @end table | |
2595 | ||
2596 | @node Directory Options | |
2597 | @section Options for Directory Search | |
2598 | @cindex directory options | |
2599 | @cindex options, directory search | |
2600 | @cindex search path | |
2601 | ||
2602 | These options specify directories to search for header files, for | |
2603 | libraries and for parts of the compiler: | |
2604 | ||
2605 | @table @code | |
2606 | @item -I@var{dir} | |
861bb6c1 JL |
2607 | Add the directory @var{dir} to the head of the list of directories to be |
2608 | searched for header files. This can be used to override a system header | |
2609 | file, substituting your own version, since these directories are | |
74291a4b MM |
2610 | searched before the system header file directories. If you use more |
2611 | than one @samp{-I} option, the directories are scanned in left-to-right | |
2612 | order; the standard system directories come after. | |
2613 | ||
2614 | @item -I- | |
2615 | Any directories you specify with @samp{-I} options before the @samp{-I-} | |
2616 | option are searched only for the case of @samp{#include "@var{file}"}; | |
2617 | they are not searched for @samp{#include <@var{file}>}. | |
2618 | ||
2619 | If additional directories are specified with @samp{-I} options after | |
2620 | the @samp{-I-}, these directories are searched for all @samp{#include} | |
2621 | directives. (Ordinarily @emph{all} @samp{-I} directories are used | |
2622 | this way.) | |
2623 | ||
2624 | In addition, the @samp{-I-} option inhibits the use of the current | |
2625 | directory (where the current input file came from) as the first search | |
2626 | directory for @samp{#include "@var{file}"}. There is no way to | |
2627 | override this effect of @samp{-I-}. With @samp{-I.} you can specify | |
2628 | searching the directory which was current when the compiler was | |
2629 | invoked. That is not exactly the same as what the preprocessor does | |
2630 | by default, but it is often satisfactory. | |
2631 | ||
2632 | @samp{-I-} does not inhibit the use of the standard system directories | |
2633 | for header files. Thus, @samp{-I-} and @samp{-nostdinc} are | |
2634 | independent. | |
2635 | ||
2636 | @item -L@var{dir} | |
2637 | Add directory @var{dir} to the list of directories to be searched | |
2638 | for @samp{-l}. | |
2639 | ||
2640 | @item -B@var{prefix} | |
2641 | This option specifies where to find the executables, libraries, | |
2642 | include files, and data files of the compiler itself. | |
2643 | ||
2644 | The compiler driver program runs one or more of the subprograms | |
2645 | @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries | |
2646 | @var{prefix} as a prefix for each program it tries to run, both with and | |
2647 | without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}). | |
2648 | ||
2649 | For each subprogram to be run, the compiler driver first tries the | |
2650 | @samp{-B} prefix, if any. If that name is not found, or if @samp{-B} | |
2651 | was not specified, the driver tries two standard prefixes, which are | |
2652 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of | |
2653 | those results in a file name that is found, the unmodified program | |
2654 | name is searched for using the directories specified in your | |
2655 | @samp{PATH} environment variable. | |
2656 | ||
2657 | @samp{-B} prefixes that effectively specify directory names also apply | |
2658 | to libraries in the linker, because the compiler translates these | |
2659 | options into @samp{-L} options for the linker. They also apply to | |
2660 | includes files in the preprocessor, because the compiler translates these | |
2661 | options into @samp{-isystem} options for the preprocessor. In this case, | |
2662 | the compiler appends @samp{include} to the prefix. | |
2663 | ||
2664 | The run-time support file @file{libgcc.a} can also be searched for using | |
2665 | the @samp{-B} prefix, if needed. If it is not found there, the two | |
2666 | standard prefixes above are tried, and that is all. The file is left | |
2667 | out of the link if it is not found by those means. | |
2668 | ||
2669 | Another way to specify a prefix much like the @samp{-B} prefix is to use | |
2670 | the environment variable @code{GCC_EXEC_PREFIX}. @xref{Environment | |
2671 | Variables}. | |
861bb6c1 JL |
2672 | |
2673 | @item -specs=@var{file} | |
2674 | Process @var{file} after the compiler reads in the standard @file{specs} | |
2675 | file, in order to override the defaults that the @file{gcc} driver | |
2676 | program uses when determining what switches to pass to @file{cc1}, | |
2677 | @file{cc1plus}, @file{as}, @file{ld}, etc. More than one | |
2678 | @samp{-specs=}@var{file} can be specified on the command line, and they | |
2679 | are processed in order, from left to right. | |
74291a4b MM |
2680 | @end table |
2681 | ||
2682 | @node Target Options | |
2683 | @section Specifying Target Machine and Compiler Version | |
2684 | @cindex target options | |
2685 | @cindex cross compiling | |
2686 | @cindex specifying machine version | |
2687 | @cindex specifying compiler version and target machine | |
2688 | @cindex compiler version, specifying | |
2689 | @cindex target machine, specifying | |
2690 | ||
2691 | By default, GNU CC compiles code for the same type of machine that you | |
2692 | are using. However, it can also be installed as a cross-compiler, to | |
2693 | compile for some other type of machine. In fact, several different | |
2694 | configurations of GNU CC, for different target machines, can be | |
2695 | installed side by side. Then you specify which one to use with the | |
2696 | @samp{-b} option. | |
2697 | ||
2698 | In addition, older and newer versions of GNU CC can be installed side | |
2699 | by side. One of them (probably the newest) will be the default, but | |
2700 | you may sometimes wish to use another. | |
2701 | ||
2702 | @table @code | |
2703 | @item -b @var{machine} | |
2704 | The argument @var{machine} specifies the target machine for compilation. | |
2705 | This is useful when you have installed GNU CC as a cross-compiler. | |
2706 | ||
2707 | The value to use for @var{machine} is the same as was specified as the | |
2708 | machine type when configuring GNU CC as a cross-compiler. For | |
2709 | example, if a cross-compiler was configured with @samp{configure | |
2710 | i386v}, meaning to compile for an 80386 running System V, then you | |
2711 | would specify @samp{-b i386v} to run that cross compiler. | |
2712 | ||
2713 | When you do not specify @samp{-b}, it normally means to compile for | |
2714 | the same type of machine that you are using. | |
2715 | ||
2716 | @item -V @var{version} | |
2717 | The argument @var{version} specifies which version of GNU CC to run. | |
2718 | This is useful when multiple versions are installed. For example, | |
2719 | @var{version} might be @samp{2.0}, meaning to run GNU CC version 2.0. | |
2720 | ||
2721 | The default version, when you do not specify @samp{-V}, is the last | |
2722 | version of GNU CC that you installed. | |
2723 | @end table | |
2724 | ||
2725 | The @samp{-b} and @samp{-V} options actually work by controlling part of | |
2726 | the file name used for the executable files and libraries used for | |
2727 | compilation. A given version of GNU CC, for a given target machine, is | |
2728 | normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}.@refill | |
2729 | ||
2730 | Thus, sites can customize the effect of @samp{-b} or @samp{-V} either by | |
2731 | changing the names of these directories or adding alternate names (or | |
2732 | symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the | |
2733 | file @file{80386} is a link to the file @file{i386v}, then @samp{-b | |
2734 | 80386} becomes an alias for @samp{-b i386v}. | |
2735 | ||
2736 | In one respect, the @samp{-b} or @samp{-V} do not completely change | |
2737 | to a different compiler: the top-level driver program @code{gcc} | |
2738 | that you originally invoked continues to run and invoke the other | |
2739 | executables (preprocessor, compiler per se, assembler and linker) | |
2740 | that do the real work. However, since no real work is done in the | |
2741 | driver program, it usually does not matter that the driver program | |
2742 | in use is not the one for the specified target and version. | |
2743 | ||
2744 | The only way that the driver program depends on the target machine is | |
2745 | in the parsing and handling of special machine-specific options. | |
2746 | However, this is controlled by a file which is found, along with the | |
2747 | other executables, in the directory for the specified version and | |
2748 | target machine. As a result, a single installed driver program adapts | |
2749 | to any specified target machine and compiler version. | |
2750 | ||
2751 | The driver program executable does control one significant thing, | |
2752 | however: the default version and target machine. Therefore, you can | |
2753 | install different instances of the driver program, compiled for | |
2754 | different targets or versions, under different names. | |
2755 | ||
2756 | For example, if the driver for version 2.0 is installed as @code{ogcc} | |
2757 | and that for version 2.1 is installed as @code{gcc}, then the command | |
2758 | @code{gcc} will use version 2.1 by default, while @code{ogcc} will use | |
2759 | 2.0 by default. However, you can choose either version with either | |
2760 | command with the @samp{-V} option. | |
2761 | ||
2762 | @node Submodel Options | |
2763 | @section Hardware Models and Configurations | |
2764 | @cindex submodel options | |
2765 | @cindex specifying hardware config | |
2766 | @cindex hardware models and configurations, specifying | |
2767 | @cindex machine dependent options | |
2768 | ||
2769 | Earlier we discussed the standard option @samp{-b} which chooses among | |
2770 | different installed compilers for completely different target | |
2771 | machines, such as Vax vs. 68000 vs. 80386. | |
2772 | ||
2773 | In addition, each of these target machine types can have its own | |
2774 | special options, starting with @samp{-m}, to choose among various | |
2775 | hardware models or configurations---for example, 68010 vs 68020, | |
2776 | floating coprocessor or none. A single installed version of the | |
2777 | compiler can compile for any model or configuration, according to the | |
2778 | options specified. | |
2779 | ||
2780 | Some configurations of the compiler also support additional special | |
2781 | options, usually for compatibility with other compilers on the same | |
2782 | platform. | |
2783 | ||
2784 | @ifset INTERNALS | |
2785 | These options are defined by the macro @code{TARGET_SWITCHES} in the | |
2786 | machine description. The default for the options is also defined by | |
2787 | that macro, which enables you to change the defaults. | |
2788 | @end ifset | |
2789 | ||
2790 | @menu | |
2791 | * M680x0 Options:: | |
2792 | * VAX Options:: | |
2793 | * SPARC Options:: | |
2794 | * Convex Options:: | |
2795 | * AMD29K Options:: | |
2796 | * ARM Options:: | |
861bb6c1 | 2797 | * M32R/D Options:: |
74291a4b MM |
2798 | * M88K Options:: |
2799 | * RS/6000 and PowerPC Options:: | |
2800 | * RT Options:: | |
2801 | * MIPS Options:: | |
2802 | * i386 Options:: | |
2803 | * HPPA Options:: | |
2804 | * Intel 960 Options:: | |
2805 | * DEC Alpha Options:: | |
2806 | * Clipper Options:: | |
2807 | * H8/300 Options:: | |
2808 | * SH Options:: | |
2809 | * System V Options:: | |
f84271d9 | 2810 | * V850 Options:: |
74291a4b MM |
2811 | @end menu |
2812 | ||
2813 | @node M680x0 Options | |
2814 | @subsection M680x0 Options | |
2815 | @cindex M680x0 options | |
2816 | ||
2817 | These are the @samp{-m} options defined for the 68000 series. The default | |
2818 | values for these options depends on which style of 68000 was selected when | |
2819 | the compiler was configured; the defaults for the most common choices are | |
2820 | given below. | |
2821 | ||
2822 | @table @code | |
2823 | @item -m68000 | |
2824 | @itemx -mc68000 | |
2825 | Generate output for a 68000. This is the default | |
2826 | when the compiler is configured for 68000-based systems. | |
2827 | ||
2828 | @item -m68020 | |
2829 | @itemx -mc68020 | |
2830 | Generate output for a 68020. This is the default | |
2831 | when the compiler is configured for 68020-based systems. | |
2832 | ||
2833 | @item -m68881 | |
2834 | Generate output containing 68881 instructions for floating point. | |
2835 | This is the default for most 68020 systems unless @samp{-nfp} was | |
2836 | specified when the compiler was configured. | |
2837 | ||
2838 | @item -m68030 | |
2839 | Generate output for a 68030. This is the default when the compiler is | |
2840 | configured for 68030-based systems. | |
2841 | ||
2842 | @item -m68040 | |
2843 | Generate output for a 68040. This is the default when the compiler is | |
2844 | configured for 68040-based systems. | |
2845 | ||
2846 | This option inhibits the use of 68881/68882 instructions that have to be | |
2847 | emulated by software on the 68040. If your 68040 does not have code to | |
2848 | emulate those instructions, use @samp{-m68040}. | |
2849 | ||
2850 | @item -m68060 | |
2851 | Generate output for a 68060. This is the default when the compiler is | |
2852 | configured for 68060-based systems. | |
2853 | ||
2854 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
2855 | have to be emulated by software on the 68060. If your 68060 does not | |
2856 | have code to emulate those instructions, use @samp{-m68060}. | |
2857 | ||
2858 | @item -m5200 | |
2859 | Generate output for a 520X "coldfire" family cpu. This is the default | |
2860 | when the compiler is configured for 520X-based systems. | |
2861 | ||
2862 | ||
2863 | @item -m68020-40 | |
2864 | Generate output for a 68040, without using any of the new instructions. | |
2865 | This results in code which can run relatively efficiently on either a | |
2866 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
2867 | 68881 instructions that are emulated on the 68040. | |
2868 | ||
861bb6c1 JL |
2869 | @item -m68020-60 |
2870 | Generate output for a 68060, without using any of the new instructions. | |
2871 | This results in code which can run relatively efficiently on either a | |
2872 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
2873 | 68881 instructions that are emulated on the 68060. | |
2874 | ||
74291a4b MM |
2875 | @item -mfpa |
2876 | Generate output containing Sun FPA instructions for floating point. | |
2877 | ||
2878 | @item -msoft-float | |
2879 | Generate output containing library calls for floating point. | |
2880 | @strong{Warning:} the requisite libraries are not available for all m68k | |
2881 | targets. Normally the facilities of the machine's usual C compiler are | |
2882 | used, but this can't be done directly in cross-compilation. You must | |
2883 | make your own arrangements to provide suitable library functions for | |
2884 | cross-compilation. The embedded targets @samp{m68k-*-aout} and | |
2885 | @samp{m68k-*-coff} do provide software floating point support. | |
2886 | ||
2887 | @item -mshort | |
2888 | Consider type @code{int} to be 16 bits wide, like @code{short int}. | |
2889 | ||
2890 | @item -mnobitfield | |
2891 | Do not use the bit-field instructions. The @samp{-m68000} option | |
2892 | implies @w{@samp{-mnobitfield}}. | |
2893 | ||
2894 | @item -mbitfield | |
2895 | Do use the bit-field instructions. The @samp{-m68020} option implies | |
2896 | @samp{-mbitfield}. This is the default if you use a configuration | |
2897 | designed for a 68020. | |
2898 | ||
2899 | @item -mrtd | |
2900 | Use a different function-calling convention, in which functions | |
2901 | that take a fixed number of arguments return with the @code{rtd} | |
2902 | instruction, which pops their arguments while returning. This | |
2903 | saves one instruction in the caller since there is no need to pop | |
2904 | the arguments there. | |
2905 | ||
2906 | This calling convention is incompatible with the one normally | |
2907 | used on Unix, so you cannot use it if you need to call libraries | |
2908 | compiled with the Unix compiler. | |
2909 | ||
2910 | Also, you must provide function prototypes for all functions that | |
2911 | take variable numbers of arguments (including @code{printf}); | |
2912 | otherwise incorrect code will be generated for calls to those | |
2913 | functions. | |
2914 | ||
2915 | In addition, seriously incorrect code will result if you call a | |
2916 | function with too many arguments. (Normally, extra arguments are | |
2917 | harmlessly ignored.) | |
2918 | ||
2919 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
2920 | 68040, and 68060 processors, but not by the 68000 or 5200. | |
861bb6c1 JL |
2921 | |
2922 | @item -malign-int | |
2923 | @itemx -mno-align-int | |
2924 | Control whether GNU CC aligns @code{int}, @code{long}, @code{long long}, | |
2925 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
2926 | boundary (@samp{-malign-int}) or a 16-bit boundary (@samp{-mno-align-int}). | |
2927 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
2928 | faster on processors with 32-bit busses at the expense of more memory. | |
2929 | ||
2930 | @strong{Warning:} if you use the @samp{-malign-int} switch, GNU CC will | |
2931 | align structures containing the above types differently than | |
2932 | most published application binary interface specifications for the m68k. | |
2933 | ||
74291a4b MM |
2934 | @end table |
2935 | ||
2936 | @node VAX Options | |
2937 | @subsection VAX Options | |
2938 | @cindex VAX options | |
2939 | ||
2940 | These @samp{-m} options are defined for the Vax: | |
2941 | ||
2942 | @table @code | |
2943 | @item -munix | |
2944 | Do not output certain jump instructions (@code{aobleq} and so on) | |
2945 | that the Unix assembler for the Vax cannot handle across long | |
2946 | ranges. | |
2947 | ||
2948 | @item -mgnu | |
2949 | Do output those jump instructions, on the assumption that you | |
2950 | will assemble with the GNU assembler. | |
2951 | ||
2952 | @item -mg | |
2953 | Output code for g-format floating point numbers instead of d-format. | |
2954 | @end table | |
2955 | ||
2956 | @node SPARC Options | |
2957 | @subsection SPARC Options | |
2958 | @cindex SPARC options | |
2959 | ||
2960 | These @samp{-m} switches are supported on the SPARC: | |
2961 | ||
2962 | @table @code | |
2963 | @item -mno-app-regs | |
2964 | @itemx -mapp-regs | |
2965 | Specify @samp{-mapp-regs} to generate output using the global registers | |
2966 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. This | |
2967 | is the default. | |
2968 | ||
2969 | To be fully SVR4 ABI compliant at the cost of some performance loss, | |
2970 | specify @samp{-mno-app-regs}. You should compile libraries and system | |
2971 | software with this option. | |
2972 | ||
2973 | @item -mfpu | |
2974 | @itemx -mhard-float | |
2975 | Generate output containing floating point instructions. This is the | |
2976 | default. | |
2977 | ||
2978 | @item -mno-fpu | |
2979 | @itemx -msoft-float | |
2980 | Generate output containing library calls for floating point. | |
2981 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
2982 | targets. Normally the facilities of the machine's usual C compiler are | |
2983 | used, but this cannot be done directly in cross-compilation. You must make | |
2984 | your own arrangements to provide suitable library functions for | |
2985 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
2986 | @samp{sparclite-*-*} do provide software floating point support. | |
2987 | ||
2988 | @samp{-msoft-float} changes the calling convention in the output file; | |
2989 | therefore, it is only useful if you compile @emph{all} of a program with | |
2990 | this option. In particular, you need to compile @file{libgcc.a}, the | |
2991 | library that comes with GNU CC, with @samp{-msoft-float} in order for | |
2992 | this to work. | |
2993 | ||
2994 | @item -mhard-quad-float | |
2995 | Generate output containing quad-word (long double) floating point | |
2996 | instructions. | |
2997 | ||
2998 | @item -msoft-quad-float | |
2999 | Generate output containing library calls for quad-word (long double) | |
3000 | floating point instructions. The functions called are those specified | |
3001 | in the SPARC ABI. This is the default. | |
3002 | ||
3003 | As of this writing, there are no sparc implementations that have hardware | |
3004 | support for the quad-word floating point instructions. They all invoke | |
3005 | a trap handler for one of these instructions, and then the trap handler | |
3006 | emulates the effect of the instruction. Because of the trap handler overhead, | |
3007 | this is much slower than calling the ABI library routines. Thus the | |
3008 | @samp{-msoft-quad-float} option is the default. | |
3009 | ||
3010 | @item -mno-epilogue | |
3011 | @itemx -mepilogue | |
3012 | With @samp{-mepilogue} (the default), the compiler always emits code for | |
3013 | function exit at the end of each function. Any function exit in | |
3014 | the middle of the function (such as a return statement in C) will | |
3015 | generate a jump to the exit code at the end of the function. | |
3016 | ||
3017 | With @samp{-mno-epilogue}, the compiler tries to emit exit code inline | |
3018 | at every function exit. | |
3019 | ||
3020 | @item -mno-flat | |
3021 | @itemx -mflat | |
3022 | With @samp{-mflat}, the compiler does not generate save/restore instructions | |
3023 | and will use a "flat" or single register window calling convention. | |
3024 | This model uses %i7 as the frame pointer and is compatible with the normal | |
3025 | register window model. Code from either may be intermixed. | |
3026 | The local registers and the input registers (0-5) are still treated as | |
3027 | "call saved" registers and will be saved on the stack as necessary. | |
3028 | ||
3029 | With @samp{-mno-flat} (the default), the compiler emits save/restore | |
3030 | instructions (except for leaf functions) and is the normal mode of operation. | |
3031 | ||
3032 | @item -mno-unaligned-doubles | |
3033 | @itemx -munaligned-doubles | |
3034 | Assume that doubles have 8 byte alignment. This is the default. | |
3035 | ||
3036 | With @samp{-munaligned-doubles}, GNU CC assumes that doubles have 8 byte | |
3037 | alignment only if they are contained in another type, or if they have an | |
3038 | absolute address. Otherwise, it assumes they have 4 byte alignment. | |
3039 | Specifying this option avoids some rare compatibility problems with code | |
3040 | generated by other compilers. It is not the default because it results | |
3041 | in a performance loss, especially for floating point code. | |
3042 | ||
3043 | @item -mv8 | |
3044 | @itemx -msparclite | |
3045 | These two options select variations on the SPARC architecture. | |
3046 | ||
3047 | By default (unless specifically configured for the Fujitsu SPARClite), | |
3048 | GCC generates code for the v7 variant of the SPARC architecture. | |
3049 | ||
3050 | @samp{-mv8} will give you SPARC v8 code. The only difference from v7 | |
3051 | code is that the compiler emits the integer multiply and integer | |
3052 | divide instructions which exist in SPARC v8 but not in SPARC v7. | |
3053 | ||
3054 | @samp{-msparclite} will give you SPARClite code. This adds the integer | |
3055 | multiply, integer divide step and scan (@code{ffs}) instructions which | |
3056 | exist in SPARClite but not in SPARC v7. | |
3057 | ||
3058 | These options are deprecated and will be deleted in GNU CC 2.9. | |
3059 | They have been replaced with @samp{-mcpu=xxx}. | |
3060 | ||
3061 | @item -mcypress | |
3062 | @itemx -msupersparc | |
3063 | These two options select the processor for which the code is optimised. | |
3064 | ||
3065 | With @samp{-mcypress} (the default), the compiler optimizes code for the | |
3066 | Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series. | |
3067 | This is also appropriate for the older SparcStation 1, 2, IPX etc. | |
3068 | ||
3069 | With @samp{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as | |
3070 | used in the SparcStation 10, 1000 and 2000 series. This flag also enables use | |
3071 | of the full SPARC v8 instruction set. | |
3072 | ||
3073 | These options are deprecated and will be deleted in GNU CC 2.9. | |
3074 | They have been replaced with @samp{-mcpu=xxx}. | |
3075 | ||
3076 | @item -mcpu=@var{cpu_type} | |
3077 | Set architecture type and instruction scheduling parameters for machine | |
3078 | type @var{cpu_type}. Supported values for @var{cpu_type} are | |
3079 | @samp{common}, @samp{cypress}, @samp{v8}, @samp{supersparc}, | |
3080 | @samp{sparclite}, @samp{f930}, @samp{f934}, | |
3081 | @samp{sparclet}, @samp{90c701}, @samp{v8plus}, @samp{v9}, | |
3082 | and @samp{ultrasparc}. Specifying @samp{v9} is only supported on true | |
3083 | 64 bit targets. | |
3084 | ||
3085 | @item -mtune=@var{cpu_type} | |
3086 | Set the instruction scheduling parameters for machine type | |
3087 | @var{cpu_type}, but do not set the architecture type as the option | |
3088 | @samp{-mcpu=}@var{cpu_type} would. The same values for | |
3089 | @samp{-mcpu=}@var{cpu_type} are used for @samp{-tune=}@var{cpu_type}. | |
3090 | ||
6d4312dd DE |
3091 | @item -malign-loops=@var{num} |
3092 | Align loops to a 2 raised to a @var{num} byte boundary. If | |
3093 | @samp{-malign-loops} is not specified, the default is 2. | |
3094 | ||
3095 | @item -malign-jumps=@var{num} | |
3096 | Align instructions that are only jumped to to a 2 raised to a @var{num} | |
3097 | byte boundary. If @samp{-malign-jumps} is not specified, the default is 2. | |
3098 | ||
3099 | @item -malign-functions=@var{num} | |
3100 | Align the start of functions to a 2 raised to @var{num} byte boundary. | |
3101 | If @samp{-malign-functions} is not specified, the default is 2 if compiling | |
3102 | for 32 bit sparc, and 5 if compiling for 64 bit sparc. | |
3103 | ||
74291a4b MM |
3104 | @end table |
3105 | ||
3106 | These @samp{-m} switches are supported in addition to the above | |
3107 | on the SPARCLET processor. | |
3108 | ||
3109 | @table @code | |
3110 | @item -mlittle-endian | |
3111 | Generate code for a processor running in little-endian mode. | |
3112 | ||
3113 | @item -mlive-g0 | |
3114 | Treat register @code{%g0} as a normal register. | |
3115 | GCC will continue to clobber it as necessary but will not assume | |
3116 | it always reads as 0. | |
3117 | ||
3118 | @item -mbroken-saverestore | |
3119 | Generate code that does not use non-trivial forms of the @code{save} and | |
3120 | @code{restore} instructions. Early versions of the SPARCLET processor do | |
3121 | not correctly handle @code{save} and @code{restore} instructions used with | |
3122 | arguments. They correctly handle them used without arguments. A @code{save} | |
3123 | instruction used without arguments increments the current window pointer | |
3124 | but does not allocate a new stack frame. It is assumed that the window | |
3125 | overflow trap handler will properly handle this case as will interrupt | |
3126 | handlers. | |
3127 | @end table | |
3128 | ||
3129 | These @samp{-m} switches are supported in addition to the above | |
3130 | on SPARC V9 processors in 64 bit environments. | |
3131 | ||
3132 | @table @code | |
3133 | @item -mlittle-endian | |
3134 | Generate code for a processor running in little-endian mode. | |
3135 | ||
3136 | @item -mmedlow | |
3137 | Generate code for the Medium/Low code model: assume a 32 bit address space. | |
3138 | Programs are statically linked, PIC is not supported. Pointers are still | |
3139 | 64 bits. | |
3140 | ||
3141 | It is very likely that a future version of GCC will rename this option. | |
3142 | ||
3143 | @item -mmedany | |
3144 | Generate code for the Medium/Anywhere code model: assume a 32 bit text | |
3145 | and a 32 bit data segment, both starting anywhere (determined at link time). | |
3146 | Programs are statically linked, PIC is not supported. Pointers are still | |
3147 | 64 bits. | |
3148 | ||
3149 | It is very likely that a future version of GCC will rename this option. | |
3150 | ||
3151 | @item -mfullany | |
3152 | Generate code for the Full/Anywhere code model: assume a full 64 bit | |
3153 | address space. PIC is not supported. | |
3154 | ||
3155 | It is very likely that a future version of GCC will rename this option. | |
3156 | ||
3157 | @item -mint64 | |
3158 | Types long and int are 64 bits. | |
3159 | ||
3160 | @item -mlong32 | |
3161 | Types long and int are 32 bits. | |
3162 | ||
3163 | @item -mlong64 | |
3164 | @itemx -mint32 | |
3165 | Type long is 64 bits, and type int is 32 bits. | |
3166 | ||
3167 | @item -mstack-bias | |
3168 | @itemx -mno-stack-bias | |
3169 | With @samp{-mstack-bias}, GNU CC assumes that the stack pointer, and | |
3170 | frame pointer if present, are offset by -2047 which must be added back | |
3171 | when making stack frame references. | |
3172 | Otherwise, assume no such offset is present. | |
3173 | @end table | |
3174 | ||
3175 | @node Convex Options | |
3176 | @subsection Convex Options | |
3177 | @cindex Convex options | |
3178 | ||
3179 | These @samp{-m} options are defined for Convex: | |
3180 | ||
3181 | @table @code | |
3182 | @item -mc1 | |
3183 | Generate output for C1. The code will run on any Convex machine. | |
3184 | The preprocessor symbol @code{__convex__c1__} is defined. | |
3185 | ||
3186 | @item -mc2 | |
3187 | Generate output for C2. Uses instructions not available on C1. | |
3188 | Scheduling and other optimizations are chosen for max performance on C2. | |
3189 | The preprocessor symbol @code{__convex_c2__} is defined. | |
3190 | ||
3191 | @item -mc32 | |
3192 | Generate output for C32xx. Uses instructions not available on C1. | |
3193 | Scheduling and other optimizations are chosen for max performance on C32. | |
3194 | The preprocessor symbol @code{__convex_c32__} is defined. | |
3195 | ||
3196 | @item -mc34 | |
3197 | Generate output for C34xx. Uses instructions not available on C1. | |
3198 | Scheduling and other optimizations are chosen for max performance on C34. | |
3199 | The preprocessor symbol @code{__convex_c34__} is defined. | |
3200 | ||
3201 | @item -mc38 | |
3202 | Generate output for C38xx. Uses instructions not available on C1. | |
3203 | Scheduling and other optimizations are chosen for max performance on C38. | |
3204 | The preprocessor symbol @code{__convex_c38__} is defined. | |
3205 | ||
3206 | @item -margcount | |
3207 | Generate code which puts an argument count in the word preceding each | |
3208 | argument list. This is compatible with regular CC, and a few programs | |
3209 | may need the argument count word. GDB and other source-level debuggers | |
3210 | do not need it; this info is in the symbol table. | |
3211 | ||
3212 | @item -mnoargcount | |
3213 | Omit the argument count word. This is the default. | |
3214 | ||
3215 | @item -mvolatile-cache | |
3216 | Allow volatile references to be cached. This is the default. | |
3217 | ||
3218 | @item -mvolatile-nocache | |
3219 | Volatile references bypass the data cache, going all the way to memory. | |
3220 | This is only needed for multi-processor code that does not use standard | |
3221 | synchronization instructions. Making non-volatile references to volatile | |
3222 | locations will not necessarily work. | |
3223 | ||
3224 | @item -mlong32 | |
3225 | Type long is 32 bits, the same as type int. This is the default. | |
3226 | ||
3227 | @item -mlong64 | |
3228 | Type long is 64 bits, the same as type long long. This option is useless, | |
3229 | because no library support exists for it. | |
3230 | @end table | |
3231 | ||
3232 | @node AMD29K Options | |
3233 | @subsection AMD29K Options | |
3234 | @cindex AMD29K options | |
3235 | ||
3236 | These @samp{-m} options are defined for the AMD Am29000: | |
3237 | ||
3238 | @table @code | |
3239 | @item -mdw | |
3240 | @kindex -mdw | |
3241 | @cindex DW bit (29k) | |
3242 | Generate code that assumes the @code{DW} bit is set, i.e., that byte and | |
3243 | halfword operations are directly supported by the hardware. This is the | |
3244 | default. | |
3245 | ||
3246 | @item -mndw | |
3247 | @kindex -mndw | |
3248 | Generate code that assumes the @code{DW} bit is not set. | |
3249 | ||
3250 | @item -mbw | |
3251 | @kindex -mbw | |
3252 | @cindex byte writes (29k) | |
3253 | Generate code that assumes the system supports byte and halfword write | |
3254 | operations. This is the default. | |
3255 | ||
3256 | @item -mnbw | |
3257 | @kindex -mnbw | |
3258 | Generate code that assumes the systems does not support byte and | |
3259 | halfword write operations. @samp{-mnbw} implies @samp{-mndw}. | |
3260 | ||
3261 | @item -msmall | |
3262 | @kindex -msmall | |
3263 | @cindex memory model (29k) | |
3264 | Use a small memory model that assumes that all function addresses are | |
3265 | either within a single 256 KB segment or at an absolute address of less | |
3266 | than 256k. This allows the @code{call} instruction to be used instead | |
3267 | of a @code{const}, @code{consth}, @code{calli} sequence. | |
3268 | ||
3269 | @item -mnormal | |
3270 | @kindex -mnormal | |
3271 | Use the normal memory model: Generate @code{call} instructions only when | |
3272 | calling functions in the same file and @code{calli} instructions | |
3273 | otherwise. This works if each file occupies less than 256 KB but allows | |
3274 | the entire executable to be larger than 256 KB. This is the default. | |
3275 | ||
3276 | @item -mlarge | |
3277 | Always use @code{calli} instructions. Specify this option if you expect | |
3278 | a single file to compile into more than 256 KB of code. | |
3279 | ||
3280 | @item -m29050 | |
3281 | @kindex -m29050 | |
3282 | @cindex processor selection (29k) | |
3283 | Generate code for the Am29050. | |
3284 | ||
3285 | @item -m29000 | |
3286 | @kindex -m29000 | |
3287 | Generate code for the Am29000. This is the default. | |
3288 | ||
3289 | @item -mkernel-registers | |
3290 | @kindex -mkernel-registers | |
3291 | @cindex kernel and user registers (29k) | |
3292 | Generate references to registers @code{gr64-gr95} instead of to | |
3293 | registers @code{gr96-gr127}. This option can be used when compiling | |
3294 | kernel code that wants a set of global registers disjoint from that used | |
3295 | by user-mode code. | |
3296 | ||
3297 | Note that when this option is used, register names in @samp{-f} flags | |
3298 | must use the normal, user-mode, names. | |
3299 | ||
3300 | @item -muser-registers | |
3301 | @kindex -muser-registers | |
3302 | Use the normal set of global registers, @code{gr96-gr127}. This is the | |
3303 | default. | |
3304 | ||
3305 | @item -mstack-check | |
3306 | @itemx -mno-stack-check | |
3307 | @kindex -mstack-check | |
3308 | @cindex stack checks (29k) | |
3309 | Insert (or do not insert) a call to @code{__msp_check} after each stack | |
3310 | adjustment. This is often used for kernel code. | |
3311 | ||
3312 | @item -mstorem-bug | |
3313 | @itemx -mno-storem-bug | |
3314 | @kindex -mstorem-bug | |
3315 | @cindex storem bug (29k) | |
3316 | @samp{-mstorem-bug} handles 29k processors which cannot handle the | |
3317 | separation of a mtsrim insn and a storem instruction (most 29000 chips | |
3318 | to date, but not the 29050). | |
3319 | ||
3320 | @item -mno-reuse-arg-regs | |
3321 | @itemx -mreuse-arg-regs | |
3322 | @kindex -mreuse-arg-regs | |
3323 | @samp{-mno-reuse-arg-regs} tells the compiler to only use incoming argument | |
3324 | registers for copying out arguments. This helps detect calling a function | |
3325 | with fewer arguments than it was declared with. | |
3326 | ||
861bb6c1 JL |
3327 | @item -mno-impure-text |
3328 | @itemx -mimpure-text | |
3329 | @kindex -mimpure-text | |
3330 | @samp{-mimpure-text}, used in addition to @samp{-shared}, tells the compiler to | |
3331 | not pass @samp{-assert pure-text} to the linker when linking a shared object. | |
3332 | ||
74291a4b MM |
3333 | @item -msoft-float |
3334 | @kindex -msoft-float | |
3335 | Generate output containing library calls for floating point. | |
3336 | @strong{Warning:} the requisite libraries are not part of GNU CC. | |
3337 | Normally the facilities of the machine's usual C compiler are used, but | |
3338 | this can't be done directly in cross-compilation. You must make your | |
3339 | own arrangements to provide suitable library functions for | |
3340 | cross-compilation. | |
3341 | @end table | |
3342 | ||
3343 | @node ARM Options | |
3344 | @subsection ARM Options | |
3345 | @cindex ARM options | |
3346 | ||
3347 | These @samp{-m} options are defined for Advanced RISC Machines (ARM) | |
3348 | architectures: | |
3349 | ||
3350 | @table @code | |
3351 | @item -mapcs-frame | |
3352 | @kindex -mapcs-frame | |
3353 | Generate a stack frame that is compliant with the ARM Procedure Call | |
3354 | Standard for all functions, even if this is not strictly necessary for | |
3355 | correct execution of the code. | |
3356 | ||
3357 | @item -mapcs-26 | |
3358 | @kindex -mapcs-26 | |
3359 | Generate code for a processor running with a 26-bit program counter, | |
3360 | and conforming to the function calling standards for the APCS 26-bit | |
3361 | option. This option replaces the @samp{-m2} and @samp{-m3} options | |
3362 | of previous releases of the compiler. | |
3363 | ||
3364 | @item -mapcs-32 | |
3365 | @kindex -mapcs-32 | |
3366 | Generate code for a processor running with a 32-bit program counter, | |
3367 | and conforming to the function calling standards for the APCS 32-bit | |
3368 | option. This option replaces the @samp{-m6} option of previous releases | |
3369 | of the compiler. | |
3370 | ||
3371 | @item -mhard-float | |
3372 | Generate output containing floating point instructions. This is the | |
3373 | default. | |
3374 | ||
3375 | @item -msoft-float | |
3376 | Generate output containing library calls for floating point. | |
3377 | @strong{Warning:} the requisite libraries are not available for all ARM | |
3378 | targets. Normally the facilities of the machine's usual C compiler are | |
3379 | used, but this cannot be done directly in cross-compilation. You must make | |
3380 | your own arrangements to provide suitable library functions for | |
3381 | cross-compilation. | |
3382 | ||
3383 | @samp{-msoft-float} changes the calling convention in the output file; | |
3384 | therefore, it is only useful if you compile @emph{all} of a program with | |
3385 | this option. In particular, you need to compile @file{libgcc.a}, the | |
3386 | library that comes with GNU CC, with @samp{-msoft-float} in order for | |
3387 | this to work. | |
3388 | ||
3389 | @item -mlittle-endian | |
3390 | Generate code for a processor running in little-endian mode. This is | |
3391 | the default for all standard configurations. | |
3392 | ||
3393 | @item -mbig-endian | |
3394 | Generate code for a processor running in big-endian mode; the default is | |
3395 | to compile code for a little-endian processor. | |
3396 | ||
3397 | @item -mwords-little-endian | |
3398 | This option only applies when generating code for big-endian processors. | |
3399 | Generate code for a little-endian word order but a big-endian byte | |
3400 | order. That is, a byte order of the form @samp{32107654}. Note: this | |
3401 | option should only be used if you require compatibility with code for | |
3402 | big-endian ARM processors generated by versions of the compiler prior to | |
3403 | 2.8. | |
3404 | ||
3405 | @item -mshort-load-bytes | |
3406 | @kindex -mshort-load-bytes | |
3407 | Do not try to load half-words (eg @samp{short}s) by loading a word from | |
3408 | an unaligned address. For some targets the MMU is configured to trap | |
3409 | unaligned loads; use this option to generate code that is safe in these | |
3410 | environments. | |
3411 | ||
3412 | @item -mno-short-load-bytes | |
3413 | @kindex -mno-short-load-bytes | |
3414 | Use unaligned word loads to load half-words (eg @samp{short}s). This | |
3415 | option produces more efficient code, but the MMU is sometimes configured | |
3416 | to trap these instructions. | |
3417 | ||
3418 | @item -mbsd | |
3419 | @kindex -mbsd | |
3420 | This option only applies to RISC iX. Emulate the native BSD-mode | |
3421 | compiler. This is the default if @samp{-ansi} is not specified. | |
3422 | ||
3423 | @item -mxopen | |
3424 | @kindex -mxopen | |
3425 | This option only applies to RISC iX. Emulate the native X/Open-mode | |
3426 | compiler. | |
3427 | ||
3428 | @item -mno-symrename | |
3429 | @kindex -mno-symrename | |
3430 | This option only applies to RISC iX. Do not run the assembler | |
3431 | post-processor, @samp{symrename}, after code has been assembled. | |
3432 | Normally it is necessary to modify some of the standard symbols in | |
3433 | preparation for linking with the RISC iX C library; this option | |
3434 | suppresses this pass. The post-processor is never run when the | |
3435 | compiler is built for cross-compilation. | |
3436 | @end table | |
3437 | ||
861bb6c1 JL |
3438 | @node M32R/D Options |
3439 | @subsection M32R/D Options | |
3440 | @cindex M32R/D options | |
3441 | ||
3442 | These @samp{-m} options are defined for Mitsubishi M32R/D architectures: | |
3443 | ||
3444 | @table @code | |
3445 | @item -mcode-model=small | |
3446 | Assume all objects live in the lower 16MB of memory (so that their addresses | |
3447 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
3448 | are reachable with the @code{bl} instruction. | |
3449 | This is the default. | |
3450 | ||
3451 | The addressability of a particular object can be set with the | |
3452 | @code{model} attribute. | |
3453 | ||
3454 | @item -mcode-model=medium | |
3455 | Assume objects may be anywhere in the 32 bit address space (the compiler | |
3456 | will generate @code{seth/add3} instructions to load their addresses), and | |
3457 | assume all subroutines are reachable with the @code{bl} instruction. | |
3458 | ||
3459 | @item -mcode-model=large | |
3460 | Assume objects may be anywhere in the 32 bit address space (the compiler | |
3461 | will generate @code{seth/add3} instructions to load their addresses), and | |
3462 | assume subroutines may not be reachable with the @code{bl} instruction | |
3463 | (the compiler will generate the much slower @code{seth/add3/jl} | |
3464 | instruction sequence). | |
3465 | ||
3466 | @item -msdata=none | |
3467 | Disable use of the small data area. Variables will be put into | |
3468 | one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the | |
3469 | @code{section} attribute has been specified). | |
3470 | This is the default. | |
3471 | ||
3472 | The small data area consists of sections @samp{.sdata} and @samp{.sbss}. | |
3473 | Objects may be explicitly put in the small data area with the | |
3474 | @code{section} attribute using one of these sections. | |
3475 | ||
3476 | @item -msdata=sdata | |
3477 | Put small global and static data in the small data area, but do not | |
3478 | generate special code to reference them. | |
3479 | ||
3480 | @item -msdata=use | |
3481 | Put small global and static data in the small data area, and generate | |
3482 | special instructions to reference them. | |
3483 | ||
3484 | @item -G @var{num} | |
3485 | @cindex smaller data references | |
3486 | Put global and static objects less than or equal to @var{num} bytes | |
3487 | into the small data or bss sections instead of the normal data or bss | |
3488 | sections. The default value of @var{num} is 8. | |
3489 | The @samp{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
3490 | for this option to have any effect. | |
3491 | ||
3492 | All modules should be compiled with the same @samp{-G @var{num}} value. | |
3493 | Compiling with different values of @var{num} may or may not work; if it | |
3494 | doesn't the linker will give an error message - incorrect code will not be | |
3495 | generated. | |
3496 | ||
3497 | @end table | |
3498 | ||
74291a4b MM |
3499 | @node M88K Options |
3500 | @subsection M88K Options | |
3501 | @cindex M88k options | |
3502 | ||
3503 | These @samp{-m} options are defined for Motorola 88k architectures: | |
3504 | ||
3505 | @table @code | |
3506 | @item -m88000 | |
3507 | @kindex -m88000 | |
3508 | Generate code that works well on both the m88100 and the | |
3509 | m88110. | |
3510 | ||
3511 | @item -m88100 | |
3512 | @kindex -m88100 | |
3513 | Generate code that works best for the m88100, but that also | |
3514 | runs on the m88110. | |
3515 | ||
3516 | @item -m88110 | |
3517 | @kindex -m88110 | |
3518 | Generate code that works best for the m88110, and may not run | |
3519 | on the m88100. | |
3520 | ||
3521 | @item -mbig-pic | |
3522 | @kindex -mbig-pic | |
3523 | Obsolete option to be removed from the next revision. | |
3524 | Use @samp{-fPIC}. | |
3525 | ||
3526 | @item -midentify-revision | |
3527 | @kindex -midentify-revision | |
3528 | @kindex ident | |
3529 | @cindex identifying source, compiler (88k) | |
3530 | Include an @code{ident} directive in the assembler output recording the | |
3531 | source file name, compiler name and version, timestamp, and compilation | |
3532 | flags used. | |
3533 | ||
3534 | @item -mno-underscores | |
3535 | @kindex -mno-underscores | |
3536 | @cindex underscores, avoiding (88k) | |
3537 | In assembler output, emit symbol names without adding an underscore | |
3538 | character at the beginning of each name. The default is to use an | |
3539 | underscore as prefix on each name. | |
3540 | ||
3541 | @item -mocs-debug-info | |
3542 | @itemx -mno-ocs-debug-info | |
3543 | @kindex -mocs-debug-info | |
3544 | @kindex -mno-ocs-debug-info | |
3545 | @cindex OCS (88k) | |
3546 | @cindex debugging, 88k OCS | |
3547 | Include (or omit) additional debugging information (about registers used | |
3548 | in each stack frame) as specified in the 88open Object Compatibility | |
3549 | Standard, ``OCS''. This extra information allows debugging of code that | |
3550 | has had the frame pointer eliminated. The default for DG/UX, SVr4, and | |
3551 | Delta 88 SVr3.2 is to include this information; other 88k configurations | |
3552 | omit this information by default. | |
3553 | ||
3554 | @item -mocs-frame-position | |
3555 | @kindex -mocs-frame-position | |
3556 | @cindex register positions in frame (88k) | |
3557 | When emitting COFF debugging information for automatic variables and | |
3558 | parameters stored on the stack, use the offset from the canonical frame | |
3559 | address, which is the stack pointer (register 31) on entry to the | |
3560 | function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use | |
3561 | @samp{-mocs-frame-position}; other 88k configurations have the default | |
3562 | @samp{-mno-ocs-frame-position}. | |
3563 | ||
3564 | @item -mno-ocs-frame-position | |
3565 | @kindex -mno-ocs-frame-position | |
3566 | @cindex register positions in frame (88k) | |
3567 | When emitting COFF debugging information for automatic variables and | |
3568 | parameters stored on the stack, use the offset from the frame pointer | |
3569 | register (register 30). When this option is in effect, the frame | |
3570 | pointer is not eliminated when debugging information is selected by the | |
3571 | -g switch. | |
3572 | ||
3573 | @item -moptimize-arg-area | |
3574 | @itemx -mno-optimize-arg-area | |
3575 | @kindex -moptimize-arg-area | |
3576 | @kindex -mno-optimize-arg-area | |
3577 | @cindex arguments in frame (88k) | |
3578 | Control how function arguments are stored in stack frames. | |
3579 | @samp{-moptimize-arg-area} saves space by optimizing them, but this | |
3580 | conflicts with the 88open specifications. The opposite alternative, | |
3581 | @samp{-mno-optimize-arg-area}, agrees with 88open standards. By default | |
3582 | GNU CC does not optimize the argument area. | |
3583 | ||
3584 | @item -mshort-data-@var{num} | |
3585 | @kindex -mshort-data-@var{num} | |
3586 | @cindex smaller data references (88k) | |
3587 | @cindex r0-relative references (88k) | |
3588 | Generate smaller data references by making them relative to @code{r0}, | |
3589 | which allows loading a value using a single instruction (rather than the | |
3590 | usual two). You control which data references are affected by | |
3591 | specifying @var{num} with this option. For example, if you specify | |
3592 | @samp{-mshort-data-512}, then the data references affected are those | |
3593 | involving displacements of less than 512 bytes. | |
3594 | @samp{-mshort-data-@var{num}} is not effective for @var{num} greater | |
3595 | than 64k. | |
3596 | ||
3597 | @item -mserialize-volatile | |
3598 | @kindex -mserialize-volatile | |
3599 | @itemx -mno-serialize-volatile | |
3600 | @kindex -mno-serialize-volatile | |
3601 | @cindex sequential consistency on 88k | |
3602 | Do, or don't, generate code to guarantee sequential consistency | |
3603 | of volatile memory references. By default, consistency is | |
3604 | guaranteed. | |
3605 | ||
3606 | The order of memory references made by the MC88110 processor does | |
3607 | not always match the order of the instructions requesting those | |
3608 | references. In particular, a load instruction may execute before | |
3609 | a preceding store instruction. Such reordering violates | |
3610 | sequential consistency of volatile memory references, when there | |
3611 | are multiple processors. When consistency must be guaranteed, | |
3612 | GNU C generates special instructions, as needed, to force | |
3613 | execution in the proper order. | |
3614 | ||
3615 | The MC88100 processor does not reorder memory references and so | |
3616 | always provides sequential consistency. However, by default, GNU | |
3617 | C generates the special instructions to guarantee consistency | |
3618 | even when you use @samp{-m88100}, so that the code may be run on an | |
3619 | MC88110 processor. If you intend to run your code only on the | |
3620 | MC88100 processor, you may use @samp{-mno-serialize-volatile}. | |
3621 | ||
3622 | The extra code generated to guarantee consistency may affect the | |
3623 | performance of your application. If you know that you can safely | |
3624 | forgo this guarantee, you may use @samp{-mno-serialize-volatile}. | |
3625 | ||
3626 | @item -msvr4 | |
3627 | @itemx -msvr3 | |
3628 | @kindex -msvr4 | |
3629 | @kindex -msvr3 | |
3630 | @cindex assembler syntax, 88k | |
3631 | @cindex SVr4 | |
3632 | Turn on (@samp{-msvr4}) or off (@samp{-msvr3}) compiler extensions | |
3633 | related to System V release 4 (SVr4). This controls the following: | |
3634 | ||
3635 | @enumerate | |
3636 | @item | |
3637 | Which variant of the assembler syntax to emit. | |
3638 | @item | |
3639 | @samp{-msvr4} makes the C preprocessor recognize @samp{#pragma weak} | |
3640 | that is used on System V release 4. | |
3641 | @item | |
3642 | @samp{-msvr4} makes GNU CC issue additional declaration directives used in | |
3643 | SVr4. | |
3644 | @end enumerate | |
3645 | ||
3646 | @samp{-msvr4} is the default for the m88k-motorola-sysv4 and | |
3647 | m88k-dg-dgux m88k configurations. @samp{-msvr3} is the default for all | |
3648 | other m88k configurations. | |
3649 | ||
3650 | @item -mversion-03.00 | |
3651 | @kindex -mversion-03.00 | |
3652 | This option is obsolete, and is ignored. | |
3653 | @c ??? which asm syntax better for GAS? option there too? | |
3654 | ||
3655 | @item -mno-check-zero-division | |
3656 | @itemx -mcheck-zero-division | |
3657 | @kindex -mno-check-zero-division | |
3658 | @kindex -mcheck-zero-division | |
3659 | @cindex zero division on 88k | |
3660 | Do, or don't, generate code to guarantee that integer division by | |
3661 | zero will be detected. By default, detection is guaranteed. | |
3662 | ||
3663 | Some models of the MC88100 processor fail to trap upon integer | |
3664 | division by zero under certain conditions. By default, when | |
3665 | compiling code that might be run on such a processor, GNU C | |
3666 | generates code that explicitly checks for zero-valued divisors | |
3667 | and traps with exception number 503 when one is detected. Use of | |
3668 | mno-check-zero-division suppresses such checking for code | |
3669 | generated to run on an MC88100 processor. | |
3670 | ||
3671 | GNU C assumes that the MC88110 processor correctly detects all | |
3672 | instances of integer division by zero. When @samp{-m88110} is | |
3673 | specified, both @samp{-mcheck-zero-division} and | |
3674 | @samp{-mno-check-zero-division} are ignored, and no explicit checks for | |
3675 | zero-valued divisors are generated. | |
3676 | ||
3677 | @item -muse-div-instruction | |
3678 | @kindex -muse-div-instruction | |
3679 | @cindex divide instruction, 88k | |
3680 | Use the div instruction for signed integer division on the | |
3681 | MC88100 processor. By default, the div instruction is not used. | |
3682 | ||
3683 | On the MC88100 processor the signed integer division instruction | |
3684 | div) traps to the operating system on a negative operand. The | |
3685 | operating system transparently completes the operation, but at a | |
3686 | large cost in execution time. By default, when compiling code | |
3687 | that might be run on an MC88100 processor, GNU C emulates signed | |
3688 | integer division using the unsigned integer division instruction | |
3689 | divu), thereby avoiding the large penalty of a trap to the | |
3690 | operating system. Such emulation has its own, smaller, execution | |
3691 | cost in both time and space. To the extent that your code's | |
3692 | important signed integer division operations are performed on two | |
3693 | nonnegative operands, it may be desirable to use the div | |
3694 | instruction directly. | |
3695 | ||
3696 | On the MC88110 processor the div instruction (also known as the | |
3697 | divs instruction) processes negative operands without trapping to | |
3698 | the operating system. When @samp{-m88110} is specified, | |
3699 | @samp{-muse-div-instruction} is ignored, and the div instruction is used | |
3700 | for signed integer division. | |
3701 | ||
3702 | Note that the result of dividing INT_MIN by -1 is undefined. In | |
3703 | particular, the behavior of such a division with and without | |
3704 | @samp{-muse-div-instruction} may differ. | |
3705 | ||
3706 | @item -mtrap-large-shift | |
3707 | @itemx -mhandle-large-shift | |
3708 | @kindex -mtrap-large-shift | |
3709 | @kindex -mhandle-large-shift | |
3710 | @cindex bit shift overflow (88k) | |
3711 | @cindex large bit shifts (88k) | |
3712 | Include code to detect bit-shifts of more than 31 bits; respectively, | |
3713 | trap such shifts or emit code to handle them properly. By default GNU CC | |
3714 | makes no special provision for large bit shifts. | |
3715 | ||
3716 | @item -mwarn-passed-structs | |
3717 | @kindex -mwarn-passed-structs | |
3718 | @cindex structure passing (88k) | |
3719 | Warn when a function passes a struct as an argument or result. | |
3720 | Structure-passing conventions have changed during the evolution of the C | |
3721 | language, and are often the source of portability problems. By default, | |
3722 | GNU CC issues no such warning. | |
3723 | @end table | |
3724 | ||
3725 | @node RS/6000 and PowerPC Options | |
3726 | @subsection IBM RS/6000 and PowerPC Options | |
3727 | @cindex RS/6000 and PowerPC Options | |
3728 | @cindex IBM RS/6000 and PowerPC Options | |
3729 | ||
3730 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
3731 | @table @code | |
3732 | @item -mpower | |
3733 | @itemx -mno-power | |
3734 | @itemx -mpower2 | |
3735 | @itemx -mno-power2 | |
3736 | @itemx -mpowerpc | |
3737 | @itemx -mno-powerpc | |
3738 | @itemx -mpowerpc-gpopt | |
3739 | @itemx -mno-powerpc-gpopt | |
3740 | @itemx -mpowerpc-gfxopt | |
3741 | @itemx -mno-powerpc-gfxopt | |
3742 | @kindex -mpower | |
3743 | @kindex -mpower2 | |
3744 | @kindex -mpowerpc | |
3745 | @kindex -mpowerpc-gpopt | |
3746 | @kindex -mpowerpc-gfxopt | |
3747 | GNU CC supports two related instruction set architectures for the | |
3748 | RS/6000 and PowerPC. The @dfn{POWER} instruction set are those | |
3749 | instructions supported by the @samp{rios} chip set used in the original | |
3750 | RS/6000 systems and the @dfn{PowerPC} instruction set is the | |
3751 | architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and | |
861bb6c1 | 3752 | the IBM 4xx microprocessors. |
74291a4b MM |
3753 | |
3754 | Neither architecture is a subset of the other. However there is a | |
3755 | large common subset of instructions supported by both. An MQ | |
3756 | register is included in processors supporting the POWER architecture. | |
3757 | ||
3758 | You use these options to specify which instructions are available on the | |
3759 | processor you are using. The default value of these options is | |
3760 | determined when configuring GNU CC. Specifying the | |
3761 | @samp{-mcpu=@var{cpu_type}} overrides the specification of these | |
3762 | options. We recommend you use the @samp{-mcpu=@var{cpu_type}} option | |
3763 | rather than the options listed above. | |
3764 | ||
3765 | The @samp{-mpower} option allows GNU CC to generate instructions that | |
3766 | are found only in the POWER architecture and to use the MQ register. | |
3767 | Specifying @samp{-mpower2} implies @samp{-power} and also allows GNU CC | |
3768 | to generate instructions that are present in the POWER2 architecture but | |
3769 | not the original POWER architecture. | |
3770 | ||
3771 | The @samp{-mpowerpc} option allows GNU CC to generate instructions that | |
3772 | are found only in the 32-bit subset of the PowerPC architecture. | |
3773 | Specifying @samp{-mpowerpc-gpopt} implies @samp{-mpowerpc} and also allows | |
3774 | GNU CC to use the optional PowerPC architecture instructions in the | |
3775 | General Purpose group, including floating-point square root. Specifying | |
3776 | @samp{-mpowerpc-gfxopt} implies @samp{-mpowerpc} and also allows GNU CC to | |
3777 | use the optional PowerPC architecture instructions in the Graphics | |
3778 | group, including floating-point select. | |
3779 | ||
3780 | If you specify both @samp{-mno-power} and @samp{-mno-powerpc}, GNU CC | |
3781 | will use only the instructions in the common subset of both | |
3782 | architectures plus some special AIX common-mode calls, and will not use | |
3783 | the MQ register. Specifying both @samp{-mpower} and @samp{-mpowerpc} | |
3784 | permits GNU CC to use any instruction from either architecture and to | |
3785 | allow use of the MQ register; specify this for the Motorola MPC601. | |
3786 | ||
3787 | @item -mnew-mnemonics | |
3788 | @itemx -mold-mnemonics | |
3789 | @kindex -mnew-mnemonics | |
3790 | @kindex -mold-mnemonics | |
3791 | Select which mnemonics to use in the generated assembler code. | |
3792 | @samp{-mnew-mnemonics} requests output that uses the assembler mnemonics | |
3793 | defined for the PowerPC architecture, while @samp{-mold-mnemonics} | |
3794 | requests the assembler mnemonics defined for the POWER architecture. | |
3795 | Instructions defined in only one architecture have only one mnemonic; | |
3796 | GNU CC uses that mnemonic irrespective of which of these options is | |
3797 | specified. | |
3798 | ||
3799 | PowerPC assemblers support both the old and new mnemonics, as will later | |
3800 | POWER assemblers. Current POWER assemblers only support the old | |
3801 | mnemonics. Specify @samp{-mnew-mnemonics} if you have an assembler that | |
3802 | supports them, otherwise specify @samp{-mold-mnemonics}. | |
3803 | ||
3804 | The default value of these options depends on how GNU CC was configured. | |
3805 | Specifying @samp{-mcpu=@var{cpu_type}} sometimes overrides the value of | |
3806 | these option. Unless you are building a cross-compiler, you should | |
3807 | normally not specify either @samp{-mnew-mnemonics} or | |
3808 | @samp{-mold-mnemonics}, but should instead accept the default. | |
3809 | ||
3810 | @item -mcpu=@var{cpu_type} | |
3811 | Set architecture type, register usage, choice of mnemonics, and | |
3812 | instruction scheduling parameters for machine type @var{cpu_type}. | |
3813 | Supported values for @var{cpu_type} are @samp{rs6000}, @samp{rios1}, | |
3814 | @samp{rios2}, @samp{rsc}, @samp{601}, @samp{602}, @samp{603}, | |
861bb6c1 JL |
3815 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{power}, |
3816 | @samp{power2}, @samp{powerpc}, @samp{403}, @samp{505}, @samp{801}, | |
3817 | @samp{821}, @samp{823}, and @samp{860} and @samp{common}. | |
3818 | @samp{-mcpu=power}, @samp{-mcpu=power2}, and @samp{-mcpu=powerpc} | |
3819 | specify generic POWER, POWER2 and pure PowerPC (i.e., not MPC601) | |
3820 | architecture machine types, with an appropriate, generic processor model | |
3821 | assumed for scheduling purposes.@refill | |
74291a4b MM |
3822 | |
3823 | @c overfull hbox here --bob 22 jul96 | |
3824 | @c original text between ignore ... end ignore | |
3825 | @ignore | |
861bb6c1 JL |
3826 | Specifying any of the @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, |
3827 | @samp{-mcpu=rsc}, @samp{-mcpu=power}, or @samp{-mcpu=power2} options | |
3828 | enables the @samp{-mpower} option and disables the @samp{-mpowerpc} | |
3829 | option; @samp{-mcpu=601} enables both the @samp{-mpower} and | |
3830 | @samp{-mpowerpc} options; all of @samp{-mcpu=602}, @samp{-mcpu=603}, | |
3831 | @samp{-mcpu=603e}, @samp{-mcpu=604}, @samp{-mcpu=604e}, | |
3832 | @samp{-mcpu=620}, @samp{-mcpu=403}, @samp{-mcpu=505}, @samp{-mcpu=801}, | |
3833 | @samp{-mcpu=821}, @samp{-mcpu=823}, @samp{-mcpu=860} and | |
3834 | @samp{-mcpu=powerpc} enable the @samp{-mpowerpc} option and disable the | |
3835 | @samp{-mpower} option; @samp{-mcpu=common} disables both the | |
3836 | @samp{-mpower} and @samp{-mpowerpc} options.@refill | |
74291a4b MM |
3837 | @end ignore |
3838 | @c changed paragraph | |
3839 | Specifying any of the following options: | |
3840 | @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, @samp{-mcpu=rsc}, | |
3841 | @samp{-mcpu=power}, or @samp{-mcpu=power2} | |
3842 | enables the @samp{-mpower} option and disables the @samp{-mpowerpc} option; | |
3843 | @samp{-mcpu=601} enables both the @samp{-mpower} and @samp{-mpowerpc} options. | |
3844 | All of @samp{-mcpu=602}, @samp{-mcpu=603}, @samp{-mcpu=603e}, | |
3845 | @samp{-mcpu=604}, @samp{-mcpu=620}, | |
3846 | enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option. | |
3847 | Exactly similarly, all of @samp{-mcpu=403}, | |
3848 | @samp{-mcpu=505}, @samp{-mcpu=821}, @samp{-mcpu=860} and @samp{-mcpu=powerpc} | |
3849 | enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option. | |
3850 | @samp{-mcpu=common} disables both the | |
3851 | @samp{-mpower} and @samp{-mpowerpc} options.@refill | |
3852 | @c end changes to prevent overfull hboxes | |
3853 | ||
3854 | AIX versions 4 or greater selects @samp{-mcpu=common} by default, so | |
3855 | that code will operate on all members of the RS/6000 and PowerPC | |
3856 | families. In that case, GNU CC will use only the instructions in the | |
3857 | common subset of both architectures plus some special AIX common-mode | |
3858 | calls, and will not use the MQ register. GNU CC assumes a generic | |
3859 | processor model for scheduling purposes. | |
3860 | ||
3861 | Specifying any of the options @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, | |
3862 | @samp{-mcpu=rsc}, @samp{-mcpu=power}, or @samp{-mcpu=power2} also | |
3863 | disables the @samp{new-mnemonics} option. Specifying @samp{-mcpu=601}, | |
3864 | @samp{-mcpu=602}, @samp{-mcpu=603}, @samp{-mcpu=603e}, @samp{-mcpu=604}, | |
3865 | @samp{620}, @samp{403}, or @samp{-mcpu=powerpc} also enables the | |
3866 | @samp{new-mnemonics} option.@refill | |
3867 | ||
3868 | Specifying @samp{-mcpu=403}, @samp{-mcpu=821}, or @samp{-mcpu=860} also | |
3869 | enables the @samp{-msoft-float} option. | |
3870 | ||
3871 | @item -mtune=@var{cpu_type} | |
3872 | Set the instruction scheduling parameters for machine type | |
3873 | @var{cpu_type}, but do not set the architecture type, register usage, | |
3874 | choice of mnemonics like @samp{-mcpu=}@var{cpu_type} would. The same | |
3875 | values for @var{cpu_type} are used for @samp{-mtune=}@var{cpu_type} as | |
3876 | for @samp{-mcpu=}@var{cpu_type}. The @samp{-mtune=}@var{cpu_type} | |
3877 | option overrides the @samp{-mcpu=}@var{cpu_type} option in terms of | |
3878 | instruction scheduling parameters. | |
3879 | ||
3880 | @item -mfull-toc | |
3881 | @itemx -mno-fp-in-toc | |
3882 | @itemx -mno-sum-in-toc | |
3883 | @itemx -mminimal-toc | |
3884 | Modify generation of the TOC (Table Of Contents), which is created for | |
3885 | every executable file. The @samp{-mfull-toc} option is selected by | |
3886 | default. In that case, GNU CC will allocate at least one TOC entry for | |
3887 | each unique non-automatic variable reference in your program. GNU CC | |
3888 | will also place floating-point constants in the TOC. However, only | |
3889 | 16,384 entries are available in the TOC. | |
3890 | ||
3891 | If you receive a linker error message that saying you have overflowed | |
3892 | the available TOC space, you can reduce the amount of TOC space used | |
3893 | with the @samp{-mno-fp-in-toc} and @samp{-mno-sum-in-toc} options. | |
3894 | @samp{-mno-fp-in-toc} prevents GNU CC from putting floating-point | |
3895 | constants in the TOC and @samp{-mno-sum-in-toc} forces GNU CC to | |
3896 | generate code to calculate the sum of an address and a constant at | |
3897 | run-time instead of putting that sum into the TOC. You may specify one | |
3898 | or both of these options. Each causes GNU CC to produce very slightly | |
3899 | slower and larger code at the expense of conserving TOC space. | |
3900 | ||
3901 | If you still run out of space in the TOC even when you specify both of | |
3902 | these options, specify @samp{-mminimal-toc} instead. This option causes | |
3903 | GNU CC to make only one TOC entry for every file. When you specify this | |
3904 | option, GNU CC will produce code that is slower and larger but which | |
3905 | uses extremely little TOC space. You may wish to use this option | |
3906 | only on files that contain less frequently executed code. @refill | |
3907 | ||
3908 | @item -mxl-call | |
3909 | @itemx -mno-xl-call | |
3910 | On AIX, pass floating-point arguments to prototyped functions beyond the | |
3911 | register save area (RSA) on the stack in addition to argument FPRs. The | |
3912 | AIX calling convention was extended but not initially documented to | |
3913 | handle an obscure K&R C case of calling a function that takes the | |
3914 | address of its arguments with fewer arguments than declared. AIX XL | |
3915 | compilers assume that floating point arguments which do not fit in the | |
3916 | RSA are on the stack when they compile a subroutine without | |
3917 | optimization. Because always storing floating-point arguments on the | |
3918 | stack is inefficient and rarely needed, this option is not enabled by | |
3919 | default and only is necessary when calling subroutines compiled by AIX | |
3920 | XL compilers without optimization. | |
3921 | ||
861bb6c1 JL |
3922 | @item -mthreads |
3923 | Support @dfn{AIX Threads}. Link an application written to use | |
3924 | @dfn{pthreads} with special libraries and startup code to enable the | |
3925 | application to run. | |
3926 | ||
3927 | @item -mpe | |
3928 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE). Link an | |
3929 | application written to use message passing with special startup code to | |
3930 | enable the application to run. The system must have PE installed in the | |
3931 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
3932 | must be overridden with the @samp{-specs=} option to specify the | |
3933 | appropriate directory location. The Parallel Environment does not | |
3934 | support threads, so the @samp{-mpe} option and the @samp{-mthreads} | |
3935 | option are incompatible. | |
3936 | ||
74291a4b MM |
3937 | @item -msoft-float |
3938 | @itemx -mhard-float | |
3939 | Generate code that does not use (uses) the floating-point register set. | |
3940 | Software floating point emulation is provided if you use the | |
3941 | @samp{-msoft-float} option, and pass the option to GNU CC when linking. | |
3942 | ||
3943 | @item -mmultiple | |
3944 | @itemx -mno-multiple | |
3945 | Generate code that uses (does not use) the load multiple word | |
3946 | instructions and the store multiple word instructions. These | |
3947 | instructions are generated by default on POWER systems, and not | |
3948 | generated on PowerPC systems. Do not use @samp{-mmultiple} on little | |
3949 | endian PowerPC systems, since those instructions do not work when the | |
3950 | processor is in little endian mode. | |
3951 | ||
3952 | @item -mstring | |
3953 | @itemx -mno-string | |
3954 | Generate code that uses (does not use) the load string instructions and the | |
3955 | store string word instructions to save multiple registers and do small block | |
861bb6c1 | 3956 | moves. These instructions are generated by default on POWER systems, and not |
74291a4b MM |
3957 | generated on PowerPC systems. Do not use @samp{-mstring} on little endian |
3958 | PowerPC systems, since those instructions do not work when the processor is in | |
3959 | little endian mode. | |
3960 | ||
861bb6c1 JL |
3961 | @item -mupdate |
3962 | @itemx -mno-update | |
3963 | Generate code that uses (does not use) the load or store instructions | |
3964 | that update the base register to the address of the calculated memory | |
3965 | location. These instructions are generated by default. If you use | |
3966 | @samp{-mno-update}, there is a small window between the time that the | |
3967 | stack pointer is updated and the address of the previous frame is | |
3968 | stored, which means code that walks the stack frame across interrupts or | |
3969 | signals may get corrupted data. | |
3970 | ||
3971 | @item -mfused-madd | |
3972 | @itemx -mno-fused-madd | |
3973 | Generate code that uses (does not use) the floating point multiply and | |
3974 | accumulate instructions. These instructions are generated by default if | |
3975 | hardware floating is used. | |
3976 | ||
74291a4b MM |
3977 | @item -mno-bit-align |
3978 | @itemx -mbit-align | |
3979 | On System V.4 and embedded PowerPC systems do not (do) force structures | |
3980 | and unions that contain bit fields to be aligned to the base type of the | |
3981 | bit field. | |
3982 | ||
3983 | For example, by default a structure containing nothing but 8 | |
3984 | @code{unsigned} bitfields of length 1 would be aligned to a 4 byte | |
3985 | boundary and have a size of 4 bytes. By using @samp{-mno-bit-align}, | |
3986 | the structure would be aligned to a 1 byte boundary and be one byte in | |
3987 | size. | |
3988 | ||
3989 | @item -mno-strict-align | |
3990 | @itemx -mstrict-align | |
3991 | On System V.4 and embedded PowerPC systems do not (do) assume that | |
3992 | unaligned memory references will be handled by the system. | |
3993 | ||
3994 | @item -mrelocatable | |
3995 | @itemx -mno-relocatable | |
3996 | On embedded PowerPC systems generate code that allows (does not allow) | |
3997 | the program to be relocated to a different address at runtime. If you | |
3998 | use @samp{-mrelocatable} on any module, all objects linked together must | |
3999 | be compiled with @samp{-mrelocatable} or @samp{-mrelocatable-lib}. | |
4000 | ||
4001 | @item -mrelocatable-lib | |
4002 | @itemx -mno-relocatable-lib | |
4003 | On embedded PowerPC systems generate code that allows (does not allow) | |
4004 | the program to be relocated to a different address at runtime. Modules | |
4005 | compiled with @samp{-mreloctable-lib} can be linked with either modules | |
4006 | compiled without @samp{-mrelocatable} and @samp{-mrelocatable-lib} or | |
4007 | with modules compiled with the @samp{-mrelocatable} options. | |
4008 | ||
4009 | @item -mno-toc | |
4010 | @itemx -mtoc | |
4011 | On System V.4 and embedded PowerPC systems do not (do) assume that | |
4012 | register 2 contains a pointer to a global area pointing to the addresses | |
4013 | used in the program. | |
4014 | ||
4015 | @item -mno-traceback | |
4016 | @itemx -mtraceback | |
4017 | On embedded PowerPC systems do not (do) generate a traceback tag before | |
4018 | the start of the function. This tag can be used by the debugger to | |
4019 | identify where the start of a function is. | |
4020 | ||
4021 | @item -mlittle | |
4022 | @itemx -mlittle-endian | |
4023 | On System V.4 and embedded PowerPC systems compile code for the | |
4024 | processor in little endian mode. The @samp{-mlittle-endian} option is | |
4025 | the same as @samp{-mlittle}. | |
4026 | ||
4027 | @item -mbig | |
4028 | @itemx -mbig-endian | |
4029 | On System V.4 and embedded PowerPC systems compile code for the | |
4030 | processor in big endian mode. The @samp{-mbig-endian} option is | |
4031 | the same as @samp{-mbig}. | |
4032 | ||
4033 | @item -mcall-sysv | |
4034 | On System V.4 and embedded PowerPC systems compile code using calling | |
4035 | conventions that adheres to the March 1995 draft of the System V | |
4036 | Application Binary Interface, PowerPC processor supplement. This is the | |
4037 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
4038 | ||
4039 | @item -mcall-sysv-eabi | |
4040 | Specify both @samp{-mcall-sysv} and @samp{-meabi} options. | |
4041 | ||
4042 | @item -mcall-sysv-noeabi | |
4043 | Specify both @samp{-mcall-sysv} and @samp{-mno-eabi} options. | |
4044 | ||
4045 | @item -mcall-aix | |
4046 | On System V.4 and embedded PowerPC systems compile code using calling | |
4047 | conventions that are similar to those used on AIX. This is the | |
4048 | default if you configured GCC using @samp{powerpc-*-eabiaix}. | |
4049 | ||
4050 | @item -mcall-solaris | |
4051 | On System V.4 and embedded PowerPC systems compile code for the Solaris | |
4052 | operating system. | |
4053 | ||
4054 | @item -mcall-linux | |
861bb6c1 JL |
4055 | On System V.4 and embedded PowerPC systems compile code for the |
4056 | Linux-based GNU system. | |
74291a4b MM |
4057 | |
4058 | @item -mprototype | |
4059 | @item -mno-prototype | |
4060 | On System V.4 and embedded PowerPC systems assume that all calls to | |
4061 | variable argument functions are properly prototyped. Otherwise, the | |
4062 | compiler must insert an instruction before every non prototyped call to | |
4063 | set or clear bit 6 of the condition code register (@var{CR}) to | |
4064 | indicate whether floating point values were passed in the floating point | |
4065 | registers in case the function takes a variable arguments. With | |
4066 | @samp{-mprototype}, only calls to prototyped variable argument functions | |
4067 | will set or clear the bit. | |
4068 | ||
4069 | @item -msim | |
4070 | On embedded PowerPC systems, assume that the startup module is called | |
4071 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
4072 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}. | |
4073 | configurations. | |
4074 | ||
4075 | @item -mmvme | |
4076 | On embedded PowerPC systems, assume that the startup module is called | |
4077 | @file{mvme-crt0.o} and the standard C libraries are @file{libmvme.a} and | |
4078 | @file{libc.a}. | |
4079 | ||
4080 | @item -memb | |
4081 | On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags | |
4082 | header to indicate that @samp{eabi} extended relocations are used. | |
4083 | ||
4084 | @item -meabi | |
4085 | @itemx -mno-eabi | |
4086 | On System V.4 and embedded PowerPC systems do (do not) adhere to the | |
4087 | Embedded Applications Binary Interface (eabi) which is a set of | |
4088 | modifications to the System V.4 specifications. Selecting @code{-meabi} | |
4089 | means that the stack is aligned to an 8 byte boundary, a function | |
4090 | @code{__eabi} is called to from @code{main} to set up the eabi | |
4091 | environment, and the @samp{-msdata} option can use both @code{r2} and | |
4092 | @code{r13} to point to two separate small data areas. Selecting | |
4093 | @code{-mno-eabi} means that the stack is aligned to a 16 byte boundary, | |
4094 | do not call an initialization function from @code{main}, and the | |
4095 | @samp{-msdata} option will only use @code{r13} to point to a single | |
4096 | small data area. The @samp{-meabi} option is on by default if you | |
4097 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
4098 | ||
4099 | @item -msdata=eabi | |
4100 | On System V.4 and embedded PowerPC systems, put small initialized | |
4101 | @code{const} global and static data in the @samp{.sdata2} section, which | |
4102 | is pointed to by register @code{r2}. Put small initialized | |
4103 | non-@code{const} global and static data in the @samp{.sdata} section, | |
4104 | which is pointed to by register @code{r13}. Put small uninitialized | |
4105 | global and static data in the @samp{.sbss} section, which is adjacent to | |
4106 | the @samp{.sdata} section. The @samp{-msdata=eabi} option is | |
4107 | incompatible with the @samp{-mrelocatable} option. The | |
4108 | @samp{-msdata=eabi} option also sets the @samp{-memb} option. | |
4109 | ||
4110 | @item -msdata=sysv | |
4111 | On System V.4 and embedded PowerPC systems, put small global and static | |
4112 | data in the @samp{.sdata} section, which is pointed to by register | |
4113 | @code{r13}. Put small uninitialized global and static data in the | |
4114 | @samp{.sbss} section, which is adjacent to the @samp{.sdata} section. | |
4115 | The @samp{-msdata=sysv} option is incompatible with the | |
4116 | @samp{-mrelocatable} option. | |
4117 | ||
4118 | @item -msdata=default | |
4119 | @itemx -msdata | |
4120 | On System V.4 and embedded PowerPC systems, if @samp{-meabi} is used, | |
4121 | compile code the same as @samp{-msdata=eabi}, otherwise compile code the | |
4122 | same as @samp{-msdata=sysv}. | |
4123 | ||
4124 | @item -msdata-data | |
4125 | On System V.4 and embedded PowerPC systems, put small global and static | |
4126 | data in the @samp{.sdata} section. Put small uninitialized global and | |
4127 | static data in the @samp{.sbss} section. Do not use register @code{r13} | |
4128 | to address small data however. This is the default behavior unless | |
4129 | other @samp{-msdata} options are used. | |
4130 | ||
4131 | @item -msdata=none | |
4132 | @itemx -mno-sdata | |
4133 | On embedded PowerPC systems, put all initialized global and static data | |
4134 | in the @samp{.data} section, and all uninitialized data in the | |
4135 | @samp{.bss} section. | |
4136 | ||
4137 | @item -G @var{num} | |
4138 | @cindex smaller data references (PowerPC) | |
4139 | @cindex .sdata/.sdata2 references (PowerPC) | |
4140 | On embbeded PowerPC systems, put global and static items less than or | |
4141 | equal to @var{num} bytes into the small data or bss sections instead of | |
4142 | the normal data or bss section. By default, @var{num} is 8. The | |
4143 | @samp{-G @var{num}} switch is also passed to the linker. | |
4144 | All modules should be compiled with the same @samp{-G @var{num}} value. | |
4145 | ||
4146 | @item -mregnames | |
4147 | @itemx -mno-regnames | |
4148 | On System V.4 and embedded PowerPC systems do (do not) emit register | |
4149 | names in the assembly language output using symbolic forms. | |
4150 | @end table | |
4151 | @node RT Options | |
4152 | @subsection IBM RT Options | |
4153 | @cindex RT options | |
4154 | @cindex IBM RT options | |
4155 | ||
4156 | These @samp{-m} options are defined for the IBM RT PC: | |
4157 | ||
4158 | @table @code | |
4159 | @item -min-line-mul | |
4160 | Use an in-line code sequence for integer multiplies. This is the | |
4161 | default. | |
4162 | ||
4163 | @item -mcall-lib-mul | |
4164 | Call @code{lmul$$} for integer multiples. | |
4165 | ||
4166 | @item -mfull-fp-blocks | |
4167 | Generate full-size floating point data blocks, including the minimum | |
4168 | amount of scratch space recommended by IBM. This is the default. | |
4169 | ||
4170 | @item -mminimum-fp-blocks | |
4171 | Do not include extra scratch space in floating point data blocks. This | |
4172 | results in smaller code, but slower execution, since scratch space must | |
4173 | be allocated dynamically. | |
4174 | ||
4175 | @cindex @file{varargs.h} and RT PC | |
4176 | @cindex @file{stdarg.h} and RT PC | |
4177 | @item -mfp-arg-in-fpregs | |
4178 | Use a calling sequence incompatible with the IBM calling convention in | |
4179 | which floating point arguments are passed in floating point registers. | |
4180 | Note that @code{varargs.h} and @code{stdargs.h} will not work with | |
4181 | floating point operands if this option is specified. | |
4182 | ||
4183 | @item -mfp-arg-in-gregs | |
4184 | Use the normal calling convention for floating point arguments. This is | |
4185 | the default. | |
4186 | ||
4187 | @item -mhc-struct-return | |
4188 | Return structures of more than one word in memory, rather than in a | |
4189 | register. This provides compatibility with the MetaWare HighC (hc) | |
4190 | compiler. Use the option @samp{-fpcc-struct-return} for compatibility | |
4191 | with the Portable C Compiler (pcc). | |
4192 | ||
4193 | @item -mnohc-struct-return | |
4194 | Return some structures of more than one word in registers, when | |
4195 | convenient. This is the default. For compatibility with the | |
4196 | IBM-supplied compilers, use the option @samp{-fpcc-struct-return} or the | |
4197 | option @samp{-mhc-struct-return}. | |
4198 | @end table | |
4199 | ||
4200 | @node MIPS Options | |
4201 | @subsection MIPS Options | |
4202 | @cindex MIPS options | |
4203 | ||
4204 | These @samp{-m} options are defined for the MIPS family of computers: | |
4205 | ||
4206 | @table @code | |
4207 | @item -mcpu=@var{cpu type} | |
4208 | Assume the defaults for the machine type @var{cpu type} when scheduling | |
4209 | instructions. The choices for @var{cpu type} are @samp{r2000}, @samp{r3000}, | |
4210 | @samp{r4000}, @samp{r4400}, @samp{r4600}, and @samp{r6000}. While picking a | |
4211 | specific @var{cpu type} will schedule things appropriately for that | |
4212 | particular chip, the compiler will not generate any code that does not | |
4213 | meet level 1 of the MIPS ISA (instruction set architecture) without | |
4214 | the @samp{-mips2} or @samp{-mips3} switches being used. | |
4215 | ||
4216 | @item -mips1 | |
4217 | Issue instructions from level 1 of the MIPS ISA. This is the default. | |
4218 | @samp{r3000} is the default @var{cpu type} at this ISA level. | |
4219 | ||
4220 | @item -mips2 | |
4221 | Issue instructions from level 2 of the MIPS ISA (branch likely, square | |
4222 | root instructions). @samp{r6000} is the default @var{cpu type} at this | |
4223 | ISA level. | |
4224 | ||
4225 | @item -mips3 | |
4226 | Issue instructions from level 3 of the MIPS ISA (64 bit instructions). | |
4227 | @samp{r4000} is the default @var{cpu type} at this ISA level. | |
4228 | This option does not change the sizes of any of the C data types. | |
4229 | ||
4230 | @item -mfp32 | |
4231 | Assume that 32 32-bit floating point registers are available. This is | |
4232 | the default. | |
4233 | ||
4234 | @item -mfp64 | |
4235 | Assume that 32 64-bit floating point registers are available. This is | |
4236 | the default when the @samp{-mips3} option is used. | |
4237 | ||
4238 | @item -mgp32 | |
4239 | Assume that 32 32-bit general purpose registers are available. This is | |
4240 | the default. | |
4241 | ||
4242 | @item -mgp64 | |
4243 | Assume that 32 64-bit general purpose registers are available. This is | |
4244 | the default when the @samp{-mips3} option is used. | |
4245 | ||
4246 | @item -mint64 | |
4247 | Types long, int, and pointer are 64 bits. This works only if @samp{-mips3} | |
4248 | is also specified. | |
4249 | ||
4250 | @item -mlong64 | |
4251 | Types long and pointer are 64 bits, and type int is 32 bits. | |
4252 | This works only if @samp{-mips3} is also specified. | |
4253 | ||
4254 | @item -mmips-as | |
4255 | Generate code for the MIPS assembler, and invoke @file{mips-tfile} to | |
4256 | add normal debug information. This is the default for all | |
4257 | platforms except for the OSF/1 reference platform, using the OSF/rose | |
4258 | object format. If the either of the @samp{-gstabs} or @samp{-gstabs+} | |
4259 | switches are used, the @file{mips-tfile} program will encapsulate the | |
4260 | stabs within MIPS ECOFF. | |
4261 | ||
4262 | @item -mgas | |
4263 | Generate code for the GNU assembler. This is the default on the OSF/1 | |
861bb6c1 JL |
4264 | reference platform, using the OSF/rose object format. Also, this is |
4265 | the default if the configure option @samp{--with-gnu-as} is used. | |
4266 | ||
4267 | @item -msplit-addresses | |
4268 | @itemx -mno-split-addresses | |
4269 | Generate code to load the high and low parts of address constants separately. | |
4270 | This allows @code{gcc} to optimize away redundant loads of the high order | |
4271 | bits of addresses. This optimization requires GNU as and GNU ld. | |
4272 | This optimization is enabled by default for some embedded targets where | |
4273 | GNU as and GNU ld are standard. | |
74291a4b MM |
4274 | |
4275 | @item -mrnames | |
4276 | @itemx -mno-rnames | |
4277 | The @samp{-mrnames} switch says to output code using the MIPS software | |
4278 | names for the registers, instead of the hardware names (ie, @var{a0} | |
4279 | instead of @var{$4}). The only known assembler that supports this option | |
4280 | is the Algorithmics assembler. | |
4281 | ||
4282 | @item -mgpopt | |
4283 | @itemx -mno-gpopt | |
4284 | The @samp{-mgpopt} switch says to write all of the data declarations | |
4285 | before the instructions in the text section, this allows the MIPS | |
4286 | assembler to generate one word memory references instead of using two | |
4287 | words for short global or static data items. This is on by default if | |
4288 | optimization is selected. | |
4289 | ||
4290 | @item -mstats | |
4291 | @itemx -mno-stats | |
4292 | For each non-inline function processed, the @samp{-mstats} switch | |
4293 | causes the compiler to emit one line to the standard error file to | |
4294 | print statistics about the program (number of registers saved, stack | |
4295 | size, etc.). | |
4296 | ||
4297 | @item -mmemcpy | |
4298 | @itemx -mno-memcpy | |
4299 | The @samp{-mmemcpy} switch makes all block moves call the appropriate | |
4300 | string function (@samp{memcpy} or @samp{bcopy}) instead of possibly | |
4301 | generating inline code. | |
4302 | ||
4303 | @item -mmips-tfile | |
4304 | @itemx -mno-mips-tfile | |
4305 | The @samp{-mno-mips-tfile} switch causes the compiler not | |
4306 | postprocess the object file with the @file{mips-tfile} program, | |
4307 | after the MIPS assembler has generated it to add debug support. If | |
4308 | @file{mips-tfile} is not run, then no local variables will be | |
4309 | available to the debugger. In addition, @file{stage2} and | |
4310 | @file{stage3} objects will have the temporary file names passed to the | |
4311 | assembler embedded in the object file, which means the objects will | |
4312 | not compare the same. The @samp{-mno-mips-tfile} switch should only | |
4313 | be used when there are bugs in the @file{mips-tfile} program that | |
4314 | prevents compilation. | |
4315 | ||
4316 | @item -msoft-float | |
4317 | Generate output containing library calls for floating point. | |
4318 | @strong{Warning:} the requisite libraries are not part of GNU CC. | |
4319 | Normally the facilities of the machine's usual C compiler are used, but | |
4320 | this can't be done directly in cross-compilation. You must make your | |
4321 | own arrangements to provide suitable library functions for | |
4322 | cross-compilation. | |
4323 | ||
4324 | @item -mhard-float | |
4325 | Generate output containing floating point instructions. This is the | |
4326 | default if you use the unmodified sources. | |
4327 | ||
4328 | @item -mabicalls | |
4329 | @itemx -mno-abicalls | |
4330 | Emit (or do not emit) the pseudo operations @samp{.abicalls}, | |
4331 | @samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for | |
4332 | position independent code. | |
4333 | ||
4334 | @item -mlong-calls | |
4335 | @itemx -mno-long-calls | |
4336 | Do all calls with the @samp{JALR} instruction, which requires | |
4337 | loading up a function's address into a register before the call. | |
4338 | You need to use this switch, if you call outside of the current | |
4339 | 512 megabyte segment to functions that are not through pointers. | |
4340 | ||
4341 | @item -mhalf-pic | |
4342 | @itemx -mno-half-pic | |
4343 | Put pointers to extern references into the data section and load them | |
4344 | up, rather than put the references in the text section. | |
4345 | ||
4346 | @item -membedded-pic | |
4347 | @itemx -mno-embedded-pic | |
4348 | Generate PIC code suitable for some embedded systems. All calls are made | |
4349 | using PC relative address, and all data is addressed using the $gp register. | |
4350 | This requires GNU as and GNU ld which do most of the work. | |
4351 | ||
4352 | @item -membedded-data | |
4353 | @itemx -mno-embedded-data | |
4354 | Allocate variables to the read-only data section first if possible, then | |
4355 | next in the small data section if possible, otherwise in data. This gives | |
4356 | slightly slower code than the default, but reduces the amount of RAM required | |
4357 | when executing, and thus may be preferred for some embedded systems. | |
4358 | ||
4359 | @item -msingle-float | |
4360 | @itemx -mdouble-float | |
4361 | The @samp{-msingle-float} switch tells gcc to assume that the floating | |
4362 | point coprocessor only supports single precision operations, as on the | |
4363 | @samp{r4650} chip. The @samp{-mdouble-float} switch permits gcc to use | |
4364 | double precision operations. This is the default. | |
4365 | ||
4366 | @item -mmad | |
4367 | @itemx -mno-mad | |
4368 | Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions, | |
4369 | as on the @samp{r4650} chip. | |
4370 | ||
4371 | @item -m4650 | |
4372 | Turns on @samp{-msingle-float}, @samp{-mmad}, and, at least for now, | |
4373 | @samp{-mcpu=r4650}. | |
4374 | ||
4375 | @item -EL | |
4376 | Compile code for the processor in little endian mode. | |
4377 | The requisite libraries are assumed to exist. | |
4378 | ||
4379 | @item -EB | |
4380 | Compile code for the processor in big endian mode. | |
4381 | The requisite libraries are assumed to exist. | |
4382 | ||
4383 | @item -G @var{num} | |
4384 | @cindex smaller data references (MIPS) | |
4385 | @cindex gp-relative references (MIPS) | |
4386 | Put global and static items less than or equal to @var{num} bytes into | |
4387 | the small data or bss sections instead of the normal data or bss | |
4388 | section. This allows the assembler to emit one word memory reference | |
4389 | instructions based on the global pointer (@var{gp} or @var{$28}), | |
4390 | instead of the normal two words used. By default, @var{num} is 8 when | |
4391 | the MIPS assembler is used, and 0 when the GNU assembler is used. The | |
4392 | @samp{-G @var{num}} switch is also passed to the assembler and linker. | |
4393 | All modules should be compiled with the same @samp{-G @var{num}} | |
4394 | value. | |
4395 | ||
4396 | @item -nocpp | |
4397 | Tell the MIPS assembler to not run it's preprocessor over user | |
4398 | assembler files (with a @samp{.s} suffix) when assembling them. | |
4399 | @end table | |
4400 | ||
4401 | @ifset INTERNALS | |
4402 | These options are defined by the macro | |
4403 | @code{TARGET_SWITCHES} in the machine description. The default for the | |
4404 | options is also defined by that macro, which enables you to change the | |
4405 | defaults. | |
4406 | @end ifset | |
4407 | ||
4408 | @node i386 Options | |
4409 | @subsection Intel 386 Options | |
4410 | @cindex i386 Options | |
4411 | @cindex Intel 386 Options | |
4412 | ||
4413 | These @samp{-m} options are defined for the i386 family of computers: | |
4414 | ||
4415 | @table @code | |
4416 | @item -m486 | |
4417 | @itemx -m386 | |
4418 | Control whether or not code is optimized for a 486 instead of an | |
4419 | 386. Code generated for an 486 will run on a 386 and vice versa. | |
4420 | ||
4421 | @item -mieee-fp | |
4422 | @itemx -mno-ieee-fp | |
4423 | Control whether or not the compiler uses IEEE floating point | |
4424 | comparisons. These handle correctly the case where the result of a | |
4425 | comparison is unordered. | |
4426 | ||
4427 | @item -msoft-float | |
4428 | Generate output containing library calls for floating point. | |
4429 | @strong{Warning:} the requisite libraries are not part of GNU CC. | |
4430 | Normally the facilities of the machine's usual C compiler are used, but | |
4431 | this can't be done directly in cross-compilation. You must make your | |
4432 | own arrangements to provide suitable library functions for | |
4433 | cross-compilation. | |
4434 | ||
4435 | On machines where a function returns floating point results in the 80387 | |
4436 | register stack, some floating point opcodes may be emitted even if | |
4437 | @samp{-msoft-float} is used. | |
4438 | ||
4439 | @item -mno-fp-ret-in-387 | |
4440 | Do not use the FPU registers for return values of functions. | |
4441 | ||
4442 | The usual calling convention has functions return values of types | |
4443 | @code{float} and @code{double} in an FPU register, even if there | |
4444 | is no FPU. The idea is that the operating system should emulate | |
4445 | an FPU. | |
4446 | ||
4447 | The option @samp{-mno-fp-ret-in-387} causes such values to be returned | |
4448 | in ordinary CPU registers instead. | |
4449 | ||
4450 | @item -mno-fancy-math-387 | |
4451 | Some 387 emulators do not support the @code{sin}, @code{cos} and | |
4452 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
4453 | generating those instructions. This option is the default on FreeBSD. | |
4454 | As of revision 2.6.1, these instructions are not generated unless you | |
4455 | also use the @samp{-ffast-math} switch. | |
4456 | ||
4457 | @item -malign-double | |
4458 | @itemx -mno-align-double | |
4459 | Control whether GNU CC aligns @code{double}, @code{long double}, and | |
4460 | @code{long long} variables on a two word boundary or a one word | |
4461 | boundary. Aligning @code{double} variables on a two word boundary will | |
4462 | produce code that runs somewhat faster on a @samp{Pentium} at the | |
4463 | expense of more memory. | |
4464 | ||
4465 | @strong{Warning:} if you use the @samp{-malign-double} switch, | |
4466 | structures containing the above types will be aligned differently than | |
4467 | the published application binary interface specifications for the 386. | |
4468 | ||
4469 | @item -msvr3-shlib | |
4470 | @itemx -mno-svr3-shlib | |
4471 | Control whether GNU CC places uninitialized locals into @code{bss} or | |
4472 | @code{data}. @samp{-msvr3-shlib} places these locals into @code{bss}. | |
4473 | These options are meaningful only on System V Release 3. | |
4474 | ||
4475 | @item -mno-wide-multiply | |
4476 | @itemx -mwide-multiply | |
4477 | Control whether GNU CC uses the @code{mul} and @code{imul} that produce | |
4478 | 64 bit results in @code{eax:edx} from 32 bit operands to do @code{long | |
4479 | long} multiplies and 32-bit division by constants. | |
4480 | ||
4481 | @item -mrtd | |
4482 | Use a different function-calling convention, in which functions that | |
4483 | take a fixed number of arguments return with the @code{ret} @var{num} | |
4484 | instruction, which pops their arguments while returning. This saves one | |
4485 | instruction in the caller since there is no need to pop the arguments | |
4486 | there. | |
4487 | ||
4488 | You can specify that an individual function is called with this calling | |
4489 | sequence with the function attribute @samp{stdcall}. You can also | |
4490 | override the @samp{-mrtd} option by using the function attribute | |
4491 | @samp{cdecl}. @xref{Function Attributes} | |
4492 | ||
4493 | @strong{Warning:} this calling convention is incompatible with the one | |
4494 | normally used on Unix, so you cannot use it if you need to call | |
4495 | libraries compiled with the Unix compiler. | |
4496 | ||
4497 | Also, you must provide function prototypes for all functions that | |
4498 | take variable numbers of arguments (including @code{printf}); | |
4499 | otherwise incorrect code will be generated for calls to those | |
4500 | functions. | |
4501 | ||
4502 | In addition, seriously incorrect code will result if you call a | |
4503 | function with too many arguments. (Normally, extra arguments are | |
4504 | harmlessly ignored.) | |
4505 | ||
4506 | @item -mreg-alloc=@var{regs} | |
4507 | Control the default allocation order of integer registers. The | |
4508 | string @var{regs} is a series of letters specifying a register. The | |
4509 | supported letters are: @code{a} allocate EAX; @code{b} allocate EBX; | |
4510 | @code{c} allocate ECX; @code{d} allocate EDX; @code{S} allocate ESI; | |
4511 | @code{D} allocate EDI; @code{B} allocate EBP. | |
4512 | ||
4513 | @item -mregparm=@var{num} | |
4514 | Control how many registers are used to pass integer arguments. By | |
4515 | default, no registers are used to pass arguments, and at most 3 | |
4516 | registers can be used. You can control this behavior for a specific | |
4517 | function by using the function attribute @samp{regparm}. @xref{Function Attributes} | |
4518 | ||
4519 | @strong{Warning:} if you use this switch, and | |
4520 | @var{num} is nonzero, then you must build all modules with the same | |
4521 | value, including any libraries. This includes the system libraries and | |
4522 | startup modules. | |
4523 | ||
4524 | @item -malign-loops=@var{num} | |
4525 | Align loops to a 2 raised to a @var{num} byte boundary. If | |
4526 | @samp{-malign-loops} is not specified, the default is 2. | |
4527 | ||
4528 | @item -malign-jumps=@var{num} | |
4529 | Align instructions that are only jumped to to a 2 raised to a @var{num} | |
4530 | byte boundary. If @samp{-malign-jumps} is not specified, the default is | |
4531 | 2 if optimizing for a 386, and 4 if optimizing for a 486. | |
4532 | ||
4533 | @item -malign-functions=@var{num} | |
4534 | Align the start of functions to a 2 raised to @var{num} byte boundary. | |
6d4312dd | 4535 | If @samp{-malign-functions} is not specified, the default is 2 if optimizing |
74291a4b MM |
4536 | for a 386, and 4 if optimizing for a 486. |
4537 | @end table | |
4538 | ||
4539 | @node HPPA Options | |
4540 | @subsection HPPA Options | |
4541 | @cindex HPPA Options | |
4542 | ||
4543 | These @samp{-m} options are defined for the HPPA family of computers: | |
4544 | ||
4545 | @table @code | |
4546 | @item -mpa-risc-1-0 | |
4547 | Generate code for a PA 1.0 processor. | |
4548 | ||
4549 | @item -mpa-risc-1-1 | |
4550 | Generate code for a PA 1.1 processor. | |
4551 | ||
861bb6c1 JL |
4552 | @item -mbig-switch |
4553 | Generate code suitable for big switch tables. Use this option only if | |
4554 | the assembler/linker complain about out of range branches within a switch | |
4555 | table. | |
4556 | ||
74291a4b MM |
4557 | @item -mjump-in-delay |
4558 | Fill delay slots of function calls with unconditional jump instructions | |
4559 | by modifying the return pointer for the function call to be the target | |
4560 | of the conditional jump. | |
4561 | ||
4562 | @item -mdisable-fpregs | |
4563 | Prevent floating point registers from being used in any manner. This is | |
4564 | necessary for compiling kernels which perform lazy context switching of | |
4565 | floating point registers. If you use this option and attempt to perform | |
4566 | floating point operations, the compiler will abort. | |
4567 | ||
4568 | @item -mdisable-indexing | |
4569 | Prevent the compiler from using indexing address modes. This avoids some | |
4570 | rather obscure problems when compiling MIG generated code under MACH. | |
4571 | ||
4572 | @item -mno-space-regs | |
4573 | Generate code that assumes the target has no space registers. This allows | |
4574 | GCC to generate faster indirect calls and use unscaled index address modes. | |
4575 | ||
4576 | Such code is suitable for level 0 PA systems and kernels. | |
4577 | ||
4578 | @item -mfast-indirect-calls | |
4579 | Generate code that assumes calls never cross space boundaries. This | |
4580 | allows GCC to emit code which performs faster indirect calls. | |
4581 | ||
4582 | This option will not work in the presense of shared libraries or nested | |
4583 | functions. | |
4584 | ||
4585 | @item -mspace | |
4586 | Optimize for space rather than execution time. Currently this only | |
4587 | enables out of line function prologues and epilogues. This option is | |
4588 | incompatable with PIC code generation and profiling. | |
4589 | ||
4590 | @item -mlong-load-store | |
4591 | Generate 3-instruction load and store sequences as sometimes required by | |
4592 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
4593 | the HP compilers. | |
4594 | ||
4595 | @item -mportable-runtime | |
4596 | Use the portable calling conventions proposed by HP for ELF systems. | |
4597 | ||
4598 | @item -mgas | |
4599 | Enable the use of assembler directives only GAS understands. | |
4600 | ||
4601 | @item -mschedule=@var{cpu type} | |
4602 | Schedule code according to the constraints for the machine type | |
4603 | @var{cpu type}. The choices for @var{cpu type} are @samp{700} for | |
4604 | 7@var{n}0 machines, @samp{7100} for 7@var{n}5 machines, and @samp{7100} | |
4605 | for 7@var{n}2 machines. @samp{7100} is the default for @var{cpu type}. | |
4606 | ||
4607 | Note the @samp{7100LC} scheduling information is incomplete and using | |
4608 | @samp{7100LC} often leads to bad schedules. For now it's probably best | |
4609 | to use @samp{7100} instead of @samp{7100LC} for the 7@var{n}2 machines. | |
4610 | ||
4611 | @item -mlinker-opt | |
4612 | Enable the optimization pass in the HPUX linker. Note this makes symbolic | |
4613 | debugging impossible. It also triggers a bug in the HPUX 8 and HPUX 9 linkers | |
4614 | in which they give bogus error messages when linking some programs. | |
4615 | ||
4616 | @item -msoft-float | |
4617 | Generate output containing library calls for floating point. | |
4618 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
4619 | targets. Normally the facilities of the machine's usual C compiler are | |
4620 | used, but this cannot be done directly in cross-compilation. You must make | |
4621 | your own arrangements to provide suitable library functions for | |
4622 | cross-compilation. The embedded target @samp{hppa1.1-*-pro} | |
4623 | does provide software floating point support. | |
4624 | ||
4625 | @samp{-msoft-float} changes the calling convention in the output file; | |
4626 | therefore, it is only useful if you compile @emph{all} of a program with | |
4627 | this option. In particular, you need to compile @file{libgcc.a}, the | |
4628 | library that comes with GNU CC, with @samp{-msoft-float} in order for | |
4629 | this to work. | |
4630 | @end table | |
4631 | ||
4632 | @node Intel 960 Options | |
4633 | @subsection Intel 960 Options | |
4634 | ||
4635 | These @samp{-m} options are defined for the Intel 960 implementations: | |
4636 | ||
4637 | @table @code | |
4638 | @item -m@var{cpu type} | |
4639 | Assume the defaults for the machine type @var{cpu type} for some of | |
4640 | the other options, including instruction scheduling, floating point | |
4641 | support, and addressing modes. The choices for @var{cpu type} are | |
4642 | @samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf}, | |
4643 | @samp{sa}, and @samp{sb}. | |
4644 | The default is | |
4645 | @samp{kb}. | |
4646 | ||
4647 | @item -mnumerics | |
4648 | @itemx -msoft-float | |
4649 | The @samp{-mnumerics} option indicates that the processor does support | |
4650 | floating-point instructions. The @samp{-msoft-float} option indicates | |
4651 | that floating-point support should not be assumed. | |
4652 | ||
4653 | @item -mleaf-procedures | |
4654 | @itemx -mno-leaf-procedures | |
4655 | Do (or do not) attempt to alter leaf procedures to be callable with the | |
4656 | @code{bal} instruction as well as @code{call}. This will result in more | |
4657 | efficient code for explicit calls when the @code{bal} instruction can be | |
4658 | substituted by the assembler or linker, but less efficient code in other | |
4659 | cases, such as calls via function pointers, or using a linker that doesn't | |
4660 | support this optimization. | |
4661 | ||
4662 | @item -mtail-call | |
4663 | @itemx -mno-tail-call | |
4664 | Do (or do not) make additional attempts (beyond those of the | |
4665 | machine-independent portions of the compiler) to optimize tail-recursive | |
4666 | calls into branches. You may not want to do this because the detection of | |
4667 | cases where this is not valid is not totally complete. The default is | |
4668 | @samp{-mno-tail-call}. | |
4669 | ||
4670 | @item -mcomplex-addr | |
4671 | @itemx -mno-complex-addr | |
4672 | Assume (or do not assume) that the use of a complex addressing mode is a | |
4673 | win on this implementation of the i960. Complex addressing modes may not | |
4674 | be worthwhile on the K-series, but they definitely are on the C-series. | |
4675 | The default is currently @samp{-mcomplex-addr} for all processors except | |
4676 | the CB and CC. | |
4677 | ||
4678 | @item -mcode-align | |
4679 | @itemx -mno-code-align | |
4680 | Align code to 8-byte boundaries for faster fetching (or don't bother). | |
4681 | Currently turned on by default for C-series implementations only. | |
4682 | ||
4683 | @ignore | |
4684 | @item -mclean-linkage | |
4685 | @itemx -mno-clean-linkage | |
4686 | These options are not fully implemented. | |
4687 | @end ignore | |
4688 | ||
4689 | @item -mic-compat | |
4690 | @itemx -mic2.0-compat | |
4691 | @itemx -mic3.0-compat | |
4692 | Enable compatibility with iC960 v2.0 or v3.0. | |
4693 | ||
4694 | @item -masm-compat | |
4695 | @itemx -mintel-asm | |
4696 | Enable compatibility with the iC960 assembler. | |
4697 | ||
4698 | @item -mstrict-align | |
4699 | @itemx -mno-strict-align | |
4700 | Do not permit (do permit) unaligned accesses. | |
4701 | ||
4702 | @item -mold-align | |
4703 | Enable structure-alignment compatibility with Intel's gcc release version | |
861bb6c1 | 4704 | 1.3 (based on gcc 1.37). This option implies @samp{-mstrict-align}. |
74291a4b MM |
4705 | @end table |
4706 | ||
4707 | @node DEC Alpha Options | |
4708 | @subsection DEC Alpha Options | |
4709 | ||
4710 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
4711 | ||
4712 | @table @code | |
4713 | @item -mno-soft-float | |
4714 | @itemx -msoft-float | |
4715 | Use (do not use) the hardware floating-point instructions for | |
4716 | floating-point operations. When @code{-msoft-float} is specified, | |
4717 | functions in @file{libgcc1.c} will be used to perform floating-point | |
4718 | operations. Unless they are replaced by routines that emulate the | |
4719 | floating-point operations, or compiled in such a way as to call such | |
4720 | emulations routines, these routines will issue floating-point | |
4721 | operations. If you are compiling for an Alpha without floating-point | |
4722 | operations, you must ensure that the library is built so as not to call | |
4723 | them. | |
4724 | ||
4725 | Note that Alpha implementations without floating-point operations are | |
4726 | required to have floating-point registers. | |
4727 | ||
4728 | @item -mfp-reg | |
4729 | @itemx -mno-fp-regs | |
4730 | Generate code that uses (does not use) the floating-point register set. | |
4731 | @code{-mno-fp-regs} implies @code{-msoft-float}. If the floating-point | |
4732 | register set is not used, floating point operands are passed in integer | |
4733 | registers as if they were integers and floating-point results are passed | |
4734 | in $0 instead of $f0. This is a non-standard calling sequence, so any | |
4735 | function with a floating-point argument or return value called by code | |
4736 | compiled with @code{-mno-fp-regs} must also be compiled with that | |
4737 | option. | |
4738 | ||
4739 | A typical use of this option is building a kernel that does not use, | |
4740 | and hence need not save and restore, any floating-point registers. | |
4741 | ||
4742 | @item -mieee | |
4743 | The Alpha architecture implements floating-point hardware optimized for | |
4744 | maximum performance. It is mostly compliant with the IEEE floating | |
4745 | point standard. However, for full compliance, software assistance is | |
4746 | required. This option generates code fully IEEE compliant code | |
4747 | @emph{except} that the @var{inexact flag} is not maintained (see below). | |
4748 | If this option is turned on, the CPP macro @code{_IEEE_FP} is defined | |
4749 | during compilation. The option is a shorthand for: @samp{-D_IEEE_FP | |
4750 | -mfp-trap-mode=su -mtrap-precision=i -mieee-conformant}. The resulting | |
4751 | code is less efficient but is able to correctly support denormalized | |
4752 | numbers and exceptional IEEE values such as not-a-number and plus/minus | |
4753 | infinity. Other Alpha compilers call this option | |
4754 | @code{-ieee_with_no_inexact}. | |
4755 | ||
4756 | @item -mieee-with-inexact | |
4757 | @c overfull hbox here --bob 22 jul96 | |
4758 | @c original text between ignore ... end ignore | |
4759 | @ignore | |
4760 | This is like @samp{-mieee} except the generated code also maintains the | |
4761 | IEEE @var{inexact flag}. Turning on this option causes the generated | |
4762 | code to implement fully-compliant IEEE math. The option is a shorthand | |
4763 | for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus @samp{-mieee-conformant}, | |
4764 | @samp{-mfp-trap-mode=sui}, and @samp{-mtrap-precision=i}. On some Alpha | |
4765 | implementations the resulting code may execute significantly slower than | |
4766 | the code generated by default. Since there is very little code that | |
4767 | depends on the @var{inexact flag}, you should normally not specify this | |
4768 | option. Other Alpha compilers call this option | |
4769 | @samp{-ieee_with_inexact}. | |
4770 | @end ignore | |
4771 | @c changed paragraph | |
4772 | This is like @samp{-mieee} except the generated code also maintains the | |
4773 | IEEE @var{inexact flag}. Turning on this option causes the generated | |
4774 | code to implement fully-compliant IEEE math. The option is a shorthand | |
4775 | for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus the three following: | |
4776 | @samp{-mieee-conformant}, | |
4777 | @samp{-mfp-trap-mode=sui}, | |
4778 | and @samp{-mtrap-precision=i}. | |
4779 | On some Alpha implementations the resulting code may execute | |
4780 | significantly slower than the code generated by default. Since there | |
4781 | is very little code that depends on the @var{inexact flag}, you should | |
4782 | normally not specify this option. Other Alpha compilers call this | |
4783 | option @samp{-ieee_with_inexact}. | |
4784 | @c end changes to prevent overfull hboxes | |
4785 | ||
4786 | @item -mfp-trap-mode=@var{trap mode} | |
4787 | This option controls what floating-point related traps are enabled. | |
4788 | Other Alpha compilers call this option @samp{-fptm }@var{trap mode}. | |
4789 | The trap mode can be set to one of four values: | |
4790 | ||
4791 | @table @samp | |
4792 | @item n | |
4793 | This is the default (normal) setting. The only traps that are enabled | |
4794 | are the ones that cannot be disabled in software (e.g., division by zero | |
4795 | trap). | |
4796 | ||
4797 | @item u | |
4798 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
4799 | as well. | |
4800 | ||
4801 | @item su | |
4802 | Like @samp{su}, but the instructions are marked to be safe for software | |
4803 | completion (see Alpha architecture manual for details). | |
4804 | ||
4805 | @item sui | |
4806 | Like @samp{su}, but inexact traps are enabled as well. | |
4807 | @end table | |
4808 | ||
4809 | @item -mfp-rounding-mode=@var{rounding mode} | |
4810 | Selects the IEEE rounding mode. Other Alpha compilers call this option | |
4811 | @samp{-fprm }@var{rounding mode}. The @var{rounding mode} can be one | |
4812 | of: | |
4813 | ||
4814 | @table @samp | |
4815 | @item n | |
4816 | Normal IEEE rounding mode. Floating point numbers are rounded towards | |
4817 | the nearest machine number or towards the even machine number in case | |
4818 | of a tie. | |
4819 | ||
4820 | @item m | |
4821 | Round towards minus infinity. | |
4822 | ||
4823 | @item c | |
4824 | Chopped rounding mode. Floating point numbers are rounded towards zero. | |
4825 | ||
4826 | @item d | |
4827 | Dynamic rounding mode. A field in the floating point control register | |
4828 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
4829 | rounding mode in effect. The C library initializes this register for | |
4830 | rounding towards plus infinity. Thus, unless your program modifies the | |
4831 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity.@end table | |
4832 | ||
4833 | @item -mtrap-precision=@var{trap precision} | |
4834 | In the Alpha architecture, floating point traps are imprecise. This | |
4835 | means without software assistance it is impossible to recover from a | |
4836 | floating trap and program execution normally needs to be terminated. | |
4837 | GNU CC can generate code that can assist operating system trap handlers | |
4838 | in determining the exact location that caused a floating point trap. | |
4839 | Depending on the requirements of an application, different levels of | |
4840 | precisions can be selected: | |
4841 | ||
4842 | @table @samp | |
4843 | @item p | |
4844 | Program precision. This option is the default and means a trap handler | |
4845 | can only identify which program caused a floating point exception. | |
4846 | ||
4847 | @item f | |
4848 | Function precision. The trap handler can determine the function that | |
4849 | caused a floating point exception. | |
4850 | ||
4851 | @item i | |
4852 | Instruction precision. The trap handler can determine the exact | |
4853 | instruction that caused a floating point exception. | |
4854 | @end table | |
4855 | ||
4856 | Other Alpha compilers provide the equivalent options called | |
4857 | @samp{-scope_safe} and @samp{-resumption_safe}. | |
4858 | ||
4859 | @item -mieee-conformant | |
4860 | This option marks the generated code as IEEE conformant. You must not | |
4861 | use this option unless you also specify @samp{-mtrap-precision=i} and either | |
4862 | @samp{-mfp-trap-mode=su} or @samp{-mfp-trap-mode=sui}. Its only effect | |
4863 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
4864 | generated assembly file. Under DEC Unix, this has the effect that | |
4865 | IEEE-conformant math library routines will be linked in. | |
4866 | ||
4867 | @item -mbuild-constants | |
4868 | Normally GNU CC examines a 32- or 64-bit integer constant to | |
4869 | see if it can construct it from smaller constants in two or three | |
4870 | instructions. If it cannot, it will output the constant as a literal and | |
4871 | generate code to load it from the data segement at runtime. | |
4872 | ||
4873 | Use this option to require GNU CC to construct @emph{all} integer constants | |
4874 | using code, even if it takes more instructions (the maximum is six). | |
4875 | ||
4876 | You would typically use this option to build a shared library dynamic | |
4877 | loader. Itself a shared library, it must relocate itself in memory | |
4878 | before it can find the variables and constants in its own data segment. | |
4879 | @end table | |
4880 | ||
4881 | @node Clipper Options | |
4882 | @subsection Clipper Options | |
4883 | ||
4884 | These @samp{-m} options are defined for the Clipper implementations: | |
4885 | ||
4886 | @table @code | |
4887 | @item -mc300 | |
4888 | Produce code for a C300 Clipper processor. This is the default. | |
4889 | ||
4890 | @itemx -mc400 | |
4891 | Produce code for a C400 Clipper processor i.e. use floating point | |
4892 | registers f8..f15. | |
4893 | @end table | |
4894 | ||
4895 | @node H8/300 Options | |
4896 | @subsection H8/300 Options | |
4897 | ||
4898 | These @samp{-m} options are defined for the H8/300 implementations: | |
4899 | ||
4900 | @table @code | |
4901 | @item -mrelax | |
4902 | Shorten some address references at link time, when possible; uses the | |
4903 | linker option @samp{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
4904 | ld.info, Using ld}, for a fuller description. | |
4905 | ||
4906 | @item -mh | |
4907 | Generate code for the H8/300H. | |
4908 | ||
dcb9d1f0 JL |
4909 | @item -ms |
4910 | Generate code for the H8/S. | |
4911 | ||
74291a4b MM |
4912 | @item -mint32 |
4913 | Make @code{int} data 32 bits by default. | |
4914 | ||
4915 | @item -malign-300 | |
4916 | On the h8/300h, use the same alignment rules as for the h8/300. | |
4917 | The default for the h8/300h is to align longs and floats on 4 byte boundaries. | |
4918 | @samp{-malign-300} causes them to be aligned on 2 byte boundaries. | |
4919 | This option has no effect on the h8/300. | |
4920 | @end table | |
4921 | ||
4922 | @node SH Options | |
4923 | @subsection SH Options | |
4924 | ||
4925 | These @samp{-m} options are defined for the SH implementations: | |
4926 | ||
4927 | @table @code | |
4928 | @item -m1 | |
4929 | Generate code for the SH1. | |
4930 | ||
4931 | @item -m2 | |
4932 | Generate code for the SH2. | |
4933 | ||
4934 | @item -m3 | |
4935 | Generate code for the SH3. | |
4936 | ||
4937 | @item -m3e | |
4938 | Generate code for the SH3e. | |
4939 | ||
4940 | @item -mb | |
4941 | Compile code for the processor in big endian mode. | |
4942 | ||
4943 | @item -ml | |
4944 | Compile code for the processor in little endian mode. | |
4945 | ||
4946 | @item -mrelax | |
4947 | Shorten some address references at link time, when possible; uses the | |
4948 | linker option @samp{-relax}. | |
4949 | @end table | |
4950 | ||
4951 | @node System V Options | |
4952 | @subsection Options for System V | |
4953 | ||
4954 | These additional options are available on System V Release 4 for | |
4955 | compatibility with other compilers on those systems: | |
4956 | ||
4957 | @table @code | |
4958 | @item -G | |
4959 | Create a shared object. | |
4960 | It is recommended that @samp{-symbolic} or @samp{-shared} be used instead. | |
4961 | ||
4962 | @item -Qy | |
4963 | Identify the versions of each tool used by the compiler, in a | |
4964 | @code{.ident} assembler directive in the output. | |
4965 | ||
4966 | @item -Qn | |
4967 | Refrain from adding @code{.ident} directives to the output file (this is | |
4968 | the default). | |
4969 | ||
4970 | @item -YP,@var{dirs} | |
4971 | Search the directories @var{dirs}, and no others, for libraries | |
4972 | specified with @samp{-l}. | |
4973 | ||
4974 | @item -Ym,@var{dir} | |
4975 | Look in the directory @var{dir} to find the M4 preprocessor. | |
4976 | The assembler uses this option. | |
4977 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
4978 | @c the generic assembler that comes with Solaris takes just -Ym. | |
4979 | @end table | |
4980 | ||
f84271d9 JL |
4981 | @node V850 Options |
4982 | @subsection V850 Options | |
4983 | @cindex V850 Options | |
4984 | ||
4985 | These @samp{-m} options are defined for V850 implementations: | |
4986 | ||
4987 | @table @code | |
4988 | @item -mlong-calls | |
4989 | @itemx -mno-long-calls | |
4990 | Treat all calls as being far away (near). If calls are assumed to be | |
4991 | far away, the compiler will always load the functions address up into a | |
4992 | register, and call indirect through the pointer. | |
4993 | ||
4994 | @item -mno-ep | |
4995 | @item -mep | |
4996 | Do not optimize (do optimize) basic blocks that use the same index | |
4997 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
4998 | use the shorter @code{sld} and @code{sst} instructions. The @samp{-mep} | |
4999 | option is on by default if you optimize. | |
5000 | ||
5001 | @item -mno-prolog-function | |
5002 | @itemx -mprolog-function | |
5003 | Do not use (do use) external functions to save and restore registers at | |
5004 | the prolog and epilog of a function. The external functions are slower, | |
5005 | but use less code space if more than one function saves the same number | |
5006 | of registers. The @samp{-mprolog-function} option is on by default if | |
5007 | you optimize. | |
5008 | ||
5009 | @item -mspace | |
5010 | Try to make the code as small as possible. At present, this just turns | |
5011 | on the @samp{-mep} and @samp{-mprolog-function} options. | |
5012 | ||
5013 | @item -mtda=@var{n} | |
5014 | Put static or global variables whose size is @var{n} bytes or less into | |
5015 | the tiny data area that register @code{ep} points to. The tiny data | |
5016 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
5017 | ||
5018 | @item -msda=@var{n} | |
5019 | Put static or global variables whose size is @var{n} bytes or less into | |
5020 | the small data area that register @code{gp} points to. The small data | |
5021 | area can hold up to 64 kilobytes. | |
5022 | ||
5023 | @item -mzda=@var{n} | |
5024 | Put static or global variables whose size is @var{n} bytes or less into | |
5025 | the first 32 kilobytes of memory. | |
8c81598d | 5026 | |
48f0be1b SC |
5027 | @item -mv850 |
5028 | Specify that the target processor is the V850. | |
5029 | ||
f84271d9 JL |
5030 | @end table |
5031 | ||
74291a4b MM |
5032 | @node Code Gen Options |
5033 | @section Options for Code Generation Conventions | |
5034 | @cindex code generation conventions | |
5035 | @cindex options, code generation | |
5036 | @cindex run-time options | |
5037 | ||
5038 | These machine-independent options control the interface conventions | |
5039 | used in code generation. | |
5040 | ||
5041 | Most of them have both positive and negative forms; the negative form | |
5042 | of @samp{-ffoo} would be @samp{-fno-foo}. In the table below, only | |
5043 | one of the forms is listed---the one which is not the default. You | |
5044 | can figure out the other form by either removing @samp{no-} or adding | |
5045 | it. | |
5046 | ||
5047 | @table @code | |
5048 | @item -fpcc-struct-return | |
5049 | Return ``short'' @code{struct} and @code{union} values in memory like | |
5050 | longer ones, rather than in registers. This convention is less | |
5051 | efficient, but it has the advantage of allowing intercallability between | |
5052 | GNU CC-compiled files and files compiled with other compilers. | |
5053 | ||
5054 | The precise convention for returning structures in memory depends | |
5055 | on the target configuration macros. | |
5056 | ||
5057 | Short structures and unions are those whose size and alignment match | |
5058 | that of some integer type. | |
5059 | ||
5060 | @item -freg-struct-return | |
5061 | Use the convention that @code{struct} and @code{union} values are | |
5062 | returned in registers when possible. This is more efficient for small | |
5063 | structures than @samp{-fpcc-struct-return}. | |
5064 | ||
5065 | If you specify neither @samp{-fpcc-struct-return} nor its contrary | |
5066 | @samp{-freg-struct-return}, GNU CC defaults to whichever convention is | |
5067 | standard for the target. If there is no standard convention, GNU CC | |
5068 | defaults to @samp{-fpcc-struct-return}, except on targets where GNU CC | |
5069 | is the principal compiler. In those cases, we can choose the standard, | |
5070 | and we chose the more efficient register return alternative. | |
5071 | ||
5072 | @item -fshort-enums | |
5073 | Allocate to an @code{enum} type only as many bytes as it needs for the | |
5074 | declared range of possible values. Specifically, the @code{enum} type | |
5075 | will be equivalent to the smallest integer type which has enough room. | |
5076 | ||
5077 | @item -fshort-double | |
5078 | Use the same size for @code{double} as for @code{float}. | |
5079 | ||
5080 | @item -fshared-data | |
5081 | Requests that the data and non-@code{const} variables of this | |
5082 | compilation be shared data rather than private data. The distinction | |
5083 | makes sense only on certain operating systems, where shared data is | |
5084 | shared between processes running the same program, while private data | |
5085 | exists in one copy per process. | |
5086 | ||
5087 | @item -fno-common | |
5088 | Allocate even uninitialized global variables in the bss section of the | |
5089 | object file, rather than generating them as common blocks. This has the | |
5090 | effect that if the same variable is declared (without @code{extern}) in | |
5091 | two different compilations, you will get an error when you link them. | |
5092 | The only reason this might be useful is if you wish to verify that the | |
5093 | program will work on other systems which always work this way. | |
5094 | ||
5095 | @item -fno-ident | |
5096 | Ignore the @samp{#ident} directive. | |
5097 | ||
5098 | @item -fno-gnu-linker | |
5099 | Do not output global initializations (such as C++ constructors and | |
5100 | destructors) in the form used by the GNU linker (on systems where the GNU | |
5101 | linker is the standard method of handling them). Use this option when | |
5102 | you want to use a non-GNU linker, which also requires using the | |
5103 | @code{collect2} program to make sure the system linker includes | |
5104 | constructors and destructors. (@code{collect2} is included in the GNU CC | |
5105 | distribution.) For systems which @emph{must} use @code{collect2}, the | |
5106 | compiler driver @code{gcc} is configured to do this automatically. | |
5107 | ||
5108 | @item -finhibit-size-directive | |
5109 | Don't output a @code{.size} assembler directive, or anything else that | |
5110 | would cause trouble if the function is split in the middle, and the | |
5111 | two halves are placed at locations far apart in memory. This option is | |
5112 | used when compiling @file{crtstuff.c}; you should not need to use it | |
5113 | for anything else. | |
5114 | ||
5115 | @item -fverbose-asm | |
5116 | Put extra commentary information in the generated assembly code to | |
5117 | make it more readable. This option is generally only of use to those | |
5118 | who actually need to read the generated assembly code (perhaps while | |
5119 | debugging the compiler itself). | |
5120 | ||
5121 | @samp{-fverbose-asm} is the default. @samp{-fno-verbose-asm} causes the | |
5122 | extra information to be omitted and is useful when comparing two assembler | |
5123 | files. | |
5124 | ||
5125 | @item -fvolatile | |
5126 | Consider all memory references through pointers to be volatile. | |
5127 | ||
5128 | @item -fvolatile-global | |
5129 | Consider all memory references to extern and global data items to | |
5130 | be volatile. | |
5131 | ||
5132 | @item -fpic | |
5133 | @cindex global offset table | |
5134 | @cindex PIC | |
5135 | Generate position-independent code (PIC) suitable for use in a shared | |
5136 | library, if supported for the target machine. Such code accesses all | |
861bb6c1 JL |
5137 | constant addresses through a global offset table (GOT). The dynamic |
5138 | loader resolves the GOT entries when the program starts (the dynamic | |
5139 | loader is not part of GNU CC; it is part of the operating system). If | |
5140 | the GOT size for the linked executable exceeds a machine-specific | |
5141 | maximum size, you get an error message from the linker indicating that | |
5142 | @samp{-fpic} does not work; in that case, recompile with @samp{-fPIC} | |
5143 | instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k | |
5144 | on the m68k and RS/6000. The 386 has no such limit.) | |
74291a4b MM |
5145 | |
5146 | Position-independent code requires special support, and therefore works | |
5147 | only on certain machines. For the 386, GNU CC supports PIC for System V | |
5148 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
5149 | position-independent. | |
5150 | ||
74291a4b MM |
5151 | @item -fPIC |
5152 | If supported for the target machine, emit position-independent code, | |
5153 | suitable for dynamic linking and avoiding any limit on the size of the | |
5154 | global offset table. This option makes a difference on the m68k, m88k, | |
5155 | and the Sparc. | |
5156 | ||
5157 | Position-independent code requires special support, and therefore works | |
5158 | only on certain machines. | |
5159 | ||
5160 | @item -ffixed-@var{reg} | |
5161 | Treat the register named @var{reg} as a fixed register; generated code | |
5162 | should never refer to it (except perhaps as a stack pointer, frame | |
5163 | pointer or in some other fixed role). | |
5164 | ||
5165 | @var{reg} must be the name of a register. The register names accepted | |
5166 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
5167 | macro in the machine description macro file. | |
5168 | ||
5169 | This flag does not have a negative form, because it specifies a | |
5170 | three-way choice. | |
5171 | ||
5172 | @item -fcall-used-@var{reg} | |
5173 | Treat the register named @var{reg} as an allocatable register that is | |
5174 | clobbered by function calls. It may be allocated for temporaries or | |
5175 | variables that do not live across a call. Functions compiled this way | |
5176 | will not save and restore the register @var{reg}. | |
5177 | ||
5178 | Use of this flag for a register that has a fixed pervasive role in the | |
5179 | machine's execution model, such as the stack pointer or frame pointer, | |
5180 | will produce disastrous results. | |
5181 | ||
5182 | This flag does not have a negative form, because it specifies a | |
5183 | three-way choice. | |
5184 | ||
5185 | @item -fcall-saved-@var{reg} | |
5186 | Treat the register named @var{reg} as an allocatable register saved by | |
5187 | functions. It may be allocated even for temporaries or variables that | |
5188 | live across a call. Functions compiled this way will save and restore | |
5189 | the register @var{reg} if they use it. | |
5190 | ||
5191 | Use of this flag for a register that has a fixed pervasive role in the | |
5192 | machine's execution model, such as the stack pointer or frame pointer, | |
5193 | will produce disastrous results. | |
5194 | ||
5195 | A different sort of disaster will result from the use of this flag for | |
5196 | a register in which function values may be returned. | |
5197 | ||
5198 | This flag does not have a negative form, because it specifies a | |
5199 | three-way choice. | |
5200 | ||
5201 | @item -fpack-struct | |
5202 | Pack all structure members together without holes. Usually you would | |
5203 | not want to use this option, since it makes the code suboptimal, and | |
5204 | the offsets of structure members won't agree with system libraries. | |
5205 | ||
861bb6c1 JL |
5206 | @item -fcheck-memory-usage |
5207 | Generate extra code to check each memory access. GNU CC will generate | |
5208 | code that is suitable for a detector of bad memory accesses such as | |
5209 | @file{Checker}. If you specify this option, you can not use the | |
5210 | @code{asm} or @code{__asm__} keywords. | |
5211 | ||
5212 | You must also specify this option when you compile functions you call that | |
5213 | have side effects. If you do not, you may get erronous messages from | |
5214 | the detector. Normally, you should compile all your code with this option. | |
5215 | If you use functions from a library that have side-effects (such as | |
5216 | @code{read}), you may not be able to recompile the library and | |
5217 | specify this option. In that case, you can enable the | |
5218 | @samp{-fprefix-function-name} option, which requests GNU CC to encapsulate | |
5219 | your code and make other functions look as if they were compiled with | |
5220 | @samp{-fcheck-memory-usage}. This is done by calling ``stubs'', | |
5221 | which are provided by the detector. If you cannot find or build | |
5222 | stubs for every function you call, you may have to specify | |
5223 | @samp{-fcheck-memory-usage} without @samp{-fprefix-function-name}. | |
5224 | ||
5225 | @item -fprefix-function-name | |
5226 | Request GNU CC to add a prefix to the symbols generated for function names. | |
5227 | GNU CC adds a prefix to the names of functions defined as well as | |
5228 | functions called. Code compiled with this option and code compiled | |
5229 | without the option can't be linked together, unless or stubs are used. | |
5230 | ||
5231 | If you compile the following code with @samp{-fprefix-function-name} | |
5232 | @example | |
5233 | extern void bar (int); | |
5234 | void | |
5235 | foo (int a) | |
5236 | @{ | |
5237 | return bar (a + 5); | |
5238 | ||
5239 | @} | |
5240 | @end example | |
5241 | ||
5242 | @noindent | |
5243 | GNU CC will compile the code as if it was written: | |
5244 | @example | |
5245 | extern void prefix_bar (int); | |
5246 | void | |
5247 | prefix_foo (int a) | |
5248 | @{ | |
5249 | return prefix_bar (a + 5); | |
5250 | @} | |
5251 | @end example | |
5252 | This option is designed to be used with @samp{-fcheck-memory-usage}. | |
5253 | ||
5254 | @item -fstack-check | |
5255 | Generate code to verify that you do not go beyond the boundary of the | |
5256 | stack. You should specify this flag if you are running in an | |
5257 | environment with multiple threads, but only rarely need to specify it in | |
5258 | a single-threaded environment since stack overflow is automatically | |
5259 | detected on nearly all systems if there is only one stack. | |
5260 | ||
74291a4b MM |
5261 | @item +e0 |
5262 | @itemx +e1 | |
5263 | Control whether virtual function definitions in classes are used to | |
5264 | generate code, or only to define interfaces for their callers. (C++ | |
5265 | only). | |
5266 | ||
5267 | These options are provided for compatibility with @code{cfront} 1.x | |
5268 | usage; the recommended alternative GNU C++ usage is in flux. @xref{C++ | |
5269 | Interface,,Declarations and Definitions in One Header}. | |
5270 | ||
5271 | With @samp{+e0}, virtual function definitions in classes are declared | |
5272 | @code{extern}; the declaration is used only as an interface | |
5273 | specification, not to generate code for the virtual functions (in this | |
5274 | compilation). | |
5275 | ||
5276 | With @samp{+e1}, G++ actually generates the code implementing virtual | |
5277 | functions defined in the code, and makes them publicly visible. | |
e5eb27e5 JL |
5278 | |
5279 | @cindex aliasing of parameters | |
5280 | @cindex parameters, aliased | |
5281 | @item -fargument-alias | |
5282 | @item -fargument-noalias | |
5283 | @item -fargument-noalias-global | |
5284 | Specify the possible relationships among parameters and between | |
5285 | parameters and global data. | |
5286 | ||
5287 | @samp{-fargument-alias} specifies that arguments (parameters) may | |
5288 | alias each other and may alias global storage. | |
5289 | @samp{-fargument-noalias} specifies that arguments do not alias | |
5290 | each other, but may alias global storage. | |
5291 | @samp{-fargument-noalias-global} specifies that arguments do not | |
5292 | alias each other and do not alias global storage. | |
5293 | ||
5294 | Each language will automatically use whatever option is required by | |
5295 | the language standard. You should not need to use these options yourself. | |
74291a4b MM |
5296 | @end table |
5297 | ||
5298 | @node Environment Variables | |
5299 | @section Environment Variables Affecting GNU CC | |
5300 | @cindex environment variables | |
5301 | ||
5302 | This section describes several environment variables that affect how GNU | |
5303 | CC operates. They work by specifying directories or prefixes to use | |
5304 | when searching for various kinds of files. | |
5305 | ||
5306 | @ifclear INTERNALS | |
5307 | Note that you can also specify places to search using options such as | |
5308 | @samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These | |
5309 | take precedence over places specified using environment variables, which | |
5310 | in turn take precedence over those specified by the configuration of GNU | |
5311 | CC. | |
5312 | @end ifclear | |
5313 | @ifset INTERNALS | |
5314 | Note that you can also specify places to search using options such as | |
5315 | @samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These | |
5316 | take precedence over places specified using environment variables, which | |
5317 | in turn take precedence over those specified by the configuration of GNU | |
5318 | CC. @xref{Driver}. | |
5319 | @end ifset | |
5320 | ||
5321 | @table @code | |
5322 | @item TMPDIR | |
5323 | @findex TMPDIR | |
5324 | If @code{TMPDIR} is set, it specifies the directory to use for temporary | |
5325 | files. GNU CC uses temporary files to hold the output of one stage of | |
5326 | compilation which is to be used as input to the next stage: for example, | |
5327 | the output of the preprocessor, which is the input to the compiler | |
5328 | proper. | |
5329 | ||
5330 | @item GCC_EXEC_PREFIX | |
5331 | @findex GCC_EXEC_PREFIX | |
5332 | If @code{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the | |
5333 | names of the subprograms executed by the compiler. No slash is added | |
5334 | when this prefix is combined with the name of a subprogram, but you can | |
5335 | specify a prefix that ends with a slash if you wish. | |
5336 | ||
5337 | If GNU CC cannot find the subprogram using the specified prefix, it | |
5338 | tries looking in the usual places for the subprogram. | |
5339 | ||
5340 | The default value of @code{GCC_EXEC_PREFIX} is | |
5341 | @file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value | |
5342 | of @code{prefix} when you ran the @file{configure} script. | |
5343 | ||
5344 | Other prefixes specified with @samp{-B} take precedence over this prefix. | |
5345 | ||
5346 | This prefix is also used for finding files such as @file{crt0.o} that are | |
5347 | used for linking. | |
5348 | ||
5349 | In addition, the prefix is used in an unusual way in finding the | |
5350 | directories to search for header files. For each of the standard | |
5351 | directories whose name normally begins with @samp{/usr/local/lib/gcc-lib} | |
5352 | (more precisely, with the value of @code{GCC_INCLUDE_DIR}), GNU CC tries | |
5353 | replacing that beginning with the specified prefix to produce an | |
5354 | alternate directory name. Thus, with @samp{-Bfoo/}, GNU CC will search | |
5355 | @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}. | |
5356 | These alternate directories are searched first; the standard directories | |
5357 | come next. | |
5358 | ||
5359 | @item COMPILER_PATH | |
5360 | @findex COMPILER_PATH | |
5361 | The value of @code{COMPILER_PATH} is a colon-separated list of | |
5362 | directories, much like @code{PATH}. GNU CC tries the directories thus | |
5363 | specified when searching for subprograms, if it can't find the | |
5364 | subprograms using @code{GCC_EXEC_PREFIX}. | |
5365 | ||
5366 | @item LIBRARY_PATH | |
5367 | @findex LIBRARY_PATH | |
5368 | The value of @code{LIBRARY_PATH} is a colon-separated list of | |
5369 | directories, much like @code{PATH}. When configured as a native compiler, | |
5370 | GNU CC tries the directories thus specified when searching for special | |
5371 | linker files, if it can't find them using @code{GCC_EXEC_PREFIX}. Linking | |
5372 | using GNU CC also uses these directories when searching for ordinary | |
5373 | libraries for the @samp{-l} option (but directories specified with | |
5374 | @samp{-L} come first). | |
5375 | ||
5376 | @item C_INCLUDE_PATH | |
5377 | @itemx CPLUS_INCLUDE_PATH | |
5378 | @itemx OBJC_INCLUDE_PATH | |
5379 | @findex C_INCLUDE_PATH | |
5380 | @findex CPLUS_INCLUDE_PATH | |
5381 | @findex OBJC_INCLUDE_PATH | |
5382 | @c @itemx OBJCPLUS_INCLUDE_PATH | |
5383 | These environment variables pertain to particular languages. Each | |
5384 | variable's value is a colon-separated list of directories, much like | |
5385 | @code{PATH}. When GNU CC searches for header files, it tries the | |
5386 | directories listed in the variable for the language you are using, after | |
5387 | the directories specified with @samp{-I} but before the standard header | |
5388 | file directories. | |
5389 | ||
5390 | @item DEPENDENCIES_OUTPUT | |
5391 | @findex DEPENDENCIES_OUTPUT | |
5392 | @cindex dependencies for make as output | |
5393 | If this variable is set, its value specifies how to output dependencies | |
5394 | for Make based on the header files processed by the compiler. This | |
5395 | output looks much like the output from the @samp{-M} option | |
5396 | (@pxref{Preprocessor Options}), but it goes to a separate file, and is | |
5397 | in addition to the usual results of compilation. | |
5398 | ||
5399 | The value of @code{DEPENDENCIES_OUTPUT} can be just a file name, in | |
5400 | which case the Make rules are written to that file, guessing the target | |
5401 | name from the source file name. Or the value can have the form | |
5402 | @samp{@var{file} @var{target}}, in which case the rules are written to | |
5403 | file @var{file} using @var{target} as the target name. | |
5404 | @end table | |
5405 | ||
5406 | @node Running Protoize | |
5407 | @section Running Protoize | |
5408 | ||
5409 | The program @code{protoize} is an optional part of GNU C. You can use | |
5410 | it to add prototypes to a program, thus converting the program to ANSI | |
5411 | C in one respect. The companion program @code{unprotoize} does the | |
5412 | reverse: it removes argument types from any prototypes that are found. | |
5413 | ||
5414 | When you run these programs, you must specify a set of source files as | |
5415 | command line arguments. The conversion programs start out by compiling | |
5416 | these files to see what functions they define. The information gathered | |
5417 | about a file @var{foo} is saved in a file named @file{@var{foo}.X}. | |
5418 | ||
5419 | After scanning comes actual conversion. The specified files are all | |
5420 | eligible to be converted; any files they include (whether sources or | |
5421 | just headers) are eligible as well. | |
5422 | ||
5423 | But not all the eligible files are converted. By default, | |
5424 | @code{protoize} and @code{unprotoize} convert only source and header | |
5425 | files in the current directory. You can specify additional directories | |
5426 | whose files should be converted with the @samp{-d @var{directory}} | |
5427 | option. You can also specify particular files to exclude with the | |
5428 | @samp{-x @var{file}} option. A file is converted if it is eligible, its | |
5429 | directory name matches one of the specified directory names, and its | |
5430 | name within the directory has not been excluded. | |
5431 | ||
5432 | Basic conversion with @code{protoize} consists of rewriting most | |
5433 | function definitions and function declarations to specify the types of | |
5434 | the arguments. The only ones not rewritten are those for varargs | |
5435 | functions. | |
5436 | ||
5437 | @code{protoize} optionally inserts prototype declarations at the | |
5438 | beginning of the source file, to make them available for any calls that | |
5439 | precede the function's definition. Or it can insert prototype | |
5440 | declarations with block scope in the blocks where undeclared functions | |
5441 | are called. | |
5442 | ||
5443 | Basic conversion with @code{unprotoize} consists of rewriting most | |
5444 | function declarations to remove any argument types, and rewriting | |
5445 | function definitions to the old-style pre-ANSI form. | |
5446 | ||
5447 | Both conversion programs print a warning for any function declaration or | |
5448 | definition that they can't convert. You can suppress these warnings | |
5449 | with @samp{-q}. | |
5450 | ||
5451 | The output from @code{protoize} or @code{unprotoize} replaces the | |
5452 | original source file. The original file is renamed to a name ending | |
5453 | with @samp{.save}. If the @samp{.save} file already exists, then | |
5454 | the source file is simply discarded. | |
5455 | ||
5456 | @code{protoize} and @code{unprotoize} both depend on GNU CC itself to | |
5457 | scan the program and collect information about the functions it uses. | |
5458 | So neither of these programs will work until GNU CC is installed. | |
5459 | ||
5460 | Here is a table of the options you can use with @code{protoize} and | |
5461 | @code{unprotoize}. Each option works with both programs unless | |
5462 | otherwise stated. | |
5463 | ||
5464 | @table @code | |
5465 | @item -B @var{directory} | |
5466 | Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the | |
5467 | usual directory (normally @file{/usr/local/lib}). This file contains | |
5468 | prototype information about standard system functions. This option | |
5469 | applies only to @code{protoize}. | |
5470 | ||
5471 | @item -c @var{compilation-options} | |
5472 | Use @var{compilation-options} as the options when running @code{gcc} to | |
5473 | produce the @samp{.X} files. The special option @samp{-aux-info} is | |
5474 | always passed in addition, to tell @code{gcc} to write a @samp{.X} file. | |
5475 | ||
5476 | Note that the compilation options must be given as a single argument to | |
5477 | @code{protoize} or @code{unprotoize}. If you want to specify several | |
5478 | @code{gcc} options, you must quote the entire set of compilation options | |
5479 | to make them a single word in the shell. | |
5480 | ||
5481 | There are certain @code{gcc} arguments that you cannot use, because they | |
5482 | would produce the wrong kind of output. These include @samp{-g}, | |
5483 | @samp{-O}, @samp{-c}, @samp{-S}, and @samp{-o} If you include these in | |
5484 | the @var{compilation-options}, they are ignored. | |
5485 | ||
5486 | @item -C | |
5487 | Rename files to end in @samp{.C} instead of @samp{.c}. | |
5488 | This is convenient if you are converting a C program to C++. | |
5489 | This option applies only to @code{protoize}. | |
5490 | ||
5491 | @item -g | |
5492 | Add explicit global declarations. This means inserting explicit | |
5493 | declarations at the beginning of each source file for each function | |
5494 | that is called in the file and was not declared. These declarations | |
5495 | precede the first function definition that contains a call to an | |
5496 | undeclared function. This option applies only to @code{protoize}. | |
5497 | ||
5498 | @item -i @var{string} | |
5499 | Indent old-style parameter declarations with the string @var{string}. | |
5500 | This option applies only to @code{protoize}. | |
5501 | ||
5502 | @code{unprotoize} converts prototyped function definitions to old-style | |
5503 | function definitions, where the arguments are declared between the | |
5504 | argument list and the initial @samp{@{}. By default, @code{unprotoize} | |
5505 | uses five spaces as the indentation. If you want to indent with just | |
5506 | one space instead, use @samp{-i " "}. | |
5507 | ||
5508 | @item -k | |
5509 | Keep the @samp{.X} files. Normally, they are deleted after conversion | |
5510 | is finished. | |
5511 | ||
5512 | @item -l | |
5513 | Add explicit local declarations. @code{protoize} with @samp{-l} inserts | |
5514 | a prototype declaration for each function in each block which calls the | |
5515 | function without any declaration. This option applies only to | |
5516 | @code{protoize}. | |
5517 | ||
5518 | @item -n | |
5519 | Make no real changes. This mode just prints information about the conversions | |
5520 | that would have been done without @samp{-n}. | |
5521 | ||
5522 | @item -N | |
5523 | Make no @samp{.save} files. The original files are simply deleted. | |
5524 | Use this option with caution. | |
5525 | ||
5526 | @item -p @var{program} | |
5527 | Use the program @var{program} as the compiler. Normally, the name | |
5528 | @file{gcc} is used. | |
5529 | ||
5530 | @item -q | |
5531 | Work quietly. Most warnings are suppressed. | |
5532 | ||
5533 | @item -v | |
5534 | Print the version number, just like @samp{-v} for @code{gcc}. | |
5535 | @end table | |
5536 | ||
5537 | If you need special compiler options to compile one of your program's | |
5538 | source files, then you should generate that file's @samp{.X} file | |
5539 | specially, by running @code{gcc} on that source file with the | |
5540 | appropriate options and the option @samp{-aux-info}. Then run | |
5541 | @code{protoize} on the entire set of files. @code{protoize} will use | |
5542 | the existing @samp{.X} file because it is newer than the source file. | |
5543 | For example: | |
5544 | ||
5545 | @example | |
5546 | gcc -Dfoo=bar file1.c -aux-info | |
5547 | protoize *.c | |
5548 | @end example | |
5549 | ||
5550 | @noindent | |
5551 | You need to include the special files along with the rest in the | |
5552 | @code{protoize} command, even though their @samp{.X} files already | |
5553 | exist, because otherwise they won't get converted. | |
5554 | ||
5555 | @xref{Protoize Caveats}, for more information on how to use | |
5556 | @code{protoize} successfully. | |
5557 |