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