source: chapter06/gcc.xml@ d4407c7

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

Disable deprecated mpx code in gcc

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

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