Home | History | Annotate | Line # | Download | only in INSTALL
build.html revision 1.3
      1  1.1    mrg <html lang="en">
      2  1.1    mrg <head>
      3  1.1    mrg <title>Installing GCC: Building</title>
      4  1.1    mrg <meta http-equiv="Content-Type" content="text/html">
      5  1.1    mrg <meta name="description" content="Installing GCC: Building">
      6  1.1    mrg <meta name="generator" content="makeinfo 4.12">
      7  1.1    mrg <link title="Top" rel="top" href="#Top">
      8  1.1    mrg <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
      9  1.1    mrg <!--
     10  1.3  skrll Copyright (C) 1988-2013 Free Software Foundation, Inc.
     11  1.1    mrg 
     12  1.1    mrg    Permission is granted to copy, distribute and/or modify this document
     13  1.3  skrll under the terms of the GNU Free Documentation License, Version 1.3 or
     14  1.1    mrg any later version published by the Free Software Foundation; with no
     15  1.1    mrg Invariant Sections, the Front-Cover texts being (a) (see below), and
     16  1.1    mrg with the Back-Cover Texts being (b) (see below).  A copy of the
     17  1.1    mrg license is included in the section entitled "GNU Free Documentation License".
     18  1.1    mrg 
     19  1.1    mrg (a) The FSF's Front-Cover Text is:
     20  1.1    mrg 
     21  1.1    mrg      A GNU Manual
     22  1.1    mrg 
     23  1.1    mrg (b) The FSF's Back-Cover Text is:
     24  1.1    mrg 
     25  1.1    mrg      You have freedom to copy and modify this GNU Manual, like GNU
     26  1.1    mrg      software.  Copies published by the Free Software Foundation raise
     27  1.1    mrg      funds for GNU development.-->
     28  1.1    mrg <meta http-equiv="Content-Style-Type" content="text/css">
     29  1.1    mrg <style type="text/css"><!--
     30  1.1    mrg   pre.display { font-family:inherit }
     31  1.1    mrg   pre.format  { font-family:inherit }
     32  1.1    mrg   pre.smalldisplay { font-family:inherit; font-size:smaller }
     33  1.1    mrg   pre.smallformat  { font-family:inherit; font-size:smaller }
     34  1.1    mrg   pre.smallexample { font-size:smaller }
     35  1.1    mrg   pre.smalllisp    { font-size:smaller }
     36  1.1    mrg   span.sc    { font-variant:small-caps }
     37  1.1    mrg   span.roman { font-family:serif; font-weight:normal; } 
     38  1.1    mrg   span.sansserif { font-family:sans-serif; font-weight:normal; } 
     39  1.1    mrg --></style>
     40  1.1    mrg </head>
     41  1.1    mrg <body>
     42  1.1    mrg <h1 class="settitle">Installing GCC: Building</h1>
     43  1.1    mrg <a name="index-Installing-GCC_003a-Building-1"></a>
     44  1.1    mrg Now that GCC is configured, you are ready to build the compiler and
     45  1.1    mrg runtime libraries.
     46  1.1    mrg 
     47  1.1    mrg    <p>Some commands executed when making the compiler may fail (return a
     48  1.1    mrg nonzero status) and be ignored by <samp><span class="command">make</span></samp>.  These failures, which
     49  1.1    mrg are often due to files that were not found, are expected, and can safely
     50  1.1    mrg be ignored.
     51  1.1    mrg 
     52  1.1    mrg    <p>It is normal to have compiler warnings when compiling certain files. 
     53  1.1    mrg Unless you are a GCC developer, you can generally ignore these warnings
     54  1.1    mrg unless they cause compilation to fail.  Developers should attempt to fix
     55  1.1    mrg any warnings encountered, however they can temporarily continue past
     56  1.1    mrg warnings-as-errors by specifying the configure flag
     57  1.1    mrg <samp><span class="option">--disable-werror</span></samp>.
     58  1.1    mrg 
     59  1.1    mrg    <p>On certain old systems, defining certain environment variables such as
     60  1.1    mrg <samp><span class="env">CC</span></samp> can interfere with the functioning of <samp><span class="command">make</span></samp>.
     61  1.1    mrg 
     62  1.1    mrg    <p>If you encounter seemingly strange errors when trying to build the
     63  1.1    mrg compiler in a directory other than the source directory, it could be
     64  1.1    mrg because you have previously configured the compiler in the source
     65  1.1    mrg directory.  Make sure you have done all the necessary preparations.
     66  1.1    mrg 
     67  1.1    mrg    <p>If you build GCC on a BSD system using a directory stored in an old System
     68  1.1    mrg V file system, problems may occur in running <samp><span class="command">fixincludes</span></samp> if the
     69  1.1    mrg System V file system doesn't support symbolic links.  These problems
     70  1.1    mrg result in a failure to fix the declaration of <code>size_t</code> in
     71  1.1    mrg <samp><span class="file">sys/types.h</span></samp>.  If you find that <code>size_t</code> is a signed type and
     72  1.1    mrg that type mismatches occur, this could be the cause.
     73  1.1    mrg 
     74  1.1    mrg    <p>The solution is not to use such a directory for building GCC.
     75  1.1    mrg 
     76  1.1    mrg    <p>Similarly, when building from SVN or snapshots, or if you modify
     77  1.1    mrg <samp><span class="file">*.l</span></samp> files, you need the Flex lexical analyzer generator
     78  1.1    mrg installed.  If you do not modify <samp><span class="file">*.l</span></samp> files, releases contain
     79  1.1    mrg the Flex-generated files and you do not need Flex installed to build
     80  1.1    mrg them.  There is still one Flex-based lexical analyzer (part of the
     81  1.1    mrg build machinery, not of GCC itself) that is used even if you only
     82  1.1    mrg build the C front end.
     83  1.1    mrg 
     84  1.1    mrg    <p>When building from SVN or snapshots, or if you modify Texinfo
     85  1.1    mrg documentation, you need version 4.7 or later of Texinfo installed if you
     86  1.1    mrg want Info documentation to be regenerated.  Releases contain Info
     87  1.1    mrg documentation pre-built for the unmodified documentation in the release.
     88  1.1    mrg 
     89  1.1    mrg <h3 class="section"><a name="TOC0"></a>Building a native compiler</h3>
     90  1.1    mrg 
     91  1.1    mrg <p>For a native build, the default configuration is to perform
     92  1.1    mrg a 3-stage bootstrap of the compiler when &lsquo;<samp><span class="samp">make</span></samp>&rsquo; is invoked. 
     93  1.1    mrg This will build the entire GCC system and ensure that it compiles
     94  1.1    mrg itself correctly.  It can be disabled with the <samp><span class="option">--disable-bootstrap</span></samp>
     95  1.1    mrg parameter to &lsquo;<samp><span class="samp">configure</span></samp>&rsquo;, but bootstrapping is suggested because
     96  1.1    mrg the compiler will be tested more completely and could also have
     97  1.1    mrg better performance.
     98  1.1    mrg 
     99  1.1    mrg    <p>The bootstrapping process will complete the following steps:
    100  1.1    mrg 
    101  1.1    mrg      <ul>
    102  1.1    mrg <li>Build tools necessary to build the compiler.
    103  1.1    mrg 
    104  1.1    mrg      <li>Perform a 3-stage bootstrap of the compiler.  This includes building
    105  1.1    mrg three times the target tools for use by the compiler such as binutils
    106  1.1    mrg (bfd, binutils, gas, gprof, ld, and opcodes) if they have been
    107  1.1    mrg individually linked or moved into the top level GCC source tree before
    108  1.1    mrg configuring.
    109  1.1    mrg 
    110  1.1    mrg      <li>Perform a comparison test of the stage2 and stage3 compilers.
    111  1.1    mrg 
    112  1.1    mrg      <li>Build runtime libraries using the stage3 compiler from the previous step.
    113  1.1    mrg 
    114  1.1    mrg    </ul>
    115  1.1    mrg 
    116  1.1    mrg    <p>If you are short on disk space you might consider &lsquo;<samp><span class="samp">make
    117  1.1    mrg bootstrap-lean</span></samp>&rsquo; instead.  The sequence of compilation is the
    118  1.1    mrg same described above, but object files from the stage1 and
    119  1.1    mrg stage2 of the 3-stage bootstrap of the compiler are deleted as
    120  1.1    mrg soon as they are no longer needed.
    121  1.1    mrg 
    122  1.1    mrg    <p>If you wish to use non-default GCC flags when compiling the stage2
    123  1.1    mrg and stage3 compilers, set <code>BOOT_CFLAGS</code> on the command line when
    124  1.1    mrg doing &lsquo;<samp><span class="samp">make</span></samp>&rsquo;.  For example, if you want to save additional space
    125  1.1    mrg during the bootstrap and in the final installation as well, you can
    126  1.1    mrg build the compiler binaries without debugging information as in the
    127  1.1    mrg following example.  This will save roughly 40% of disk space both for
    128  1.1    mrg the bootstrap and the final installation.  (Libraries will still contain
    129  1.1    mrg debugging information.)
    130  1.1    mrg 
    131  1.3  skrll <pre class="smallexample">     make BOOT_CFLAGS='-O' bootstrap
    132  1.1    mrg </pre>
    133  1.1    mrg    <p>You can place non-default optimization flags into <code>BOOT_CFLAGS</code>; they
    134  1.1    mrg are less well tested here than the default of &lsquo;<samp><span class="samp">-g -O2</span></samp>&rsquo;, but should
    135  1.1    mrg still work.  In a few cases, you may find that you need to specify special
    136  1.1    mrg flags such as <samp><span class="option">-msoft-float</span></samp> here to complete the bootstrap; or,
    137  1.1    mrg if the native compiler miscompiles the stage1 compiler, you may need
    138  1.1    mrg to work around this, by choosing <code>BOOT_CFLAGS</code> to avoid the parts
    139  1.1    mrg of the stage1 compiler that were miscompiled, or by using &lsquo;<samp><span class="samp">make
    140  1.1    mrg bootstrap4</span></samp>&rsquo; to increase the number of stages of bootstrap.
    141  1.1    mrg 
    142  1.1    mrg    <p><code>BOOT_CFLAGS</code> does not apply to bootstrapped target libraries. 
    143  1.1    mrg Since these are always compiled with the compiler currently being
    144  1.1    mrg bootstrapped, you can use <code>CFLAGS_FOR_TARGET</code> to modify their
    145  1.1    mrg compilation flags, as for non-bootstrapped target libraries. 
    146  1.1    mrg Again, if the native compiler miscompiles the stage1 compiler, you may
    147  1.1    mrg need to work around this by avoiding non-working parts of the stage1
    148  1.1    mrg compiler.  Use <code>STAGE1_TFLAGS</code> to this end.
    149  1.1    mrg 
    150  1.1    mrg    <p>If you used the flag <samp><span class="option">--enable-languages=...</span></samp> to restrict
    151  1.1    mrg the compilers to be built, only those you've actually enabled will be
    152  1.1    mrg built.  This will of course only build those runtime libraries, for
    153  1.1    mrg which the particular compiler has been built.  Please note,
    154  1.1    mrg that re-defining <samp><span class="env">LANGUAGES</span></samp> when calling &lsquo;<samp><span class="samp">make</span></samp>&rsquo;
    155  1.1    mrg <strong>does not</strong> work anymore!
    156  1.1    mrg 
    157  1.1    mrg    <p>If the comparison of stage2 and stage3 fails, this normally indicates
    158  1.1    mrg that the stage2 compiler has compiled GCC incorrectly, and is therefore
    159  1.1    mrg a potentially serious bug which you should investigate and report.  (On
    160  1.1    mrg a few systems, meaningful comparison of object files is impossible; they
    161  1.1    mrg always appear &ldquo;different&rdquo;.  If you encounter this problem, you will
    162  1.1    mrg need to disable comparison in the <samp><span class="file">Makefile</span></samp>.)
    163  1.1    mrg 
    164  1.1    mrg    <p>If you do not want to bootstrap your compiler, you can configure with
    165  1.1    mrg <samp><span class="option">--disable-bootstrap</span></samp>.  In particular cases, you may want to
    166  1.1    mrg bootstrap your compiler even if the target system is not the same as
    167  1.1    mrg the one you are building on: for example, you could build a
    168  1.1    mrg <code>powerpc-unknown-linux-gnu</code> toolchain on a
    169  1.1    mrg <code>powerpc64-unknown-linux-gnu</code> host.  In this case, pass
    170  1.1    mrg <samp><span class="option">--enable-bootstrap</span></samp> to the configure script.
    171  1.1    mrg 
    172  1.1    mrg    <p><code>BUILD_CONFIG</code> can be used to bring in additional customization
    173  1.1    mrg to the build.  It can be set to a whitespace-separated list of names. 
    174  1.1    mrg For each such <code>NAME</code>, top-level <samp><span class="file">config/</span><code>NAME</code><span class="file">.mk</span></samp> will
    175  1.1    mrg be included by the top-level <samp><span class="file">Makefile</span></samp>, bringing in any settings
    176  1.1    mrg it contains.  The default <code>BUILD_CONFIG</code> can be set using the
    177  1.1    mrg configure option <samp><span class="option">--with-build-config=</span><code>NAME</code><span class="option">...</span></samp>.  Some
    178  1.1    mrg examples of supported build configurations are:
    179  1.1    mrg 
    180  1.1    mrg      <dl>
    181  1.1    mrg <dt>&lsquo;<samp><span class="samp">bootstrap-O1</span></samp>&rsquo;<dd>Removes any <samp><span class="option">-O</span></samp>-started option from <code>BOOT_CFLAGS</code>, and adds
    182  1.1    mrg <samp><span class="option">-O1</span></samp> to it.  &lsquo;<samp><span class="samp">BUILD_CONFIG=bootstrap-O1</span></samp>&rsquo; is equivalent to
    183  1.1    mrg &lsquo;<samp><span class="samp">BOOT_CFLAGS='-g -O1'</span></samp>&rsquo;.
    184  1.1    mrg 
    185  1.1    mrg      <br><dt>&lsquo;<samp><span class="samp">bootstrap-O3</span></samp>&rsquo;<dd>Analogous to <code>bootstrap-O1</code>.
    186  1.1    mrg 
    187  1.3  skrll      <br><dt>&lsquo;<samp><span class="samp">bootstrap-lto</span></samp>&rsquo;<dd>Enables Link-Time Optimization for host tools during bootstrapping. 
    188  1.3  skrll &lsquo;<samp><span class="samp">BUILD_CONFIG=bootstrap-lto</span></samp>&rsquo; is equivalent to adding
    189  1.3  skrll <samp><span class="option">-flto</span></samp> to &lsquo;<samp><span class="samp">BOOT_CFLAGS</span></samp>&rsquo;.
    190  1.3  skrll 
    191  1.1    mrg      <br><dt>&lsquo;<samp><span class="samp">bootstrap-debug</span></samp>&rsquo;<dd>Verifies that the compiler generates the same executable code, whether
    192  1.1    mrg or not it is asked to emit debug information.  To this end, this
    193  1.1    mrg option builds stage2 host programs without debug information, and uses
    194  1.1    mrg <samp><span class="file">contrib/compare-debug</span></samp> to compare them with the stripped stage3
    195  1.1    mrg object files.  If <code>BOOT_CFLAGS</code> is overridden so as to not enable
    196  1.1    mrg debug information, stage2 will have it, and stage3 won't.  This option
    197  1.1    mrg is enabled by default when GCC bootstrapping is enabled, if
    198  1.1    mrg <code>strip</code> can turn object files compiled with and without debug
    199  1.1    mrg info into identical object files.  In addition to better test
    200  1.1    mrg coverage, this option makes default bootstraps faster and leaner.
    201  1.1    mrg 
    202  1.1    mrg      <br><dt>&lsquo;<samp><span class="samp">bootstrap-debug-big</span></samp>&rsquo;<dd>Rather than comparing stripped object files, as in
    203  1.1    mrg <code>bootstrap-debug</code>, this option saves internal compiler dumps
    204  1.1    mrg during stage2 and stage3 and compares them as well, which helps catch
    205  1.1    mrg additional potential problems, but at a great cost in terms of disk
    206  1.1    mrg space.  It can be specified in addition to &lsquo;<samp><span class="samp">bootstrap-debug</span></samp>&rsquo;.
    207  1.1    mrg 
    208  1.1    mrg      <br><dt>&lsquo;<samp><span class="samp">bootstrap-debug-lean</span></samp>&rsquo;<dd>This option saves disk space compared with <code>bootstrap-debug-big</code>,
    209  1.1    mrg but at the expense of some recompilation.  Instead of saving the dumps
    210  1.1    mrg of stage2 and stage3 until the final compare, it uses
    211  1.1    mrg <samp><span class="option">-fcompare-debug</span></samp> to generate, compare and remove the dumps
    212  1.1    mrg during stage3, repeating the compilation that already took place in
    213  1.1    mrg stage2, whose dumps were not saved.
    214  1.1    mrg 
    215  1.1    mrg      <br><dt>&lsquo;<samp><span class="samp">bootstrap-debug-lib</span></samp>&rsquo;<dd>This option tests executable code invariance over debug information
    216  1.1    mrg generation on target libraries, just like <code>bootstrap-debug-lean</code>
    217  1.1    mrg tests it on host programs.  It builds stage3 libraries with
    218  1.1    mrg <samp><span class="option">-fcompare-debug</span></samp>, and it can be used along with any of the
    219  1.1    mrg <code>bootstrap-debug</code> options above.
    220  1.1    mrg 
    221  1.1    mrg      <p>There aren't <code>-lean</code> or <code>-big</code> counterparts to this option
    222  1.1    mrg because most libraries are only build in stage3, so bootstrap compares
    223  1.1    mrg would not get significant coverage.  Moreover, the few libraries built
    224  1.1    mrg in stage2 are used in stage3 host programs, so we wouldn't want to
    225  1.1    mrg compile stage2 libraries with different options for comparison purposes.
    226  1.1    mrg 
    227  1.1    mrg      <br><dt>&lsquo;<samp><span class="samp">bootstrap-debug-ckovw</span></samp>&rsquo;<dd>Arranges for error messages to be issued if the compiler built on any
    228  1.1    mrg stage is run without the option <samp><span class="option">-fcompare-debug</span></samp>.  This is
    229  1.1    mrg useful to verify the full <samp><span class="option">-fcompare-debug</span></samp> testing coverage.  It
    230  1.1    mrg must be used along with <code>bootstrap-debug-lean</code> and
    231  1.1    mrg <code>bootstrap-debug-lib</code>.
    232  1.1    mrg 
    233  1.1    mrg      <br><dt>&lsquo;<samp><span class="samp">bootstrap-time</span></samp>&rsquo;<dd>Arranges for the run time of each program started by the GCC driver,
    234  1.1    mrg built in any stage, to be logged to <samp><span class="file">time.log</span></samp>, in the top level of
    235  1.1    mrg the build tree.
    236  1.1    mrg 
    237  1.1    mrg    </dl>
    238  1.1    mrg 
    239  1.1    mrg <h3 class="section"><a name="TOC1"></a>Building a cross compiler</h3>
    240  1.1    mrg 
    241  1.1    mrg <p>When building a cross compiler, it is not generally possible to do a
    242  1.1    mrg 3-stage bootstrap of the compiler.  This makes for an interesting problem
    243  1.1    mrg as parts of GCC can only be built with GCC.
    244  1.1    mrg 
    245  1.1    mrg    <p>To build a cross compiler, we recommend first building and installing a
    246  1.1    mrg native compiler.  You can then use the native GCC compiler to build the
    247  1.1    mrg cross compiler.  The installed native compiler needs to be GCC version
    248  1.1    mrg 2.95 or later.
    249  1.1    mrg 
    250  1.1    mrg    <p>If the cross compiler is to be built with support for the Java
    251  1.1    mrg programming language and the ability to compile .java source files is
    252  1.1    mrg desired, the installed native compiler used to build the cross
    253  1.1    mrg compiler needs to be the same GCC version as the cross compiler.  In
    254  1.1    mrg addition the cross compiler needs to be configured with
    255  1.1    mrg <samp><span class="option">--with-ecj-jar=...</span></samp>.
    256  1.1    mrg 
    257  1.1    mrg    <p>Assuming you have already installed a native copy of GCC and configured
    258  1.1    mrg your cross compiler, issue the command <samp><span class="command">make</span></samp>, which performs the
    259  1.1    mrg following steps:
    260  1.1    mrg 
    261  1.1    mrg      <ul>
    262  1.1    mrg <li>Build host tools necessary to build the compiler.
    263  1.1    mrg 
    264  1.1    mrg      <li>Build target tools for use by the compiler such as binutils (bfd,
    265  1.1    mrg binutils, gas, gprof, ld, and opcodes)
    266  1.1    mrg if they have been individually linked or moved into the top level GCC source
    267  1.1    mrg tree before configuring.
    268  1.1    mrg 
    269  1.1    mrg      <li>Build the compiler (single stage only).
    270  1.1    mrg 
    271  1.1    mrg      <li>Build runtime libraries using the compiler from the previous step. 
    272  1.1    mrg </ul>
    273  1.1    mrg 
    274  1.1    mrg    <p>Note that if an error occurs in any step the make process will exit.
    275  1.1    mrg 
    276  1.1    mrg    <p>If you are not building GNU binutils in the same source tree as GCC,
    277  1.1    mrg you will need a cross-assembler and cross-linker installed before
    278  1.1    mrg configuring GCC.  Put them in the directory
    279  1.1    mrg <samp><var>prefix</var><span class="file">/</span><var>target</var><span class="file">/bin</span></samp>.  Here is a table of the tools
    280  1.1    mrg you should put in this directory:
    281  1.1    mrg 
    282  1.1    mrg      <dl>
    283  1.1    mrg <dt><samp><span class="file">as</span></samp><dd>This should be the cross-assembler.
    284  1.1    mrg 
    285  1.1    mrg      <br><dt><samp><span class="file">ld</span></samp><dd>This should be the cross-linker.
    286  1.1    mrg 
    287  1.1    mrg      <br><dt><samp><span class="file">ar</span></samp><dd>This should be the cross-archiver: a program which can manipulate
    288  1.1    mrg archive files (linker libraries) in the target machine's format.
    289  1.1    mrg 
    290  1.1    mrg      <br><dt><samp><span class="file">ranlib</span></samp><dd>This should be a program to construct a symbol table in an archive file. 
    291  1.1    mrg </dl>
    292  1.1    mrg 
    293  1.1    mrg    <p>The installation of GCC will find these programs in that directory,
    294  1.1    mrg and copy or link them to the proper place to for the cross-compiler to
    295  1.1    mrg find them when run later.
    296  1.1    mrg 
    297  1.1    mrg    <p>The easiest way to provide these files is to build the Binutils package. 
    298  1.1    mrg Configure it with the same <samp><span class="option">--host</span></samp> and <samp><span class="option">--target</span></samp>
    299  1.1    mrg options that you use for configuring GCC, then build and install
    300  1.1    mrg them.  They install their executables automatically into the proper
    301  1.1    mrg directory.  Alas, they do not support all the targets that GCC
    302  1.1    mrg supports.
    303  1.1    mrg 
    304  1.1    mrg    <p>If you are not building a C library in the same source tree as GCC,
    305  1.1    mrg you should also provide the target libraries and headers before
    306  1.1    mrg configuring GCC, specifying the directories with
    307  1.1    mrg <samp><span class="option">--with-sysroot</span></samp> or <samp><span class="option">--with-headers</span></samp> and
    308  1.1    mrg <samp><span class="option">--with-libs</span></samp>.  Many targets also require &ldquo;start files&rdquo; such
    309  1.1    mrg as <samp><span class="file">crt0.o</span></samp> and
    310  1.1    mrg <samp><span class="file">crtn.o</span></samp> which are linked into each executable.  There may be several
    311  1.1    mrg alternatives for <samp><span class="file">crt0.o</span></samp>, for use with profiling or other
    312  1.1    mrg compilation options.  Check your target's definition of
    313  1.1    mrg <code>STARTFILE_SPEC</code> to find out what start files it uses.
    314  1.1    mrg 
    315  1.1    mrg <h3 class="section"><a name="TOC2"></a>Building in parallel</h3>
    316  1.1    mrg 
    317  1.1    mrg <p>GNU Make 3.80 and above, which is necessary to build GCC, support
    318  1.1    mrg building in parallel.  To activate this, you can use &lsquo;<samp><span class="samp">make -j 2</span></samp>&rsquo;
    319  1.1    mrg instead of &lsquo;<samp><span class="samp">make</span></samp>&rsquo;.  You can also specify a bigger number, and
    320  1.1    mrg in most cases using a value greater than the number of processors in
    321  1.1    mrg your machine will result in fewer and shorter I/O latency hits, thus
    322  1.1    mrg improving overall throughput; this is especially true for slow drives
    323  1.1    mrg and network filesystems.
    324  1.1    mrg 
    325  1.1    mrg <h3 class="section"><a name="TOC3"></a>Building the Ada compiler</h3>
    326  1.1    mrg 
    327  1.1    mrg <p>In order to build GNAT, the Ada compiler, you need a working GNAT
    328  1.3  skrll compiler (GCC version 4.0 or later). 
    329  1.1    mrg This includes GNAT tools such as <samp><span class="command">gnatmake</span></samp> and
    330  1.1    mrg <samp><span class="command">gnatlink</span></samp>, since the Ada front end is written in Ada and
    331  1.1    mrg uses some GNAT-specific extensions.
    332  1.1    mrg 
    333  1.1    mrg    <p>In order to build a cross compiler, it is suggested to install
    334  1.1    mrg the new compiler as native first, and then use it to build the cross
    335  1.1    mrg compiler.
    336  1.1    mrg 
    337  1.1    mrg    <p><samp><span class="command">configure</span></samp> does not test whether the GNAT installation works
    338  1.1    mrg and has a sufficiently recent version; if too old a GNAT version is
    339  1.1    mrg installed, the build will fail unless <samp><span class="option">--enable-languages</span></samp> is
    340  1.1    mrg used to disable building the Ada front end.
    341  1.1    mrg 
    342  1.1    mrg    <p><samp><span class="env">ADA_INCLUDE_PATH</span></samp> and <samp><span class="env">ADA_OBJECT_PATH</span></samp> environment variables
    343  1.1    mrg must not be set when building the Ada compiler, the Ada tools, or the
    344  1.1    mrg Ada runtime libraries. You can check that your build environment is clean
    345  1.1    mrg by verifying that &lsquo;<samp><span class="samp">gnatls -v</span></samp>&rsquo; lists only one explicit path in each
    346  1.1    mrg section.
    347  1.1    mrg 
    348  1.1    mrg <h3 class="section"><a name="TOC4"></a>Building with profile feedback</h3>
    349  1.1    mrg 
    350  1.1    mrg <p>It is possible to use profile feedback to optimize the compiler itself.  This
    351  1.1    mrg should result in a faster compiler binary.  Experiments done on x86 using gcc
    352  1.1    mrg 3.3 showed approximately 7 percent speedup on compiling C programs.  To
    353  1.1    mrg bootstrap the compiler with profile feedback, use <code>make profiledbootstrap</code>.
    354  1.1    mrg 
    355  1.1    mrg    <p>When &lsquo;<samp><span class="samp">make profiledbootstrap</span></samp>&rsquo; is run, it will first build a <code>stage1</code>
    356  1.1    mrg compiler.  This compiler is used to build a <code>stageprofile</code> compiler
    357  1.1    mrg instrumented to collect execution counts of instruction and branch
    358  1.1    mrg probabilities.  Then runtime libraries are compiled with profile collected. 
    359  1.1    mrg Finally a <code>stagefeedback</code> compiler is built using the information collected.
    360  1.1    mrg 
    361  1.1    mrg    <p>Unlike standard bootstrap, several additional restrictions apply.  The
    362  1.1    mrg compiler used to build <code>stage1</code> needs to support a 64-bit integral type. 
    363  1.1    mrg It is recommended to only use GCC for this.  Also parallel make is currently
    364  1.1    mrg not supported since collisions in profile collecting may occur.
    365  1.1    mrg 
    366  1.1    mrg    <p><hr />
    367  1.1    mrg <p><a href="./index.html">Return to the GCC Installation page</a>
    368  1.1    mrg 
    369  1.1    mrg <!-- ***Testing***************************************************************** -->
    370  1.1    mrg <!-- ***Final install*********************************************************** -->
    371  1.1    mrg <!-- ***Binaries**************************************************************** -->
    372  1.1    mrg <!-- ***Specific**************************************************************** -->
    373  1.1    mrg <!-- ***Old documentation****************************************************** -->
    374  1.1    mrg <!-- ***GFDL******************************************************************** -->
    375  1.1    mrg <!-- *************************************************************************** -->
    376  1.1    mrg <!-- Part 6 The End of the Document -->
    377  1.1    mrg </body></html>
    378  1.1    mrg 
    379