source: chapter06/gcc.xml@ b8dd57d6

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

Use --with-arch=i486 only for x86. Also force '-m64' for 64-bit builds.

Lastly, use 'make' instead of 'make bootstrap' on gcc pass 1. The bootstrap is now default.

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

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