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">
8 <sect1 id="ch-system-gcc" role="wrap">
9 <?dbhtml filename="gcc.html"?>
11 <sect1info condition="script">
12 <productname>gcc</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
17 <title>GCC-&gcc-version;</title>
19 <indexterm zone="ch-system-gcc">
20 <primary sortas="a-GCC">GCC</primary>
23 <sect2 role="package">
26 <para>The GCC package contains the GNU compiler collection, which includes
27 the C and C++ compilers.</para>
30 <segtitle>&buildtime;</segtitle>
31 <segtitle>&diskspace;</segtitle>
34 <seg>&gcc-ch6-sbu;</seg>
35 <seg>&gcc-ch6-du;</seg>
41 <sect2 role="installation">
42 <title>Installation of GCC</title>
44 <para>First fix a problem identified upstream:</para>
46 <screen><userinput remap="pre">patch -Np1 -i ../gcc-6.1.0-asan-1.patch</userinput></screen>
48 <para>The GCC documentation recommends building GCC in a dedicated build directory:</para>
50 <screen><userinput remap="pre">mkdir -v build
51 cd build</userinput></screen>
53 <para>Prepare GCC for compilation:</para>
55 <screen><userinput remap="configure">SED=sed \
56 ../configure --prefix=/usr \
57 --enable-languages=c,c++ \
60 --with-system-zlib</userinput></screen>
62 <para>Note that for other languages, there are some prerequisites that
63 are not yet available. See the
64 <ulink url="&blfs-book;general/gcc.html">BLFS Book</ulink>
65 for instructions on how to build all of GCC's supported languages.</para>
68 <title>The meaning of the new configure option:</title>
71 <term><envar>SED=sed</envar></term>
73 <para>Setting this environment variable prevents a hard-coded
74 path to /tools/bin/sed.</para>
79 <term><parameter>--with-system-zlib</parameter></term>
81 <para>This switch tells GCC to link to the system installed copy of
82 the Zlib library, rather than its own internal copy.</para>
87 <para>Compile the package:</para>
89 <screen><userinput remap="make">make</userinput></screen>
92 <para>In this section, the test suite for GCC is considered
93 critical. Do not skip it under any circumstance.</para>
96 <para>One set of tests in the GCC test suite is known to exhaust the stack,
97 so increase the stack size prior to running the tests:</para>
99 <screen><userinput remap="test">ulimit -s 32768</userinput></screen>
101 <para>Test the results, but do not stop at errors:</para>
103 <screen><userinput remap="test">make -k check</userinput></screen>
105 <para>To receive a summary of the test suite results, run:</para>
107 <screen><userinput remap="test">../contrib/test_summary</userinput></screen>
109 <para>For only the summaries, pipe the output through
110 <userinput>grep -A7 Summ</userinput>.</para>
112 <para>Results can be compared with those located at <ulink
113 url="&test-results;"/> and <ulink url="http://gcc.gnu.org/ml/gcc-testresults/"/>.</para>
115 <para>A few unexpected failures cannot always be avoided. The GCC developers
116 are usually aware of these issues, but have not resolved them yet.
117 In particular, two tests in the libstdc++ test suite are known to fail
118 when running as the root user as we do here.
119 Unless the test results are vastly different from those at the above URL,
120 it is safe to continue.</para>
122 <para>Install the package:</para>
124 <screen><userinput remap="install">make install</userinput></screen>
126 <para>Create a symlink required by the <ulink
127 url="http://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s09.html">FHS</ulink>
128 for "historical" reasons.</para>
130 <screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
132 <para>Many packages use the name <command>cc</command> to call the C
133 compiler. To satisfy those packages, create a symlink:</para>
135 <screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
137 <para>Add a compatibility symlink to enable building programs with
138 Link Time Optimization (LTO):</para>
140 <screen><userinput remap="install">install -v -dm755 /usr/lib/bfd-plugins
141 ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/&gcc-version;/liblto_plugin.so \
142 /usr/lib/bfd-plugins/</userinput></screen>
144 <para>Now that our final toolchain is in place, it is important to again ensure
145 that compiling and linking will work as expected. We do this by performing
146 the same sanity checks as we did earlier in the chapter:</para>
148 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
150 xpointer="xpointer(//*[@os='a'])"/>
152 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
154 xpointer="xpointer(//*[@os='b'])"/>
156 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
158 xpointer="xpointer(//*[@os='c'])"/>
160 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
162 xpointer="xpointer(//*[@os='d'])"/>
164 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
166 xpointer="xpointer(//*[@os='e'])"/>
168 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
170 xpointer="xpointer(//*[@os='f'])"/>
172 <screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
173 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
174 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
176 <para>Depending on your machine architecture, the above may differ slightly,
177 the difference usually being the name of the directory
178 after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
179 a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
180 towards the end of the string. The important thing to
181 look for here is that <command>gcc</command> has found all three
182 <filename>crt*.o</filename> files under the
183 <filename class="directory">/usr/lib</filename> directory.</para>
185 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
187 xpointer="xpointer(//*[@os='g'])"/>
189 <screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
191 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
193 xpointer="xpointer(//*[@os='h'])"/>
195 <screen><computeroutput>#include <...> search starts here:
196 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
198 /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed
199 /usr/include</computeroutput></screen>
201 <para>Again, note that the directory named after your target triplet may be
202 different than the above, depending on your architecture.</para>
204 <note><para>As of version 4.3.0, GCC now unconditionally installs the
205 <filename>limits.h</filename> file into the private
206 <filename class="directory">include-fixed</filename> directory, and that
207 directory is required to be in place.</para></note>
209 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
211 xpointer="xpointer(//*[@os='i'])"/>
213 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
215 xpointer="xpointer(//*[@os='j'])"/>
217 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
219 xpointer="xpointer(//*[@os='k'])"/>
221 <screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib32")
222 SEARCH_DIR("/usr/local/lib32")
224 SEARCH_DIR("/usr/lib32")
225 SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
226 SEARCH_DIR("/usr/local/lib")
228 SEARCH_DIR("/usr/lib");</computeroutput></screen>
230 <para>A 64-bit system may see a few different directories. For example, here
231 is the output from an x86_64 machine:</para>
233 <screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
234 SEARCH_DIR("/usr/local/lib64")
236 SEARCH_DIR("/usr/lib64")
237 SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
238 SEARCH_DIR("/usr/local/lib")
240 SEARCH_DIR("/usr/lib");</computeroutput></screen>
242 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
244 xpointer="xpointer(//*[@os='l'])"/>
246 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
248 xpointer="xpointer(//*[@os='m'])"/>
250 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
252 xpointer="xpointer(//*[@os='n'])"/>
254 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
256 xpointer="xpointer(//*[@os='o'])"/>
258 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
260 xpointer="xpointer(//*[@os='p'])"/>
262 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
264 xpointer="xpointer(//*[@os='q'])"/>
266 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
268 xpointer="xpointer(//*[@os='r'])"/>
270 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
272 xpointer="xpointer(//*[@os='s'])"/>
274 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
276 xpointer="xpointer(//*[@os='t'])"/>
278 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
280 xpointer="xpointer(//*[@os='u'])"/>
282 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
284 xpointer="xpointer(//*[@os='v'])"/>
286 <para>Finally, move a misplaced file:</para>
288 <screen><userinput remap="install">mkdir -pv /usr/share/gdb/auto-load/usr/lib
289 mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib</userinput></screen>
293 <sect2 id="contents-gcc" role="content">
294 <title>Contents of GCC</title>
297 <segtitle>Installed programs</segtitle>
298 <segtitle>Installed libraries</segtitle>
299 <segtitle>Installed directories</segtitle>
302 <seg>c++, cc (link to gcc), cpp, g++, gcc,
303 gcc-ar, gcc-nm, gcc-ranlib, and gcov</seg>
305 <seg>libasan.{a,so}, libatomic.{a,so}, libgcc.a, libgcc_eh.a,
306 libgcc_s.so, libgcov.a, libgomp.{a,so}, libiberty.a, libitm.{a,so},
308 libquadmath.{a,so}, libssp.{a,so},
309 libssp_nonshared.a, libstdc++.{a,so}, libsupc++.a, and libtsan.{a,so}</seg>
311 <seg>/usr/include/c++, /usr/lib/gcc, /usr/libexec/gcc, and
312 /usr/share/gcc-&gcc-version;</seg>
317 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
318 <?dbfo list-presentation="list"?>
319 <?dbhtml list-presentation="table"?>
321 <varlistentry id="c">
322 <term><command>c++</command></term>
324 <para>The C++ compiler</para>
325 <indexterm zone="ch-system-gcc c">
326 <primary sortas="b-c++">c++</primary>
331 <varlistentry id="cc">
332 <term><command>cc</command></term>
334 <para>The C compiler</para>
335 <indexterm zone="ch-system-gcc cc">
336 <primary sortas="b-cc">cc</primary>
341 <varlistentry id="cpp">
342 <term><command>cpp</command></term>
344 <para>The C preprocessor; it is used by the compiler to expand the
345 #include, #define, and similar statements in the source files</para>
346 <indexterm zone="ch-system-gcc cpp">
347 <primary sortas="b-cpp">cpp</primary>
352 <varlistentry id="g">
353 <term><command>g++</command></term>
355 <para>The C++ compiler</para>
356 <indexterm zone="ch-system-gcc g">
357 <primary sortas="b-g++">g++</primary>
362 <varlistentry id="gcc">
363 <term><command>gcc</command></term>
365 <para>The C compiler</para>
366 <indexterm zone="ch-system-gcc gcc">
367 <primary sortas="b-gcc">gcc</primary>
372 <varlistentry id="gcc-ar">
373 <term><command>gcc-ar</command></term>
375 <para>A wrapper around <command>ar</command> that adds a
376 plugin to the command line. This program is only used
377 to add "link time optimization" and is not useful with the
378 default build options</para>
379 <indexterm zone="ch-system-gcc gcc-ar">
380 <primary sortas="b-gcc-ar">gc-ar</primary>
385 <varlistentry id="gcc-nm">
386 <term><command>gcc-nm</command></term>
388 <para>A wrapper around <command>nm</command> that adds a
389 plugin to the command line. This program is only used
390 to add "link time optimization" and is not useful with the
391 default build options</para>
392 <indexterm zone="ch-system-gcc gcc-nm">
393 <primary sortas="b-gcc-nm">gc-nm</primary>
398 <varlistentry id="gcc-ranlib">
399 <term><command>gcc-ranlib</command></term>
401 <para>A wrapper around <command>ranlib</command> that adds a
402 plugin to the command line. This program is only used
403 to add "link time optimization" and is not useful with the
404 default build options</para>
405 <indexterm zone="ch-system-gcc gcc-ranlib">
406 <primary sortas="b-gcc-ranlib">gc-ranlib</primary>
411 <varlistentry id="gcov">
412 <term><command>gcov</command></term>
414 <para>A coverage testing tool; it is used to analyze programs to
415 determine where optimizations will have the most effect</para>
416 <indexterm zone="ch-system-gcc gcov">
417 <primary sortas="b-gcov">gcov</primary>
422 <varlistentry id="libasan">
423 <term><command>libasan</command></term>
425 <para>The Address Sanitizer runtime library</para>
426 <indexterm zone="ch-system-gcc libasan">
427 <primary sortas="b-libasan">libasan</primary>
432 <varlistentry id="libgcc">
433 <term><filename class="libraryfile">libgcc</filename></term>
435 <para>Contains run-time support for <command>gcc</command></para>
436 <indexterm zone="ch-system-gcc libgcc">
437 <primary sortas="c-libgcc">libgcc</primary>
442 <varlistentry id="libgcov">
443 <term><filename class="libraryfile">libgcov</filename></term>
445 <para>This library is linked in to a program when GCC is instructed
446 to enable profiling</para>
447 <indexterm zone="ch-system-gcc libgcov">
448 <primary sortas="c-libgcov">libgcov</primary>
453 <varlistentry id="libgomp">
454 <term><filename class="libraryfile">libgomp</filename></term>
456 <para>GNU implementation of the OpenMP API for multi-platform
457 shared-memory parallel programming in C/C++ and Fortran</para>
458 <indexterm zone="ch-system-gcc libgomp">
459 <primary sortas="c-libgomp">libgomp</primary>
464 <varlistentry id="libiberty">
465 <term><filename class="libraryfile">libiberty</filename></term>
467 <para>Contains routines used by various GNU programs, including
468 <command>getopt</command>, <command>obstack</command>,
469 <command>strerror</command>, <command>strtol</command>, and
470 <command>strtoul</command></para>
471 <indexterm zone="ch-system-gcc libiberty">
472 <primary sortas="c-libiberty">libiberty</primary>
477 <varlistentry id="liblto_plugin">
478 <term><filename class="libraryfile">liblto_plugin</filename></term>
480 <para>GCC's Link Time Optimization (LTO) plugin allows GCC to perform
481 optimizations across compilation units</para>
482 <indexterm zone="ch-system-gcc liblto_plugin">
483 <primary sortas="c-liblto_plugin">liblto_plugin</primary>
488 <varlistentry id="libquadmath">
489 <term><filename class="libraryfile">libquadmath</filename></term>
491 <para>GCC Quad Precision Math Library API</para>
492 <indexterm zone="ch-system-gcc libquadmath">
493 <primary sortas="c-libquadmath">libquadmath</primary>
498 <varlistentry id="libssp">
499 <term><filename class="libraryfile">libssp</filename></term>
501 <para>Contains routines supporting GCC's stack-smashing protection
503 <indexterm zone="ch-system-gcc libssp">
504 <primary sortas="c-libssp">libssp</primary>
509 <varlistentry id="libstdc">
510 <term><filename class="libraryfile">libstdc++</filename></term>
512 <para>The standard C++ library</para>
513 <indexterm zone="ch-system-gcc libstdc">
514 <primary sortas="c-libstdc++">libstdc++</primary>
519 <varlistentry id="libsupc">
520 <term><filename class="libraryfile">libsupc++</filename></term>
522 <para>Provides supporting routines for the C++ programming
524 <indexterm zone="ch-system-gcc libsupc">
525 <primary sortas="c-libsupc++">libsupc++</primary>
530 <varlistentry id="libtsan">
531 <term><filename class="libraryfile">libtsan</filename></term>
533 <para>The Thread Sanitizer runtime library</para>
534 <indexterm zone="ch-system-gcc libtsan">
535 <primary sortas="c-libtsan">libtsan</primary>