Mercurial > hg > CbC > CbC_gcc
annotate INSTALL/build.html @ 20:9de9dad105d4
update gcc from 4.4.0 to 4.4.1.
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 24 Sep 2009 14:29:28 +0900 |
parents | 58ad6c70ea60 |
children |
rev | line source |
---|---|
0 | 1 <html lang="en"> |
2 <head> | |
3 <title>Installing GCC: Building</title> | |
4 <meta http-equiv="Content-Type" content="text/html"> | |
5 <meta name="description" content="Installing GCC: Building"> | |
19
58ad6c70ea60
update gcc from 4.4.0 to 4.4.1.
kent@firefly.cr.ie.u-ryukyu.ac.jp
parents:
0
diff
changeset
|
6 <meta name="generator" content="makeinfo 4.13"> |
0 | 7 <link title="Top" rel="top" href="#Top"> |
8 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> | |
9 <!-- | |
10 Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, | |
11 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, | |
12 2008 Free Software Foundation, Inc. | |
13 | |
14 Permission is granted to copy, distribute and/or modify this document | |
15 under the terms of the GNU Free Documentation License, Version 1.2 or | |
16 any later version published by the Free Software Foundation; with no | |
17 Invariant Sections, the Front-Cover texts being (a) (see below), and | |
18 with the Back-Cover Texts being (b) (see below). A copy of the | |
19 license is included in the section entitled "GNU Free Documentation License". | |
20 | |
21 (a) The FSF's Front-Cover Text is: | |
22 | |
23 A GNU Manual | |
24 | |
25 (b) The FSF's Back-Cover Text is: | |
26 | |
27 You have freedom to copy and modify this GNU Manual, like GNU | |
28 software. Copies published by the Free Software Foundation raise | |
29 funds for GNU development.--> | |
30 <meta http-equiv="Content-Style-Type" content="text/css"> | |
31 <style type="text/css"><!-- | |
32 pre.display { font-family:inherit } | |
33 pre.format { font-family:inherit } | |
34 pre.smalldisplay { font-family:inherit; font-size:smaller } | |
35 pre.smallformat { font-family:inherit; font-size:smaller } | |
36 pre.smallexample { font-size:smaller } | |
37 pre.smalllisp { font-size:smaller } | |
38 span.sc { font-variant:small-caps } | |
39 span.roman { font-family:serif; font-weight:normal; } | |
40 span.sansserif { font-family:sans-serif; font-weight:normal; } | |
41 --></style> | |
42 </head> | |
43 <body> | |
44 <h1 class="settitle">Installing GCC: Building</h1> | |
45 <a name="index-Installing-GCC_003a-Building-1"></a> | |
46 Now that GCC is configured, you are ready to build the compiler and | |
47 runtime libraries. | |
48 | |
49 <p>Some commands executed when making the compiler may fail (return a | |
50 nonzero status) and be ignored by <samp><span class="command">make</span></samp>. These failures, which | |
51 are often due to files that were not found, are expected, and can safely | |
52 be ignored. | |
53 | |
54 <p>It is normal to have compiler warnings when compiling certain files. | |
55 Unless you are a GCC developer, you can generally ignore these warnings | |
56 unless they cause compilation to fail. Developers should attempt to fix | |
57 any warnings encountered, however they can temporarily continue past | |
58 warnings-as-errors by specifying the configure flag | |
59 <samp><span class="option">--disable-werror</span></samp>. | |
60 | |
61 <p>On certain old systems, defining certain environment variables such as | |
62 <samp><span class="env">CC</span></samp> can interfere with the functioning of <samp><span class="command">make</span></samp>. | |
63 | |
64 <p>If you encounter seemingly strange errors when trying to build the | |
65 compiler in a directory other than the source directory, it could be | |
66 because you have previously configured the compiler in the source | |
67 directory. Make sure you have done all the necessary preparations. | |
68 | |
69 <p>If you build GCC on a BSD system using a directory stored in an old System | |
70 V file system, problems may occur in running <samp><span class="command">fixincludes</span></samp> if the | |
71 System V file system doesn't support symbolic links. These problems | |
72 result in a failure to fix the declaration of <code>size_t</code> in | |
73 <samp><span class="file">sys/types.h</span></samp>. If you find that <code>size_t</code> is a signed type and | |
74 that type mismatches occur, this could be the cause. | |
75 | |
76 <p>The solution is not to use such a directory for building GCC. | |
77 | |
78 <p>Similarly, when building from SVN or snapshots, or if you modify | |
79 <samp><span class="file">*.l</span></samp> files, you need the Flex lexical analyzer generator | |
80 installed. If you do not modify <samp><span class="file">*.l</span></samp> files, releases contain | |
81 the Flex-generated files and you do not need Flex installed to build | |
82 them. There is still one Flex-based lexical analyzer (part of the | |
83 build machinery, not of GCC itself) that is used even if you only | |
84 build the C front end. | |
85 | |
86 <p>When building from SVN or snapshots, or if you modify Texinfo | |
87 documentation, you need version 4.7 or later of Texinfo installed if you | |
88 want Info documentation to be regenerated. Releases contain Info | |
89 documentation pre-built for the unmodified documentation in the release. | |
90 | |
91 <h3 class="section"><a name="TOC0"></a>Building a native compiler</h3> | |
92 | |
93 <p>For a native build, the default configuration is to perform | |
94 a 3-stage bootstrap of the compiler when ‘<samp><span class="samp">make</span></samp>’ is invoked. | |
95 This will build the entire GCC system and ensure that it compiles | |
96 itself correctly. It can be disabled with the <samp><span class="option">--disable-bootstrap</span></samp> | |
97 parameter to ‘<samp><span class="samp">configure</span></samp>’, but bootstrapping is suggested because | |
98 the compiler will be tested more completely and could also have | |
99 better performance. | |
100 | |
101 <p>The bootstrapping process will complete the following steps: | |
102 | |
103 <ul> | |
104 <li>Build tools necessary to build the compiler. | |
105 | |
106 <li>Perform a 3-stage bootstrap of the compiler. This includes building | |
107 three times the target tools for use by the compiler such as binutils | |
108 (bfd, binutils, gas, gprof, ld, and opcodes) if they have been | |
109 individually linked or moved into the top level GCC source tree before | |
110 configuring. | |
111 | |
112 <li>Perform a comparison test of the stage2 and stage3 compilers. | |
113 | |
114 <li>Build runtime libraries using the stage3 compiler from the previous step. | |
115 | |
116 </ul> | |
117 | |
118 <p>If you are short on disk space you might consider ‘<samp><span class="samp">make | |
119 bootstrap-lean</span></samp>’ instead. The sequence of compilation is the | |
120 same described above, but object files from the stage1 and | |
121 stage2 of the 3-stage bootstrap of the compiler are deleted as | |
122 soon as they are no longer needed. | |
123 | |
124 <p>If you wish to use non-default GCC flags when compiling the stage2 | |
125 and stage3 compilers, set <code>BOOT_CFLAGS</code> on the command line when | |
126 doing ‘<samp><span class="samp">make</span></samp>’. For example, if you want to save additional space | |
127 during the bootstrap and in the final installation as well, you can | |
128 build the compiler binaries without debugging information as in the | |
129 following example. This will save roughly 40% of disk space both for | |
130 the bootstrap and the final installation. (Libraries will still contain | |
131 debugging information.) | |
132 | |
133 <pre class="smallexample"> make BOOT_CFLAGS='-O' bootstrap | |
134 </pre> | |
135 <p>You can place non-default optimization flags into <code>BOOT_CFLAGS</code>; they | |
136 are less well tested here than the default of ‘<samp><span class="samp">-g -O2</span></samp>’, but should | |
137 still work. In a few cases, you may find that you need to specify special | |
138 flags such as <samp><span class="option">-msoft-float</span></samp> here to complete the bootstrap; or, | |
139 if the native compiler miscompiles the stage1 compiler, you may need | |
140 to work around this, by choosing <code>BOOT_CFLAGS</code> to avoid the parts | |
141 of the stage1 compiler that were miscompiled, or by using ‘<samp><span class="samp">make | |
142 bootstrap4</span></samp>’ to increase the number of stages of bootstrap. | |
143 | |
144 <p><code>BOOT_CFLAGS</code> does not apply to bootstrapped target libraries. | |
145 Since these are always compiled with the compiler currently being | |
146 bootstrapped, you can use <code>CFLAGS_FOR_TARGET</code> to modify their | |
147 compilation flags, as for non-bootstrapped target libraries. | |
148 Again, if the native compiler miscompiles the stage1 compiler, you may | |
149 need to work around this by avoiding non-working parts of the stage1 | |
150 compiler. Use <code>STAGE1_LIBCFLAGS</code> to this end. | |
151 | |
152 <p>If you used the flag <samp><span class="option">--enable-languages=...</span></samp> to restrict | |
153 the compilers to be built, only those you've actually enabled will be | |
154 built. This will of course only build those runtime libraries, for | |
155 which the particular compiler has been built. Please note, | |
156 that re-defining <samp><span class="env">LANGUAGES</span></samp> when calling ‘<samp><span class="samp">make</span></samp>’ | |
157 <strong>does not</strong> work anymore! | |
158 | |
159 <p>If the comparison of stage2 and stage3 fails, this normally indicates | |
160 that the stage2 compiler has compiled GCC incorrectly, and is therefore | |
161 a potentially serious bug which you should investigate and report. (On | |
162 a few systems, meaningful comparison of object files is impossible; they | |
163 always appear “different”. If you encounter this problem, you will | |
164 need to disable comparison in the <samp><span class="file">Makefile</span></samp>.) | |
165 | |
166 <p>If you do not want to bootstrap your compiler, you can configure with | |
167 <samp><span class="option">--disable-bootstrap</span></samp>. In particular cases, you may want to | |
168 bootstrap your compiler even if the target system is not the same as | |
169 the one you are building on: for example, you could build a | |
170 <code>powerpc-unknown-linux-gnu</code> toolchain on a | |
171 <code>powerpc64-unknown-linux-gnu</code> host. In this case, pass | |
172 <samp><span class="option">--enable-bootstrap</span></samp> to the configure script. | |
173 | |
174 <h3 class="section"><a name="TOC1"></a>Building a cross compiler</h3> | |
175 | |
176 <p>When building a cross compiler, it is not generally possible to do a | |
177 3-stage bootstrap of the compiler. This makes for an interesting problem | |
178 as parts of GCC can only be built with GCC. | |
179 | |
180 <p>To build a cross compiler, we first recommend building and installing a | |
181 native compiler. You can then use the native GCC compiler to build the | |
182 cross compiler. The installed native compiler needs to be GCC version | |
183 2.95 or later. | |
184 | |
185 <p>If the cross compiler is to be built with support for the Java | |
186 programming language and the ability to compile .java source files is | |
187 desired, the installed native compiler used to build the cross | |
188 compiler needs to be the same GCC version as the cross compiler. In | |
189 addition the cross compiler needs to be configured with | |
190 <samp><span class="option">--with-ecj-jar=...</span></samp>. | |
191 | |
192 <p>Assuming you have already installed a native copy of GCC and configured | |
193 your cross compiler, issue the command <samp><span class="command">make</span></samp>, which performs the | |
194 following steps: | |
195 | |
196 <ul> | |
197 <li>Build host tools necessary to build the compiler. | |
198 | |
199 <li>Build target tools for use by the compiler such as binutils (bfd, | |
200 binutils, gas, gprof, ld, and opcodes) | |
201 if they have been individually linked or moved into the top level GCC source | |
202 tree before configuring. | |
203 | |
204 <li>Build the compiler (single stage only). | |
205 | |
206 <li>Build runtime libraries using the compiler from the previous step. | |
207 </ul> | |
208 | |
209 <p>Note that if an error occurs in any step the make process will exit. | |
210 | |
211 <p>If you are not building GNU binutils in the same source tree as GCC, | |
212 you will need a cross-assembler and cross-linker installed before | |
213 configuring GCC. Put them in the directory | |
214 <samp><var>prefix</var><span class="file">/</span><var>target</var><span class="file">/bin</span></samp>. Here is a table of the tools | |
215 you should put in this directory: | |
216 | |
217 <dl> | |
218 <dt><samp><span class="file">as</span></samp><dd>This should be the cross-assembler. | |
219 | |
220 <br><dt><samp><span class="file">ld</span></samp><dd>This should be the cross-linker. | |
221 | |
222 <br><dt><samp><span class="file">ar</span></samp><dd>This should be the cross-archiver: a program which can manipulate | |
223 archive files (linker libraries) in the target machine's format. | |
224 | |
225 <br><dt><samp><span class="file">ranlib</span></samp><dd>This should be a program to construct a symbol table in an archive file. | |
226 </dl> | |
227 | |
228 <p>The installation of GCC will find these programs in that directory, | |
229 and copy or link them to the proper place to for the cross-compiler to | |
230 find them when run later. | |
231 | |
232 <p>The easiest way to provide these files is to build the Binutils package. | |
233 Configure it with the same <samp><span class="option">--host</span></samp> and <samp><span class="option">--target</span></samp> | |
234 options that you use for configuring GCC, then build and install | |
235 them. They install their executables automatically into the proper | |
236 directory. Alas, they do not support all the targets that GCC | |
237 supports. | |
238 | |
239 <p>If you are not building a C library in the same source tree as GCC, | |
240 you should also provide the target libraries and headers before | |
241 configuring GCC, specifying the directories with | |
242 <samp><span class="option">--with-sysroot</span></samp> or <samp><span class="option">--with-headers</span></samp> and | |
243 <samp><span class="option">--with-libs</span></samp>. Many targets also require “start files” such | |
244 as <samp><span class="file">crt0.o</span></samp> and | |
245 <samp><span class="file">crtn.o</span></samp> which are linked into each executable. There may be several | |
246 alternatives for <samp><span class="file">crt0.o</span></samp>, for use with profiling or other | |
247 compilation options. Check your target's definition of | |
248 <code>STARTFILE_SPEC</code> to find out what start files it uses. | |
249 | |
250 <h3 class="section"><a name="TOC2"></a>Building in parallel</h3> | |
251 | |
252 <p>GNU Make 3.79 and above, which is necessary to build GCC, support | |
253 building in parallel. To activate this, you can use ‘<samp><span class="samp">make -j 2</span></samp>’ | |
254 instead of ‘<samp><span class="samp">make</span></samp>’. You can also specify a bigger number, and | |
255 in most cases using a value greater than the number of processors in | |
256 your machine will result in fewer and shorter I/O latency hits, thus | |
257 improving overall throughput; this is especially true for slow drives | |
258 and network filesystems. | |
259 | |
260 <h3 class="section"><a name="TOC3"></a>Building the Ada compiler</h3> | |
261 | |
262 <p>In order to build GNAT, the Ada compiler, you need a working GNAT | |
263 compiler (GCC version 3.4 or later). | |
264 This includes GNAT tools such as <samp><span class="command">gnatmake</span></samp> and | |
265 <samp><span class="command">gnatlink</span></samp>, since the Ada front end is written in Ada and | |
266 uses some GNAT-specific extensions. | |
267 | |
268 <p>In order to build a cross compiler, it is suggested to install | |
269 the new compiler as native first, and then use it to build the cross | |
270 compiler. | |
271 | |
272 <p><samp><span class="command">configure</span></samp> does not test whether the GNAT installation works | |
273 and has a sufficiently recent version; if too old a GNAT version is | |
274 installed, the build will fail unless <samp><span class="option">--enable-languages</span></samp> is | |
275 used to disable building the Ada front end. | |
276 | |
277 <p><samp><span class="env">ADA_INCLUDE_PATH</span></samp> and <samp><span class="env">ADA_OBJECT_PATH</span></samp> environment variables | |
278 must not be set when building the Ada compiler, the Ada tools, or the | |
279 Ada runtime libraries. You can check that your build environment is clean | |
280 by verifying that ‘<samp><span class="samp">gnatls -v</span></samp>’ lists only one explicit path in each | |
281 section. | |
282 | |
283 <h3 class="section"><a name="TOC4"></a>Building with profile feedback</h3> | |
284 | |
285 <p>It is possible to use profile feedback to optimize the compiler itself. This | |
286 should result in a faster compiler binary. Experiments done on x86 using gcc | |
287 3.3 showed approximately 7 percent speedup on compiling C programs. To | |
288 bootstrap the compiler with profile feedback, use <code>make profiledbootstrap</code>. | |
289 | |
290 <p>When ‘<samp><span class="samp">make profiledbootstrap</span></samp>’ is run, it will first build a <code>stage1</code> | |
291 compiler. This compiler is used to build a <code>stageprofile</code> compiler | |
292 instrumented to collect execution counts of instruction and branch | |
293 probabilities. Then runtime libraries are compiled with profile collected. | |
294 Finally a <code>stagefeedback</code> compiler is built using the information collected. | |
295 | |
296 <p>Unlike standard bootstrap, several additional restrictions apply. The | |
297 compiler used to build <code>stage1</code> needs to support a 64-bit integral type. | |
298 It is recommended to only use GCC for this. Also parallel make is currently | |
299 not supported since collisions in profile collecting may occur. | |
300 | |
301 <p><hr /> | |
302 <p><a href="./index.html">Return to the GCC Installation page</a> | |
303 | |
304 <!-- ***Testing***************************************************************** --> | |
305 <!-- ***Final install*********************************************************** --> | |
306 <!-- ***Binaries**************************************************************** --> | |
307 <!-- ***Specific**************************************************************** --> | |
308 <!-- ***Old documentation****************************************************** --> | |
309 <!-- ***GFDL******************************************************************** --> | |
310 <!-- *************************************************************************** --> | |
311 <!-- Part 6 The End of the Document --> | |
312 </body></html> | |
313 |