Using and Porting the GNU Compiler Collection (GCC) Iii
Total Page:16
File Type:pdf, Size:1020Kb
Using and Porting the GNU Compiler Collection Richard M. Stallman Last updated 22 June 2001 for GCC 3.1 Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. For GCC Version 3.1 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. i Short Contents Introduction ...................................... 1 1 Compile C, C++, Objective-C, Fortran, Java or CHILL ..... 3 2 Language Standards Supported by GCC ............... 5 3 GCC Command Options .......................... 7 4 Installing GNU CC ............................ 137 5 Extensions to the C Language Family................ 149 6 Extensions to the C++ Language ................... 199 7 GNU Objective-C runtime features ................. 211 8 gcov: a Test Coverage Program ................... 217 9 Known Causes of Trouble with GCC ................ 223 10 Reporting Bugs ............................... 243 11 How To Get Help with GCC ...................... 251 12 Contributing to GCC Development ................. 253 13 Using GCC on VMS ........................... 255 14 Additional Makefile and configure information. ......... 261 15 GCC and Portability ........................... 265 16 Interfacing to GCC Output ....................... 267 17 Passes and Files of the Compiler ................... 269 18 Trees: The intermediate representation used by the C and C++ front ends ................................... 277 19 RTL Representation............................ 309 20 Machine Descriptions ........................... 351 21 Target Description Macros and Functions ............. 417 22 The Configuration File .......................... 541 23 Makefile Fragments ............................ 545 Funding Free Software ............................. 549 Linux and the GNU Project ......................... 551 GNU GENERAL PUBLIC LICENSE ................... 553 GNU Free Documentation License ..................... 561 Contributors to GCC .............................. 569 Option Index.................................... 577 Index ......................................... 587 ii Using and Porting the GNU Compiler Collection (GCC) iii Table of Contents Introduction .................................. 1 1 Compile C, C++, Objective-C, Fortran, Java or CHILL ................................... 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 ................. 15 3.3 Compiling C++ Programs ............................... 18 3.4 Options Controlling C Dialect ........................... 18 3.5 Options Controlling C++ Dialect......................... 23 3.6 Options Controlling Objective-C Dialect ................. 28 3.7 Options to Control Diagnostic Messages Formatting ...... 29 3.8 Options to Request or Suppress Warnings ................ 30 3.9 Options for Debugging Your Program or GCC............ 41 3.10 Options That Control Optimization .................... 49 3.11 Options Controlling the Preprocessor ................... 59 3.12 Passing Options to the Assembler ...................... 63 3.13 Options for Linking ................................... 63 3.14 Options for Directory Search ........................... 66 3.15 Specifying subprocesses and the switches to pass to them ....................................................... 68 3.16 Specifying Target Machine and Compiler Version ........ 74 3.17 Hardware Models and Configurations ................... 75 3.17.1 M680x0 Options .............................. 75 3.17.2 M68hc1x Options............................. 77 3.17.3 VAX Options ................................ 78 3.17.4 SPARC Options .............................. 78 3.17.5 Convex Options .............................. 82 3.17.6 AMD29K Options ............................ 83 3.17.7 ARM Options ................................ 84 3.17.8 MN10200 Options ............................ 88 3.17.9 MN10300 Options ............................ 89 3.17.10 M32R/D Options............................ 89 3.17.11 M88K Options .............................. 90 3.17.12 IBM RS/6000 and PowerPC Options.......... 93 3.17.13 IBM RT Options ........................... 100 3.17.14 MIPS Options.............................. 101 3.17.15 Intel 386 Options ........................... 105 3.17.16 HPPA Options ............................. 108 iv Using and Porting the GNU Compiler Collection (GCC) 3.17.17 Intel 960 Options ........................... 110 3.17.18 DEC Alpha Options ........................ 111 3.17.19 Clipper Options ............................ 115 3.17.20 H8/300 Options ............................ 115 3.17.21 SH Options ................................ 115 3.17.22 Options for System V ....................... 117 3.17.23 TMS320C3x/C4x Options................... 117 3.17.24 V850 Options .............................. 119 3.17.25 ARC Options .............................. 120 3.17.26 NS32K Options ............................ 120 3.17.27 AVR Options .............................. 122 3.17.28 MCore Options............................. 123 3.17.29 IA-64 Options .............................. 123 3.17.30 D30V Options.............................. 125 3.17.31 S/390 and zSeries Options .................. 125 3.18 Options for Code Generation Conventions.............. 126 3.19 Environment Variables Affecting GCC ................. 132 3.20 Running Protoize .................................... 134 4 Installing GNU CC ...................... 137 4.1 Files Created by configure............................ 138 4.2 Configurations Supported by GNU CC.................. 138 4.3 Building and Installing a Cross-Compiler................ 139 4.3.1 Steps of Cross-Compilation .................... 140 4.3.2 Configuring a Cross-Compiler ................. 140 4.3.3 Tools and Libraries for a Cross-Compiler ....... 140 4.3.4 Cross-Compilers and Header Files.............. 141 4.3.5 Actually Building the Cross-Compiler .......... 142 4.4 Installing GNU CC on VMS ........................... 142 4.5 collect2 ............................................. 146 4.6 Standard Header File Directories ....................... 146 5 Extensions to the C Language Family ..... 149 5.1 Statements and Declarations in Expressions ............. 149 5.2 Locally Declared Labels ............................... 150 5.3 Labels as Values ...................................... 151 5.4 Nested Functions...................................... 152 5.5 Constructing Function Calls ........................... 153 5.6 Naming an Expression’s Type .......................... 154 5.7 Referring to a Type with typeof ....................... 155 5.8 Generalized Lvalues ................................... 155 5.9 Conditionals with Omitted Operands ................... 156 5.10 Double-Word Integers ................................ 157 5.11 Complex Numbers ................................... 157 5.12 Hex Floats .......................................... 158 5.13 Arrays of Length Zero ................................ 158 5.14 Arrays of Variable Length ............................ 159 5.15 Macros with a Variable Number of Arguments. ......... 160 v 5.16 Slightly Looser Rules for Escaped Newlines ............ 161 5.17 String Literals with Embedded Newlines ............... 161 5.18 Non-Lvalue Arrays May Have Subscripts ............... 162 5.19 Arithmetic on void- and Function-Pointers............. 162 5.20 Non-Constant Initializers ............................. 162 5.21 Compound Literals ................................... 162 5.22 Designated Initializers ................................ 163 5.23 Case Ranges ......................................... 165 5.24 Cast to a Union Type ................................ 165 5.25 Mixed Declarations and Code ......................... 165 5.26 Declaring Attributes of Functions ..................... 166 5.27 Attribute Syntax ..................................... 173 5.28 Prototypes and Old-Style Function Definitions ......... 175 5.29 C++ Style Comments ................................. 176 5.30 Dollar Signs in Identifier Names ....................... 176 5.31 The Character hESCi in Constants...................... 177 5.32 Inquiring on Alignment of Types or Variables .......... 177 5.33 Specifying Attributes of Variables ..................... 177 5.34 Specifying Attributes of Types ........................ 181 5.35 An Inline Function is As Fast As a Macro .............. 183 5.36 Assembler Instructions with C Expression Operands .... 185 5.36.1 i386 floating point asm operands.............. 189 5.37 Controlling Names Used in Assembler Code ............ 190 5.38 Variables in Specified Registers........................ 190 5.38.1 Defining Global Register Variables