source: chapter06/gcc.xml@ 9a605b8

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 9a605b8 was 0cba512d, checked in by DJ Lucas <dj@…>, 7 years ago

Minor order and text change.

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

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