source: chapter06/gcc.xml@ c528e3a

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.4 7.5 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 c528e3a was c528e3a, checked in by Bruce Dubbs <bdubbs@…>, 11 years ago

Minor touchups

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10186 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>Apply a <command>sed</command> substitution that will suppress the
45 installation of <filename class="libraryfile">libiberty.a</filename>. The
46 version of <filename class="libraryfile">libiberty.a</filename> provided by
47 Binutils will be used instead:</para>
48
49<screen><userinput remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
50
51 <para>Again, do not build the .info files. They are broken with the current
52 version of <command>makeinfo</command>.</para>
53
54 <screen><userinput remap="pre">sed -i 's/BUILD_INFO=info/BUILD_INFO=/' gcc/configure</userinput></screen>
55
56
57
58 <para>As in <xref linkend="ch-tools-gcc-pass2"/>, apply the following
59 <command>sed</command> to force the build to use the
60 <option>-fomit-frame-pointer</option> compiler flag in order to ensure
61 consistent compiler builds:</para>
62
63<screen><userinput remap="pre">case `uname -m` in
64 i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in ;;
65esac</userinput></screen>
66
67 <para>Also fix an error in one of the check Makefiles:</para>
68
69<screen><userinput remap="pre">sed -i -e /autogen/d -e /check.sh/d fixincludes/Makefile.in</userinput></screen>
70
71 <para>The GCC documentation recommends building GCC outside of the source
72 directory in a dedicated build directory:</para>
73
74<screen><userinput remap="pre">mkdir -v ../gcc-build
75cd ../gcc-build</userinput></screen>
76
77 <para>Prepare GCC for compilation:</para>
78
79<screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/usr \
80 --libexecdir=/usr/lib \
81 --enable-shared \
82 --enable-threads=posix \
83 --enable-__cxa_atexit \
84 --enable-clocale=gnu \
85 --enable-languages=c,c++ \
86 --disable-multilib \
87 --disable-bootstrap \
88 --with-system-zlib</userinput></screen>
89
90 <para>Note that for other languages, there are some prerequisites that
91 are not available. See the BLFS Book for instructions on how to
92 build all the GCC supported languages.</para>
93
94 <variablelist>
95 <title>The meaning of the new configure option:</title>
96
97 <varlistentry>
98 <term><parameter>--with-system-zlib</parameter></term>
99 <listitem>
100 <para>This switch tells GCC to link to the system installed copy of
101 the Zlib library, rather than its own internal copy.</para>
102 </listitem>
103 </varlistentry>
104 </variablelist>
105
106 <note>
107 <para>There is an optional argument to <command>configure</command>,
108 <option>--enable-lto</option>, that can be used to allow
109 <command>gcc</command> to do do "link time optimization" if specified. No
110 packages in LFS or BLFS currently use this capability.</para>
111
112 <para>To use this feature, it must also be enabled in
113 <application>binutils</application>.</para>
114 </note>
115
116 <para>Compile the package:</para>
117
118<screen><userinput remap="make">make</userinput></screen>
119
120 <important>
121 <para>In this section, the test suite for GCC is considered
122 critical. Do not skip it under any circumstance.</para>
123 </important>
124
125 <para>One set of tests in the GCC test suite is known to exhaust the stack,
126 so increase the stack size prior to running the tests:</para>
127
128<screen><userinput remap="test">ulimit -s 32768</userinput></screen>
129
130 <para>Test the results, but do not stop at errors:</para>
131
132<screen><userinput remap="test">make -k check</userinput></screen>
133
134 <para>To receive a summary of the test suite results, run:</para>
135
136<screen><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
137
138 <para>For only the summaries, pipe the output through
139 <userinput>grep -A7 Summ</userinput>.</para>
140
141 <para>Results can be compared with those located at <ulink
142 url="&test-results;"/> and <ulink url="http://gcc.gnu.org/ml/gcc-testresults/"/>.</para>
143
144 <para>A few unexpected failures cannot always be avoided. The GCC developers
145 are usually aware of these issues, but have not resolved them yet. In
146 particular, the <filename class="libraryfile">libmudflap</filename> tests
147 are known to be particularly problematic as a result of a bug in GCC
148 (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
149 Unless the test results are vastly different from those at the above URL,
150 it is safe to continue.</para>
151
152 <para>Install the package:</para>
153
154<screen><userinput remap="install">make install</userinput></screen>
155
156 <para>Some packages expect the C preprocessor to be installed in the
157 <filename class="directory">/lib</filename> directory.
158 To support those packages, create this symlink:</para>
159
160<screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
161
162 <para>Many packages use the name <command>cc</command> to call the C
163 compiler. To satisfy those packages, create a symlink:</para>
164
165<screen><userinput remap="install">ln -sv gcc /usr/bin/cc</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/lib")
245SEARCH_DIR("/usr/local/lib")
246SEARCH_DIR("/lib")
247SEARCH_DIR("/usr/lib");</computeroutput></screen>
248
249 <para>A 64-bit system may see a few more directories. For example, here
250 is the output from an x86_64 machine:</para>
251
252<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
253SEARCH_DIR("/usr/local/lib64")
254SEARCH_DIR("/lib64")
255SEARCH_DIR("/usr/lib64")
256SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
257SEARCH_DIR("/usr/local/lib")
258SEARCH_DIR("/lib")
259SEARCH_DIR("/usr/lib");</computeroutput></screen>
260
261 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
262 href="adjusting.xml"
263 xpointer="xpointer(//*[@os='l'])"/>
264
265 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
266 href="adjusting.xml"
267 xpointer="xpointer(//*[@os='m'])"/>
268
269 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
270 href="adjusting.xml"
271 xpointer="xpointer(//*[@os='n'])"/>
272
273 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
274 href="adjusting.xml"
275 xpointer="xpointer(//*[@os='o'])"/>
276
277 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
278 href="adjusting.xml"
279 xpointer="xpointer(//*[@os='p'])"/>
280
281 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
282 href="adjusting.xml"
283 xpointer="xpointer(//*[@os='q'])"/>
284
285 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
286 href="adjusting.xml"
287 xpointer="xpointer(//*[@os='r'])"/>
288
289 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
290 href="adjusting.xml"
291 xpointer="xpointer(//*[@os='s'])"/>
292
293 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
294 href="adjusting.xml"
295 xpointer="xpointer(//*[@os='t'])"/>
296
297 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
298 href="adjusting.xml"
299 xpointer="xpointer(//*[@os='u'])"/>
300
301 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
302 href="adjusting.xml"
303 xpointer="xpointer(//*[@os='v'])"/>
304
305 <para>Finally, move a misplaced file:</para>
306
307<screen><userinput remap="install">mkdir -pv /usr/share/gdb/auto-load/usr/lib
308mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib</userinput></screen>
309
310 </sect2>
311
312 <sect2 id="contents-gcc" role="content">
313 <title>Contents of GCC</title>
314
315 <segmentedlist>
316 <segtitle>Installed programs</segtitle>
317 <segtitle>Installed libraries</segtitle>
318 <segtitle>Installed directories</segtitle>
319
320 <seglistitem>
321 <seg>c++, cc (link to gcc), cpp, g++, gcc,
322 gcc-ar, gcc-nm, gcc-ranlib, gccbug, and gcov</seg>
323
324 <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.{a,so},
325 liblto_plugin.so, libmudflap.{a,so}, libmudflapth.{a,so},
326 libquadmath.{a,so}, libssp.{a,so},
327 libssp_nonshared.a, libstdc++.{a,so} and libsupc++.a</seg>
328
329 <seg>/usr/include/c++, /usr/lib/gcc, /usr/share/gcc-&gcc-version;</seg>
330 </seglistitem>
331 </segmentedlist>
332
333 <variablelist>
334 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
335 <?dbfo list-presentation="list"?>
336 <?dbhtml list-presentation="table"?>
337
338 <varlistentry id="c">
339 <term><command>c++</command></term>
340 <listitem>
341 <para>The C++ compiler</para>
342 <indexterm zone="ch-system-gcc c">
343 <primary sortas="b-c++">c++</primary>
344 </indexterm>
345 </listitem>
346 </varlistentry>
347
348 <varlistentry id="cc">
349 <term><command>cc</command></term>
350 <listitem>
351 <para>The C compiler</para>
352 <indexterm zone="ch-system-gcc cc">
353 <primary sortas="b-cc">cc</primary>
354 </indexterm>
355 </listitem>
356 </varlistentry>
357
358 <varlistentry id="cpp">
359 <term><command>cpp</command></term>
360 <listitem>
361 <para>The C preprocessor; it is used by the compiler to expand the
362 #include, #define, and similar statements in the source files</para>
363 <indexterm zone="ch-system-gcc cpp">
364 <primary sortas="b-cpp">cpp</primary>
365 </indexterm>
366 </listitem>
367 </varlistentry>
368
369 <varlistentry id="g">
370 <term><command>g++</command></term>
371 <listitem>
372 <para>The C++ compiler</para>
373 <indexterm zone="ch-system-gcc g">
374 <primary sortas="b-g++">g++</primary>
375 </indexterm>
376 </listitem>
377 </varlistentry>
378
379 <varlistentry id="gcc">
380 <term><command>gcc</command></term>
381 <listitem>
382 <para>The C compiler</para>
383 <indexterm zone="ch-system-gcc gcc">
384 <primary sortas="b-gcc">gcc</primary>
385 </indexterm>
386 </listitem>
387 </varlistentry>
388
389 <varlistentry id="gcc-ar">
390 <term><command>gcc-ar</command></term>
391 <listitem>
392 <para>A wrapper around <command>ar</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-ar">
397 <primary sortas="b-gcc-ar">gc-ar</primary>
398 </indexterm>
399 </listitem>
400 </varlistentry>
401
402 <varlistentry id="gcc-nm">
403 <term><command>gcc-nm</command></term>
404 <listitem>
405 <para>A wrapper around <command>nm</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-nm">
410 <primary sortas="b-gcc-nm">gc-nm</primary>
411 </indexterm>
412 </listitem>
413 </varlistentry>
414
415 <varlistentry id="gcc-ranlib">
416 <term><command>gcc-ranlib</command></term>
417 <listitem>
418 <para>A wrapper around <command>ranlib</command> that adds a
419 plugin to the command line. This program is only used
420 to add "link time optization" and is not useful with the
421 default build options.</para>
422 <indexterm zone="ch-system-gcc gcc-ranlib">
423 <primary sortas="b-gcc-ranlib">gc-ranlib</primary>
424 </indexterm>
425 </listitem>
426 </varlistentry>
427
428 <varlistentry id="gccbug">
429 <term><command>gccbug</command></term>
430 <listitem>
431 <para>A shell script used to help create useful bug reports</para>
432 <indexterm zone="ch-system-gcc gccbug">
433 <primary sortas="b-gccbug">gccbug</primary>
434 </indexterm>
435 </listitem>
436 </varlistentry>
437
438 <varlistentry id="gcov">
439 <term><command>gcov</command></term>
440 <listitem>
441 <para>A coverage testing tool; it is used to analyze programs to
442 determine where optimizations will have the most effect</para>
443 <indexterm zone="ch-system-gcc gcov">
444 <primary sortas="b-gcov">gcov</primary>
445 </indexterm>
446 </listitem>
447 </varlistentry>
448
449 <varlistentry id="libgcc">
450 <term><filename class="libraryfile">libgcc</filename></term>
451 <listitem>
452 <para>Contains run-time support for <command>gcc</command></para>
453 <indexterm zone="ch-system-gcc libgcc">
454 <primary sortas="c-libgcc*">libgcc*</primary>
455 </indexterm>
456 </listitem>
457 </varlistentry>
458
459 <varlistentry id="libgcov">
460 <term><filename class="libraryfile">libgcov</filename></term>
461 <listitem>
462 <para>This library is linked in to a program when GCC is instructed
463 to enable profiling</para>
464 <indexterm zone="ch-system-gcc libgcov">
465 <primary sortas="c-libgcov">libgcov</primary>
466 </indexterm>
467 </listitem>
468 </varlistentry>
469
470 <varlistentry id="libgomp">
471 <term><filename class="libraryfile">libgomp</filename></term>
472 <listitem>
473 <para>GNU implementation of the OpenMP API for multi-platform
474 shared-memory parallel programming in C/C++ and Fortran</para>
475 <indexterm zone="ch-system-gcc libgomp">
476 <primary sortas="c-libgomp">libgomp</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 </variablelist>
546
547 </sect2>
548
549</sect1>
Note: See TracBrowser for help on using the repository browser.