home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / gcc.info-6 (.txt) < prev    next >
GNU Info File  |  1995-11-26  |  22KB  |  370 lines

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