source: chapter06/gcc.xml@ 98e7ac4

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 98e7ac4 was 98e7ac4, checked in by DJ Lucas <dj@…>, 7 years ago

Update toolchain sanity checks to use values for x86_64.

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