|
|
1.1.1.7 root 1: This is Info file gcc.info, produced by Makeinfo-1.55 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:
1.1.1.8 ! root 6: Published by the Free Software Foundation 59 Temple Place - Suite 330
! 7: Boston, MA 02111-1307 USA
1.1.1.5 root 8:
1.1.1.8 ! root 9: Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software
! 10: Foundation, Inc.
1.1 root 11:
1.1.1.3 root 12: Permission is granted to make and distribute verbatim copies of this
13: manual provided the copyright notice and this permission notice are
14: preserved on all copies.
1.1 root 15:
16: Permission is granted to copy and distribute modified versions of
17: this manual under the conditions for verbatim copying, provided also
1.1.1.7 root 18: that the sections entitled "GNU General Public License," "Funding for
19: Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
20: included exactly as in the original, and provided that the entire
21: resulting derived work is distributed under the terms of a permission
22: notice identical to this one.
1.1 root 23:
24: Permission is granted to copy and distribute translations of this
25: manual into another language, under the above conditions for modified
1.1.1.3 root 26: versions, except that the sections entitled "GNU General Public
1.1.1.7 root 27: License," "Funding for Free Software," and "Protect Your Freedom--Fight
28: `Look And Feel'", and this permission notice, may be included in
29: translations approved by the Free Software Foundation instead of in the
30: original English.
31:
32:
1.1.1.8 ! root 33: File: gcc.info, Node: Installation, Next: C Extensions, Prev: Invoking GCC, Up: Top
1.1.1.7 root 34:
1.1.1.8 ! root 35: Installing GNU CC
! 36: *****************
1.1.1.7 root 37:
38: * Menu:
39:
1.1.1.8 ! root 40: * Configurations:: Configurations Supported by GNU CC.
! 41: * Other Dir:: Compiling in a separate directory (not where the source is).
! 42: * Cross-Compiler:: Building and installing a cross-compiler.
! 43: * Sun Install:: See below for installation on the Sun.
! 44: * VMS Install:: See below for installation on VMS.
! 45: * Collect2:: How `collect2' works; how it finds `ld'.
! 46: * Header Dirs:: Understanding the standard header file directories.
! 47:
! 48: Here is the procedure for installing GNU CC on a Unix system. See
! 49: *Note VMS Install::, for VMS systems. In this section we assume you
! 50: compile in the same directory that contains the source files; see *Note
! 51: Other Dir::, to find out how to compile in a separate directory on Unix
! 52: systems.
! 53:
! 54: You cannot install GNU C by itself on MSDOS; it will not compile
! 55: under any MSDOS compiler except itself. You need to get the complete
! 56: compilation package DJGPP, which includes binaries as well as sources,
! 57: and includes all the necessary compilation tools and libraries.
! 58:
! 59: 1. If you have built GNU CC previously in the same directory for a
! 60: different target machine, do `make distclean' to delete all files
! 61: that might be invalid. One of the files this deletes is
! 62: `Makefile'; if `make distclean' complains that `Makefile' does not
! 63: exist, it probably means that the directory is already suitably
! 64: clean.
! 65:
! 66: 2. On a System V release 4 system, make sure `/usr/bin' precedes
! 67: `/usr/ucb' in `PATH'. The `cc' command in `/usr/ucb' uses
! 68: libraries which have bugs.
! 69:
! 70: 3. Specify the host, build and target machine configurations. You do
! 71: this by running the file `configure'.
! 72:
! 73: The "build" machine is the system which you are using, the "host"
! 74: machine is the system where you want to run the resulting compiler
! 75: (normally the build machine), and the "target" machine is the
! 76: system for which you want the compiler to generate code.
! 77:
! 78: If you are building a compiler to produce code for the machine it
! 79: runs on (a native compiler), you normally do not need to specify
! 80: any operands to `configure'; it will try to guess the type of
! 81: machine you are on and use that as the build, host and target
! 82: machines. So you don't need to specify a configuration when
! 83: building a native compiler unless `configure' cannot figure out
! 84: what your configuration is or guesses wrong.
! 85:
! 86: In those cases, specify the build machine's "configuration name"
! 87: with the `--build' option; the host and target will default to be
! 88: the same as the build machine. (If you are building a
! 89: cross-compiler, see *Note Cross-Compiler::.)
! 90:
! 91: Here is an example:
! 92:
! 93: ./configure --build=sparc-sun-sunos4.1
! 94:
! 95: A configuration name may be canonical or it may be more or less
! 96: abbreviated.
! 97:
! 98: A canonical configuration name has three parts, separated by
! 99: dashes. It looks like this: `CPU-COMPANY-SYSTEM'. (The three
! 100: parts may themselves contain dashes; `configure' can figure out
! 101: which dashes serve which purpose.) For example,
! 102: `m68k-sun-sunos4.1' specifies a Sun 3.
! 103:
! 104: You can also replace parts of the configuration by nicknames or
! 105: aliases. For example, `sun3' stands for `m68k-sun', so
! 106: `sun3-sunos4.1' is another way to specify a Sun 3. You can also
! 107: use simply `sun3-sunos', since the version of SunOS is assumed by
! 108: default to be version 4. `sun3-bsd' also works, since `configure'
! 109: knows that the only BSD variant on a Sun 3 is SunOS.
! 110:
! 111: You can specify a version number after any of the system types,
! 112: and some of the CPU types. In most cases, the version is
! 113: irrelevant, and will be ignored. So you might as well specify the
! 114: version if you know it.
! 115:
! 116: See *Note Configurations::, for a list of supported configuration
! 117: names and notes on many of the configurations. You should check
! 118: the notes in that section before proceeding any further with the
! 119: installation of GNU CC.
! 120:
! 121: There are four additional options you can specify independently to
! 122: describe variant hardware and software configurations. These are
! 123: `--with-gnu-as', `--with-gnu-ld', `--with-stabs' and `--nfp'.
! 124:
! 125: `--with-gnu-as'
! 126: If you will use GNU CC with the GNU assembler (GAS), you
! 127: should declare this by using the `--with-gnu-as' option when
! 128: you run `configure'.
! 129:
! 130: Using this option does not install GAS. It only modifies the
! 131: output of GNU CC to work with GAS. Building and installing
! 132: GAS is up to you.
! 133:
! 134: Conversely, if you *do not* wish to use GAS and do not specify
! 135: `--with-gnu-as' when building GNU CC, it is up to you to make
! 136: sure that GAS is not installed. GNU CC searches for a
! 137: program named `as' in various directories; if the program it
! 138: finds is GAS, then it runs GAS. If you are not sure where
! 139: GNU CC finds the assembler it is using, try specifying `-v'
! 140: when you run it.
! 141:
! 142: The systems where it makes a difference whether you use GAS
! 143: are
! 144: `hppa1.0-ANY-ANY', `hppa1.1-ANY-ANY', `i386-ANY-sysv',
! 145: `i386-ANY-isc',
! 146: `i860-ANY-bsd', `m68k-bull-sysv', `m68k-hp-hpux',
! 147: `m68k-sony-bsd',
! 148: `m68k-altos-sysv', `m68000-hp-hpux', `m68000-att-sysv',
! 149: `ANY-lynx-lynxos', and `mips-ANY'). On any other system,
! 150: `--with-gnu-as' has no effect.
! 151:
! 152: On the systems listed above (except for the HP-PA, for ISC on
! 153: the 386, and for `mips-sgi-irix5.*'), if you use GAS, you
! 154: should also use the GNU linker (and specify `--with-gnu-ld').
! 155:
! 156: `--with-gnu-ld'
! 157: Specify the option `--with-gnu-ld' if you plan to use the GNU
! 158: linker with GNU CC.
! 159:
! 160: This option does not cause the GNU linker to be installed; it
! 161: just modifies the behavior of GNU CC to work with the GNU
! 162: linker. Specifically, it inhibits the installation of
! 163: `collect2', a program which otherwise serves as a front-end
! 164: for the system's linker on most configurations.
! 165:
! 166: `--with-stabs'
! 167: On MIPS based systems and on Alphas, you must specify whether
! 168: you want GNU CC to create the normal ECOFF debugging format,
! 169: or to use BSD-style stabs passed through the ECOFF symbol
! 170: table. The normal ECOFF debug format cannot fully handle
! 171: languages other than C. BSD stabs format can handle other
! 172: languages, but it only works with the GNU debugger GDB.
! 173:
! 174: Normally, GNU CC uses the ECOFF debugging format by default;
! 175: if you prefer BSD stabs, specify `--with-stabs' when you
! 176: configure GNU CC.
! 177:
! 178: No matter which default you choose when you configure GNU CC,
! 179: the user can use the `-gcoff' and `-gstabs+' options to
! 180: specify explicitly the debug format for a particular
! 181: compilation.
! 182:
! 183: `--with-stabs' is meaningful on the ISC system on the 386,
! 184: also, if `--with-gas' is used. It selects use of stabs
! 185: debugging information embedded in COFF output. This kind of
! 186: debugging information supports C++ well; ordinary COFF
! 187: debugging information does not.
! 188:
! 189: `--with-stabs' is also meaningful on 386 systems running
! 190: SVR4. It selects use of stabs debugging information embedded
! 191: in ELF output. The C++ compiler currently (2.6.0) does not
! 192: support the DWARF debugging information normally used on 386
! 193: SVR4 platforms; stabs provide a workable alternative. This
! 194: requires gas and gdb, as the normal SVR4 tools can not
! 195: generate or interpret stabs.
! 196:
! 197: `--nfp'
! 198: On certain systems, you must specify whether the machine has
! 199: a floating point unit. These systems include
! 200: `m68k-sun-sunosN' and `m68k-isi-bsd'. On any other system,
! 201: `--nfp' currently has no effect, though perhaps there are
! 202: other systems where it could usefully make a difference.
! 203:
! 204: The `configure' script searches subdirectories of the source
! 205: directory for other compilers that are to be integrated into GNU
! 206: CC. The GNU compiler for C++, called G++ is in a subdirectory
! 207: named `cp'. `configure' inserts rules into `Makefile' to build
! 208: all of those compilers.
! 209:
! 210: Here we spell out what files will be set up by `configure'.
! 211: Normally you need not be concerned with these files.
! 212:
! 213: * A file named `config.h' is created that contains a `#include'
! 214: of the top-level config file for the machine you will run the
! 215: compiler on (*note Config::.). This file is responsible for
! 216: defining information about the host machine. It includes
! 217: `tm.h'.
! 218:
! 219: The top-level config file is located in the subdirectory
! 220: `config'. Its name is always `xm-SOMETHING.h'; usually
! 221: `xm-MACHINE.h', but there are some exceptions.
! 222:
! 223: If your system does not support symbolic links, you might
! 224: want to set up `config.h' to contain a `#include' command
! 225: which refers to the appropriate file.
! 226:
! 227: * A file named `tconfig.h' is created which includes the
! 228: top-level config file for your target machine. This is used
! 229: for compiling certain programs to run on that machine.
! 230:
! 231: * A file named `tm.h' is created which includes the
! 232: machine-description macro file for your target machine. It
! 233: should be in the subdirectory `config' and its name is often
! 234: `MACHINE.h'.
! 235:
! 236: * The command file `configure' also constructs the file
! 237: `Makefile' by adding some text to the template file
! 238: `Makefile.in'. The additional text comes from files in the
! 239: `config' directory, named `t-TARGET' and `x-HOST'. If these
! 240: files do not exist, it means nothing needs to be added for a
! 241: given target or host.
! 242:
! 243: 4. The standard directory for installing GNU CC is `/usr/local/lib'.
! 244: If you want to install its files somewhere else, specify
! 245: `--prefix=DIR' when you run `configure'. Here DIR is a directory
! 246: name to use instead of `/usr/local' for all purposes with one
! 247: exception: the directory `/usr/local/include' is searched for
! 248: header files no matter where you install the compiler. To override
! 249: this name, use the `--local-prefix' option below.
! 250:
! 251: 5. Specify `--local-prefix=DIR' if you want the compiler to search
! 252: directory `DIR/include' for locally installed header files
! 253: *instead* of `/usr/local/include'.
! 254:
! 255: You should specify `--local-prefix' *only* if your site has a
! 256: different convention (not `/usr/local') for where to put
! 257: site-specific files.
! 258:
! 259: *Do not* specify `/usr' as the `--local-prefix'! The directory
! 260: you use for `--local-prefix' *must not* contain any of the
! 261: system's standard header files. If it did contain them, certain
! 262: programs would be miscompiled (including GNU Emacs, on certain
! 263: targets), because this would override and nullify the header file
! 264: corrections made by the `fixincludes' script.
! 265:
! 266: 6. Make sure the Bison parser generator is installed. (This is
! 267: unnecessary if the Bison output files `c-parse.c' and `cexp.c' are
! 268: more recent than `c-parse.y' and `cexp.y' and you do not plan to
! 269: change the `.y' files.)
! 270:
! 271: Bison versions older than Sept 8, 1988 will produce incorrect
! 272: output for `c-parse.c'.
! 273:
! 274: 7. If you have chosen a configuration for GNU CC which requires other
! 275: GNU tools (such as GAS or the GNU linker) instead of the standard
! 276: system tools, install the required tools in the build directory
! 277: under the names `as', `ld' or whatever is appropriate. This will
! 278: enable the compiler to find the proper tools for compilation of
! 279: the program `enquire'.
! 280:
! 281: Alternatively, you can do subsequent compilation using a value of
! 282: the `PATH' environment variable such that the necessary GNU tools
! 283: come before the standard system tools.
! 284:
! 285: 8. Build the compiler. Just type `make LANGUAGES=c' in the compiler
! 286: directory.
! 287:
! 288: `LANGUAGES=c' specifies that only the C compiler should be
! 289: compiled. The makefile normally builds compilers for all the
! 290: supported languages; currently, C, C++ and Objective C. However,
! 291: C is the only language that is sure to work when you build with
! 292: other non-GNU C compilers. In addition, building anything but C
! 293: at this stage is a waste of time.
! 294:
! 295: In general, you can specify the languages to build by typing the
! 296: argument `LANGUAGES="LIST"', where LIST is one or more words from
! 297: the list `c', `c++', and `objective-c'. If you have any
! 298: additional GNU compilers as subdirectories of the GNU CC source
! 299: directory, you may also specify their names in this list.
! 300:
! 301: Ignore any warnings you may see about "statement not reached" in
! 302: `insn-emit.c'; they are normal. Also, warnings about "unknown
! 303: escape sequence" are normal in `genopinit.c' and perhaps some
! 304: other files. Likewise, you should ignore warnings about "constant
! 305: is so large that it is unsigned" in `insn-emit.c' and
! 306: `insn-recog.c' and a warning about a comparison always being zero
! 307: in `enquire.o'. Any other compilation errors may represent bugs in
! 308: the port to your machine or operating system, and should be
! 309: investigated and reported (*note Bugs::.).
! 310:
! 311: Some commercial compilers fail to compile GNU CC because they have
! 312: bugs or limitations. For example, the Microsoft compiler is said
! 313: to run out of macro space. Some Ultrix compilers run out of
! 314: expression space; then you need to break up the statement where
! 315: the problem happens.
! 316:
! 317: 9. If you are building a cross-compiler, stop here. *Note
! 318: Cross-Compiler::.
! 319:
! 320: 10. Move the first-stage object files and executables into a
! 321: subdirectory with this command:
! 322:
! 323: make stage1
! 324:
! 325: The files are moved into a subdirectory named `stage1'. Once
! 326: installation is complete, you may wish to delete these files with
! 327: `rm -r stage1'.
! 328:
! 329: 11. If you have chosen a configuration for GNU CC which requires other
! 330: GNU tools (such as GAS or the GNU linker) instead of the standard
! 331: system tools, install the required tools in the `stage1'
! 332: subdirectory under the names `as', `ld' or whatever is
! 333: appropriate. This will enable the stage 1 compiler to find the
! 334: proper tools in the following stage.
! 335:
! 336: Alternatively, you can do subsequent compilation using a value of
! 337: the `PATH' environment variable such that the necessary GNU tools
! 338: come before the standard system tools.
! 339:
! 340: 12. Recompile the compiler with itself, with this command:
! 341:
! 342: make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2"
! 343:
! 344: This is called making the stage 2 compiler.
! 345:
! 346: The command shown above builds compilers for all the supported
! 347: languages. If you don't want them all, you can specify the
! 348: languages to build by typing the argument `LANGUAGES="LIST"'. LIST
! 349: should contain one or more words from the list `c', `c++',
! 350: `objective-c', and `proto'. Separate the words with spaces.
! 351: `proto' stands for the programs `protoize' and `unprotoize'; they
! 352: are not a separate language, but you use `LANGUAGES' to enable or
! 353: disable their installation.
! 354:
! 355: If you are going to build the stage 3 compiler, then you might
! 356: want to build only the C language in stage 2.
! 357:
! 358: Once you have built the stage 2 compiler, if you are short of disk
! 359: space, you can delete the subdirectory `stage1'.
! 360:
! 361: On a 68000 or 68020 system lacking floating point hardware, unless
! 362: you have selected a `tm.h' file that expects by default that there
! 363: is no such hardware, do this instead:
! 364:
! 365: make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2 -msoft-float"
! 366:
! 367: 13. If you wish to test the compiler by compiling it with itself one
! 368: more time, install any other necessary GNU tools (such as GAS or
! 369: the GNU linker) in the `stage2' subdirectory as you did in the
! 370: `stage1' subdirectory, then do this:
1.1.1.7 root 371:
1.1.1.8 ! root 372: make stage2
! 373: make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2"
1.1.1.6 root 374:
1.1.1.8 ! root 375: This is called making the stage 3 compiler. Aside from the `-B'
! 376: option, the compiler options should be the same as when you made
! 377: the stage 2 compiler. But the `LANGUAGES' option need not be the
! 378: same. The command shown above builds compilers for all the
! 379: supported languages; if you don't want them all, you can specify
! 380: the languages to build by typing the argument `LANGUAGES="LIST"',
! 381: as described above.
! 382:
! 383: If you do not have to install any additional GNU tools, you may
! 384: use the command
! 385:
! 386: make bootstrap LANGUAGES=LANGUAGE-LIST BOOT_CFLAGS=OPTION-LIST
! 387:
! 388: instead of making `stage1', `stage2', and performing the two
! 389: compiler builds.
! 390:
! 391: 14. Then compare the latest object files with the stage 2 object
! 392: files--they ought to be identical, aside from time stamps (if any).
! 393:
! 394: On some systems, meaningful comparison of object files is
! 395: impossible; they always appear "different." This is currently
! 396: true on Solaris and some systems that use ELF object file format.
! 397: On some versions of Irix on SGI machines and DEC Unix (OSF/1) on
! 398: Alpha systems, you will not be able to compare the files without
! 399: specifying `-save-temps'; see the description of individual
! 400: systems above to see if you get comparison failures. You may have
! 401: similar problems on other systems.
! 402:
! 403: Use this command to compare the files:
! 404:
! 405: make compare
! 406:
! 407: This will mention any object files that differ between stage 2 and
! 408: stage 3. Any difference, no matter how innocuous, indicates that
! 409: the stage 2 compiler has compiled GNU CC incorrectly, and is
! 410: therefore a potentially serious bug which you should investigate
! 411: and report (*note Bugs::.).
! 412:
! 413: If your system does not put time stamps in the object files, then
! 414: this is a faster way to compare them (using the Bourne shell):
! 415:
! 416: for file in *.o; do
! 417: cmp $file stage2/$file
! 418: done
! 419:
! 420: If you have built the compiler with the `-mno-mips-tfile' option on
! 421: MIPS machines, you will not be able to compare the files.
! 422:
! 423: 15. Install the compiler driver, the compiler's passes and run-time
! 424: support with `make install'. Use the same value for `CC',
! 425: `CFLAGS' and `LANGUAGES' that you used when compiling the files
! 426: that are being installed. One reason this is necessary is that
! 427: some versions of Make have bugs and recompile files gratuitously
! 428: when you do this step. If you use the same variable values, those
! 429: files will be recompiled properly.
! 430:
! 431: For example, if you have built the stage 2 compiler, you can use
! 432: the following command:
! 433:
! 434: make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES="LIST"
! 435:
! 436: This copies the files `cc1', `cpp' and `libgcc.a' to files `cc1',
! 437: `cpp' and `libgcc.a' in the directory
! 438: `/usr/local/lib/gcc-lib/TARGET/VERSION', which is where the
! 439: compiler driver program looks for them. Here TARGET is the target
! 440: machine type specified when you ran `configure', and VERSION is
! 441: the version number of GNU CC. This naming scheme permits various
! 442: versions and/or cross-compilers to coexist.
! 443:
! 444: This also copies the driver program `xgcc' into
! 445: `/usr/local/bin/gcc', so that it appears in typical execution
! 446: search paths.
! 447:
! 448: On some systems, this command causes recompilation of some files.
! 449: This is usually due to bugs in `make'. You should either ignore
! 450: this problem, or use GNU Make.
! 451:
! 452: *Warning: there is a bug in `alloca' in the Sun library. To avoid
! 453: this bug, be sure to install the executables of GNU CC that were
! 454: compiled by GNU CC. (That is, the executables from stage 2 or 3,
! 455: not stage 1.) They use `alloca' as a built-in function and never
! 456: the one in the library.*
! 457:
! 458: (It is usually better to install GNU CC executables from stage 2
! 459: or 3, since they usually run faster than the ones compiled with
! 460: some other compiler.)
! 461:
! 462: 16. If you're going to use C++, it's likely that you need to also
! 463: install the libg++ distribution. It should be available from the
! 464: same place where you got the GNU C distribution. Just as GNU C
! 465: does not distribute a C runtime library, it also does not include
! 466: a C++ run-time library. All I/O functionality, special class
! 467: libraries, etc., are available in the libg++ distribution.
1.1.1.6 root 468:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.