source: chapter06/gcc.xml@ 60b23a6f

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

Update to dejagnu-1.6.
Update to linux-4.5.1.
Wording change in Chapter 6 GCC.

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

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