source: chapter06/gcc.xml@ 2efa44a

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 2efa44a was 2efa44a, checked in by Bruce Dubbs <bdubbs@…>, 12 years ago

Upgrade to perl-5.16.1
Removed unneeded sed instruction from Chapter 6 perl
Updated gcc instructions to fix some make check errors

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

  • Property mode set to 100644
File size: 17.4 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 remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
50
51 <para>As in <xref linkend="ch-tools-gcc-pass2"/>, apply the following
52 <command>sed</command> to force the build to use the
53 <option>-fomit-frame-pointer</option> compiler flag in order to ensure
54 consistent compiler builds:</para>
55
56<screen><userinput remap="pre">case `uname -m` in
57 i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in ;;
58esac</userinput></screen>
59
60 <para>Also fix an error in one of the check Makefiles:</para>
61
62<screen><userinput remap="pre">sed -i -e /autogen/d -e /check.sh/d fixincludes/Makefile.in</userinput></screen>
63
64 <para>The GCC documentation recommends building GCC outside of the source
65 directory in a dedicated build directory:</para>
66
67<screen><userinput remap="pre">mkdir -v ../gcc-build
68cd ../gcc-build</userinput></screen>
69
70 <para>Prepare GCC for compilation:</para>
71
72<screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/usr \
73 --libexecdir=/usr/lib \
74 --enable-shared \
75 --enable-threads=posix \
76 --enable-__cxa_atexit \
77 --enable-clocale=gnu \
78 --enable-languages=c,c++ \
79 --disable-multilib \
80 --disable-bootstrap \
81 --with-system-zlib</userinput></screen>
82
83 <para>Note that for other languages, there are some prerequisites that
84 are not available. See the BLFS Book for instructions on how to
85 build all the GCC supported languages.</para>
86
87 <variablelist>
88 <title>The meaning of the new configure option:</title>
89
90 <varlistentry>
91 <term><parameter>--with-system-zlib</parameter></term>
92 <listitem>
93 <para>This switch tells GCC to link to the system installed copy of
94 the Zlib library, rather than its own internal copy.</para>
95 </listitem>
96 </varlistentry>
97 </variablelist>
98
99 <para>Compile the package:</para>
100
101<screen><userinput remap="make">make</userinput></screen>
102
103 <important>
104 <para>In this section, the test suite for GCC is considered
105 critical. Do not skip it under any circumstance.</para>
106 </important>
107
108 <para>One set of tests in the GCC test suite is known to exhaust the stack,
109 so increase the stack size prior to running the tests:</para>
110
111<screen><userinput remap="test">ulimit -s 32768</userinput></screen>
112
113 <para>Test the results, but do not stop at errors:</para>
114
115<screen><userinput remap="test">make -k check</userinput></screen>
116
117 <para>To receive a summary of the test suite results, run:</para>
118
119<screen><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
120
121 <para>For only the summaries, pipe the output through
122 <userinput>grep -A7 Summ</userinput>.</para>
123
124 <para>Results can be compared with those located at <ulink
125 url="&test-results;"/> and <ulink url="http://gcc.gnu.org/ml/gcc-testresults/"/>.</para>
126
127 <para>A few unexpected failures cannot always be avoided. The GCC developers
128 are usually aware of these issues, but have not resolved them yet. In
129 particular, the <filename class="libraryfile">libmudflap</filename> tests
130 are known to be particularly problematic as a result of a bug in GCC
131 (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
132 Unless the test results are vastly different from those at the above URL,
133 it is safe to continue.</para>
134
135 <para>Install the package:</para>
136
137<screen><userinput remap="install">make install</userinput></screen>
138
139 <para>Some packages expect the C preprocessor to be installed in the
140 <filename class="directory">/lib</filename> directory.
141 To support those packages, create this symlink:</para>
142
143<screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
144
145 <para>Many packages use the name <command>cc</command> to call the C
146 compiler. To satisfy those packages, create a symlink:</para>
147
148<screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
149
150 <para>Now that our final toolchain is in place, it is important to again ensure
151 that compiling and linking will work as expected. We do this by performing
152 the same sanity checks as we did earlier in the chapter:</para>
153
154 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
155 href="adjusting.xml"
156 xpointer="xpointer(//*[@os='a'])"/>
157
158 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
159 href="adjusting.xml"
160 xpointer="xpointer(//*[@os='b'])"/>
161
162 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
163 href="adjusting.xml"
164 xpointer="xpointer(//*[@os='c'])"/>
165
166 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
167 href="adjusting.xml"
168 xpointer="xpointer(//*[@os='d'])"/>
169
170 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
171 href="adjusting.xml"
172 xpointer="xpointer(//*[@os='e'])"/>
173
174 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
175 href="adjusting.xml"
176 xpointer="xpointer(//*[@os='f'])"/>
177
178<screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
179/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
180/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
181
182 <para>Depending on your machine architecture, the above may differ slightly,
183 the difference usually being the name of the directory
184 after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
185 a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
186 towards the end of the string. The important thing to
187 look for here is that <command>gcc</command> has found all three
188 <filename>crt*.o</filename> files under the
189 <filename class="directory">/usr/lib</filename> directory.</para>
190
191 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
192 href="adjusting.xml"
193 xpointer="xpointer(//*[@os='g'])"/>
194
195<screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
196
197 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
198 href="adjusting.xml"
199 xpointer="xpointer(//*[@os='h'])"/>
200
201<screen><computeroutput>#include &lt;...&gt; search starts here:
202 /usr/local/include
203 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
204 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed
205 /usr/include</computeroutput></screen>
206
207 <para>Again, note that the directory named after your target triplet may be
208 different than the above, depending on your architecture.</para>
209
210 <note><para>As of version 4.3.0, GCC now unconditionally installs the
211 <filename>limits.h</filename> file into the private
212 <filename class="directory">include-fixed</filename> directory, and that
213 directory is required to be in place.</para></note>
214
215 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
216 href="adjusting.xml"
217 xpointer="xpointer(//*[@os='i'])"/>
218
219 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
220 href="adjusting.xml"
221 xpointer="xpointer(//*[@os='j'])"/>
222
223 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
224 href="adjusting.xml"
225 xpointer="xpointer(//*[@os='k'])"/>
226
227<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
228SEARCH_DIR("/usr/local/lib")
229SEARCH_DIR("/lib")
230SEARCH_DIR("/usr/lib");</computeroutput></screen>
231
232 <para>A 64-bit system may see a few more directories. For example, here
233 is the output from an x86_64 machine:</para>
234
235<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
236SEARCH_DIR("/usr/local/lib64")
237SEARCH_DIR("/lib64")
238SEARCH_DIR("/usr/lib64")
239SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
240SEARCH_DIR("/usr/local/lib")
241SEARCH_DIR("/lib")
242SEARCH_DIR("/usr/lib");</computeroutput></screen>
243
244 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
245 href="adjusting.xml"
246 xpointer="xpointer(//*[@os='l'])"/>
247
248 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
249 href="adjusting.xml"
250 xpointer="xpointer(//*[@os='m'])"/>
251
252 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
253 href="adjusting.xml"
254 xpointer="xpointer(//*[@os='n'])"/>
255
256 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
257 href="adjusting.xml"
258 xpointer="xpointer(//*[@os='o'])"/>
259
260 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
261 href="adjusting.xml"
262 xpointer="xpointer(//*[@os='p'])"/>
263
264 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
265 href="adjusting.xml"
266 xpointer="xpointer(//*[@os='q'])"/>
267
268 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
269 href="adjusting.xml"
270 xpointer="xpointer(//*[@os='r'])"/>
271
272 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
273 href="adjusting.xml"
274 xpointer="xpointer(//*[@os='s'])"/>
275
276 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
277 href="adjusting.xml"
278 xpointer="xpointer(//*[@os='t'])"/>
279
280 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
281 href="adjusting.xml"
282 xpointer="xpointer(//*[@os='u'])"/>
283
284 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
285 href="adjusting.xml"
286 xpointer="xpointer(//*[@os='v'])"/>
287
288 <para>Finally, move a misplaced file:</para>
289
290<screen><userinput remap="install">mkdir -pv /usr/share/gdb/auto-load/usr/lib
291mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib</userinput></screen>
292
293 </sect2>
294
295 <sect2 id="contents-gcc" role="content">
296 <title>Contents of GCC</title>
297
298 <segmentedlist>
299 <segtitle>Installed programs</segtitle>
300 <segtitle>Installed libraries</segtitle>
301 <segtitle>Installed directories</segtitle>
302
303 <seglistitem>
304 <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
305 <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.{a,so},
306 liblto_plugin.so, libmudflap.{a,so}, libmudflapth.{a,so},
307 libquadmath.{a,so}, libssp.{a,so},
308 libssp_nonshared.a, libstdc++.{a,so} and libsupc++.a</seg>
309 <seg>/usr/include/c++, /usr/lib/gcc, /usr/share/gcc-&gcc-version;</seg>
310 </seglistitem>
311 </segmentedlist>
312
313 <variablelist>
314 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
315 <?dbfo list-presentation="list"?>
316 <?dbhtml list-presentation="table"?>
317
318 <varlistentry id="c">
319 <term><command>c++</command></term>
320 <listitem>
321 <para>The C++ compiler</para>
322 <indexterm zone="ch-system-gcc c">
323 <primary sortas="b-c++">c++</primary>
324 </indexterm>
325 </listitem>
326 </varlistentry>
327
328 <varlistentry id="cc">
329 <term><command>cc</command></term>
330 <listitem>
331 <para>The C compiler</para>
332 <indexterm zone="ch-system-gcc cc">
333 <primary sortas="b-cc">cc</primary>
334 </indexterm>
335 </listitem>
336 </varlistentry>
337
338 <varlistentry id="cpp">
339 <term><command>cpp</command></term>
340 <listitem>
341 <para>The C preprocessor; it is used by the compiler to expand the
342 #include, #define, and similar statements in the source files</para>
343 <indexterm zone="ch-system-gcc cpp">
344 <primary sortas="b-cpp">cpp</primary>
345 </indexterm>
346 </listitem>
347 </varlistentry>
348
349 <varlistentry id="g">
350 <term><command>g++</command></term>
351 <listitem>
352 <para>The C++ compiler</para>
353 <indexterm zone="ch-system-gcc g">
354 <primary sortas="b-g++">g++</primary>
355 </indexterm>
356 </listitem>
357 </varlistentry>
358
359 <varlistentry id="gcc">
360 <term><command>gcc</command></term>
361 <listitem>
362 <para>The C compiler</para>
363 <indexterm zone="ch-system-gcc gcc">
364 <primary sortas="b-gcc">gcc</primary>
365 </indexterm>
366 </listitem>
367 </varlistentry>
368
369 <varlistentry id="gccbug">
370 <term><command>gccbug</command></term>
371 <listitem>
372 <para>A shell script used to help create useful bug reports</para>
373 <indexterm zone="ch-system-gcc gccbug">
374 <primary sortas="b-gccbug">gccbug</primary>
375 </indexterm>
376 </listitem>
377 </varlistentry>
378
379 <varlistentry id="gcov">
380 <term><command>gcov</command></term>
381 <listitem>
382 <para>A coverage testing tool; it is used to analyze programs to
383 determine where optimizations will have the most effect</para>
384 <indexterm zone="ch-system-gcc gcov">
385 <primary sortas="b-gcov">gcov</primary>
386 </indexterm>
387 </listitem>
388 </varlistentry>
389
390 <varlistentry id="libgcc">
391 <term><filename class="libraryfile">libgcc</filename></term>
392 <listitem>
393 <para>Contains run-time support for <command>gcc</command></para>
394 <indexterm zone="ch-system-gcc libgcc">
395 <primary sortas="c-libgcc*">libgcc*</primary>
396 </indexterm>
397 </listitem>
398 </varlistentry>
399
400 <varlistentry id="libgcov">
401 <term><filename class="libraryfile">libgcov</filename></term>
402 <listitem>
403 <para>This library is linked in to a program when GCC is instructed
404 to enable profiling</para>
405 <indexterm zone="ch-system-gcc libgcov">
406 <primary sortas="c-libgcov">libgcov</primary>
407 </indexterm>
408 </listitem>
409 </varlistentry>
410
411 <varlistentry id="libgomp">
412 <term><filename class="libraryfile">libgomp</filename></term>
413 <listitem>
414 <para>GNU implementation of the OpenMP API for multi-platform
415 shared-memory parallel programming in C/C++ and Fortran</para>
416 <indexterm zone="ch-system-gcc libgomp">
417 <primary sortas="c-libgomp">libgomp</primary>
418 </indexterm>
419 </listitem>
420 </varlistentry>
421
422 <varlistentry id="liblto_plugin">
423 <term><filename class="libraryfile">liblto_plugin</filename></term>
424 <listitem>
425 <para>GCC's Link Time Optimization (LTO) plugin allows GCC to perform
426 optimizations across compilation units.</para>
427 <indexterm zone="ch-system-gcc liblto_plugin">
428 <primary sortas="c-liblto_plugin*">liblto_plugin*</primary>
429 </indexterm>
430 </listitem>
431 </varlistentry>
432
433 <varlistentry id="libmudflap">
434 <term><filename class="libraryfile">libmudflap</filename></term>
435 <listitem>
436 <para>Contains routines that support GCC's bounds checking
437 functionality</para>
438 <indexterm zone="ch-system-gcc libmudflap">
439 <primary sortas="c-libmudflap*">libmudflap*</primary>
440 </indexterm>
441 </listitem>
442 </varlistentry>
443
444 <varlistentry id="libquadmath">
445 <term><filename class="libraryfile">libquadmath</filename></term>
446 <listitem>
447 <para>GCC Quad Precision Math Library API</para>
448 <indexterm zone="ch-system-gcc libquadmath">
449 <primary sortas="c-libquadmath*">libquadmath*</primary>
450 </indexterm>
451 </listitem>
452 </varlistentry>
453
454 <varlistentry id="libssp">
455 <term><filename class="libraryfile">libssp</filename></term>
456 <listitem>
457 <para>Contains routines supporting GCC's stack-smashing protection
458 functionality</para>
459 <indexterm zone="ch-system-gcc libssp">
460 <primary sortas="c-libssp*">libssp*</primary>
461 </indexterm>
462 </listitem>
463 </varlistentry>
464
465 <varlistentry id="libstdc">
466 <term><filename class="libraryfile">libstdc++</filename></term>
467 <listitem>
468 <para>The standard C++ library</para>
469 <indexterm zone="ch-system-gcc libstdc">
470 <primary sortas="c-libstdc++">libstdc++</primary>
471 </indexterm>
472 </listitem>
473 </varlistentry>
474
475 <varlistentry id="libsupc">
476 <term><filename class="libraryfile">libsupc++</filename></term>
477 <listitem>
478 <para>Provides supporting routines for the C++ programming
479 language</para>
480 <indexterm zone="ch-system-gcc libsupc">
481 <primary sortas="c-libsupc++">libsupc++</primary>
482 </indexterm>
483 </listitem>
484 </varlistentry>
485
486 </variablelist>
487
488 </sect2>
489
490</sect1>
Note: See TracBrowser for help on using the repository browser.