source: chapter06/gcc.xml@ 1c8cc71

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.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 1c8cc71 was 1c8cc71, checked in by Douglas R. Reno <renodr@…>, 6 years ago

Modify gcc test note for Intel chips with MPX support that do NOT have it enabled in the kernel (most host systems)

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

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