|
|
1.1.1.2 ! root 1: This is Info file gcc.info, produced by Makeinfo-1.44 from the input 1.1 root 2: file gcc.texi. 3: 4: This file documents the use and the internals of the GNU compiler. 5: 6: Copyright (C) 1988, 1989, 1992 Free Software Foundation, Inc. 7: 8: Permission is granted to make and distribute verbatim copies of 9: this manual provided the copyright notice and this permission notice 10: are preserved on all copies. 11: 12: Permission is granted to copy and distribute modified versions of 13: this manual under the conditions for verbatim copying, provided also 14: that the section entitled "GNU General Public License" is included 15: exactly as in the original, and provided that the entire resulting 16: derived work is distributed under the terms of a permission notice 17: identical to this one. 18: 19: Permission is granted to copy and distribute translations of this 20: manual into another language, under the above conditions for modified 21: versions, except that the section entitled "GNU General Public 22: License" and this permission notice may be included in translations 23: approved by the Free Software Foundation instead of in the original 24: English. 25: 26: 27: File: gcc.info, Node: Warning Options, Next: Debugging Options, Prev: Dialect Options, Up: Invoking GCC 28: 29: Options to Request or Suppress Warnings 30: ======================================= 31: 32: Warnings are diagnostic messages that report constructions which 33: are not inherently erroneous but which are risky or suggest there may 34: have been an error. 35: 36: You can request many specific warnings with options beginning `-W', 37: for example `-Wimplicit' to request warnings on implicit declarations. 38: Each of these specific warning options also has a negative form 39: beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'. 40: This manual lists only one of the two forms, whichever is not the 41: default. 42: 43: These options control the amount and kinds of warnings produced by 44: GNU CC: 45: 46: `-fsyntax-only' 47: Check the code for syntax errors, but don't emit any output. 48: 49: `-w' 50: Inhibit all warning messages. 51: 1.1.1.2 ! root 52: `-Wno_import' ! 53: Inhibit warning messages about the use of `#import'. ! 54: 1.1 root 55: `-pedantic' 56: Issue all the warnings demanded by strict ANSI standard C; reject 57: all programs that use forbidden extensions. 58: 59: Valid ANSI standard C programs should compile properly with or 60: without this option (though a rare few will require `-ansi'). 61: However, without this option, certain GNU extensions and 62: traditional C features are supported as well. With this option, 63: they are rejected. 64: 65: `-pedantic' does not cause warning messages for use of the 66: alternate keywords whose names begin and end with `__'. Pedantic 67: warnings are also disabled in the expression that follows 68: `__extension__'. However, only system header files should use 69: these escape routes; application programs should avoid them. 70: *Note Alternate Keywords::. 71: 72: This option is not intended to be useful; it exists only to 73: satisfy pedants who would otherwise claim that GNU CC fails to 74: support the ANSI standard. 75: 76: Some users try to use `-pedantic' to check programs for strict 77: ANSI C conformance. They soon find that it does not do quite 78: what they want: it finds some non-ANSI practices, but not 79: all--only those for which ANSI C *requires* a diagnostic. 80: 81: A feature to report any failure to conform to ANSI C might be 82: useful in some instances, but would require considerable 83: additional work and would be quite different from `-pedantic'. 84: We recommend, rather, that users take advantage of the extensions 85: of GNU C and disregard the limitations of other compilers. Aside 86: from certain supercomputers and obsolete small machines, there is 87: less and less reason ever to use any other C compiler other than 88: for bootstrapping GNU CC. 89: 90: `-pedantic-errors' 91: Like `-pedantic', except that errors are produced rather than 92: warnings. 93: 94: `-W' 95: Print extra warning messages for these events: 96: 97: * A nonvolatile automatic variable might be changed by a call 98: to `longjmp'. These warnings as well are possible only in 99: optimizing compilation. 100: 101: The compiler sees only the calls to `setjmp'. It cannot know 102: where `longjmp' will be called; in fact, a signal handler 103: could call it at any point in the code. As a result, you 104: may get a warning even when there is in fact no problem 105: because `longjmp' cannot in fact be called at the place 106: which would cause a problem. 107: 108: * A function can return either with or without a value. 109: (Falling off the end of the function body is considered 110: returning without a value.) For example, this function 111: would evoke such a warning: 112: 113: foo (a) 114: { 115: if (a > 0) 116: return a; 117: } 118: 119: * An expression-statement contains no side effects. 120: 121: * An unsigned value is compared against zero with `>' or `<='. 122: 123: `-Wimplicit' 124: Warn whenever a function or parameter is implicitly declared. 125: 126: `-Wreturn-type' 127: Warn whenever a function is defined with a return-type that 128: defaults to `int'. Also warn about any `return' statement with no 129: return-value in a function whose return-type is not `void'. 130: 131: `-Wunused' 132: Warn whenever a local variable is unused aside from its 133: declaration, whenever a function is declared static but never 134: defined, and whenever a statement computes a result that is 135: explicitly not used. 136: 137: `-Wswitch' 138: Warn whenever a `switch' statement has an index of enumeral type 139: and lacks a `case' for one or more of the named codes of that 140: enumeration. (The presence of a `default' label prevents this 141: warning.) `case' labels outside the enumeration range also 142: provoke warnings when this option is used. 143: 144: `-Wcomment' 145: Warn whenever a comment-start sequence `/*' appears in a comment. 146: 147: `-Wtrigraphs' 148: Warn if any trigraphs are encountered (assuming they are enabled). 149: 150: `-Wformat' 151: Check calls to `printf' and `scanf', etc., to make sure that the 152: arguments supplied have types appropriate to the format string 153: specified. 154: 155: `-Wchar-subscripts' 156: Warn if an array subscript has type `char'. This is a common 157: cause of error, as programmers often forget that this type is 158: signed on some machines. 159: 160: `-Wuninitialized' 161: An automatic variable is used without first being initialized. 162: 163: These warnings are possible only in optimizing compilation, 164: because they require data flow information that is computed only 165: when optimizing. If you don't specify `-O', you simply won't get 166: these warnings. 167: 168: These warnings occur only for variables that are candidates for 169: register allocation. Therefore, they do not occur for a variable 170: that is declared `volatile', or whose address is taken, or whose 171: size is other than 1, 2, 4 or 8 bytes. Also, they do not occur 172: for structures, unions or arrays, even when they are in registers. 173: 174: Note that there may be no warning about a variable that is used 175: only to compute a value that itself is never used, because such 176: computations may be deleted by data flow analysis before the 177: warnings are printed. 178: 179: These warnings are made optional because GNU CC is not smart 180: enough to see all the reasons why the code might be correct 181: despite appearing to have an error. Here is one example of how 182: this can happen: 183: 184: { 185: int x; 186: switch (y) 187: { 188: case 1: x = 1; 189: break; 190: case 2: x = 4; 191: break; 192: case 3: x = 5; 193: } 194: foo (x); 195: } 196: 197: If the value of `y' is always 1, 2 or 3, then `x' is always 198: initialized, but GNU CC doesn't know this. Here is another 199: common case: 200: 201: { 202: int save_y; 203: if (change_y) save_y = y, y = new_y; 204: ... 205: if (change_y) y = save_y; 206: } 207: 208: This has no bug because `save_y' is used only if it is set. 209: 210: Some spurious warnings can be avoided if you declare as 211: `volatile' all the functions you use that never return. *Note 212: Function Attributes::. 213: 1.1.1.2 ! root 214: `-Wparentheses' ! 215: Warn if parentheses are omitted in certain contexts. ! 216: 1.1 root 217: `-Wall' 218: All of the above `-W' options combined. These are all the 219: options which pertain to usage that we recommend avoiding and 220: that we believe is easy to avoid, even in conjunction with macros. 221: 222: The remaining `-W...' options are not implied by `-Wall' because 223: they warn about constructions that we consider reasonable to use, on 224: occasion, in clean programs. 225: 226: `-Wtraditional' 227: Warn about certain constructs that behave differently in 228: traditional and ANSI C. 229: 230: * Macro arguments occurring within string constants in the 231: macro body. These would substitute the argument in 232: traditional C, but are part of the constant in ANSI C. 233: 234: * A function declared external in one block and then used 235: after the end of the block. 236: 237: * A `switch' statement has an operand of type `long'. 238: 239: `-Wshadow' 240: Warn whenever a local variable shadows another local variable. 241: 242: `-Wid-clash-LEN' 243: Warn whenever two distinct identifiers match in the first LEN 244: characters. This may help you prepare a program that will compile 245: with certain obsolete, brain-damaged compilers. 246: 247: `-Wpointer-arith' 248: Warn about anything that depends on the "size of" a function type 249: or of `void'. GNU C assigns these types a size of 1, for 250: convenience in calculations with `void *' pointers and pointers 251: to functions. 252: 253: `-Wcast-qual' 254: Warn whenever a pointer is cast so as to remove a type qualifier 255: from the target type. For example, warn if a `const char *' is 256: cast to an ordinary `char *'. 257: 258: `-Wcast-align' 259: Warn whenever a pointer is cast such that the required alignment 260: of the target is increased. For example, warn if a `char *' is 261: cast to an `int *' on machines where integers can only be 262: accessed at two- or four-byte boundaries. 263: 264: `-Wwrite-strings' 265: Give string constants the type `const char[LENGTH]' so that 266: copying the address of one into a non-`const' `char *' pointer 267: will get a warning. These warnings will help you find at compile 268: time code that can try to write into a string constant, but only 269: if you have been very careful about using `const' in declarations 270: and prototypes. Otherwise, it will just be a nuisance; this is 271: why we did not make `-Wall' request these warnings. 272: 273: `-Wconversion' 274: Warn if a prototype causes a type conversion that is different 275: from what would happen to the same argument in the absence of a 276: prototype. This includes conversions of fixed point to floating 277: and vice versa, and conversions changing the width or signedness 278: of a fixed point argument except when the same as the default 279: promotion. 280: 281: `-Waggregate-return' 282: Warn if any functions that return structures or unions are 283: defined or called. (In languages where you can return an array, 284: this also elicits a warning.) 285: 286: `-Wstrict-prototypes' 287: Warn if a function is declared or defined without specifying the 288: argument types. (An old-style function definition is permitted 289: without a warning if preceded by a declaration which specifies 290: the argument types.) 291: 292: `-Wmissing-prototypes' 293: Warn if a global function is defined without a previous prototype 294: declaration. This warning is issued even if the definition itself 295: provides a prototype. The aim is to detect global functions that 296: fail to be declared in header files. 297: 298: `-Wredundant-decls' 299: Warn if anything is declared more than once in the same scope, 300: even in cases where multiple declaration is valid and changes 301: nothing. 302: 303: `-Wnested-externs' 304: Warn if an `extern' declaration is encountered within an function. 305: 1.1.1.2 ! root 306: `-Winline' ! 307: Warn if a function can not be inlined, and either it was declared ! 308: as inline, or else the `-finline-functions' option was given. 1.1 root 309: 310: `-Werror' 311: Make all warnings into errors. 312: 313: 314: File: gcc.info, Node: Debugging Options, Next: Optimize Options, Prev: Warning Options, Up: Invoking GCC 315: 316: Options for Debugging Your Program or GNU CC 317: ============================================ 318: 319: GNU CC has various special options that are used for debugging 320: either your program or GCC: 321: 322: `-g' 323: Produce debugging information in the operating system's native 1.1.1.2 ! root 324: format (stabs, COFF, XCOFF, or DWARF). GDB can work with this 1.1 root 325: debugging information. 326: 327: On most systems that use stabs format, `-g' enables use of extra 328: debugging information that only GDB can use; this extra 329: information makes debugging work better in GDB but will probably 330: make DBX crash or refuse to read the program. If you want to 331: control for certain whether to generate the extra information, 332: use `-gstabs+' or `-gstabs' (see below). 333: 334: Unlike most other C compilers, GNU CC allows you to use `-g' with 335: `-O'. The shortcuts taken by optimized code may occasionally 336: produce surprising results: some variables you declared may not 337: exist at all; flow of control may briefly move where you did not 338: expect it; some statements may not be executed because they 339: compute constant results or their values were already at hand; 340: some statements may execute in different places because they were 341: moved out of loops. 342: 343: Nevertheless it proves possible to debug optimized output. This 344: makes it reasonable to use the optimizer for programs that might 345: have bugs. 346: 347: The following options are useful when GNU CC is generated with the 348: capability for more than one debugging format. 349: 350: `-ggdb' 351: Produce debugging information in the native format (if that is 352: supported), including GDB extensions if at all possible. 353: 354: `-gstabs' 355: Produce debugging information in stabs format (if that is 356: supported), without GDB extensions. This is the format used by 357: DBX on most BSD systems. 358: 359: `-gstabs+' 360: Produce debugging information in stabs format (if that is 361: supported), using GDB extensions. The use of these extensions is 362: likely to make DBX crash or refuse to read the program. 363: 364: `-gcoff' 365: Produce debugging information in COFF format (if that is 366: supported). This is the format used by SDB on COFF systems. 367: 1.1.1.2 ! root 368: `-gxcoff' ! 369: Produce debugging information in XCOFF format (if that is ! 370: supported). This is the format used on IBM RS/6000 systems. ! 371: 1.1 root 372: `-gdwarf' 373: Produce debugging information in DWARF format (if that is 374: supported). This is the format used by SDB on systems that use 375: DWARF. 376: 377: `-gLEVEL' 378: `-ggdbLEVEL' 379: `-gstabsLEVEL' 380: `-gcoffLEVEL' 1.1.1.2 ! root 381: `-gxcoffLEVEL' 1.1 root 382: `-gdwarfLEVEL' 383: Request debugging information and also use LEVEL to specify how 384: much information. The default level is 2. 385: 386: Level 1 produces minimal information, enough for making 387: backtraces in parts of the program that you don't plan to debug. 388: This includes descriptions of functions and external variables, 389: but no information about local variables and no line numbers. 390: 391: Level 3 includes extra information, such as all the macro 392: definitions present in the program. Some debuggers support macro 393: expansion when you use `-g3'. 394: 395: `-p' 396: Generate extra code to write profile information suitable for the 397: analysis program `prof'. 398: 399: `-pg' 400: Generate extra code to write profile information suitable for the 401: analysis program `gprof'. 402: 403: `-a' 404: Generate extra code to write profile information for basic blocks, 405: which will record the number of times each basic block is 406: executed. This data could be analyzed by a program like `tcov'. 407: Note, however, that the format of the data is not what `tcov' 408: expects. Eventually GNU `gprof' should be extended to process 409: this data. 410: 411: `-dLETTERS' 412: Says to make debugging dumps during compilation at times 413: specified by LETTERS. This is used for debugging the compiler. 414: The file names for most of the dumps are made by appending a word 415: to the source file name (e.g. `foo.c.rtl' or `foo.c.jump'). 416: Here are the possible letters for use in LETTERS, and their 417: meanings: 418: 419: `M' 420: Dump all macro definitions, at the end of preprocessing, and 421: write no output. 422: 423: `N' 424: Dump all macro names, at the end of preprocessing. 425: 426: `D' 427: Dump all macro definitions, at the end of preprocessing, in 428: addition to normal output. 429: 430: `y' 431: Dump debugging information during parsing, to standard error. 432: 433: `r' 434: Dump after RTL generation, to `FILE.rtl'. 435: 436: `x' 437: Just generate RTL for a function instead of compiling it. 438: Usually used with `r'. 439: 440: `j' 441: Dump after first jump optimization, to `FILE.jump'. 442: 443: `s' 444: Dump after CSE (including the jump optimization that 445: sometimes follows CSE), to `FILE.cse'. 446: 447: `L' 448: Dump after loop optimization, to `FILE.loop'. 449: 450: `t' 451: Dump after the second CSE pass (including the jump 452: optimization that sometimes follows CSE), to `FILE.cse2'. 453: 454: `f' 455: Dump after flow analysis, to `FILE.flow'. 456: 457: `c' 458: Dump after instruction combination, to `FILE.combine'. 459: 460: `S' 461: Dump after the first instruction scheduling pass, to 462: `FILE.sched'. 463: 464: `l' 465: Dump after local register allocation, to `FILE.lreg'. 466: 467: `g' 468: Dump after global register allocation, to `FILE.greg'. 469: 470: `R' 471: Dump after the second instruction scheduling pass, to 472: `FILE.sched2'. 473: 474: `J' 475: Dump after last jump optimization, to `FILE.jump2'. 476: 477: `d' 478: Dump after delayed branch scheduling, to `FILE.dbr'. 479: 480: `k' 481: Dump after conversion from registers to stack, to 482: `FILE.stack'. 483: 484: `a' 485: Produce all the dumps listed above. 486: 487: `m' 488: Print statistics on memory usage, at the end of the run, to 489: standard error. 490: 491: `p' 492: Annotate the assembler output with a comment indicating which 493: pattern and alternative was used. 494: 495: `-fpretend-float' 496: When running a cross-compiler, pretend that the target machine 497: uses the same floating point format as the host machine. This 498: causes incorrect output of the actual floating constants, but the 499: actual instruction sequence will probably be the same as GNU CC 500: would make when running on the target machine. 501: 502: `-save-temps' 503: Store the usual "temporary" intermediate files permanently; place 504: them in the current directory and name them based on the source 505: file. Thus, compiling `foo.c' with `-c -save-temps' would 1.1.1.2 ! root 506: produce files `foo.i' and `foo.s', as well as `foo.o'. 1.1 root 507: 508: 509: File: gcc.info, Node: Optimize Options, Next: Preprocessor Options, Prev: Debugging Options, Up: Invoking GCC 510: 511: Options That Control Optimization 512: ================================= 513: 514: These options control various sorts of optimizations: 515: 516: `-O' 517: Optimize. Optimizing compilation takes somewhat more time, and a 518: lot more memory for a large function. 519: 520: Without `-O', the compiler's goal is to reduce the cost of 521: compilation and to make debugging produce the expected results. 522: Statements are independent: if you stop the program with a 523: breakpoint between statements, you can then assign a new value to 524: any variable or change the program counter to any other statement 525: in the function and get exactly the results you would expect from 526: the source code. 527: 528: Without `-O', only variables declared `register' are allocated in 529: registers. The resulting compiled code is a little worse than 530: produced by PCC without `-O'. 531: 532: With `-O', the compiler tries to reduce code size and execution 533: time. 534: 535: When `-O' is specified, `-fthread-jumps' and `-fdelayed-branch' 536: are turned on. On some machines other flags may also be turned 537: on. 538: 539: `-O2' 1.1.1.2 ! root 540: Optimize even more. Nearly all supported optimizations that do ! 541: not involve a space-speed tradeoff are performed. As compared to ! 542: `-O', this option increases both compilation time and the ! 543: performance of the generated code. ! 544: ! 545: `-O2' turns on all `-fFLAG' options that enable more ! 546: optimization, except for `-funroll-loops', `-funroll-all-loops' ! 547: and `-fomit-frame-pointer'. 1.1 root 548: 549: Options of the form `-fFLAG' specify machine-independent flags. 550: Most flags have both positive and negative forms; the negative form of 551: `-ffoo' would be `-fno-foo'. In the table below, only one of the 552: forms is listed--the one which is not the default. You can figure out 553: the other form by either removing `no-' or adding it. 554: 555: `-ffloat-store' 556: Do not store floating point variables in registers. This 557: prevents undesirable excess precision on machines such as the 558: 68000 where the floating registers (of the 68881) keep more 559: precision than a `double' is supposed to have. 560: 561: For most programs, the excess precision does only good, but a few 562: programs rely on the precise definition of IEEE floating point. 563: Use `-ffloat-store' for such programs. 564: 565: `-fno-defer-pop' 566: Always pop the arguments to each function call as soon as that 567: function returns. For machines which must pop arguments after a 568: function call, the compiler normally lets arguments accumulate on 569: the stack for several function calls and pops them all at once. 570: 571: `-fforce-mem' 572: Force memory operands to be copied into registers before doing 573: arithmetic on them. This may produce better code by making all 574: memory references potential common subexpressions. When they are 575: not common subexpressions, instruction combination should 576: eliminate the separate register-load. I am interested in hearing 577: about the difference this makes. 578: 579: `-fforce-addr' 580: Force memory address constants to be copied into registers before 581: doing arithmetic on them. This may produce better code just as 582: `-fforce-mem' may. I am interested in hearing about the 583: difference this makes. 584: 585: `-fomit-frame-pointer' 586: Don't keep the frame pointer in a register for functions that 587: don't need one. This avoids the instructions to save, set up and 588: restore frame pointers; it also makes an extra register available 589: in many functions. *It also makes debugging impossible on some 590: machines.* 591: 592: On some machines, such as the Vax, this flag has no effect, 593: because the standard calling sequence automatically handles the 594: frame pointer and nothing is saved by pretending it doesn't 595: exist. The machine-description macro `FRAME_POINTER_REQUIRED' 596: controls whether a target machine supports this flag. *Note 597: Registers::. 598: 599: `-finline' 600: Pay attention to the `inline' keyword. Normally the negation of 601: this option `-fno-inline' is used to keep the compiler from 602: expanding any functions inline. However, the opposite effect may 603: be desirable when compiling without optimization, since inline 604: expansion is turned off in that case. 605: 606: `-finline-functions' 607: Integrate all simple functions into their callers. The compiler 608: heuristically decides which functions are simple enough to be 609: worth integrating in this way. 610: 611: If all calls to a given function are integrated, and the function 612: is declared `static', then the function is normally not output as 613: assembler code in its own right. 614: 615: `-fcaller-saves' 616: Enable values to be allocated in registers that will be clobbered 617: by function calls, by emitting extra instructions to save and 618: restore the registers around such calls. Such allocation is done 619: only when it seems to result in better code than would otherwise 620: be produced. 621: 622: This option is enabled by default on certain machines, usually 623: those which have no call-preserved registers to use instead. 624: 625: `-fkeep-inline-functions' 626: Even if all calls to a given function are integrated, and the 627: function is declared `static', nevertheless output a separate 628: run-time callable version of the function. 629: 630: `-fno-function-cse' 631: Do not put function addresses in registers; make each instruction 632: that calls a constant function contain the function's address 633: explicitly. 634: 635: This option results in less efficient code, but some strange hacks 636: that alter the assembler output may be confused by the 637: optimizations performed when this option is not used. 638: 639: The following options control specific optimizations. The `-O2' 640: option turns on all of these optimizations except `-funroll-loops' and 641: `-funroll-all-loops'. The `-O' option usually turns on the 642: `-fthread-jumps' and `-fdelayed-branch' options, but specific machines 643: may change the default optimizations. 644: 645: You can use the following flags in the rare cases when "fine-tuning" 646: of optimizations to be performed is desired. 647: 648: `-fstrength-reduce' 649: Perform the optimizations of loop strength reduction and 650: elimination of iteration variables. 651: 652: `-fthread-jumps' 653: Perform optimizations where we check to see if a jump branches to 654: a location where another comparison subsumed by the first is 655: found. If so, the first branch is redirected to either the 656: destination of the second branch or a point immediately following 657: it, depending on whether the condition is known to be true or 658: false. 659: 660: `-fcse-follow-jumps' 661: In common subexpression elimination, scan through jump 662: instructions in certain cases. This is not as powerful as 663: completely global CSE, but not as slow either. 664: 665: `-frerun-cse-after-loop' 666: Re-run common subexpression elimination after loop optimizations 667: has been performed. 668: 669: `-fexpensive-optimizations' 670: Perform a number of minor optimizations that are relatively 671: expensive. 672: 673: `-fdelayed-branch' 674: If supported for the target machine, attempt to reorder 675: instructions to exploit instruction slots available after delayed 676: branch instructions. 677: 678: `-fschedule-insns' 679: If supported for the target machine, attempt to reorder 680: instructions to eliminate execution stalls due to required data 681: being unavailable. This helps machines that have slow floating 682: point or memory load instructions by allowing other instructions 683: to be issued until the result of the load or floating point 684: instruction is required. 685: 686: `-fschedule-insns2' 687: Similar to `-fschedule-insns', but requests an additional pass of 688: instruction scheduling after register allocation has been done. 689: This is especially useful on machines with a relatively small 690: number of registers and where memory load instructions take more 691: than one cycle. 692: 693: `-funroll-loops' 694: Perform the optimization of loop unrolling. This is only done 695: for loops whose number of iterations can be determined at compile 696: time or run time. `-funroll-loop' implies `-fstrength-reduce' and 697: `-frerun-cse-after-loop'. 698: 699: `-funroll-all-loops' 700: Perform the optimization of loop unrolling. This is done for all 701: loops and usually makes programs run more slowly. 702: `-funroll-all-loops' implies `-fstrength-reduce' and 703: `-frerun-cse-after-loop'. 704: 705: `-fno-peephole' 706: Disable any machine-specific peephole optimizations. 707: 708: 709: File: gcc.info, Node: Preprocessor Options, Next: Link Options, Prev: Optimize Options, Up: Invoking GCC 710: 711: Options Controlling the Preprocessor 712: ==================================== 713: 714: These options control the C preprocessor, which is run on each C 715: source file before actual compilation. 716: 717: If you use the `-E' option, nothing is done except preprocessing. 718: Some of these options make sense only together with `-E' because they 719: cause the preprocessor output to be unsuitable for actual compilation. 720: 721: `-include FILE' 722: Process FILE as input before processing the regular input file. 723: In effect, the contents of FILE are compiled first. Any `-D' and 724: `-U' options on the command line are always processed before 725: `-include FILE', regardless of the order in which they are 726: written. All the `-include' and `-imacros' options are processed 727: in the order in which they are written. 728: 729: `-imacros FILE' 730: Process FILE as input, discarding the resulting output, before 731: processing the regular input file. Because the output generated 732: from FILE is discarded, the only effect of `-imacros FILE' is to 733: make the macros defined in FILE available for use in the main 734: input. 735: 736: Any `-D' and `-U' options on the command line are always 737: processed before `-imacros FILE', regardless of the order in 738: which they are written. All the `-include' and `-imacros' 739: options are processed in the order in which they are written. 740: 741: `-nostdinc' 742: Do not search the standard system directories for header files. 743: Only the directories you have specified with `-I' options (and the 744: current directory, if appropriate) are searched. *Note Directory 745: Options::, for information on `-I'. 746: 747: By using both `-nostdinc' and `-I-', you can limit the 748: include-file search path to only those directories you specify 749: explicitly. 750: 751: `-undef' 752: Do not predefine any nonstandard macros. (Including architecture 753: flags). 754: 755: `-E' 756: Run only the C preprocessor. Preprocess all the C source files 757: specified and output the results to standard output or to the 758: specified output file. 759: 760: `-C' 761: Tell the preprocessor not to discard comments. Used with the 762: `-E' option. 763: 764: `-P' 765: Tell the preprocessor not to generate `#line' commands. Used 766: with the `-E' option. 767: 768: `-M' 769: Tell the preprocessor to output a rule suitable for `make' 770: describing the dependencies of each object file. For each source 771: file, the preprocessor outputs one `make'-rule whose target is 772: the object file name for that source file and whose dependencies 773: are all the files `#include'd in it. This rule may be a single 774: line or may be continued with `\'-newline if it is long. The 775: list of rules is printed on standard output instead of the 776: preprocessed C program. 777: 778: `-M' implies `-E'. 779: 780: Another way to specify output of a `make' rule is by setting the 781: environment variable `DEPENDENCIES_OUTPUT' (*note Environment 782: Variables::.). 783: 784: `-MM' 785: Like `-M' but the output mentions only the user header files 786: included with `#include "FILE"'. System header files included 787: with `#include <FILE>' are omitted. 788: 789: `-MD' 790: Like `-M' but the dependency information is written to files with 791: names made by replacing `.c' with `.d' at the end of the input 792: file names. This is in addition to compiling the file as 793: specified--`-MD' does not inhibit ordinary compilation the way 794: `-M' does. 795: 796: The Mach utility `md' can be used to merge the `.d' files into a 797: single dependency file suitable for using with the `make' command. 798: 799: `-MMD' 800: Like `-MD' except mention only user header files, not system 801: header files. 802: 803: `-H' 804: Print the name of each header file used, in addition to other 805: normal activities. 806: 807: `-DMACRO' 808: Define macro MACRO with the string `1' as its definition. 809: 810: `-DMACRO=DEFN' 811: Define macro MACRO as DEFN. All instances of `-D' on the command 812: line are processed before any `-U' options. 813: 814: `-UMACRO' 815: Undefine macro MACRO. `-U' options are evaluated after all `-D' 816: options, but before any `-include' and `-imacros' options. 817: 818: `-dM' 819: Tell the preprocessor to output only a list of the macro 820: definitions that are in effect at the end of preprocessing. Used 821: with the `-E' option. 822: 823: `-dD' 824: Tell the preprocessing to pass all macro definitions into the 825: output, in their proper sequence in the rest of the output. 826: 827: `-dN' 828: Like `-dD' except that the macro arguments and contents are 829: omitted. Only `#define NAME' is included in the output. 830: 831: `-trigraphs' 832: Support ANSI C trigraphs. You don't want to know about this 833: brain-damage. The `-ansi' option also has this effect. 834: 835: 836: File: gcc.info, Node: Link Options, Next: Directory Options, Prev: Preprocessor Options, Up: Invoking GCC 837: 838: Options for Linking 839: =================== 840: 841: These options come into play when the compiler links object files 842: into an executable output file. They are meaningless if the compiler 843: is not doing a link step. 844: 845: `OBJECT-FILE-NAME' 846: A file name that does not end in a special recognized suffix is 847: considered to name an object file or library. (Object files are 848: distinguished from libraries by the linker according to the file 849: contents.) If linking is done, these object files are used as 850: input to the linker. 851: 852: `-c' 853: `-S' 854: `-E' 855: If any of these options is used, then the linker is not run, and 856: object file names should not be used as arguments. *Note Overall 857: Options::. 858: 859: `-lLIBRARY' 860: Search the library named LIBRARY when linking. 861: 862: It makes a difference where in the command you write this option; 863: the linker searches processes libraries and object files in the 1.1.1.2 ! root 864: order they are specified. Thus, `foo.o -lz bar.o' searches 1.1 root 865: library `z' after file `foo.o' but before `bar.o'. If `bar.o' 866: refers to functions in `z', those functions may not be loaded. 867: 868: The linker searches a standard list of directories for the 869: library, which is actually a file named `libLIBRARY.a'. The 870: linker then uses this file as if it had been specified precisely 871: by name. 872: 873: The directories searched include several standard system 874: directories plus any that you specify with `-L'. 875: 876: Normally the files found this way are library files--archive files 877: whose members are object files. The linker handles an archive 878: file by scanning through it for members which define symbols that 879: have so far been referenced but not defined. But if the file 880: that is found is an ordinary object file, it is linked in the 881: usual fashion. The only difference between using an `-l' option 882: and specifying a file name is that `-l' surrounds LIBRARY with 883: `lib' and `.a' and searches several directories. 884: 885: `-nostdlib' 886: Don't use the standard system libraries and startup files when 887: linking. Only the files you specify will be passed to the linker. 888: 889: `-static' 890: On systems that support dynamic linking, this prevents linking 891: with the shared libraries. On other systems, this option has no 892: effect. 893: 894: `-shared' 895: Produce a shared object which can then be linked with other 896: objects to form an executable. Only a few systems support this 897: option. 898: 899: `-symbolic' 900: Bind references to global symbols when building a shared object. 901: Warn about any unresolved references (unless overridden by the 902: link editor option `-Xlinker -z -Xlinker defs'). Only a few 903: systems support this option. 904: 905: `-Xlinker OPTION' 906: Pass OPTION as an option to the linker. You can use this to 907: supply system-specific linker options which GNU CC does not know 908: how to recognize. 909: 910: If you want to pass an option that takes an argument, you must use 911: `-Xlinker' twice, once for the option and once for the argument. 912: For example, to pass `-assert definitions', you must write 913: `-Xlinker -assert -Xlinker definitions'. It does not work to 914: write `-Xlinker "-assert definitions"', because this passes the 915: entire string as a single argument, which is not what the linker 916: expects. 917: 918: 919: File: gcc.info, Node: Directory Options, Next: Target Options, Prev: Link Options, Up: Invoking GCC 920: 921: Options for Directory Search 922: ============================ 923: 924: These options specify directories to search for header files, for 925: libraries and for parts of the compiler: 926: 927: `-IDIR' 928: Append directory DIR to the list of directories searched for 929: include files. 930: 931: `-I-' 932: Any directories you specify with `-I' options before the `-I-' 933: option are searched only for the case of `#include "FILE"'; they 934: are not searched for `#include <FILE>'. 935: 936: If additional directories are specified with `-I' options after 937: the `-I-', these directories are searched for all `#include' 938: directives. (Ordinarily *all* `-I' directories are used this 939: way.) 940: 941: In addition, the `-I-' option inhibits the use of the current 942: directory (where the current input file came from) as the first 943: search directory for `#include "FILE"'. There is no way to 944: override this effect of `-I-'. With `-I.' you can specify 945: searching the directory which was current when the compiler was 946: invoked. That is not exactly the same as what the preprocessor 947: does by default, but it is often satisfactory. 948: 949: `-I-' does not inhibit the use of the standard system directories 950: for header files. Thus, `-I-' and `-nostdinc' are independent. 951: 952: `-LDIR' 953: Add directory DIR to the list of directories to be searched for 954: `-l'. 955: 956: `-BPREFIX' 957: This option specifies where to find the executables, libraries and 958: data files of the compiler itself. 959: 960: The compiler driver program runs one or more of the subprograms 961: `cpp', `cc1', `as' and `ld'. It tries PREFIX as a prefix for 962: each program it tries to run, both with and without 963: `MACHINE/VERSION/' (*note Target Options::.). 964: 965: For each subprogram to be run, the compiler driver first tries the 966: `-B' prefix, if any. If that name is not found, or if `-B' was 967: not specified, the driver tries two standard prefixes, which are 1.1.1.2 ! root 968: `/usr/lib/gcc/' and `/usr/local/lib/gcc-lib/'. If neither of ! 969: those results in a file name that is found, the unmodified program ! 970: name is searched for using the directories specified in your ! 971: `PATH' environment variable. 1.1 root 972: 973: `-B' prefixes that effectively specify directory names also apply 974: to libraries in the linker, because the compiler translates these 975: options into `-L' options for the linker. 976: 977: The run-time support file `libgcc.a' can also be searched for 978: using the `-B' prefix, if needed. If it is not found there, the 979: two standard prefixes above are tried, and that is all. The file 980: is left out of the link if it is not found by those means. 981: 982: Another way to specify a prefix much like the `-B' prefix is to 983: use the environment variable `GCC_EXEC_PREFIX'. *Note 984: Environment Variables::. 985: 986: 987: File: gcc.info, Node: Target Options, Next: Submodel Options, Prev: Directory Options, Up: Invoking GCC 988: 989: Specifying Target Machine and Compiler Version 990: ============================================== 991: 992: By default, GNU CC compiles code for the same type of machine that 993: you are using. However, it can also be installed as a cross-compiler, 994: to compile for some other type of machine. In fact, several different 995: configurations of GNU CC, for different target machines, can be 996: installed side by side. Then you specify which one to use with the 997: `-b' option. 998: 999: In addition, older and newer versions of GNU CC can be installed 1000: side by side. One of them (probably the newest) will be the default, 1001: but you may sometimes wish to use another. 1002: 1003: `-b MACHINE' 1004: The argument MACHINE specifies the target machine for compilation. 1005: This is useful when you have installed GNU CC as a cross-compiler. 1006: 1007: The value to use for MACHINE is the same as was specified as the 1008: machine type when configuring GNU CC as a cross-compiler. For 1009: example, if a cross-compiler was configured with `configure 1010: i386v', meaning to compile for an 80386 running System V, then you 1011: would specify `-b i386v' to run that cross compiler. 1012: 1013: When you do not specify `-b', it normally means to compile for 1014: the same type of machine that you are using. 1015: 1016: `-V VERSION' 1017: The argument VERSION specifies which version of GNU CC to run. 1018: This is useful when multiple versions are installed. For example, 1019: VERSION might be `2.0', meaning to run GNU CC version 2.0. 1020: 1021: The default version, when you do not specify `-V', is controlled 1022: by the way GNU CC is installed. Normally, it will be a version 1023: that is recommended for general use. 1024: 1025: The `-b' and `-V' options actually work by controlling part of the 1026: file name used for the executable files and libraries used for 1027: compilation. A given version of GNU CC, for a given target machine, is 1.1.1.2 ! root 1028: normally kept in the directory ! 1029: `/usr/local/lib/gcc-lib/MACHINE/VERSION'. 1.1 root 1030: 1031: It follows that sites can customize the effect of `-b' or `-V' 1032: either by changing the names of these directories or adding alternate 1.1.1.2 ! root 1033: names (or symbolic links). Thus, if `/usr/local/lib/gcc-lib/80386' is ! 1034: a link to `/usr/local/lib/gcc-lib/i386v', then `-b 80386' will be an ! 1035: alias for `-b i386v'. 1.1 root 1036: 1037: In one respect, the `-b' or `-V' do not completely change to a 1038: different compiler: the top-level driver program `gcc' that you 1039: originally invoked continues to run and invoke the other executables 1040: (preprocessor, compiler per se, assembler and linker) that do the real 1041: work. However, since no real work is done in the driver program, it 1042: usually does not matter that the driver program in use is not the one 1043: for the specified target and version. 1044: 1045: The only way that the driver program depends on the target machine 1046: is in the parsing and handling of special machine-specific options. 1047: However, this is controlled by a file which is found, along with the 1048: other executables, in the directory for the specified version and 1049: target machine. As a result, a single installed driver program adapts 1050: to any specified target machine and compiler version. 1051: 1052: The driver program executable does control one significant thing, 1053: however: the default version and target machine. Therefore, you can 1054: install different instances of the driver program, compiled for 1055: different targets or versions, under different names. 1056: 1057: For example, if the driver for version 2.0 is installed as `ogcc' 1058: and that for version 2.1 is installed as `gcc', then the command `gcc' 1059: will use version 2.1 by default, while `ogcc' will use 2.0 by default. 1060: However, you can choose either version with either command with the 1061: `-V' option. 1062: 1063: 1064: File: gcc.info, Node: Submodel Options, Next: Code Gen Options, Prev: Target Options, Up: Invoking GCC 1065: 1066: Specifying Hardware Models and Configurations 1067: ============================================= 1068: 1069: Earlier we discussed the standard option `-b' which chooses among 1070: different installed compilers for completely different target 1071: machines, such as Vax vs. 68000 vs. 80386. 1072: 1073: In addition, each of these target machine types can have its own 1074: special options, starting with `-m', to choose among various hardware 1075: models or configurations--for example, 68010 vs 68020, floating 1076: coprocessor or none. A single installed version of the compiler can 1077: compile for any model or configuration, according to the options 1078: specified. 1079: 1080: These options are defined by the macro `TARGET_SWITCHES' in the 1081: machine description. The default for the options is also defined by 1082: that macro, which enables you to change the defaults. 1083: 1084: * Menu: 1085: 1086: * M680x0 Options:: 1087: * VAX Options:: 1088: * SPARC Options:: 1089: * Convex Options:: 1090: * AMD29K Options:: 1091: * M88K Options:: 1092: * RS/6000 Options:: 1093: * RT Options:: 1094: * MIPS Options:: 1.1.1.2 ! root 1095: * i386 Options:: 1.1 root 1096: 1097: 1098: File: gcc.info, Node: M680x0 Options, Next: Vax Options, Prev: Submodel Options, Up: Submodel Options 1099: 1100: M680x0 Options 1101: -------------- 1102: 1103: These are the `-m' options defined for the 68000 series. The 1104: default values for these options depends on which style of 68000 was 1105: selected when the compiler was configured; the defaults for the most 1106: common choices are given below. 1107: 1108: `-m68020' 1109: `-mc68020' 1110: Generate output for a 68020 (rather than a 68000). This is the 1111: default when the compiler is configured for 68020-based systems. 1112: 1113: `-m68000' 1114: `-mc68000' 1115: Generate output for a 68000 (rather than a 68020). This is the 1116: default when the compiler is configured for a 68000-based systems. 1117: 1118: `-m68881' 1119: Generate output containing 68881 instructions for floating point. 1120: This is the default for most 68020 systems unless `-nfp' was 1121: specified when the compiler was configured. 1122: 1123: `-mfpa' 1124: Generate output containing Sun FPA instructions for floating 1125: point. 1126: 1127: `-msoft-float' 1128: Generate output containing library calls for floating point. 1129: *Warning:* the requisite libraries are not part of GNU CC. 1130: Normally the facilities of the machine's usual C compiler are 1131: used, but this can't be done directly in cross-compilation. You 1132: must make your own arrangements to provide suitable library 1133: functions for cross-compilation. 1134: 1135: `-mshort' 1136: Consider type `int' to be 16 bits wide, like `short int'. 1137: 1138: `-mnobitfield' 1139: Do not use the bit-field instructions. `-m68000' implies 1140: `-mnobitfield'. 1141: 1142: `-mbitfield' 1143: Do use the bit-field instructions. `-m68020' implies 1144: `-mbitfield'. This is the default if you use the unmodified 1145: sources configured for a 68020. 1146: 1147: `-mrtd' 1148: Use a different function-calling convention, in which functions 1149: that take a fixed number of arguments return with the `rtd' 1150: instruction, which pops their arguments while returning. This 1151: saves one instruction in the caller since there is no need to pop 1152: the arguments there. 1153: 1154: This calling convention is incompatible with the one normally 1155: used on Unix, so you cannot use it if you need to call libraries 1156: compiled with the Unix compiler. 1157: 1158: Also, you must provide function prototypes for all functions that 1159: take variable numbers of arguments (including `printf'); 1160: otherwise incorrect code will be generated for calls to those 1161: functions. 1162: 1163: In addition, seriously incorrect code will result if you call a 1164: function with too many arguments. (Normally, extra arguments are 1165: harmlessly ignored.) 1166: 1167: The `rtd' instruction is supported by the 68010 and 68020 1168: processors, but not by the 68000. 1169: 1170: 1171: File: gcc.info, Node: VAX Options, Next: Sparc Options, Prev: M680x0 Options, Up: Submodel Options 1172: 1173: VAX Options 1174: ----------- 1175: 1176: These `-m' options are defined for the Vax: 1177: 1178: `-munix' 1179: Do not output certain jump instructions (`aobleq' and so on) that 1180: the Unix assembler for the Vax cannot handle across long ranges. 1181: 1182: `-mgnu' 1183: Do output those jump instructions, on the assumption that you 1184: will assemble with the GNU assembler. 1185: 1186: `-mg' 1187: Output code for g-format floating point numbers instead of 1188: d-format. 1189: 1190: 1191: File: gcc.info, Node: Sparc Options, Next: Convex Options, Prev: Vax Options, Up: Submodel Options 1192: 1193: SPARC Options 1194: ------------- 1195: 1196: These `-m' switches are supported on the Sparc: 1197: 1.1.1.2 ! root 1198: `-mforce-align' ! 1199: Make sure all objects of type `double' are 8-byte aligned in ! 1200: memory and use double-word instructions to reference them. ! 1201: 1.1 root 1202: `-mno-epilogue' 1203: Generate separate return instructions for `return' statements. 1204: This has both advantages and disadvantages; I don't recall what 1205: they are. 1206: 1207: 1208: File: gcc.info, Node: Convex Options, Next: AMD29K Options, Prev: SPARC Options, Up: Submodel Options 1209: 1210: Convex Options 1211: -------------- 1212: 1213: These `-m' options are defined for the Convex: 1214: 1215: `-mc1' 1216: Generate output for a C1. This is the default when the compiler 1217: is configured for a C1. 1218: 1219: `-mc2' 1220: Generate output for a C2. This is the default when the compiler 1221: is configured for a C2. 1222: 1223: `-margcount' 1224: Generate code which puts an argument count in the word preceding 1225: each argument list. Some nonportable Convex and Vax programs 1226: need this word. (Debuggers don't, except for functions with 1227: variable-length argument lists; this info is in the symbol table.) 1228: 1229: `-mnoargcount' 1230: Omit the argument count word. This is the default if you use the 1231: unmodified sources. 1232: 1233: 1234: File: gcc.info, Node: AMD29K Options, Next: M88K Options, Prev: Convex Options, Up: Submodel Options 1235: 1236: AMD29K Options 1237: -------------- 1238: 1239: These `-m' options are defined for the AMD Am29000: 1240: 1241: `-mdw' 1242: Generate code that assumes the `DW' bit is set, i.e., that byte 1243: and halfword operations are directly supported by the hardware. 1244: This is the default. 1245: 1246: `-mnodw' 1247: Generate code that assumes the `DW' bit is not set. 1248: 1249: `-mbw' 1250: Generate code that assumes the system supports byte and halfword 1251: write operations. This is the default. 1252: 1253: `-mnbw' 1254: Generate code that assumes the systems does not support byte and 1255: halfword write operations. `-mnbw' implies `-mnodw'. 1256: 1257: `-msmall' 1258: Use a small memory model that assumes that all function addresses 1259: are either within a single 256 KB segment or at an absolute 1260: address of less than 256K. This allows the `call' instruction to 1261: be used instead of a `const', `consth', `calli' sequence. 1262: 1263: `-mlarge' 1264: Do not assume that the `call' instruction can be used; this is the 1265: default. 1266: 1267: `-m29050' 1268: Generate code for the Am29050. 1269: 1270: `-m29000' 1271: Generate code for the Am29000. This is the default. 1272: 1273: `-mkernel-registers' 1274: Generate references to registers `gr64-gr95' instead of 1275: `gr96-gr127'. This option can be used when compiling kernel code 1276: that wants a set of global registers disjoint from that used by 1277: user-mode code. 1278: 1279: Note that when this option is used, register names in `-f' flags 1280: must use the normal, user-mode, names. 1281: 1282: `-muser-registers' 1283: Use the normal set of global registers, `gr96-gr127'. This is the 1284: default. 1285: 1286: `-mstack-check' 1287: Insert a call to `__msp_check' after each stack adjustment. This 1288: is often used for kernel code. 1289: 1290:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.