source: chapter06/gcc.xml@ bff5fef

7.6-systemd 7.7-systemd 7.8-systemd 7.9-systemd
Last change on this file since bff5fef was bff5fef, checked in by Krejzi <krejzi@…>, 10 years ago

Merged trunk.

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

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