source: chapter06/gcc.xml@ 5c31092

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 5c31092 was 5c31092, checked in by Krejzi <krejzi@…>, 10 years ago

Remove excess empty spaces from chapter6 gcc.

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

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