source: chapter06/gcc.xml@ cff604f

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.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 cff604f was 238d351, checked in by Bruce Dubbs <bdubbs@…>, 10 years ago

Update to gcc-4.9.2

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

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