build.html revision 1.12 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.12 mrg <!-- Copyright (C) 1988-2019 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.11 mrg <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
23 1.11 mrg <head>
24 1.11 mrg <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25 1.11 mrg <title>Installing GCC</title>
26 1.11 mrg
27 1.11 mrg <meta name="description" content="Installing GCC">
28 1.11 mrg <meta name="keywords" content="Installing GCC">
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.11 mrg blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
37 1.11 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.11 mrg div.lisp {margin-left: 3.2em}
41 1.11 mrg div.smalldisplay {margin-left: 3.2em}
42 1.11 mrg div.smallexample {margin-left: 3.2em}
43 1.11 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.11 mrg pre.smalldisplay {font-family: inherit; font-size: smaller}
50 1.11 mrg pre.smallexample {font-size: smaller}
51 1.11 mrg pre.smallformat {font-family: inherit; font-size: smaller}
52 1.11 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.11 mrg <h1 class="settitle" align="center">Installing GCC</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.11 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’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.11 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 ‘<samp>make</samp>’ 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 ‘<samp>configure</samp>’, 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 ‘<samp>make
161 1.11 mrg bootstrap-lean</samp>’ 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 ‘<samp>make</samp>’. 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.11 mrg <div class="smallexample">
176 1.11 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 ‘<samp>-g -O2</samp>’, 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 ‘<samp>make
186 1.11 mrg bootstrap4</samp>’ 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=…</samp> to restrict
197 1.11 mrg the compilers to be built, only those you’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 ‘<samp>make</samp>’
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 “different”. 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.11 mrg <dt>‘<samp>bootstrap-O1</samp>’</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. ‘<samp>BUILD_CONFIG=bootstrap-O1</samp>’ is equivalent to
230 1.11 mrg ‘<samp>BOOT_CFLAGS='-g -O1'</samp>’.
231 1.11 mrg </p>
232 1.11 mrg </dd>
233 1.11 mrg <dt>‘<samp>bootstrap-O3</samp>’</dt>
234 1.11 mrg <dd><p>Analogous to <code>bootstrap-O1</code>.
235 1.11 mrg </p>
236 1.11 mrg </dd>
237 1.11 mrg <dt>‘<samp>bootstrap-lto</samp>’</dt>
238 1.11 mrg <dd><p>Enables Link-Time Optimization for host tools during bootstrapping.
239 1.11 mrg ‘<samp>BUILD_CONFIG=bootstrap-lto</samp>’ is equivalent to adding
240 1.11 mrg <samp>-flto</samp> to ‘<samp>BOOT_CFLAGS</samp>’. This option assumes that the host
241 1.5 mrg supports the linker plugin (e.g. GNU ld version 2.21 or later or GNU gold
242 1.5 mrg version 2.21 or later).
243 1.11 mrg </p>
244 1.11 mrg </dd>
245 1.11 mrg <dt>‘<samp>bootstrap-lto-noplugin</samp>’</dt>
246 1.11 mrg <dd><p>This option is similar to <code>bootstrap-lto</code>, but is intended for
247 1.11 mrg hosts that do not support the linker plugin. Without the linker plugin
248 1.11 mrg static libraries are not compiled with link-time optimizations. Since
249 1.11 mrg the GCC middle end and back end are in <samp>libbackend.a</samp> this means
250 1.5 mrg that only the front end is actually LTO optimized.
251 1.11 mrg </p>
252 1.11 mrg </dd>
253 1.12 mrg <dt>‘<samp>bootstrap-lto-lean</samp>’</dt>
254 1.12 mrg <dd><p>This option is similar to <code>bootstrap-lto</code>, but is intended for
255 1.12 mrg faster build by only using LTO in the final bootstrap stage.
256 1.12 mrg With ‘<samp>make profiledbootstrap</samp>’ the LTO frontend
257 1.12 mrg is trained only on generator files.
258 1.12 mrg </p>
259 1.12 mrg </dd>
260 1.11 mrg <dt>‘<samp>bootstrap-debug</samp>’</dt>
261 1.11 mrg <dd><p>Verifies that the compiler generates the same executable code, whether
262 1.1 mrg or not it is asked to emit debug information. To this end, this
263 1.1 mrg option builds stage2 host programs without debug information, and uses
264 1.11 mrg <samp>contrib/compare-debug</samp> to compare them with the stripped stage3
265 1.1 mrg object files. If <code>BOOT_CFLAGS</code> is overridden so as to not enable
266 1.11 mrg debug information, stage2 will have it, and stage3 won’t. This option
267 1.1 mrg is enabled by default when GCC bootstrapping is enabled, if
268 1.1 mrg <code>strip</code> can turn object files compiled with and without debug
269 1.1 mrg info into identical object files. In addition to better test
270 1.1 mrg coverage, this option makes default bootstraps faster and leaner.
271 1.11 mrg </p>
272 1.11 mrg </dd>
273 1.11 mrg <dt>‘<samp>bootstrap-debug-big</samp>’</dt>
274 1.11 mrg <dd><p>Rather than comparing stripped object files, as in
275 1.1 mrg <code>bootstrap-debug</code>, this option saves internal compiler dumps
276 1.1 mrg during stage2 and stage3 and compares them as well, which helps catch
277 1.1 mrg additional potential problems, but at a great cost in terms of disk
278 1.11 mrg space. It can be specified in addition to ‘<samp>bootstrap-debug</samp>’.
279 1.11 mrg </p>
280 1.11 mrg </dd>
281 1.11 mrg <dt>‘<samp>bootstrap-debug-lean</samp>’</dt>
282 1.11 mrg <dd><p>This option saves disk space compared with <code>bootstrap-debug-big</code>,
283 1.1 mrg but at the expense of some recompilation. Instead of saving the dumps
284 1.1 mrg of stage2 and stage3 until the final compare, it uses
285 1.11 mrg <samp>-fcompare-debug</samp> to generate, compare and remove the dumps
286 1.1 mrg during stage3, repeating the compilation that already took place in
287 1.1 mrg stage2, whose dumps were not saved.
288 1.11 mrg </p>
289 1.11 mrg </dd>
290 1.11 mrg <dt>‘<samp>bootstrap-debug-lib</samp>’</dt>
291 1.11 mrg <dd><p>This option tests executable code invariance over debug information
292 1.1 mrg generation on target libraries, just like <code>bootstrap-debug-lean</code>
293 1.1 mrg tests it on host programs. It builds stage3 libraries with
294 1.11 mrg <samp>-fcompare-debug</samp>, and it can be used along with any of the
295 1.1 mrg <code>bootstrap-debug</code> options above.
296 1.11 mrg </p>
297 1.11 mrg <p>There aren’t <code>-lean</code> or <code>-big</code> counterparts to this option
298 1.1 mrg because most libraries are only build in stage3, so bootstrap compares
299 1.1 mrg would not get significant coverage. Moreover, the few libraries built
300 1.11 mrg in stage2 are used in stage3 host programs, so we wouldn’t want to
301 1.1 mrg compile stage2 libraries with different options for comparison purposes.
302 1.11 mrg </p>
303 1.11 mrg </dd>
304 1.11 mrg <dt>‘<samp>bootstrap-debug-ckovw</samp>’</dt>
305 1.11 mrg <dd><p>Arranges for error messages to be issued if the compiler built on any
306 1.11 mrg stage is run without the option <samp>-fcompare-debug</samp>. This is
307 1.11 mrg useful to verify the full <samp>-fcompare-debug</samp> testing coverage. It
308 1.1 mrg must be used along with <code>bootstrap-debug-lean</code> and
309 1.1 mrg <code>bootstrap-debug-lib</code>.
310 1.11 mrg </p>
311 1.11 mrg </dd>
312 1.11 mrg <dt>‘<samp>bootstrap-cet</samp>’</dt>
313 1.11 mrg <dd><p>This option enables Intel CET for host tools during bootstrapping.
314 1.11 mrg ‘<samp>BUILD_CONFIG=bootstrap-cet</samp>’ is equivalent to adding
315 1.11 mrg <samp>-fcf-protection</samp> to ‘<samp>BOOT_CFLAGS</samp>’. This option
316 1.11 mrg assumes that the host supports Intel CET (e.g. GNU assembler version
317 1.11 mrg 2.30 or later).
318 1.11 mrg </p>
319 1.11 mrg </dd>
320 1.11 mrg <dt>‘<samp>bootstrap-time</samp>’</dt>
321 1.11 mrg <dd><p>Arranges for the run time of each program started by the GCC driver,
322 1.11 mrg built in any stage, to be logged to <samp>time.log</samp>, in the top level of
323 1.1 mrg the build tree.
324 1.11 mrg </p>
325 1.11 mrg </dd>
326 1.11 mrg </dl>
327 1.1 mrg
328 1.11 mrg <a name="Building-a-cross-compiler"></a>
329 1.11 mrg <h3 class="section">Building a cross compiler</h3>
330 1.1 mrg
331 1.1 mrg <p>When building a cross compiler, it is not generally possible to do a
332 1.1 mrg 3-stage bootstrap of the compiler. This makes for an interesting problem
333 1.1 mrg as parts of GCC can only be built with GCC.
334 1.11 mrg </p>
335 1.11 mrg <p>To build a cross compiler, we recommend first building and installing a
336 1.1 mrg native compiler. You can then use the native GCC compiler to build the
337 1.1 mrg cross compiler. The installed native compiler needs to be GCC version
338 1.1 mrg 2.95 or later.
339 1.11 mrg </p>
340 1.11 mrg <p>Assuming you have already installed a native copy of GCC and configured
341 1.11 mrg your cross compiler, issue the command <code>make</code>, which performs the
342 1.1 mrg following steps:
343 1.11 mrg </p>
344 1.11 mrg <ul>
345 1.11 mrg <li> Build host tools necessary to build the compiler.
346 1.1 mrg
347 1.11 mrg </li><li> Build target tools for use by the compiler such as binutils (bfd,
348 1.1 mrg binutils, gas, gprof, ld, and opcodes)
349 1.1 mrg if they have been individually linked or moved into the top level GCC source
350 1.1 mrg tree before configuring.
351 1.1 mrg
352 1.11 mrg </li><li> Build the compiler (single stage only).
353 1.10 mrg
354 1.11 mrg </li><li> Build runtime libraries using the compiler from the previous step.
355 1.11 mrg </li></ul>
356 1.1 mrg
357 1.11 mrg <p>Note that if an error occurs in any step the make process will exit.
358 1.11 mrg </p>
359 1.11 mrg <p>If you are not building GNU binutils in the same source tree as GCC,
360 1.1 mrg you will need a cross-assembler and cross-linker installed before
361 1.1 mrg configuring GCC. Put them in the directory
362 1.11 mrg <samp><var>prefix</var>/<var>target</var>/bin</samp>. Here is a table of the tools
363 1.1 mrg you should put in this directory:
364 1.11 mrg </p>
365 1.11 mrg <dl compact="compact">
366 1.11 mrg <dt><samp>as</samp></dt>
367 1.11 mrg <dd><p>This should be the cross-assembler.
368 1.11 mrg </p>
369 1.11 mrg </dd>
370 1.11 mrg <dt><samp>ld</samp></dt>
371 1.11 mrg <dd><p>This should be the cross-linker.
372 1.11 mrg </p>
373 1.11 mrg </dd>
374 1.11 mrg <dt><samp>ar</samp></dt>
375 1.11 mrg <dd><p>This should be the cross-archiver: a program which can manipulate
376 1.11 mrg archive files (linker libraries) in the target machine’s format.
377 1.11 mrg </p>
378 1.11 mrg </dd>
379 1.11 mrg <dt><samp>ranlib</samp></dt>
380 1.11 mrg <dd><p>This should be a program to construct a symbol table in an archive file.
381 1.11 mrg </p></dd>
382 1.1 mrg </dl>
383 1.1 mrg
384 1.11 mrg <p>The installation of GCC will find these programs in that directory,
385 1.1 mrg and copy or link them to the proper place to for the cross-compiler to
386 1.1 mrg find them when run later.
387 1.11 mrg </p>
388 1.11 mrg <p>The easiest way to provide these files is to build the Binutils package.
389 1.11 mrg Configure it with the same <samp>--host</samp> and <samp>--target</samp>
390 1.1 mrg options that you use for configuring GCC, then build and install
391 1.1 mrg them. They install their executables automatically into the proper
392 1.1 mrg directory. Alas, they do not support all the targets that GCC
393 1.1 mrg supports.
394 1.11 mrg </p>
395 1.11 mrg <p>If you are not building a C library in the same source tree as GCC,
396 1.1 mrg you should also provide the target libraries and headers before
397 1.1 mrg configuring GCC, specifying the directories with
398 1.11 mrg <samp>--with-sysroot</samp> or <samp>--with-headers</samp> and
399 1.11 mrg <samp>--with-libs</samp>. Many targets also require “start files” such
400 1.11 mrg as <samp>crt0.o</samp> and
401 1.11 mrg <samp>crtn.o</samp> which are linked into each executable. There may be several
402 1.11 mrg alternatives for <samp>crt0.o</samp>, for use with profiling or other
403 1.11 mrg compilation options. Check your target’s definition of
404 1.1 mrg <code>STARTFILE_SPEC</code> to find out what start files it uses.
405 1.11 mrg </p>
406 1.11 mrg <a name="Building-in-parallel"></a>
407 1.11 mrg <h3 class="section">Building in parallel</h3>
408 1.1 mrg
409 1.1 mrg <p>GNU Make 3.80 and above, which is necessary to build GCC, support
410 1.11 mrg building in parallel. To activate this, you can use ‘<samp>make -j 2</samp>’
411 1.11 mrg instead of ‘<samp>make</samp>’. You can also specify a bigger number, and
412 1.1 mrg in most cases using a value greater than the number of processors in
413 1.1 mrg your machine will result in fewer and shorter I/O latency hits, thus
414 1.1 mrg improving overall throughput; this is especially true for slow drives
415 1.1 mrg and network filesystems.
416 1.11 mrg </p>
417 1.11 mrg <a name="Building-the-Ada-compiler"></a>
418 1.11 mrg <h3 class="section">Building the Ada compiler</h3>
419 1.1 mrg
420 1.1 mrg <p>In order to build GNAT, the Ada compiler, you need a working GNAT
421 1.11 mrg compiler (GCC version 4.0 or later).
422 1.11 mrg This includes GNAT tools such as <code>gnatmake</code> and
423 1.11 mrg <code>gnatlink</code>, since the Ada front end is written in Ada and
424 1.1 mrg uses some GNAT-specific extensions.
425 1.11 mrg </p>
426 1.11 mrg <p>In order to build a cross compiler, it is suggested to install
427 1.1 mrg the new compiler as native first, and then use it to build the cross
428 1.1 mrg compiler.
429 1.11 mrg </p>
430 1.11 mrg <p><code>configure</code> does not test whether the GNAT installation works
431 1.1 mrg and has a sufficiently recent version; if too old a GNAT version is
432 1.11 mrg installed, the build will fail unless <samp>--enable-languages</samp> is
433 1.1 mrg used to disable building the Ada front end.
434 1.11 mrg </p>
435 1.11 mrg <p><code>ADA_INCLUDE_PATH</code> and <code>ADA_OBJECT_PATH</code> environment variables
436 1.1 mrg must not be set when building the Ada compiler, the Ada tools, or the
437 1.1 mrg Ada runtime libraries. You can check that your build environment is clean
438 1.11 mrg by verifying that ‘<samp>gnatls -v</samp>’ lists only one explicit path in each
439 1.1 mrg section.
440 1.11 mrg </p>
441 1.11 mrg <a name="Building-with-profile-feedback"></a>
442 1.11 mrg <h3 class="section">Building with profile feedback</h3>
443 1.1 mrg
444 1.1 mrg <p>It is possible to use profile feedback to optimize the compiler itself. This
445 1.1 mrg should result in a faster compiler binary. Experiments done on x86 using gcc
446 1.1 mrg 3.3 showed approximately 7 percent speedup on compiling C programs. To
447 1.1 mrg bootstrap the compiler with profile feedback, use <code>make profiledbootstrap</code>.
448 1.11 mrg </p>
449 1.11 mrg <p>When ‘<samp>make profiledbootstrap</samp>’ is run, it will first build a <code>stage1</code>
450 1.1 mrg compiler. This compiler is used to build a <code>stageprofile</code> compiler
451 1.1 mrg instrumented to collect execution counts of instruction and branch
452 1.11 mrg probabilities. Training run is done by building <code>stagetrain</code>
453 1.11 mrg compiler. Finally a <code>stagefeedback</code> compiler is built
454 1.11 mrg using the information collected.
455 1.11 mrg </p>
456 1.11 mrg <p>Unlike standard bootstrap, several additional restrictions apply. The
457 1.11 mrg compiler used to build <code>stage1</code> needs to support a 64-bit integral type.
458 1.8 mrg It is recommended to only use GCC for this.
459 1.11 mrg </p>
460 1.11 mrg <p>On Linux/x86_64 hosts with some restrictions (no virtualization) it is
461 1.11 mrg also possible to do autofdo build with ‘<samp>make
462 1.11 mrg autoprofiledback</samp>’. This uses Linux perf to sample branches in the
463 1.11 mrg binary and then rebuild it with feedback derived from the profile.
464 1.10 mrg Linux perf and the <code>autofdo</code> toolkit needs to be installed for
465 1.10 mrg this.
466 1.11 mrg </p>
467 1.11 mrg <p>Only the profile from the current build is used, so when an error
468 1.10 mrg occurs it is recommended to clean before restarting. Otherwise
469 1.10 mrg the code quality may be much worse.
470 1.11 mrg </p>
471 1.11 mrg <hr />
472 1.11 mrg <p>
473 1.11 mrg <p><a href="./index.html">Return to the GCC Installation page</a>
474 1.11 mrg </p>
475 1.11 mrg
476 1.11 mrg
477 1.11 mrg
478 1.11 mrg
479 1.11 mrg
480 1.11 mrg
481 1.11 mrg
482 1.11 mrg <hr>
483 1.8 mrg
484 1.8 mrg
485 1.7 mrg
486 1.11 mrg </body>
487 1.11 mrg </html>
488