source: chapter06/gcc.xml@ d13c6db

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.6 7.7 7.8 7.9 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 d13c6db was d13c6db, checked in by Bruce Dubbs <bdubbs@…>, 10 years ago

Clarify kernel configuration settings.
Fix gcc LTO symlink for i686 systems.
Fix kbd-2.0.1.tar.gz md5sum.
Fix procps-ng url.

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

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