source: chapter06/gcc.xml@ b484748

Last change on this file since b484748 was b484748, checked in by Jeremy Huntwork <jhuntwork@…>, 17 years ago

Add '--disable-bootstrap' to GCC pass 2 and chapter 6 GCC to achieve traditional LFS build methods with GCC 4.2.1

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

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