source: chapter06/gcc.xml@ 421011f

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.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 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 421011f was 404d641, checked in by Matthew Burgess <matthew@…>, 12 years ago

Run fixincludes again, by removing the sed that disabled it. It no longer attempts to fix up host headers.

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

  • Property mode set to 100644
File size: 17.2 KB
RevLine 
[673b0d8]1<?xml version="1.0" encoding="ISO-8859-1"?>
[b06ca36]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[673b0d8]4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
[6a82dd9]7
[81fd230]8<sect1 id="ch-system-gcc" role="wrap">
[6a82dd9]9 <?dbhtml filename="gcc.html"?>
10
[e747759]11 <sect1info condition="script">
12 <productname>gcc</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
15 </sect1info>
16
[6a82dd9]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/>
[6370fa6]25
[6a82dd9]26 <para>The GCC package contains the GNU compiler collection, which includes
27 the C and C++ compilers.</para>
[673b0d8]28
[6a82dd9]29 <segmentedlist>
30 <segtitle>&buildtime;</segtitle>
31 <segtitle>&diskspace;</segtitle>
[5888299]32
[6a82dd9]33 <seglistitem>
[e4a5635]34 <seg>&gcc-ch6-sbu;</seg>
35 <seg>&gcc-ch6-du;</seg>
[6a82dd9]36 </seglistitem>
37 </segmentedlist>
[3554fa3a]38
[6a82dd9]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>
[37dcf2a]48
[0445a3d]49<screen><userinput remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
[73aedd1d]50
[07312f6]51 <para>As in <xref linkend="ch-tools-gcc-pass2"/>, apply the following
52 <command>sed</command> to force the build to use the
53 <option>-fomit-frame-pointer</option> compiler flag in order to ensure
54 consistent compiler builds:</para>
[2e02c35]55
[6e88633]56<screen><userinput remap="pre">case `uname -m` in
[9f5aaf7]57 i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in ;;
[6e88633]58esac</userinput></screen>
[2e02c35]59
[6a82dd9]60 <para>The GCC documentation recommends building GCC outside of the source
61 directory in a dedicated build directory:</para>
[73aedd1d]62
[0445a3d]63<screen><userinput remap="pre">mkdir -v ../gcc-build
[73aedd1d]64cd ../gcc-build</userinput></screen>
65
[6a82dd9]66 <para>Prepare GCC for compilation:</para>
[73aedd1d]67
[9f5aaf7]68<screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/usr \
69 --libexecdir=/usr/lib \
70 --enable-shared \
[aa2d8f0]71 --enable-threads=posix \
[9f5aaf7]72 --enable-__cxa_atexit \
73 --enable-clocale=gnu \
74 --enable-languages=c,c++ \
75 --disable-multilib \
76 --disable-bootstrap \
77 --with-system-zlib</userinput></screen>
[73aedd1d]78
[1cdaff9]79 <para>Note that for other languages, there are some prerequisites that
80 are not available. See the BLFS Book for instructions on how to
[182d5d3]81 build all the GCC supported languages.</para>
82
[ae4d45a]83 <variablelist>
84 <title>The meaning of the new configure option:</title>
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
[8dac2e2]90 the Zlib library, rather than its own internal copy.</para>
[ae4d45a]91 </listitem>
92 </varlistentry>
93 </variablelist>
94
[6a82dd9]95 <para>Compile the package:</para>
[73aedd1d]96
[0445a3d]97<screen><userinput remap="make">make</userinput></screen>
[73aedd1d]98
[6a82dd9]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>
[81fd230]103
[4e48f56e]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 16384</userinput></screen>
108
[6a82dd9]109 <para>Test the results, but do not stop at errors:</para>
[73aedd1d]110
[0445a3d]111<screen><userinput remap="test">make -k check</userinput></screen>
[73aedd1d]112
[9278974d]113 <para>To receive a summary of the test suite results, run:</para>
114
[0445a3d]115<screen><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
[9278974d]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
[536ce32]121 url="&test-results;"/> and <ulink url="http://gcc.gnu.org/ml/gcc-testresults/"/>.</para>
[9278974d]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
[16a59d0d]126 are known to be particularly problematic as a result of a bug in GCC
[9278974d]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>
[73aedd1d]130
[6a82dd9]131 <para>Install the package:</para>
[73aedd1d]132
[0445a3d]133<screen><userinput remap="install">make install</userinput></screen>
[73aedd1d]134
[6a82dd9]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>
[73aedd1d]138
[0445a3d]139<screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
[73aedd1d]140
[6a82dd9]141 <para>Many packages use the name <command>cc</command> to call the C
142 compiler. To satisfy those packages, create a symlink:</para>
[1ba726f]143
[0445a3d]144<screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
[1ba726f]145
[09f1daf]146 <para>Now that our final toolchain is in place, it is important to again ensure
147 that compiling and linking will work as expected. We do this by performing
148 the same sanity checks as we did earlier in the chapter:</para>
149
[d9441360]150 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]151 href="adjusting.xml"
[09f1daf]152 xpointer="xpointer(//*[@os='a'])"/>
153
[d9441360]154 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]155 href="adjusting.xml"
[09f1daf]156 xpointer="xpointer(//*[@os='b'])"/>
157
[d9441360]158 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]159 href="adjusting.xml"
[09f1daf]160 xpointer="xpointer(//*[@os='c'])"/>
161
[d9441360]162 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]163 href="adjusting.xml"
[09f1daf]164 xpointer="xpointer(//*[@os='d'])"/>
165
[d9441360]166 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]167 href="adjusting.xml"
[09f1daf]168 xpointer="xpointer(//*[@os='e'])"/>
169
[d9441360]170 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]171 href="adjusting.xml"
[09f1daf]172 xpointer="xpointer(//*[@os='f'])"/>
173
174<screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
175/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
176/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
177
[6e88633]178 <para>Depending on your machine architecture, the above may differ slightly,
179 the difference usually being the name of the directory
180 after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
181 a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
182 towards the end of the string. The important thing to
[5f7456b]183 look for here is that <command>gcc</command> has found all three
184 <filename>crt*.o</filename> files under the
185 <filename class="directory">/usr/lib</filename> directory.</para>
[6e88633]186
[d9441360]187 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]188 href="adjusting.xml"
[09f1daf]189 xpointer="xpointer(//*[@os='g'])"/>
190
[041c8f67]191<screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
[e9a652b]192
[d9441360]193 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]194 href="adjusting.xml"
[09f1daf]195 xpointer="xpointer(//*[@os='h'])"/>
196
[e9a652b]197<screen><computeroutput>#include &lt;...&gt; search starts here:
[0a6f214]198 /usr/local/include
[865fe24]199 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
[3f39abf3]200 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed
[e9a652b]201 /usr/include</computeroutput></screen>
202
[6e88633]203 <para>Again, note that the directory named after your target triplet may be
204 different than the above, depending on your architecture.</para>
205
[3f39abf3]206 <note><para>As of version 4.3.0, GCC now unconditionally installs the
207 <filename>limits.h</filename> file into the private
[041c8f67]208 <filename class="directory">include-fixed</filename> directory, and that
[3f39abf3]209 directory is required to be in place.</para></note>
210
[d9441360]211 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]212 href="adjusting.xml"
[09f1daf]213 xpointer="xpointer(//*[@os='i'])"/>
214
[d9441360]215 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]216 href="adjusting.xml"
[09f1daf]217 xpointer="xpointer(//*[@os='j'])"/>
218
[d9441360]219 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]220 href="adjusting.xml"
[09f1daf]221 xpointer="xpointer(//*[@os='k'])"/>
222
[e9a652b]223<screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
224SEARCH_DIR("/usr/local/lib")
225SEARCH_DIR("/lib")
[6e88633]226SEARCH_DIR("/usr/lib");</computeroutput></screen>
227
228 <para>A 64-bit system may see a few more directories. For example, here
[f1994dc]229 is the output from an x86_64 machine:</para>
[6e88633]230
231<screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
232SEARCH_DIR("/usr/local/lib64")
233SEARCH_DIR("/lib64")
234SEARCH_DIR("/usr/lib64")
235SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
236SEARCH_DIR("/usr/local/lib")
237SEARCH_DIR("/lib")
[e9a652b]238SEARCH_DIR("/usr/lib");</computeroutput></screen>
239
[d9441360]240 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]241 href="adjusting.xml"
[09f1daf]242 xpointer="xpointer(//*[@os='l'])"/>
243
[d9441360]244 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]245 href="adjusting.xml"
[09f1daf]246 xpointer="xpointer(//*[@os='m'])"/>
247
[d9441360]248 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]249 href="adjusting.xml"
[09f1daf]250 xpointer="xpointer(//*[@os='n'])"/>
251
[d9441360]252 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]253 href="adjusting.xml"
[09f1daf]254 xpointer="xpointer(//*[@os='o'])"/>
255
[d9441360]256 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]257 href="adjusting.xml"
[09f1daf]258 xpointer="xpointer(//*[@os='p'])"/>
259
[d9441360]260 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]261 href="adjusting.xml"
[09f1daf]262 xpointer="xpointer(//*[@os='q'])"/>
263
[d9441360]264 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]265 href="adjusting.xml"
[09f1daf]266 xpointer="xpointer(//*[@os='r'])"/>
267
[d9441360]268 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]269 href="adjusting.xml"
[09f1daf]270 xpointer="xpointer(//*[@os='s'])"/>
271
[d9441360]272 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]273 href="adjusting.xml"
[09f1daf]274 xpointer="xpointer(//*[@os='t'])"/>
[6a82dd9]275
[d9441360]276 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]277 href="adjusting.xml"
[e9a652b]278 xpointer="xpointer(//*[@os='u'])"/>
279
[d9441360]280 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
[1a3e6a3]281 href="adjusting.xml"
[e9a652b]282 xpointer="xpointer(//*[@os='v'])"/>
283
[970a126]284 <para>Finally, move a misplaced file:</para>
[39ec01c]285
[970a126]286<screen><userinput remap="install">mkdir -pv /usr/share/gdb/auto-load/usr/lib
287mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib</userinput></screen>
[39ec01c]288
[6a82dd9]289 </sect2>
290
291 <sect2 id="contents-gcc" role="content">
292 <title>Contents of GCC</title>
293
294 <segmentedlist>
295 <segtitle>Installed programs</segtitle>
296 <segtitle>Installed libraries</segtitle>
[fe05b08]297 <segtitle>Installed directories</segtitle>
[6a82dd9]298
299 <seglistitem>
300 <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
[90aae6b]301 <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.{a,so},
[3119ddc]302 liblto_plugin.so, libmudflap.{a,so}, libmudflapth.{a,so},
303 libquadmath.{a,so}, libssp.{a,so},
[90aae6b]304 libssp_nonshared.a, libstdc++.{a,so} and libsupc++.a</seg>
[fe05b08]305 <seg>/usr/include/c++, /usr/lib/gcc, /usr/share/gcc-&gcc-version;</seg>
[6a82dd9]306 </seglistitem>
307 </segmentedlist>
308
309 <variablelist>
310 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
311 <?dbfo list-presentation="list"?>
312 <?dbhtml list-presentation="table"?>
313
[75128571]314 <varlistentry id="c">
315 <term><command>c++</command></term>
316 <listitem>
317 <para>The C++ compiler</para>
318 <indexterm zone="ch-system-gcc c">
319 <primary sortas="b-c++">c++</primary>
320 </indexterm>
321 </listitem>
322 </varlistentry>
323
[6a82dd9]324 <varlistentry id="cc">
325 <term><command>cc</command></term>
326 <listitem>
327 <para>The C compiler</para>
328 <indexterm zone="ch-system-gcc cc">
329 <primary sortas="b-cc">cc</primary>
330 </indexterm>
331 </listitem>
332 </varlistentry>
333
334 <varlistentry id="cpp">
335 <term><command>cpp</command></term>
336 <listitem>
337 <para>The C preprocessor; it is used by the compiler to expand the
338 #include, #define, and similar statements in the source files</para>
339 <indexterm zone="ch-system-gcc cpp">
340 <primary sortas="b-cpp">cpp</primary>
341 </indexterm>
342 </listitem>
343 </varlistentry>
344
345 <varlistentry id="g">
346 <term><command>g++</command></term>
347 <listitem>
348 <para>The C++ compiler</para>
349 <indexterm zone="ch-system-gcc g">
350 <primary sortas="b-g++">g++</primary>
351 </indexterm>
352 </listitem>
353 </varlistentry>
354
355 <varlistentry id="gcc">
356 <term><command>gcc</command></term>
357 <listitem>
358 <para>The C compiler</para>
359 <indexterm zone="ch-system-gcc gcc">
360 <primary sortas="b-gcc">gcc</primary>
361 </indexterm>
362 </listitem>
363 </varlistentry>
364
365 <varlistentry id="gccbug">
366 <term><command>gccbug</command></term>
367 <listitem>
368 <para>A shell script used to help create useful bug reports</para>
369 <indexterm zone="ch-system-gcc gccbug">
370 <primary sortas="b-gccbug">gccbug</primary>
371 </indexterm>
372 </listitem>
373 </varlistentry>
374
375 <varlistentry id="gcov">
376 <term><command>gcov</command></term>
377 <listitem>
378 <para>A coverage testing tool; it is used to analyze programs to
379 determine where optimizations will have the most effect</para>
380 <indexterm zone="ch-system-gcc gcov">
381 <primary sortas="b-gcov">gcov</primary>
382 </indexterm>
383 </listitem>
384 </varlistentry>
385
386 <varlistentry id="libgcc">
387 <term><filename class="libraryfile">libgcc</filename></term>
388 <listitem>
389 <para>Contains run-time support for <command>gcc</command></para>
390 <indexterm zone="ch-system-gcc libgcc">
391 <primary sortas="c-libgcc*">libgcc*</primary>
392 </indexterm>
393 </listitem>
394 </varlistentry>
395
[90aae6b]396 <varlistentry id="libgcov">
397 <term><filename class="libraryfile">libgcov</filename></term>
398 <listitem>
399 <para>This library is linked in to a program when GCC is instructed
400 to enable profiling</para>
401 <indexterm zone="ch-system-gcc libgcov">
402 <primary sortas="c-libgcov">libgcov</primary>
403 </indexterm>
404 </listitem>
405 </varlistentry>
406
407 <varlistentry id="libgomp">
408 <term><filename class="libraryfile">libgomp</filename></term>
409 <listitem>
410 <para>GNU implementation of the OpenMP API for multi-platform
411 shared-memory parallel programming in C/C++ and Fortran</para>
412 <indexterm zone="ch-system-gcc libgomp">
413 <primary sortas="c-libgomp">libgomp</primary>
414 </indexterm>
415 </listitem>
416 </varlistentry>
417
[3119ddc]418 <varlistentry id="liblto_plugin">
419 <term><filename class="libraryfile">liblto_plugin</filename></term>
420 <listitem>
421 <para>GCC's Link Time Optimization (LTO) plugin allows GCC to perform
422 optimizations across compilation units.</para>
423 <indexterm zone="ch-system-gcc liblto_plugin">
424 <primary sortas="c-liblto_plugin*">liblto_plugin*</primary>
425 </indexterm>
426 </listitem>
427 </varlistentry>
428
[2791a8e]429 <varlistentry id="libmudflap">
430 <term><filename class="libraryfile">libmudflap</filename></term>
431 <listitem>
432 <para>Contains routines that support GCC's bounds checking
433 functionality</para>
434 <indexterm zone="ch-system-gcc libmudflap">
435 <primary sortas="c-libmudflap*">libmudflap*</primary>
436 </indexterm>
437 </listitem>
438 </varlistentry>
439
[3119ddc]440 <varlistentry id="libquadmath">
441 <term><filename class="libraryfile">libquadmath</filename></term>
442 <listitem>
443 <para>GCC Quad Precision Math Library API</para>
444 <indexterm zone="ch-system-gcc libquadmath">
445 <primary sortas="c-libquadmath*">libquadmath*</primary>
446 </indexterm>
447 </listitem>
448 </varlistentry>
449
[2791a8e]450 <varlistentry id="libssp">
451 <term><filename class="libraryfile">libssp</filename></term>
452 <listitem>
453 <para>Contains routines supporting GCC's stack-smashing protection
454 functionality</para>
455 <indexterm zone="ch-system-gcc libssp">
456 <primary sortas="c-libssp*">libssp*</primary>
457 </indexterm>
458 </listitem>
459 </varlistentry>
460
[6a82dd9]461 <varlistentry id="libstdc">
462 <term><filename class="libraryfile">libstdc++</filename></term>
463 <listitem>
464 <para>The standard C++ library</para>
465 <indexterm zone="ch-system-gcc libstdc">
466 <primary sortas="c-libstdc++">libstdc++</primary>
467 </indexterm>
468 </listitem>
469 </varlistentry>
470
471 <varlistentry id="libsupc">
472 <term><filename class="libraryfile">libsupc++</filename></term>
473 <listitem>
474 <para>Provides supporting routines for the C++ programming
475 language</para>
476 <indexterm zone="ch-system-gcc libsupc">
477 <primary sortas="c-libsupc++">libsupc++</primary>
478 </indexterm>
479 </listitem>
480 </varlistentry>
481
482 </variablelist>
483
484 </sect2>
[673b0d8]485
486</sect1>
Note: See TracBrowser for help on using the repository browser.