source: chapter06/gcc.xml@ d49e97c

Last change on this file since d49e97c was d49e97c, checked in by Bruce Dubbs <bdubbs@…>, 7 years ago

Create branch without lib64 symlinks

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/nosym@11148 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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