source: chapter06/gcc.xml@ a55875ee

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 a55875ee was a55875ee, checked in by Matthew Burgess <matthew@…>, 11 years ago

Remove notes about enabling LTO support; it's enabled by default by both GCC and Binutils.

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

  • Property mode set to 100644
File size: 19.2 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>Workaround a bug so that GCC doesn't install
54 <filename class="libraryfile">libiberty.a</filename>, which is already
55 provided by Binutils:</para>
56
57<screen><userinput remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
58
59 <para>Also fix an error in one of the check Makefiles:</para>
60
61<screen><userinput remap="pre">sed -i -e /autogen/d -e /check.sh/d fixincludes/Makefile.in</userinput></screen>
62
63 <para>The GCC documentation recommends building GCC outside of the source
64 directory in a dedicated build directory:</para>
65
66<screen><userinput remap="pre">mkdir -v ../gcc-build
67cd ../gcc-build</userinput></screen>
68
69 <para>Prepare GCC for compilation:</para>
70
71<screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/usr \
72 --libexecdir=/usr/lib \
73 --enable-shared \
74 --enable-threads=posix \
75 --enable-__cxa_atexit \
76 --enable-clocale=gnu \
77 --enable-languages=c,c++ \
78 --disable-multilib \
79 --disable-bootstrap \
80 --disable-install-libiberty \
81 --with-system-zlib</userinput></screen>
82
83 <para>Note that for other languages, there are some prerequisites that
84 are not available. See the BLFS Book for instructions on how to
85 build all the GCC supported languages.</para>
86
87 <variablelist>
88 <title>The meaning of the new configure option:</title>
89
90 <varlistentry>
91 <term><parameter>--disable-install-libiberty</parameter></term>
92 <listitem>
93 <para>This prevents GCC from installing its own copy of libiberty,
94 which is already provided by Binutils-&binutils-version;.</para>
95 </listitem>
96 </varlistentry>
97
98 <varlistentry>
99 <term><parameter>--with-system-zlib</parameter></term>
100 <listitem>
101 <para>This switch tells GCC to link to the system installed copy of
102 the Zlib library, rather than its own internal copy.</para>
103 </listitem>
104 </varlistentry>
105 </variablelist>
106
107 <para>Compile the package:</para>
108
109<screen><userinput remap="make">make</userinput></screen>
110
111 <important>
112 <para>In this section, the test suite for GCC is considered
113 critical. Do not skip it under any circumstance.</para>
114 </important>
115
116 <para>One set of tests in the GCC test suite is known to exhaust the stack,
117 so increase the stack size prior to running the tests:</para>
118
119<screen><userinput remap="test">ulimit -s 32768</userinput></screen>
120
121 <para>Test the results, but do not stop at errors:</para>
122
123<screen><userinput remap="test">make -k check</userinput></screen>
124
125 <para>To receive a summary of the test suite results, run:</para>
126
127<screen><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
128
129 <para>For only the summaries, pipe the output through
130 <userinput>grep -A7 Summ</userinput>.</para>
131
132 <para>Results can be compared with those located at <ulink
133 url="&test-results;"/> and <ulink url="http://gcc.gnu.org/ml/gcc-testresults/"/>.</para>
134
135 <para>A few unexpected failures cannot always be avoided. The GCC developers
136 are usually aware of these issues, but have not resolved them yet. In
137 particular, the <filename class="libraryfile">libmudflap</filename> tests
138 are known to be particularly problematic as a result of a bug in GCC
139 (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
140 Unless the test results are vastly different from those at the above URL,
141 it is safe to continue.</para>
142
143 <para>Install the package:</para>
144
145<screen><userinput remap="install">make install</userinput></screen>
146
147 <para>Some packages expect the C preprocessor to be installed in the
148 <filename class="directory">/lib</filename> directory.
149 To support those packages, create this symlink:</para>
150
151<screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
152
153 <para>Many packages use the name <command>cc</command> to call the C
154 compiler. To satisfy those packages, create a symlink:</para>
155
156<screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
157
158 <para>Now that our final toolchain is in place, it is important to again ensure
159 that compiling and linking will work as expected. We do this by performing
160 the same sanity checks as we did earlier in the chapter:</para>
161
162 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
163 href="adjusting.xml"
164 xpointer="xpointer(//*[@os='a'])"/>
165
166 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
167 href="adjusting.xml"
168 xpointer="xpointer(//*[@os='b'])"/>
169
170 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
171 href="adjusting.xml"
172 xpointer="xpointer(//*[@os='c'])"/>
173
174 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
175 href="adjusting.xml"
176 xpointer="xpointer(//*[@os='d'])"/>
177
178 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
179 href="adjusting.xml"
180 xpointer="xpointer(//*[@os='e'])"/>
181
182 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
183 href="adjusting.xml"
184 xpointer="xpointer(//*[@os='f'])"/>
185
186<screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
187/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
188/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
189
190 <para>Depending on your machine architecture, the above may differ slightly,
191 the difference usually being the name of the directory
192 after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
193 a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
194 towards the end of the string. The important thing to
195 look for here is that <command>gcc</command> has found all three
196 <filename>crt*.o</filename> files under the
197 <filename class="directory">/usr/lib</filename> directory.</para>
198
199 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
200 href="adjusting.xml"
201 xpointer="xpointer(//*[@os='g'])"/>
202
203<screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
204
205 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
206 href="adjusting.xml"
207 xpointer="xpointer(//*[@os='h'])"/>
208
209<screen><computeroutput>#include &lt;...&gt; search starts here:
210 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
211 /usr/local/include
212 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed
213 /usr/include</computeroutput></screen>
214
215 <para>Again, note that the directory named after your target triplet may be
216 different than the above, depending on your architecture.</para>
217
218 <note><para>As of version 4.3.0, GCC now unconditionally installs the
219 <filename>limits.h</filename> file into the private
220 <filename class="directory">include-fixed</filename> directory, and that
221 directory is required to be in place.</para></note>
222
223 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
224 href="adjusting.xml"
225 xpointer="xpointer(//*[@os='i'])"/>
226
227 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
228 href="adjusting.xml"
229 xpointer="xpointer(//*[@os='j'])"/>
230
231 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
232 href="adjusting.xml"
233 xpointer="xpointer(//*[@os='k'])"/>
234
235<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
236SEARCH_DIR("/usr/local/lib")
237SEARCH_DIR("/lib")
238SEARCH_DIR("/usr/lib");</computeroutput></screen>
239
240 <para>A 64-bit system may see a few more directories. For example, here
241 is the output from an x86_64 machine:</para>
242
243<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
244SEARCH_DIR("/usr/local/lib64")
245SEARCH_DIR("/lib64")
246SEARCH_DIR("/usr/lib64")
247SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
248SEARCH_DIR("/usr/local/lib")
249SEARCH_DIR("/lib")
250SEARCH_DIR("/usr/lib");</computeroutput></screen>
251
252 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
253 href="adjusting.xml"
254 xpointer="xpointer(//*[@os='l'])"/>
255
256 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
257 href="adjusting.xml"
258 xpointer="xpointer(//*[@os='m'])"/>
259
260 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
261 href="adjusting.xml"
262 xpointer="xpointer(//*[@os='n'])"/>
263
264 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
265 href="adjusting.xml"
266 xpointer="xpointer(//*[@os='o'])"/>
267
268 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
269 href="adjusting.xml"
270 xpointer="xpointer(//*[@os='p'])"/>
271
272 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
273 href="adjusting.xml"
274 xpointer="xpointer(//*[@os='q'])"/>
275
276 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
277 href="adjusting.xml"
278 xpointer="xpointer(//*[@os='r'])"/>
279
280 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
281 href="adjusting.xml"
282 xpointer="xpointer(//*[@os='s'])"/>
283
284 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
285 href="adjusting.xml"
286 xpointer="xpointer(//*[@os='t'])"/>
287
288 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
289 href="adjusting.xml"
290 xpointer="xpointer(//*[@os='u'])"/>
291
292 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
293 href="adjusting.xml"
294 xpointer="xpointer(//*[@os='v'])"/>
295
296 <para>Finally, move a misplaced file:</para>
297
298<screen><userinput remap="install">mkdir -pv /usr/share/gdb/auto-load/usr/lib
299mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib</userinput></screen>
300
301 </sect2>
302
303 <sect2 id="contents-gcc" role="content">
304 <title>Contents of GCC</title>
305
306 <segmentedlist>
307 <segtitle>Installed programs</segtitle>
308 <segtitle>Installed libraries</segtitle>
309 <segtitle>Installed directories</segtitle>
310
311 <seglistitem>
312 <seg>c++, cc (link to gcc), cpp, g++, gcc,
313 gcc-ar, gcc-nm, gcc-ranlib, gccbug, and gcov</seg>
314
315 <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.{a,so},
316 liblto_plugin.so, libmudflap.{a,so}, libmudflapth.{a,so},
317 libquadmath.{a,so}, libssp.{a,so},
318 libssp_nonshared.a, libstdc++.{a,so} and libsupc++.a</seg>
319
320 <seg>/usr/include/c++, /usr/lib/gcc, /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="gccbug">
420 <term><command>gccbug</command></term>
421 <listitem>
422 <para>A shell script used to help create useful bug reports</para>
423 <indexterm zone="ch-system-gcc gccbug">
424 <primary sortas="b-gccbug">gccbug</primary>
425 </indexterm>
426 </listitem>
427 </varlistentry>
428
429 <varlistentry id="gcov">
430 <term><command>gcov</command></term>
431 <listitem>
432 <para>A coverage testing tool; it is used to analyze programs to
433 determine where optimizations will have the most effect</para>
434 <indexterm zone="ch-system-gcc gcov">
435 <primary sortas="b-gcov">gcov</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="liblto_plugin">
473 <term><filename class="libraryfile">liblto_plugin</filename></term>
474 <listitem>
475 <para>GCC's Link Time Optimization (LTO) plugin allows GCC to perform
476 optimizations across compilation units.</para>
477 <indexterm zone="ch-system-gcc liblto_plugin">
478 <primary sortas="c-liblto_plugin*">liblto_plugin*</primary>
479 </indexterm>
480 </listitem>
481 </varlistentry>
482
483 <varlistentry id="libmudflap">
484 <term><filename class="libraryfile">libmudflap</filename></term>
485 <listitem>
486 <para>Contains routines that support GCC's bounds checking
487 functionality</para>
488 <indexterm zone="ch-system-gcc libmudflap">
489 <primary sortas="c-libmudflap*">libmudflap*</primary>
490 </indexterm>
491 </listitem>
492 </varlistentry>
493
494 <varlistentry id="libquadmath">
495 <term><filename class="libraryfile">libquadmath</filename></term>
496 <listitem>
497 <para>GCC Quad Precision Math Library API</para>
498 <indexterm zone="ch-system-gcc libquadmath">
499 <primary sortas="c-libquadmath*">libquadmath*</primary>
500 </indexterm>
501 </listitem>
502 </varlistentry>
503
504 <varlistentry id="libssp">
505 <term><filename class="libraryfile">libssp</filename></term>
506 <listitem>
507 <para>Contains routines supporting GCC's stack-smashing protection
508 functionality</para>
509 <indexterm zone="ch-system-gcc libssp">
510 <primary sortas="c-libssp*">libssp*</primary>
511 </indexterm>
512 </listitem>
513 </varlistentry>
514
515 <varlistentry id="libstdc">
516 <term><filename class="libraryfile">libstdc++</filename></term>
517 <listitem>
518 <para>The standard C++ library</para>
519 <indexterm zone="ch-system-gcc libstdc">
520 <primary sortas="c-libstdc++">libstdc++</primary>
521 </indexterm>
522 </listitem>
523 </varlistentry>
524
525 <varlistentry id="libsupc">
526 <term><filename class="libraryfile">libsupc++</filename></term>
527 <listitem>
528 <para>Provides supporting routines for the C++ programming
529 language</para>
530 <indexterm zone="ch-system-gcc libsupc">
531 <primary sortas="c-libsupc++">libsupc++</primary>
532 </indexterm>
533 </listitem>
534 </varlistentry>
535
536 </variablelist>
537
538 </sect2>
539
540</sect1>
Note: See TracBrowser for help on using the repository browser.