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