source: chapter06/gcc.xml@ adb10b0

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

Remove unneeded instructions from gcc

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

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