source: trunk/src/gcc/INSTALL/build.html@ 1036

Last change on this file since 1036 was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 9.7 KB
Line 
1<html lang="en"><head>
2<title>Installing GCC: Building</title>
3<meta http-equiv="Content-Type" content="text/html">
4<meta name=description content="Installing GCC: Building">
5<meta name=generator content="makeinfo 4.0">
6<link href="http://texinfo.org/" rel=generator-home>
7</head><body>
8
9<p>N<p>ow that GCC is configured, you are ready to build the compiler and
10runtime libraries.
11
12<p>We <strong>highly</strong> recommend that GCC be built using GNU make;
13other versions may work, then again they might not.
14GNU make is required for compiling GNAT (the Ada compiler) and the Java
15runtime library.
16
17<p>(For example, many broken versions of make will fail if you use the
18recommended setup where <var>objdir</var> is different from <var>srcdir</var>.
19Other broken versions may recompile parts of the compiler when
20installing the compiler.)
21
22<p>Some commands executed when making the compiler may fail (return a
23nonzero status) and be ignored by <code>make</code>. These failures, which
24are often due to files that were not found, are expected, and can safely
25be ignored.
26
27<p>It is normal to have compiler warnings when compiling certain files.
28Unless you are a GCC developer, you can generally ignore these warnings
29unless they cause compilation to fail.
30
31<p>On certain old systems, defining certain environment variables such as
32<code>CC</code> can interfere with the functioning of <code>make</code>.
33
34<p>If you encounter seemingly strange errors when trying to build the
35compiler in a directory other than the source directory, it could be
36because you have previously configured the compiler in the source
37directory. Make sure you have done all the necessary preparations.
38
39<p>If you build GCC on a BSD system using a directory stored in an old System
40V file system, problems may occur in running <code>fixincludes</code> if the
41System V file system doesn't support symbolic links. These problems
42result in a failure to fix the declaration of <code>size_t</code> in
43<code>sys/types.h</code>. If you find that <code>size_t</code> is a signed type and
44that type mismatches occur, this could be the cause.
45
46<p>The solution is not to use such a directory for building GCC.
47
48<p>When building from CVS or snapshots, or if you modify parser sources,
49you need the Bison parser generator installed. Any version 1.25 or
50later should work; older versions may also work. If you do not modify
51parser sources, releases contain the Bison-generated files and you do
52not need Bison installed to build them.
53
54<p>When building from CVS or snapshots, or if you modify Texinfo
55documentation, you need version 4.1 or later of Texinfo installed if you
56want Info documentation to be regenerated. Releases contain Info
57documentation pre-built for the unmodified documentation in the release.
58
59<h2><a name="TOC0">Building a native compiler</h2>
60
61<p>For a native build issue the command <code>make bootstrap</code>. This
62will build the entire GCC system, which includes the following steps:
63
64<ul>
65<li>Build host tools necessary to build the compiler such as texinfo, bison,
66gperf.
67
68<li>Build target tools for use by the compiler such as binutils (bfd,
69binutils, gas, gprof, ld, and opcodes)
70if they have been individually linked
71or moved into the top level GCC source tree before configuring.
72
73<li>Perform a 3-stage bootstrap of the compiler.
74
75<li>Perform a comparison test of the stage2 and stage3 compilers.
76
77<li>Build runtime libraries using the stage3 compiler from the previous step.
78
79</ul>
80
81<p>If you are short on disk space you might consider <code>make
82bootstrap-lean</code> instead. This is identical to <code>make
83bootstrap</code> except that object files from the stage1 and
84stage2 of the 3-stage bootstrap of the compiler are deleted as
85soon as they are no longer needed.
86
87<p>If you want to save additional space during the bootstrap and in
88the final installation as well, you can build the compiler binaries
89without debugging information as in the following example. This will save
90roughly 40% of disk space both for the bootstrap and the final installation.
91(Libraries will still contain debugging information.)
92
93<pre> make CFLAGS='-O' LIBCFLAGS='-g -O2' \
94 LIBCXXFLAGS='-g -O2 -fno-implicit-templates' bootstrap
95</pre>
96
97<p>If you wish to use non-default GCC flags when compiling the stage2 and
98stage3 compilers, set <code>BOOT_CFLAGS</code> on the command line when doing
99<code>make bootstrap</code>. Non-default optimization flags are less well
100tested here than the default of <code>-g -O2</code>, but should still work.
101In a few cases, you may find that you need to specify special flags such
102as <code>-msoft-float</code> here to complete the bootstrap; or, if the
103native compiler miscompiles the stage1 compiler, you may need to work
104around this, by choosing <code>BOOT_CFLAGS</code> to avoid the parts of the
105stage1 compiler that were miscompiled, or by using <code>make
106bootstrap4</code> to increase the number of stages of bootstrap.
107
108<p>If you used the flag <code>--enable-languages=<small>...</small></code> to restrict
109the compilers to be built, only those you've actually enabled will be
110built. This will of course only build those runtime libraries, for
111which the particular compiler has been built. Please note,
112that re-defining <code>LANGUAGES</code> when calling <code>make bootstrap</code>
113<strong>does not</strong> work anymore!
114
115<p>If the comparison of stage2 and stage3 fails, this normally indicates
116that the stage2 compiler has compiled GCC incorrectly, and is therefore
117a potentially serious bug which you should investigate and report. (On
118a few systems, meaningful comparison of object files is impossible; they
119always appear "different". If you encounter this problem, you will
120need to disable comparison in the <code>Makefile</code>.)
121
122<h2><a name="TOC1">Building a cross compiler</h2>
123
124<p>We recommend reading the
125<a href="http://www.objsw.com/CrossGCC/">crossgcc FAQ</a>
126for information about building cross compilers.
127
128<p>When building a cross compiler, it is not generally possible to do a
1293-stage bootstrap of the compiler. This makes for an interesting problem
130as parts of GCC can only be built with GCC.
131
132<p>To build a cross compiler, we first recommend building and installing a
133native compiler. You can then use the native GCC compiler to build the
134cross compiler. The installed native compiler needs to be GCC version
1352.95 or later.
136
137<p>Assuming you have already installed a native copy of GCC and configured
138your cross compiler, issue the command <code>make</code>, which performs the
139following steps:
140
141<ul>
142<li>Build host tools necessary to build the compiler such as texinfo, bison,
143gperf.
144
145<li>Build target tools for use by the compiler such as binutils (bfd,
146binutils, gas, gprof, ld, and opcodes)
147if they have been individually linked or moved into the top level GCC source
148tree before configuring.
149
150<li>Build the compiler (single stage only).
151
152<li>Build runtime libraries using the compiler from the previous step.
153</ul>
154
155<p>Note that if an error occurs in any step the make process will exit.
156
157<h2><a name="TOC2">Building in parallel</h2>
158
159<p>If you have a multiprocessor system you can use <code>make bootstrap
160MAKE="make -j 2" -j 2</code> or just <code>make -j 2 bootstrap</code>
161for GNU Make 3.79 and above instead of just <code>make bootstrap</code>
162when building GCC. You can use a bigger number instead of two if
163you like. In most cases, it won't help to use a number bigger than
164the number of processors in your machine.
165
166<h2><a name="TOC3">Building the Ada compiler</h2>
167
168<p>In order to build GNAT, the Ada compiler, you need a working GNAT
169compiler (GNAT version 3.13 or later, or GCC version 3.1 or later),
170since the Ada front end is written in Ada (with some
171GNAT-specific extensions), and GNU make.
172
173<p>However, you do not need a full installation of GNAT, just the GNAT
174binary <code>gnat1</code>, a copy of <code>gnatbind</code>, and a compiler driver
175which can deal with Ada input (by invoking the <code>gnat1</code> binary).
176You can specify this compiler driver by setting the <code>ADAC</code>
177environment variable at the configure step. <code>configure</code> can
178detect the driver automatically if it has got a common name such as
179<code>gcc</code> or <code>gnatgcc</code>. Of course, you still need a working
180C compiler (the compiler driver can be different or not).
181<code>configure</code> does not test whether the GNAT installation works
182and has a sufficiently recent version; if too old a GNAT version is
183installed, the build will fail unless <code>--enable-languages</code> is
184used to disable building the Ada front end.
185
186<p>Additional build tools (such as <code>gnatmake</code>) or a working GNAT
187run-time library installation are usually <em>not</em> required. However,
188if you want to bootstrap the compiler using a minimal version of GNAT,
189you have to issue the following commands before invoking <code>make
190bootstrap</code> (this assumes that you start with an unmodified and consistent
191source distribution):
192
193<pre> cd <var>srcdir</var>/gcc/ada
194 touch treeprs.ads [es]info.h nmake.ad[bs]
195</pre>
196
197<p>At the moment, the GNAT library and several tools for GNAT are not built
198by <code>make bootstrap</code>. You have to invoke
199<code>make gnatlib_and_tools</code> in the <code><var>objdir</var>/gcc</code>
200subdirectory before proceeding with the next steps.
201
202<p>For example, you can build a native Ada compiler by issuing the
203following commands (assuming <code>make</code> is GNU make):
204
205<pre> cd <var>objdir</var>
206 <var>srcdir</var>/configure --enable-languages=c,ada
207 cd <var>srcdir</var>/gcc/ada
208 touch treeprs.ads [es]info.h nmake.ad[bs]
209 cd <var>objdir</var>
210 make bootstrap
211 cd gcc
212 make gnatlib_and_tools
213 cd ..
214</pre>
215
216<p>Currently, when compiling the Ada front end, you cannot use the parallel
217build feature described in the previous section.
218
219<hr />
220<p>
221<a href="./index.html">Return to the GCC Installation page</a>
222
223</body></html>
224
Note: See TracBrowser for help on using the repository browser.