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