OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [INSTALL/] [build.html] - Blame information for rev 20

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.