source: chapter06/gcc.xml@ 3710570

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

Change the location for the python gdb module
generated by gcc to the correct location.

Fix a logic error in the ifdown script.

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

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