source: chapter06/gcc.xml@ c11bcb7

Last change on this file since c11bcb7 was c11bcb7, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Merged r8366 from trunk.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/jh/BOOK@8367 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 14.7 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-system-gcc" role="wrap">
9 <?dbhtml filename="gcc.html"?>
10
11 <sect1info condition="script">
12 <productname>gcc</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
15 </sect1info>
16
17 <title>GCC-&gcc-version;</title>
18
19 <indexterm zone="ch-system-gcc">
20 <primary sortas="a-GCC">GCC</primary>
21 </indexterm>
22
23 <sect2 role="package">
24 <title/>
25
26 <para>The GCC package contains the GNU compiler collection, which includes
27 the C and C++ compilers.</para>
28
29 <segmentedlist>
30 <segtitle>&buildtime;</segtitle>
31 <segtitle>&diskspace;</segtitle>
32
33 <seglistitem>
34 <seg>&gcc-ch6-sbu;</seg>
35 <seg>&gcc-ch6-du;</seg>
36 </seglistitem>
37 </segmentedlist>
38
39 </sect2>
40
41 <sect2 role="installation">
42 <title>Installation of GCC</title>
43
44 <para>Apply a <command>sed</command> substitution that will suppress the
45 installation of <filename class="libraryfile">libiberty.a</filename>. The
46 version of <filename class="libraryfile">libiberty.a</filename> provided by
47 Binutils will be used instead:</para>
48
49<screen><userinput>sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
50
51 <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
52 built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
53 Non-bootstrap builds omit this flag by default, so apply the following
54 <command>sed</command> to use it in order to ensure consistent compiler
55 builds:</para>
56
57<screen><userinput>sed -i 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in</userinput></screen>
58
59 <para>The <command>fixincludes</command> script is known to occasionally
60 erroneously attempt to &quot;fix&quot; the system headers installed so far. As
61 the headers installed by GCC-&gcc-version; and Glibc-&glibc-version; are known
62 to not require fixing, issue the following command to prevent the
63 <command>fixincludes</command> script from running:</para>
64
65<screen><userinput>sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in</userinput></screen>
66
67 <para>GCC provides a <command>gccbug</command> script which detects at
68 compile time whether mktemp is present, and hardcodes the result in a test.
69 This will cause the script to fall back to using less random names for
70 temporary files. We will be installing mktemp later, so the following sed
71 will simulate its presence:</para>
72
73<screen><userinput>sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in</userinput></screen>
74
75 <para>The GCC documentation recommends building GCC outside of the source
76 directory in a dedicated build directory:</para>
77
78<screen><userinput>mkdir -v ../gcc-build
79cd ../gcc-build</userinput></screen>
80
81 <para>Set the --with-arch flag if the machine is x86:</para>
82
83<screen><userinput>test $(uname -m | grep i?86) &amp;&amp; WITHARCH="--with-arch=i486"</userinput></screen>
84
85 <para>Prepare GCC for compilation:</para>
86
87<screen><userinput>../gcc-&gcc-version;/configure --prefix=/usr \
88 --libexecdir=/usr/lib --enable-shared \
89 --enable-threads=posix --enable-__cxa_atexit \
90 --enable-clocale=gnu --enable-languages=c,c++ \
91 --disable-multilib --disable-bootstrap \
92 $WITHARCH
93unset WITHARCH</userinput></screen>
94
95 <para>Compile the package:</para>
96
97<screen><userinput>make</userinput></screen>
98
99 <important>
100 <para>In this section, the test suite for GCC is considered
101 critical. Do not skip it under any circumstance.</para>
102 </important>
103
104 <para>Test the results, but do not stop at errors:</para>
105
106<screen><userinput>make -k check</userinput></screen>
107
108 <para>To receive a summary of the test suite results, run:</para>
109
110<screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
111
112 <para>For only the summaries, pipe the output through
113 <userinput>grep -A7 Summ</userinput>.</para>
114
115 <para>Results can be compared with those located at <ulink
116 url="&test-results;"/>.</para>
117
118 <para>A few unexpected failures cannot always be avoided. The GCC developers
119 are usually aware of these issues, but have not resolved them yet. In
120 particular, the <filename class="libraryfile">libmudflap</filename> tests
121 are known be particularly problematic as a result of a bug in GCC
122 (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
123 Unless the test results are vastly different from those at the above URL,
124 it is safe to continue.</para>
125
126 <para>Install the package:</para>
127
128<screen><userinput>make install</userinput></screen>
129
130 <para>Some packages expect the C preprocessor to be installed in the
131 <filename class="directory">/lib</filename> directory.
132 To support those packages, create this symlink:</para>
133
134<screen><userinput>ln -sv ../usr/bin/cpp /lib</userinput></screen>
135
136 <para>Many packages use the name <command>cc</command> to call the C
137 compiler. To satisfy those packages, create a symlink:</para>
138
139<screen><userinput>ln -sv gcc /usr/bin/cc</userinput></screen>
140
141 <para>Now that our final toolchain is in place, it is important to again ensure
142 that compiling and linking will work as expected. We do this by performing
143 the same sanity checks as we did earlier in the chapter:</para>
144
145 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
146 href="readjusting.xml"
147 xpointer="xpointer(//*[@os='a'])"/>
148
149 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
150 href="readjusting.xml"
151 xpointer="xpointer(//*[@os='b'])"/>
152
153 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
154 href="readjusting.xml"
155 xpointer="xpointer(//*[@os='c'])"/>
156
157 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
158 href="readjusting.xml"
159 xpointer="xpointer(//*[@os='d'])"/>
160
161 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
162 href="readjusting.xml"
163 xpointer="xpointer(//*[@os='e'])"/>
164
165 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
166 href="readjusting.xml"
167 xpointer="xpointer(//*[@os='f'])"/>
168
169<screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
170/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
171/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
172
173 <para>Depending on your machine architecture, the above may differ slightly,
174 the difference usually being the name of the directory
175 after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
176 a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
177 towards the end of the string. The important thing to
178 look for here is that gcc has found all three <filename>crt*.o</filename> files under
179 the <filename class="directory">/usr/lib</filename> directory.</para>
180
181 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
182 href="readjusting.xml"
183 xpointer="xpointer(//*[@os='g'])"/>
184
185<screen><userinput>grep -B3 '^ /usr/include' dummy.log</userinput></screen>
186
187 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
188 href="readjusting.xml"
189 xpointer="xpointer(//*[@os='h'])"/>
190
191<screen><computeroutput>#include &lt;...&gt; search starts here:
192 /usr/local/include
193 /usr/lib/gcc/x86_64-unknown-linux-gnu/&gcc-version;/include
194 /usr/include</computeroutput></screen>
195
196 <para>Again, note that the directory named after your target triplet may be
197 different than the above, depending on your architecture.</para>
198
199 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
200 href="readjusting.xml"
201 xpointer="xpointer(//*[@os='i'])"/>
202
203 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
204 href="readjusting.xml"
205 xpointer="xpointer(//*[@os='j'])"/>
206
207 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
208 href="readjusting.xml"
209 xpointer="xpointer(//*[@os='k'])"/>
210
211<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
212SEARCH_DIR("/usr/local/lib")
213SEARCH_DIR("/lib")
214SEARCH_DIR("/usr/lib");</computeroutput></screen>
215
216 <para>A 64-bit system may see a few more directories. For example, here
217 is the output from a x86_64 machine:</para>
218
219<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
220SEARCH_DIR("/usr/local/lib64")
221SEARCH_DIR("/lib64")
222SEARCH_DIR("/usr/lib64")
223SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
224SEARCH_DIR("/usr/local/lib")
225SEARCH_DIR("/lib")
226SEARCH_DIR("/usr/lib");</computeroutput></screen>
227
228 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
229 href="readjusting.xml"
230 xpointer="xpointer(//*[@os='l'])"/>
231
232 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
233 href="readjusting.xml"
234 xpointer="xpointer(//*[@os='m'])"/>
235
236 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
237 href="readjusting.xml"
238 xpointer="xpointer(//*[@os='n'])"/>
239
240 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
241 href="readjusting.xml"
242 xpointer="xpointer(//*[@os='o'])"/>
243
244 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
245 href="readjusting.xml"
246 xpointer="xpointer(//*[@os='p'])"/>
247
248 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
249 href="readjusting.xml"
250 xpointer="xpointer(//*[@os='q'])"/>
251
252 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
253 href="readjusting.xml"
254 xpointer="xpointer(//*[@os='r'])"/>
255
256 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
257 href="readjusting.xml"
258 xpointer="xpointer(//*[@os='s'])"/>
259
260 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
261 href="readjusting.xml"
262 xpointer="xpointer(//*[@os='t'])"/>
263
264 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
265 href="readjusting.xml"
266 xpointer="xpointer(//*[@os='u'])"/>
267
268 <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
269 href="readjusting.xml"
270 xpointer="xpointer(//*[@os='v'])"/>
271
272 </sect2>
273
274 <sect2 id="contents-gcc" role="content">
275 <title>Contents of GCC</title>
276
277 <segmentedlist>
278 <segtitle>Installed programs</segtitle>
279 <segtitle>Installed libraries</segtitle>
280
281 <seglistitem>
282 <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
283 <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libmudflap.{a,so},
284 libssp.{a,so}libstdc++.{a,so}, and libsupc++.a</seg>
285 </seglistitem>
286 </segmentedlist>
287
288 <variablelist>
289 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
290 <?dbfo list-presentation="list"?>
291 <?dbhtml list-presentation="table"?>
292
293 <varlistentry id="c">
294 <term><command>c++</command></term>
295 <listitem>
296 <para>The C++ compiler</para>
297 <indexterm zone="ch-system-gcc c">
298 <primary sortas="b-c++">c++</primary>
299 </indexterm>
300 </listitem>
301 </varlistentry>
302
303 <varlistentry id="cc">
304 <term><command>cc</command></term>
305 <listitem>
306 <para>The C compiler</para>
307 <indexterm zone="ch-system-gcc cc">
308 <primary sortas="b-cc">cc</primary>
309 </indexterm>
310 </listitem>
311 </varlistentry>
312
313 <varlistentry id="cpp">
314 <term><command>cpp</command></term>
315 <listitem>
316 <para>The C preprocessor; it is used by the compiler to expand the
317 #include, #define, and similar statements in the source files</para>
318 <indexterm zone="ch-system-gcc cpp">
319 <primary sortas="b-cpp">cpp</primary>
320 </indexterm>
321 </listitem>
322 </varlistentry>
323
324 <varlistentry id="g">
325 <term><command>g++</command></term>
326 <listitem>
327 <para>The C++ compiler</para>
328 <indexterm zone="ch-system-gcc g">
329 <primary sortas="b-g++">g++</primary>
330 </indexterm>
331 </listitem>
332 </varlistentry>
333
334 <varlistentry id="gcc">
335 <term><command>gcc</command></term>
336 <listitem>
337 <para>The C compiler</para>
338 <indexterm zone="ch-system-gcc gcc">
339 <primary sortas="b-gcc">gcc</primary>
340 </indexterm>
341 </listitem>
342 </varlistentry>
343
344 <varlistentry id="gccbug">
345 <term><command>gccbug</command></term>
346 <listitem>
347 <para>A shell script used to help create useful bug reports</para>
348 <indexterm zone="ch-system-gcc gccbug">
349 <primary sortas="b-gccbug">gccbug</primary>
350 </indexterm>
351 </listitem>
352 </varlistentry>
353
354 <varlistentry id="gcov">
355 <term><command>gcov</command></term>
356 <listitem>
357 <para>A coverage testing tool; it is used to analyze programs to
358 determine where optimizations will have the most effect</para>
359 <indexterm zone="ch-system-gcc gcov">
360 <primary sortas="b-gcov">gcov</primary>
361 </indexterm>
362 </listitem>
363 </varlistentry>
364
365 <varlistentry id="libgcc">
366 <term><filename class="libraryfile">libgcc</filename></term>
367 <listitem>
368 <para>Contains run-time support for <command>gcc</command></para>
369 <indexterm zone="ch-system-gcc libgcc">
370 <primary sortas="c-libgcc*">libgcc*</primary>
371 </indexterm>
372 </listitem>
373 </varlistentry>
374
375 <varlistentry id="libmudflap">
376 <term><filename class="libraryfile">libmudflap</filename></term>
377 <listitem>
378 <para>Contains routines that support GCC's bounds checking
379 functionality</para>
380 <indexterm zone="ch-system-gcc libmudflap">
381 <primary sortas="c-libmudflap*">libmudflap*</primary>
382 </indexterm>
383 </listitem>
384 </varlistentry>
385
386 <varlistentry id="libssp">
387 <term><filename class="libraryfile">libssp</filename></term>
388 <listitem>
389 <para>Contains routines supporting GCC's stack-smashing protection
390 functionality</para>
391 <indexterm zone="ch-system-gcc libssp">
392 <primary sortas="c-libssp*">libssp*</primary>
393 </indexterm>
394 </listitem>
395 </varlistentry>
396
397 <varlistentry id="libstdc">
398 <term><filename class="libraryfile">libstdc++</filename></term>
399 <listitem>
400 <para>The standard C++ library</para>
401 <indexterm zone="ch-system-gcc libstdc">
402 <primary sortas="c-libstdc++">libstdc++</primary>
403 </indexterm>
404 </listitem>
405 </varlistentry>
406
407 <varlistentry id="libsupc">
408 <term><filename class="libraryfile">libsupc++</filename></term>
409 <listitem>
410 <para>Provides supporting routines for the C++ programming
411 language</para>
412 <indexterm zone="ch-system-gcc libsupc">
413 <primary sortas="c-libsupc++">libsupc++</primary>
414 </indexterm>
415 </listitem>
416 </varlistentry>
417
418 </variablelist>
419
420 </sect2>
421
422</sect1>
Note: See TracBrowser for help on using the repository browser.