Using and Porting the GNU Compiler Collection
Total Page:16
File Type:pdf, Size:1020Kb
Using and Porting the GNU Compiler Collection Richard M. Stallman Last updated 14 June 2001 for gcc-3.0 Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. For GCC Version 3.0 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 copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License”, the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”. (a) The FSF’s Front-Cover Text is: A GNU Manual (b) The FSF’s Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. Short Contents Introduction......................................... 1 1 Compile C, C++, Objective C, Fortran, Java ............... 3 2 Language Standards Supported by GCC .................. 5 3 GCC Command Options ............................. 7 4 Installing GNU CC ............................... 111 5 Extensions to the C Language Family .................. 121 6 Extensions to the C++ Language ...................... 165 7 GNU Objective-C runtime features .................... 175 8 gcov: a Test Coverage Program ...................... 181 9 Known Causes of Trouble with GCC ................... 187 10 Reporting Bugs.................................. 203 11 How To Get Help with GCC ......................... 209 12 Contributing to GCC Development .................... 211 13 Using GCC on VMS .............................. 213 14 Makefile Targets ................................. 217 15 GCC and Portability .............................. 219 16 Interfacing to GCC Output ......................... 221 17 Passes and Files of the Compiler ...................... 223 18 Trees: The intermediate representation used by the C and C++ front-ends...................................... 229 19 RTL Representation .............................. 255 20 Machine Descriptions .............................. 291 21 Target Description Macros .......................... 349 22 The Configuration File............................. 453 23 Makefile Fragments ............................... 457 Funding Free Software ................................ 459 Linux and the GNU Project ............................ 461 GNU GENERAL PUBLIC LICENSE ...................... 463 GNU Free Documentation License ........................ 469 Contributors to GCC ................................. 475 Option Index ...................................... 481 Index ............................................ 493 Table of Contents Introduction ..................................... 1 1 Compile C, C++, Objective C, Fortran, Java .... 3 2 Language Standards Supported by GCC ....... 5 3 GCC Command Options ...................... 7 3.1 Option Summary ............................................ 7 3.2 Options Controlling the Kind of Output...................... 10 3.3 Compiling C++ Programs ................................... 12 3.4 Options Controlling C Dialect ............................... 12 3.5 Options Controlling C++ Dialect ............................. 16 3.6 Options Controlling Objective-C Dialect ..................... 21 3.7 Options to Control Diagnostic Messages Formatting........... 21 3.8 Options to Request or Suppress Warnings .................... 22 3.9 Options for Debugging Your Program or GCC ................ 32 3.10 Options That Control Optimization......................... 38 3.11 Options Controlling the Preprocessor ....................... 46 3.12 Passing Options to the Assembler........................... 49 3.13 Options for Linking........................................ 49 3.14 Options for Directory Search ............................... 51 3.15 Specifying subprocesses and the switches to pass to them ..... 52 3.16 Specifying Target Machine and Compiler Version ............ 57 3.17 Hardware Models and Configurations ....................... 58 3.17.1 M680x0 Options .................................. 59 3.17.2 M68hc1x Options ................................. 61 3.17.3 VAX Options..................................... 61 3.17.4 SPARC Options .................................. 61 3.17.5 Convex Options .................................. 64 3.17.6 AMD29K Options ................................ 65 3.17.7 ARM Options .................................... 66 3.17.8 MN10200 Options ................................ 70 3.17.9 MN10300 Options ................................ 70 3.17.10 M32R/D Options ................................ 71 3.17.11 M88K Options .................................. 72 3.17.12 IBM RS/6000 and PowerPC Options .............. 74 3.17.13 IBM RT Options ................................ 80 3.17.14 MIPS Options ................................... 80 3.17.15 Intel 386 Options ................................ 84 3.17.16 HPPA Options .................................. 87 3.17.17 Intel 960 Options ................................ 88 3.17.18 DEC Alpha Options ............................. 90 3.17.19 Clipper Options ................................. 93 3.17.20 H8/300 Options ................................. 93 3.17.21 SH Options ..................................... 93 3.17.22 Options for System V ............................ 94 3.17.23 TMS320C3x/C4x Options ........................ 94 3.17.24 V850 Options ................................... 96 3.17.25 ARC Options.................................... 97 3.17.26 NS32K Options.................................. 97 3.17.27 AVR Options.................................... 99 3.17.28 MCore Options .................................. 99 3.17.29 IA-64 Options .................................. 100 3.17.30 D30V Options .................................. 101 3.18 Options for Code Generation Conventions .................. 102 3.19 Environment Variables Affecting GCC ..................... 107 3.20 Running Protoize ........................................ 108 4 Installing GNU CC ......................... 111 4.1 Files Created by configure ................................ 112 4.2 Configurations Supported by GNU CC ...................... 113 4.3 Building and Installing a Cross-Compiler .................... 114 4.3.1 Steps of Cross-Compilation ........................ 114 4.3.2 Configuring a Cross-Compiler...................... 114 4.3.3 Tools and Libraries for a Cross-Compiler ........... 115 4.3.4 Cross-Compilers and Header Files .................. 116 4.3.5 Actually Building the Cross-Compiler .............. 116 4.4 Installing GNU CC on VMS................................ 117 4.5 collect2 ................................................. 119 4.6 Standard Header File Directories ........................... 120 5 Extensions to the C Language Family ........ 121 5.1 Statements and Declarations in Expressions ................. 121 5.2 Locally Declared Labels.................................... 122 5.3 Labels as Values .......................................... 122 5.4 Nested Functions .......................................... 123 5.5 Constructing Function Calls................................ 125 5.6 Naming an Expression’s Type .............................. 126 5.7 Referring to a Type with typeof ........................... 126 5.8 Generalized Lvalues ....................................... 127 5.9 Conditionals with Omitted Operands ....................... 128 5.10 Double-Word Integers .................................... 128 5.11 Complex Numbers........................................ 129 5.12 Hex Floats............................................... 129 5.13 Arrays of Length Zero .................................... 129 5.14 Arrays of Variable Length................................. 131 5.15 Macros with a Variable Number of Arguments. ............. 132 5.16 Slightly Looser Rules for Escaped Newlines................. 132 5.17 String Literals with Embedded Newlines ................... 132 5.18 Non-Lvalue Arrays May Have Subscripts ................... 133 5.19 Arithmetic on void- and Function-Pointers................. 133 5.20 Non-Constant Initializers ................................. 133 5.21 Compound Literals ....................................... 133 5.22 Designated Initializers .................................... 134 5.23 Case Ranges ............................................. 135 5.24 Cast to a Union Type .................................... 135 5.25 Mixed Declarations and Code ............................. 136 5.26 Declaring Attributes of Functions.......................... 136 5.27 Attribute Syntax ......................................... 142 5.28 Prototypes and Old-Style Function Definitions.............. 144 5.29 C++ Style Comments ..................................... 145 5.30 Dollar Signs in Identifier Names ........................... 145 5.31 The Character hESCi in Constants .......................... 145 5.32 Inquiring on Alignment of Types or Variables............... 145 5.33 Specifying Attributes of Variables ......................... 146 5.34 Specifying Attributes of Types ............................ 149 5.35 An Inline Function is As Fast As a Macro .................. 151 5.36 Assembler Instructions with C Expression Operands .......