Home | History | Annotate | Line # | Download | only in INSTALL
      1  1.11  mrg <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      2  1.11  mrg <html>
      3  1.15  mrg <!-- Copyright (C) 1988-2022 Free Software Foundation, Inc.
      4   1.1  mrg 
      5  1.11  mrg Permission is granted to copy, distribute and/or modify this document
      6   1.3  mrg under the terms of the GNU Free Documentation License, Version 1.3 or
      7   1.1  mrg any later version published by the Free Software Foundation; with no
      8   1.1  mrg Invariant Sections, the Front-Cover texts being (a) (see below), and
      9   1.1  mrg with the Back-Cover Texts being (b) (see below).  A copy of the
     10  1.11  mrg license is included in the section entitled "GNU
     11  1.11  mrg Free Documentation License".
     12   1.1  mrg 
     13   1.1  mrg (a) The FSF's Front-Cover Text is:
     14   1.1  mrg 
     15  1.11  mrg A GNU Manual
     16   1.1  mrg 
     17   1.1  mrg (b) The FSF's Back-Cover Text is:
     18   1.1  mrg 
     19  1.11  mrg You have freedom to copy and modify this GNU Manual, like GNU
     20   1.1  mrg      software.  Copies published by the Free Software Foundation raise
     21  1.11  mrg      funds for GNU development. -->
     22  1.14  mrg <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
     23  1.14  mrg <head>
     24  1.14  mrg <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
     25  1.13  mrg <title>Installing GCC: Building</title>
     26  1.11  mrg 
     27  1.13  mrg <meta name="description" content="Installing GCC: Building">
     28  1.13  mrg <meta name="keywords" content="Installing GCC: Building">
     29  1.11  mrg <meta name="resource-type" content="document">
     30  1.11  mrg <meta name="distribution" content="global">
     31  1.11  mrg <meta name="Generator" content="makeinfo">
     32  1.11  mrg <style type="text/css">
     33  1.11  mrg <!--
     34  1.11  mrg a.summary-letter {text-decoration: none}
     35  1.11  mrg blockquote.indentedblock {margin-right: 0em}
     36  1.14  mrg blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
     37  1.14  mrg blockquote.smallquotation {font-size: smaller}
     38  1.11  mrg div.display {margin-left: 3.2em}
     39  1.11  mrg div.example {margin-left: 3.2em}
     40  1.14  mrg div.lisp {margin-left: 3.2em}
     41  1.14  mrg div.smalldisplay {margin-left: 3.2em}
     42  1.14  mrg div.smallexample {margin-left: 3.2em}
     43  1.14  mrg div.smalllisp {margin-left: 3.2em}
     44  1.11  mrg kbd {font-style: oblique}
     45  1.11  mrg pre.display {font-family: inherit}
     46  1.11  mrg pre.format {font-family: inherit}
     47  1.11  mrg pre.menu-comment {font-family: serif}
     48  1.11  mrg pre.menu-preformatted {font-family: serif}
     49  1.14  mrg pre.smalldisplay {font-family: inherit; font-size: smaller}
     50  1.14  mrg pre.smallexample {font-size: smaller}
     51  1.14  mrg pre.smallformat {font-family: inherit; font-size: smaller}
     52  1.14  mrg pre.smalllisp {font-size: smaller}
     53  1.11  mrg span.nolinebreak {white-space: nowrap}
     54  1.11  mrg span.roman {font-family: initial; font-weight: normal}
     55  1.11  mrg span.sansserif {font-family: sans-serif; font-weight: normal}
     56  1.11  mrg ul.no-bullet {list-style: none}
     57  1.11  mrg -->
     58  1.11  mrg </style>
     59  1.11  mrg 
     60  1.11  mrg 
     61   1.1  mrg </head>
     62  1.11  mrg 
     63  1.11  mrg <body lang="en">
     64  1.13  mrg <h1 class="settitle" align="center">Installing GCC: Building</h1>
     65  1.11  mrg 
     66  1.11  mrg 
     67  1.11  mrg 
     68  1.11  mrg 
     69  1.11  mrg 
     70  1.11  mrg 
     71  1.11  mrg 
     72  1.11  mrg 
     73  1.11  mrg 
     74  1.11  mrg 
     75  1.11  mrg 
     76  1.11  mrg 
     77  1.11  mrg 
     78  1.11  mrg 
     79  1.11  mrg 
     80  1.11  mrg 
     81  1.11  mrg 
     82  1.11  mrg 
     83  1.11  mrg 
     84  1.11  mrg 
     85  1.14  mrg <a name="index-Installing-GCC_003a-Building"></a>
     86  1.11  mrg 
     87  1.11  mrg <p>Now that GCC is configured, you are ready to build the compiler and
     88  1.10  mrg runtime libraries.
     89  1.11  mrg </p>
     90  1.11  mrg <p>Some commands executed when making the compiler may fail (return a
     91  1.11  mrg nonzero status) and be ignored by <code>make</code>.  These failures, which
     92   1.1  mrg are often due to files that were not found, are expected, and can safely
     93   1.1  mrg be ignored.
     94  1.11  mrg </p>
     95  1.11  mrg <p>It is normal to have compiler warnings when compiling certain files.
     96   1.1  mrg Unless you are a GCC developer, you can generally ignore these warnings
     97   1.1  mrg unless they cause compilation to fail.  Developers should attempt to fix
     98   1.1  mrg any warnings encountered, however they can temporarily continue past
     99   1.1  mrg warnings-as-errors by specifying the configure flag
    100  1.11  mrg <samp>--disable-werror</samp>.
    101  1.11  mrg </p>
    102  1.11  mrg <p>On certain old systems, defining certain environment variables such as
    103  1.11  mrg <code>CC</code> can interfere with the functioning of <code>make</code>.
    104  1.11  mrg </p>
    105  1.11  mrg <p>If you encounter seemingly strange errors when trying to build the
    106   1.1  mrg compiler in a directory other than the source directory, it could be
    107   1.1  mrg because you have previously configured the compiler in the source
    108   1.1  mrg directory.  Make sure you have done all the necessary preparations.
    109  1.11  mrg </p>
    110  1.11  mrg <p>If you build GCC on a BSD system using a directory stored in an old System
    111  1.11  mrg V file system, problems may occur in running <code>fixincludes</code> if the
    112  1.11  mrg System V file system doesn&rsquo;t support symbolic links.  These problems
    113   1.1  mrg result in a failure to fix the declaration of <code>size_t</code> in
    114  1.11  mrg <samp>sys/types.h</samp>.  If you find that <code>size_t</code> is a signed type and
    115   1.1  mrg that type mismatches occur, this could be the cause.
    116  1.11  mrg </p>
    117  1.11  mrg <p>The solution is not to use such a directory for building GCC.
    118  1.11  mrg </p>
    119  1.11  mrg <p>Similarly, when building from the source repository or snapshots, or if you modify
    120  1.11  mrg <samp>*.l</samp> files, you need the Flex lexical analyzer generator
    121  1.11  mrg installed.  If you do not modify <samp>*.l</samp> files, releases contain
    122   1.1  mrg the Flex-generated files and you do not need Flex installed to build
    123   1.1  mrg them.  There is still one Flex-based lexical analyzer (part of the
    124   1.1  mrg build machinery, not of GCC itself) that is used even if you only
    125   1.1  mrg build the C front end.
    126  1.11  mrg </p>
    127  1.11  mrg <p>When building from the source repository or snapshots, or if you modify Texinfo
    128   1.1  mrg documentation, you need version 4.7 or later of Texinfo installed if you
    129   1.1  mrg want Info documentation to be regenerated.  Releases contain Info
    130   1.1  mrg documentation pre-built for the unmodified documentation in the release.
    131  1.11  mrg </p>
    132  1.14  mrg <a name="Building-a-native-compiler"></a>
    133  1.11  mrg <h3 class="section">Building a native compiler</h3>
    134   1.1  mrg 
    135   1.1  mrg <p>For a native build, the default configuration is to perform
    136  1.11  mrg a 3-stage bootstrap of the compiler when &lsquo;<samp>make</samp>&rsquo; is invoked.
    137   1.1  mrg This will build the entire GCC system and ensure that it compiles
    138  1.11  mrg itself correctly.  It can be disabled with the <samp>--disable-bootstrap</samp>
    139  1.11  mrg parameter to &lsquo;<samp>configure</samp>&rsquo;, but bootstrapping is suggested because
    140   1.1  mrg the compiler will be tested more completely and could also have
    141   1.1  mrg better performance.
    142  1.11  mrg </p>
    143  1.11  mrg <p>The bootstrapping process will complete the following steps:
    144  1.11  mrg </p>
    145  1.11  mrg <ul>
    146  1.11  mrg <li> Build tools necessary to build the compiler.
    147   1.1  mrg 
    148  1.11  mrg </li><li> Perform a 3-stage bootstrap of the compiler.  This includes building
    149   1.1  mrg three times the target tools for use by the compiler such as binutils
    150   1.1  mrg (bfd, binutils, gas, gprof, ld, and opcodes) if they have been
    151   1.1  mrg individually linked or moved into the top level GCC source tree before
    152   1.1  mrg configuring.
    153   1.1  mrg 
    154  1.11  mrg </li><li> Perform a comparison test of the stage2 and stage3 compilers.
    155   1.1  mrg 
    156  1.11  mrg </li><li> Build runtime libraries using the stage3 compiler from the previous step.
    157   1.1  mrg 
    158  1.11  mrg </li></ul>
    159   1.1  mrg 
    160  1.11  mrg <p>If you are short on disk space you might consider &lsquo;<samp>make
    161  1.11  mrg bootstrap-lean</samp>&rsquo; instead.  The sequence of compilation is the
    162   1.1  mrg same described above, but object files from the stage1 and
    163   1.1  mrg stage2 of the 3-stage bootstrap of the compiler are deleted as
    164   1.1  mrg soon as they are no longer needed.
    165  1.11  mrg </p>
    166  1.11  mrg <p>If you wish to use non-default GCC flags when compiling the stage2
    167   1.1  mrg and stage3 compilers, set <code>BOOT_CFLAGS</code> on the command line when
    168  1.11  mrg doing &lsquo;<samp>make</samp>&rsquo;.  For example, if you want to save additional space
    169   1.1  mrg during the bootstrap and in the final installation as well, you can
    170   1.1  mrg build the compiler binaries without debugging information as in the
    171   1.1  mrg following example.  This will save roughly 40% of disk space both for
    172   1.1  mrg the bootstrap and the final installation.  (Libraries will still contain
    173   1.1  mrg debugging information.)
    174  1.11  mrg </p>
    175  1.14  mrg <div class="smallexample">
    176  1.14  mrg <pre class="smallexample">make BOOT_CFLAGS='-O' bootstrap
    177  1.11  mrg </pre></div>
    178   1.1  mrg 
    179  1.11  mrg <p>You can place non-default optimization flags into <code>BOOT_CFLAGS</code>; they
    180  1.11  mrg are less well tested here than the default of &lsquo;<samp>-g -O2</samp>&rsquo;, but should
    181   1.1  mrg still work.  In a few cases, you may find that you need to specify special
    182  1.11  mrg flags such as <samp>-msoft-float</samp> here to complete the bootstrap; or,
    183   1.1  mrg if the native compiler miscompiles the stage1 compiler, you may need
    184   1.1  mrg to work around this, by choosing <code>BOOT_CFLAGS</code> to avoid the parts
    185  1.11  mrg of the stage1 compiler that were miscompiled, or by using &lsquo;<samp>make
    186  1.11  mrg bootstrap4</samp>&rsquo; to increase the number of stages of bootstrap.
    187  1.11  mrg </p>
    188  1.11  mrg <p><code>BOOT_CFLAGS</code> does not apply to bootstrapped target libraries.
    189   1.1  mrg Since these are always compiled with the compiler currently being
    190   1.1  mrg bootstrapped, you can use <code>CFLAGS_FOR_TARGET</code> to modify their
    191  1.11  mrg compilation flags, as for non-bootstrapped target libraries.
    192   1.1  mrg Again, if the native compiler miscompiles the stage1 compiler, you may
    193   1.1  mrg need to work around this by avoiding non-working parts of the stage1
    194   1.1  mrg compiler.  Use <code>STAGE1_TFLAGS</code> to this end.
    195  1.11  mrg </p>
    196  1.11  mrg <p>If you used the flag <samp>--enable-languages=&hellip;</samp> to restrict
    197  1.11  mrg the compilers to be built, only those you&rsquo;ve actually enabled will be
    198   1.1  mrg built.  This will of course only build those runtime libraries, for
    199   1.1  mrg which the particular compiler has been built.  Please note,
    200  1.11  mrg that re-defining <code>LANGUAGES</code> when calling &lsquo;<samp>make</samp>&rsquo;
    201   1.1  mrg <strong>does not</strong> work anymore!
    202  1.11  mrg </p>
    203  1.11  mrg <p>If the comparison of stage2 and stage3 fails, this normally indicates
    204   1.1  mrg that the stage2 compiler has compiled GCC incorrectly, and is therefore
    205   1.1  mrg a potentially serious bug which you should investigate and report.  (On
    206   1.1  mrg a few systems, meaningful comparison of object files is impossible; they
    207   1.1  mrg always appear &ldquo;different&rdquo;.  If you encounter this problem, you will
    208  1.11  mrg need to disable comparison in the <samp>Makefile</samp>.)
    209  1.11  mrg </p>
    210  1.11  mrg <p>If you do not want to bootstrap your compiler, you can configure with
    211  1.11  mrg <samp>--disable-bootstrap</samp>.  In particular cases, you may want to
    212   1.1  mrg bootstrap your compiler even if the target system is not the same as
    213   1.1  mrg the one you are building on: for example, you could build a
    214   1.1  mrg <code>powerpc-unknown-linux-gnu</code> toolchain on a
    215   1.1  mrg <code>powerpc64-unknown-linux-gnu</code> host.  In this case, pass
    216  1.11  mrg <samp>--enable-bootstrap</samp> to the configure script.
    217  1.11  mrg </p>
    218  1.11  mrg <p><code>BUILD_CONFIG</code> can be used to bring in additional customization
    219  1.11  mrg to the build.  It can be set to a whitespace-separated list of names.
    220  1.11  mrg For each such <code>NAME</code>, top-level <samp>config/<code>NAME</code>.mk</samp> will
    221  1.11  mrg be included by the top-level <samp>Makefile</samp>, bringing in any settings
    222   1.1  mrg it contains.  The default <code>BUILD_CONFIG</code> can be set using the
    223  1.11  mrg configure option <samp>--with-build-config=<code>NAME</code>...</samp>.  Some
    224   1.1  mrg examples of supported build configurations are:
    225  1.11  mrg </p>
    226  1.11  mrg <dl compact="compact">
    227  1.14  mrg <dt>&lsquo;<samp>bootstrap-O1</samp>&rsquo;</dt>
    228  1.11  mrg <dd><p>Removes any <samp>-O</samp>-started option from <code>BOOT_CFLAGS</code>, and adds
    229  1.11  mrg <samp>-O1</samp> to it.  &lsquo;<samp>BUILD_CONFIG=bootstrap-O1</samp>&rsquo; is equivalent to
    230  1.11  mrg &lsquo;<samp>BOOT_CFLAGS='-g -O1'</samp>&rsquo;.
    231  1.11  mrg </p>
    232  1.11  mrg </dd>
    233  1.14  mrg <dt>&lsquo;<samp>bootstrap-O3</samp>&rsquo;</dt>
    234  1.14  mrg <dt>&lsquo;<samp>bootstrap-Og</samp>&rsquo;</dt>
    235  1.11  mrg <dd><p>Analogous to <code>bootstrap-O1</code>.
    236  1.11  mrg </p>
    237  1.11  mrg </dd>
    238  1.14  mrg <dt>&lsquo;<samp>bootstrap-lto</samp>&rsquo;</dt>
    239  1.11  mrg <dd><p>Enables Link-Time Optimization for host tools during bootstrapping.
    240  1.11  mrg &lsquo;<samp>BUILD_CONFIG=bootstrap-lto</samp>&rsquo; is equivalent to adding
    241  1.11  mrg <samp>-flto</samp> to &lsquo;<samp>BOOT_CFLAGS</samp>&rsquo;.  This option assumes that the host
    242   1.5  mrg supports the linker plugin (e.g. GNU ld version 2.21 or later or GNU gold
    243   1.5  mrg version 2.21 or later).
    244  1.11  mrg </p>
    245  1.11  mrg </dd>
    246  1.14  mrg <dt>&lsquo;<samp>bootstrap-lto-noplugin</samp>&rsquo;</dt>
    247  1.11  mrg <dd><p>This option is similar to <code>bootstrap-lto</code>, but is intended for
    248  1.11  mrg hosts that do not support the linker plugin.  Without the linker plugin 
    249  1.11  mrg static libraries are not compiled with link-time optimizations.  Since 
    250  1.11  mrg the GCC middle end and back end are in <samp>libbackend.a</samp> this means
    251   1.5  mrg that only the front end is actually LTO optimized.
    252  1.11  mrg </p>
    253  1.11  mrg </dd>
    254  1.14  mrg <dt>&lsquo;<samp>bootstrap-lto-lean</samp>&rsquo;</dt>
    255  1.12  mrg <dd><p>This option is similar to <code>bootstrap-lto</code>, but is intended for
    256  1.12  mrg faster build by only using LTO in the final bootstrap stage.
    257  1.12  mrg With &lsquo;<samp>make profiledbootstrap</samp>&rsquo; the LTO frontend
    258  1.12  mrg is trained only on generator files.
    259  1.12  mrg </p>
    260  1.12  mrg </dd>
    261  1.14  mrg <dt>&lsquo;<samp>bootstrap-debug</samp>&rsquo;</dt>
    262  1.11  mrg <dd><p>Verifies that the compiler generates the same executable code, whether
    263   1.1  mrg or not it is asked to emit debug information.  To this end, this
    264   1.1  mrg option builds stage2 host programs without debug information, and uses
    265  1.11  mrg <samp>contrib/compare-debug</samp> to compare them with the stripped stage3
    266   1.1  mrg object files.  If <code>BOOT_CFLAGS</code> is overridden so as to not enable
    267  1.11  mrg debug information, stage2 will have it, and stage3 won&rsquo;t.  This option
    268   1.1  mrg is enabled by default when GCC bootstrapping is enabled, if
    269   1.1  mrg <code>strip</code> can turn object files compiled with and without debug
    270   1.1  mrg info into identical object files.  In addition to better test
    271   1.1  mrg coverage, this option makes default bootstraps faster and leaner.
    272  1.11  mrg </p>
    273  1.11  mrg </dd>
    274  1.14  mrg <dt>&lsquo;<samp>bootstrap-debug-big</samp>&rsquo;</dt>
    275  1.11  mrg <dd><p>Rather than comparing stripped object files, as in
    276   1.1  mrg <code>bootstrap-debug</code>, this option saves internal compiler dumps
    277   1.1  mrg during stage2 and stage3 and compares them as well, which helps catch
    278   1.1  mrg additional potential problems, but at a great cost in terms of disk
    279  1.11  mrg space.  It can be specified in addition to &lsquo;<samp>bootstrap-debug</samp>&rsquo;.
    280  1.11  mrg </p>
    281  1.11  mrg </dd>
    282  1.14  mrg <dt>&lsquo;<samp>bootstrap-debug-lean</samp>&rsquo;</dt>
    283  1.11  mrg <dd><p>This option saves disk space compared with <code>bootstrap-debug-big</code>,
    284   1.1  mrg but at the expense of some recompilation.  Instead of saving the dumps
    285   1.1  mrg of stage2 and stage3 until the final compare, it uses
    286  1.11  mrg <samp>-fcompare-debug</samp> to generate, compare and remove the dumps
    287   1.1  mrg during stage3, repeating the compilation that already took place in
    288   1.1  mrg stage2, whose dumps were not saved.
    289  1.11  mrg </p>
    290  1.11  mrg </dd>
    291  1.14  mrg <dt>&lsquo;<samp>bootstrap-debug-lib</samp>&rsquo;</dt>
    292  1.11  mrg <dd><p>This option tests executable code invariance over debug information
    293   1.1  mrg generation on target libraries, just like <code>bootstrap-debug-lean</code>
    294   1.1  mrg tests it on host programs.  It builds stage3 libraries with
    295  1.11  mrg <samp>-fcompare-debug</samp>, and it can be used along with any of the
    296   1.1  mrg <code>bootstrap-debug</code> options above.
    297  1.11  mrg </p>
    298  1.11  mrg <p>There aren&rsquo;t <code>-lean</code> or <code>-big</code> counterparts to this option
    299   1.1  mrg because most libraries are only build in stage3, so bootstrap compares
    300   1.1  mrg would not get significant coverage.  Moreover, the few libraries built
    301  1.11  mrg in stage2 are used in stage3 host programs, so we wouldn&rsquo;t want to
    302   1.1  mrg compile stage2 libraries with different options for comparison purposes.
    303  1.11  mrg </p>
    304  1.11  mrg </dd>
    305  1.14  mrg <dt>&lsquo;<samp>bootstrap-debug-ckovw</samp>&rsquo;</dt>
    306  1.11  mrg <dd><p>Arranges for error messages to be issued if the compiler built on any
    307  1.11  mrg stage is run without the option <samp>-fcompare-debug</samp>.  This is
    308  1.11  mrg useful to verify the full <samp>-fcompare-debug</samp> testing coverage.  It
    309   1.1  mrg must be used along with <code>bootstrap-debug-lean</code> and
    310   1.1  mrg <code>bootstrap-debug-lib</code>.
    311  1.11  mrg </p>
    312  1.11  mrg </dd>
    313  1.14  mrg <dt>&lsquo;<samp>bootstrap-cet</samp>&rsquo;</dt>
    314  1.11  mrg <dd><p>This option enables Intel CET for host tools during bootstrapping.
    315  1.11  mrg &lsquo;<samp>BUILD_CONFIG=bootstrap-cet</samp>&rsquo; is equivalent to adding
    316  1.11  mrg <samp>-fcf-protection</samp> to &lsquo;<samp>BOOT_CFLAGS</samp>&rsquo;.  This option
    317  1.11  mrg assumes that the host supports Intel CET (e.g. GNU assembler version
    318  1.11  mrg 2.30 or later).
    319  1.11  mrg </p>
    320  1.11  mrg </dd>
    321  1.14  mrg <dt>&lsquo;<samp>bootstrap-time</samp>&rsquo;</dt>
    322  1.11  mrg <dd><p>Arranges for the run time of each program started by the GCC driver,
    323  1.11  mrg built in any stage, to be logged to <samp>time.log</samp>, in the top level of
    324   1.1  mrg the build tree.
    325  1.11  mrg </p>
    326  1.11  mrg </dd>
    327  1.14  mrg <dt>&lsquo;<samp>bootstrap-asan</samp>&rsquo;</dt>
    328  1.13  mrg <dd><p>Compiles GCC itself using Address Sanitization in order to catch invalid memory
    329  1.13  mrg accesses within the GCC code.
    330  1.13  mrg </p>
    331  1.13  mrg </dd>
    332  1.15  mrg <dt>&lsquo;<samp>bootstrap-hwasan</samp>&rsquo;</dt>
    333  1.15  mrg <dd><p>Compiles GCC itself using HWAddress Sanitization in order to catch invalid
    334  1.15  mrg memory accesses within the GCC code.  This option is only available on AArch64
    335  1.15  mrg systems that are running Linux kernel version 5.4 or later.
    336  1.15  mrg </p>
    337  1.15  mrg </dd>
    338  1.11  mrg </dl>
    339   1.1  mrg 
    340  1.14  mrg <a name="Building-a-cross-compiler"></a>
    341  1.11  mrg <h3 class="section">Building a cross compiler</h3>
    342   1.1  mrg 
    343   1.1  mrg <p>When building a cross compiler, it is not generally possible to do a
    344   1.1  mrg 3-stage bootstrap of the compiler.  This makes for an interesting problem
    345   1.1  mrg as parts of GCC can only be built with GCC.
    346  1.11  mrg </p>
    347  1.11  mrg <p>To build a cross compiler, we recommend first building and installing a
    348   1.1  mrg native compiler.  You can then use the native GCC compiler to build the
    349   1.1  mrg cross compiler.  The installed native compiler needs to be GCC version
    350   1.1  mrg 2.95 or later.
    351  1.11  mrg </p>
    352  1.11  mrg <p>Assuming you have already installed a native copy of GCC and configured
    353  1.11  mrg your cross compiler, issue the command <code>make</code>, which performs the
    354   1.1  mrg following steps:
    355  1.11  mrg </p>
    356  1.11  mrg <ul>
    357  1.11  mrg <li> Build host tools necessary to build the compiler.
    358   1.1  mrg 
    359  1.11  mrg </li><li> Build target tools for use by the compiler such as binutils (bfd,
    360   1.1  mrg binutils, gas, gprof, ld, and opcodes)
    361   1.1  mrg if they have been individually linked or moved into the top level GCC source
    362   1.1  mrg tree before configuring.
    363   1.1  mrg 
    364  1.11  mrg </li><li> Build the compiler (single stage only).
    365  1.10  mrg 
    366  1.11  mrg </li><li> Build runtime libraries using the compiler from the previous step.
    367  1.11  mrg </li></ul>
    368   1.1  mrg 
    369  1.11  mrg <p>Note that if an error occurs in any step the make process will exit.
    370  1.11  mrg </p>
    371  1.11  mrg <p>If you are not building GNU binutils in the same source tree as GCC,
    372   1.1  mrg you will need a cross-assembler and cross-linker installed before
    373   1.1  mrg configuring GCC.  Put them in the directory
    374  1.11  mrg <samp><var>prefix</var>/<var>target</var>/bin</samp>.  Here is a table of the tools
    375   1.1  mrg you should put in this directory:
    376  1.11  mrg </p>
    377  1.11  mrg <dl compact="compact">
    378  1.14  mrg <dt><samp>as</samp></dt>
    379  1.11  mrg <dd><p>This should be the cross-assembler.
    380  1.11  mrg </p>
    381  1.11  mrg </dd>
    382  1.14  mrg <dt><samp>ld</samp></dt>
    383  1.11  mrg <dd><p>This should be the cross-linker.
    384  1.11  mrg </p>
    385  1.11  mrg </dd>
    386  1.14  mrg <dt><samp>ar</samp></dt>
    387  1.11  mrg <dd><p>This should be the cross-archiver: a program which can manipulate
    388  1.11  mrg archive files (linker libraries) in the target machine&rsquo;s format.
    389  1.11  mrg </p>
    390  1.11  mrg </dd>
    391  1.14  mrg <dt><samp>ranlib</samp></dt>
    392  1.11  mrg <dd><p>This should be a program to construct a symbol table in an archive file.
    393  1.11  mrg </p></dd>
    394   1.1  mrg </dl>
    395   1.1  mrg 
    396  1.11  mrg <p>The installation of GCC will find these programs in that directory,
    397   1.1  mrg and copy or link them to the proper place to for the cross-compiler to
    398   1.1  mrg find them when run later.
    399  1.11  mrg </p>
    400  1.11  mrg <p>The easiest way to provide these files is to build the Binutils package.
    401  1.11  mrg Configure it with the same <samp>--host</samp> and <samp>--target</samp>
    402   1.1  mrg options that you use for configuring GCC, then build and install
    403   1.1  mrg them.  They install their executables automatically into the proper
    404   1.1  mrg directory.  Alas, they do not support all the targets that GCC
    405   1.1  mrg supports.
    406  1.11  mrg </p>
    407  1.11  mrg <p>If you are not building a C library in the same source tree as GCC,
    408   1.1  mrg you should also provide the target libraries and headers before
    409   1.1  mrg configuring GCC, specifying the directories with
    410  1.11  mrg <samp>--with-sysroot</samp> or <samp>--with-headers</samp> and
    411  1.11  mrg <samp>--with-libs</samp>.  Many targets also require &ldquo;start files&rdquo; such
    412  1.11  mrg as <samp>crt0.o</samp> and
    413  1.11  mrg <samp>crtn.o</samp> which are linked into each executable.  There may be several
    414  1.11  mrg alternatives for <samp>crt0.o</samp>, for use with profiling or other
    415  1.11  mrg compilation options.  Check your target&rsquo;s definition of
    416   1.1  mrg <code>STARTFILE_SPEC</code> to find out what start files it uses.
    417  1.11  mrg </p>
    418  1.14  mrg <a name="Building-in-parallel"></a>
    419  1.11  mrg <h3 class="section">Building in parallel</h3>
    420   1.1  mrg 
    421   1.1  mrg <p>GNU Make 3.80 and above, which is necessary to build GCC, support
    422  1.11  mrg building in parallel.  To activate this, you can use &lsquo;<samp>make -j 2</samp>&rsquo;
    423  1.11  mrg instead of &lsquo;<samp>make</samp>&rsquo;.  You can also specify a bigger number, and
    424   1.1  mrg in most cases using a value greater than the number of processors in
    425   1.1  mrg your machine will result in fewer and shorter I/O latency hits, thus
    426   1.1  mrg improving overall throughput; this is especially true for slow drives
    427   1.1  mrg and network filesystems.
    428  1.11  mrg </p>
    429  1.14  mrg <a name="Building-the-Ada-compiler"></a>
    430  1.11  mrg <h3 class="section">Building the Ada compiler</h3>
    431   1.1  mrg 
    432  1.13  mrg <p><a href="prerequisites.html#GNAT-prerequisite">GNAT prerequisites</a>.
    433  1.11  mrg </p>
    434  1.15  mrg <a name="Building-the-D-compiler"></a>
    435  1.15  mrg <h3 class="section">Building the D compiler</h3>
    436  1.15  mrg 
    437  1.15  mrg <p><a href="prerequisites.html#GDC-prerequisite">GDC prerequisites</a>.
    438  1.15  mrg </p>
    439  1.14  mrg <a name="Building-with-profile-feedback"></a>
    440  1.11  mrg <h3 class="section">Building with profile feedback</h3>
    441   1.1  mrg 
    442   1.1  mrg <p>It is possible to use profile feedback to optimize the compiler itself.  This
    443   1.1  mrg should result in a faster compiler binary.  Experiments done on x86 using gcc
    444   1.1  mrg 3.3 showed approximately 7 percent speedup on compiling C programs.  To
    445   1.1  mrg bootstrap the compiler with profile feedback, use <code>make profiledbootstrap</code>.
    446  1.11  mrg </p>
    447  1.11  mrg <p>When &lsquo;<samp>make profiledbootstrap</samp>&rsquo; is run, it will first build a <code>stage1</code>
    448   1.1  mrg compiler.  This compiler is used to build a <code>stageprofile</code> compiler
    449   1.1  mrg instrumented to collect execution counts of instruction and branch
    450  1.11  mrg probabilities.  Training run is done by building <code>stagetrain</code>
    451  1.11  mrg compiler.  Finally a <code>stagefeedback</code> compiler is built
    452  1.11  mrg using the information collected.
    453  1.11  mrg </p>
    454  1.11  mrg <p>Unlike standard bootstrap, several additional restrictions apply.  The
    455  1.11  mrg compiler used to build <code>stage1</code> needs to support a 64-bit integral type.
    456   1.8  mrg It is recommended to only use GCC for this.
    457  1.11  mrg </p>
    458  1.11  mrg <p>On Linux/x86_64 hosts with some restrictions (no virtualization) it is
    459  1.11  mrg also possible to do autofdo build with &lsquo;<samp>make
    460  1.11  mrg autoprofiledback</samp>&rsquo;. This uses Linux perf to sample branches in the
    461  1.11  mrg binary and then rebuild it with feedback derived from the profile.
    462  1.10  mrg Linux perf and the <code>autofdo</code> toolkit needs to be installed for
    463  1.10  mrg this.
    464  1.11  mrg </p>
    465  1.11  mrg <p>Only the profile from the current build is used, so when an error
    466  1.10  mrg occurs it is recommended to clean before restarting. Otherwise
    467  1.10  mrg the code quality may be much worse.
    468  1.11  mrg </p>
    469  1.11  mrg <hr />
    470  1.11  mrg <p>
    471  1.11  mrg <p><a href="./index.html">Return to the GCC Installation page</a>
    472  1.11  mrg </p>
    473  1.11  mrg 
    474  1.11  mrg 
    475  1.11  mrg 
    476  1.11  mrg 
    477  1.11  mrg 
    478  1.11  mrg 
    479  1.14  mrg <hr>
    480   1.8  mrg 
    481   1.8  mrg 
    482   1.7  mrg 
    483  1.11  mrg </body>
    484  1.11  mrg </html>
    485