Using the GNU Compiler Collection

Using the GNU Compiler Collection

Using the GNU Compiler Collection Richard M. Stallman Last updated 21 May 2002 for MIPS SDE v5.0 / gcc-2.96 Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998, 1999 Free Software Foundation, Inc. For MIPS SDE v5.0 / GCC Version 2.96 Published by the Free Software Foundation 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA Last printed April, 1998. Printed copies are available for $50 each. ISBN 1-882114-37-X Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled “GNU General Public License” and “Funding for Free Software” are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the sections entitled “GNU General Public License” and “Funding for Free Software”, and this permission notice, may be included in transla- tions approved by the Free Software Foundation instead of in the original English. Introduction 1 Introduction This manual documents how to run the GNU compiler, as well as its new features and incom- patibilities, and how to report bugs. It corresponds to GCC version 2.96. 2 Using the GNU Compiler Collection Chapter 1: Compile C, C++, Objective C, Fortran, Java or CHILL 3 1 Compile C, C++, Objective C, Fortran, Java or CHILL Several versions of the compiler (C, C++, Objective C, Fortran, Java and CHILL) are integrated; this is why we use the name “GNU Compiler Collection”. GCC can compile programs written in any of these languages. The Fortran and CHILL compilers are described in separate manuals. The Java compiler currently has no manual documenting it. “GCC” is a common shorthand term for the GNU Compiler Collection. This is both the most general name for the compiler, and the name used when the emphasis is on compiling C programs (as the abbreviation formerly stood for “GNU C Compiler”). When referring to C++ compilation, it is usual to call the compiler “G++”. Since there is only one compiler, it is also accurate to call it “GCC” no matter what the language context; however, the term “G++” is more useful when the emphasis is on compiling C++ programs. We use the name “GCC” to refer to the compilation system as a whole, and more specifically to the language-independent part of the compiler. For example, we refer to the optimization options as affecting the behavior of “GCC” or sometimes just “the compiler”. Front ends for other languages, such as Ada 95 and Pascal exist but have not yet been integrated into GCC. These front-ends, like that for C++, are built in subdirectories of GCC and link to it. The result is an integrated compiler that can compile programs written in C, C++, Objective C, or any of the languages for which you have installed front ends. In this manual, we only discuss the options for the C, Objective-C, and C++ compilers and those of the GCC core. Consult the documentation of the other front ends for the options to use when compiling programs written in other languages. G++ is a compiler, not merely a preprocessor. G++ builds object code directly from your C++ program source. There is no intermediate C version of the program. (By contrast, for example, some other implementations use a program that generates a C program from your C++ source.) Avoiding an intermediate C representation of the program means that you get better object code, and better debugging information. The GNU debugger, GDB, works with this information in the object code to give you comprehensive C++ source-level editing capabilities (see section “C and C++” in Debugging with GDB). 4 Using the GNU Compiler Collection Chapter 2: GCC Command Options 5 2 GCC Command Options When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The “overall options” allow you to stop this process at an intermediate stage. For example, the ‘-c’ option says not to run the linker. Then the output consists of object files output by the assembler. Other options are passed on to one stage of processing. Some options control the preprocessor and others the compiler itself. Yet other options control the assembler and linker; most of these are not documented here, since you rarely need to use any of them. Most of the command line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. If the description for a particular option does not mention a source language, you can use that option with all supported languages. See Section 2.3 [Compiling C++ Programs], page 10, for a summary of special options for com- piling C++ programs. The gcc program accepts options and file names as operands. Many options have multiletter names; therefore multiple single-letter options may not be grouped: ‘-dr’ is very different from ‘-d -r’. You can mix options and other arguments. For the most part, the order you use doesn’t matter. Order does matter when you use several options of the same kind; for example, if you specify ‘-L’ more than once, the directories are searched in the order specified. Many options have long names starting with ‘-f’ or with ‘-W’—for example, ‘-fforce-mem’, ‘-fstrength-reduce’, ‘-Wformat’ and so on. Most of these have both positive and negative forms; the negative form of ‘-ffoo’ would be ‘-fno-foo’. This manual documents only one of these two forms, whichever one is not the default. 2.1 Option Summary Here is a summary of all the options, grouped by type. Explanations are in the following sections. Overall Options See Section 2.2 [Options Controlling the Kind of Output], page 8. -c -S -E -o ®le -pipe -pass-exit-codes -v --help -x language C Language Options See Section 2.4 [Options Controlling C Dialect], page 11. -ansi -fstd -fallow-single-precision -fcond-mismatch -fno-asm -fno-builtin -ffreestanding -fhosted -fsigned-bitfields -funsigned-bitfields -fsigned-char -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs C++ Language Options See Section 2.5 [Options Controlling C++ Dialect], page 15. -fno-access-control -fcheck-new -fconserve-space -fdollars-in-identifiers -fno-elide-constructors -fexternal-templates -ffor-scope -fno-for-scope -fno-gnu-keywords -fguiding-decls -fhonor-std -fhuge-objects -fno-implicit-templates -finit-priority -fno-implement-inlines -fname-mangling-version-n 6 Using the GNU Compiler Collection -fno-default-inline -fno-operator-names -fno-optional-diags -fpermissive -frepo -fstrict-prototype -fsquangle -ftemplate-depth-n -fuse-cxa-atexit -fvtable-thunks -nostdinc++ -Wctor-dtor-privacy -Wno-deprecated -Weffc++ -Wno-non-template-friend -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions -Wreorder -Wsign-promo -Wsynth Warning Options See Section 2.6 [Options to Request or Suppress Warnings], page 21. -fsyntax-only -pedantic -pedantic-errors -w -W -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment -Wconversion -Werror -Wformat -Wid-clash-len -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Wimport -Werror-implicit-function-declaration -Wfloat-equal -Winline -Wlarger-than-len -Wlong-long -Wmain -Wmissing-declarations -Wmissing-noreturn -Wparentheses -Wparentheses-else -Wpointer-arith -Wredundant-decls -Wreturn-type -Wlongjmp-clobbers -Wshadow -Wsign-compare -Wstrict-prototypes -Wswitch -Wtraditional -Wmultichar -Wno-import -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wundef -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable -Wunused-value -Wwrite-strings C-only Warning Options -Wbad-function-cast -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wtraditional Debugging Options See Section 2.7 [Options for Debugging Your Program or GCC], page 29. -dletters -fdump-unnumbered -fdump-translation-unit-®le -fpretend-float -fprofile-arcs -ftest-coverage -g -glevel -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ -p -pg -print-file-name=library -print-libgcc-file-name -print-prog-name=program -print-search-dirs -save-temps -time Optimization Options See Section 2.8 [Options that Control Optimization], page 33. -falign-functions=n -falign-labels=n -falign-loops=n -falign-jumps=n -fbranch-probabilities -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -flive-range -fdelayed-branch -fdelete-null-pointer-checks -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -fno-math-errno -fdata-sections -ffunction-sections -fgcse -finline-functions -finline-limit=n -fkeep-inline-functions Chapter 2: GCC Command Options 7 -fmove-all-movables -fno-default-inline -fno-defer-pop -fno-function-cse -fno-inline -fno-peephole -fomit-frame-pointer -foptimize-register-moves -foptimize-sibling-calls -fregmove -frerun-cse-after-loop -frerun-loop-opt -freduce-all-givs -fschedule-insns -fschedule-insns2 -fssa -fstrength-reduce -fstrict-aliasing -fthread-jumps -funroll-all-loops -funroll-loops -O -O0 -O1 -O2 -O3 -Os Preprocessor Options See Section 2.9 [Options Controlling the Preprocessor], page 40. -Aquestion(answer) -C -dD -dM -dN -Dmacro[=defn] -E -H -idirafter dir -include ®le -imacros ®le -iprefix ®le -iwithprefix dir -iwithprefixbefore dir -isystem dir -isystem-c++ dir -M -MD -MM -MMD -MG -nostdinc -P -trigraphs -undef -Umacro -Wp,option Assembler Option See Section 2.10 [Passing Options to the Assembler], page 43. -Wa,option Linker Options See Section 2.11 [Options for Linking], page 43. object-®le-name -llibrary -nostartfiles -nodefaultlibs -nostdlib -s -static -shared -symbolic -Wl,option -Xlinker option -u symbol Directory Options See Section 2.12 [Options for Directory Search], page 46.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    178 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us