<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../../general.ent">
  %general-entities;
]>

<sect1 id="ch-system-gcc" role="wrap">
  <?dbhtml filename="gcc.html"?>

  <title>GCC-&gcc-version;</title>

  <indexterm zone="ch-system-gcc">
    <primary sortas="a-GCC">GCC</primary>
  </indexterm>

  <sect2 role="package">
    <title/>

    <para>The GCC package contains the GNU compiler collection, which includes
    the C and C++ compilers.</para>

  </sect2>

  <sect2 role="installation">
    <title>Installation of GCC</title>

<!--GCC Branch Update Area
    <para os="p1">The following patch contains a number of updates to the
    &gcc-version; branch by the GCC developers:</para>

<screen os="p2"><userinput>patch -Np1 -i ../&gcc-branch_update-patch;</userinput></screen>
-->

    <para os="fix1">Apply a <command>sed</command> substitution that will
    suppress the execution of the <command>fixincludes</command> script:</para>

<screen os="fix2"><userinput>sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in</userinput></screen>

    <para os="f">The GCC documentation recommends building GCC outside of the source
    directory in a dedicated build directory:</para>

<screen os="g"><userinput>mkdir -v ../gcc-build
cd ../gcc-build</userinput></screen>

    <para os="h">Prepare GCC for compilation:</para>

<screen os="i"><userinput>SED=sed CC="gcc -isystem /usr/include" \
CXX="g++ -isystem /usr/include" \
LDFLAGS="-Wl,-rpath-link,/usr/lib:/lib" \
../gcc-&gcc-version;/configure \
    --prefix=/usr \
    --libexecdir=/usr/lib \
    --enable-languages=c,c++ \
    --disable-multilib \
    --with-system-zlib \
    --enable-install-libiberty \
    --disable-bootstrap</userinput></screen>

    <variablelist os="i1">
      <title>The meaning of the new configure options:</title>

      <varlistentry>
        <term><parameter>SED=sed</parameter></term>
        <listitem>
          <para>This prevents a hard-coded path to
          <filename>/tools/bin/sed</filename> in the <command>fixincl</command>
          program.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--disable-bootstrap</parameter></term>
        <listitem>
          <para>For a native build, GCC defaults to performing a 3-stage
          "bootstrap" of the compiler. This means that GCC is compiled a total
          of 3 times - it is compiled once, the first stage compiler is used
          to build itself again, and the second stage compiler builds itself
          once more. The second and third passes are then compared, verifying
          that GCC is able to reproduce itself successfully. However, there is
          no need for this with the CLFS build process so we disable it here.</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para os="j">Compile the package:</para>

<screen os="k"><userinput>make</userinput></screen>

    <important os="l">
      <para>Due to GCC's critical role in a properly functioning system,
      the CLFS developers strongly recommend running the testsuite.</para>
    </important>

   <para os="s1">Increase the stack size prior to running the tests:</para>

<screen os="s2"><userinput remap="test">ulimit -s 32768</userinput></screen>

    <para os="m">Test the results, but do not stop at errors:</para>

<screen os="n"><userinput remap="test">make -k check</userinput></screen>

    <para os="o">The <parameter>-k</parameter> flag is used to make the test suite
    run through to completion and not stop at the first failure. The GCC test
    suite is very comprehensive and is almost guaranteed to generate a few
    failures. To receive a summary of the test suite results, run:</para>

<screen os="p"><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>

    <para os="q">For only the summaries, pipe the output through
    <userinput>grep -A7 Summ</userinput>.</para>

    <para os="r">A few unexpected failures cannot always be avoided. The
    GCC developers are usually aware of these issues, but have not
    resolved them yet.</para>

    <para os="s">Install the package:</para>

<screen os="t"><userinput>make install</userinput></screen>

    <para os="w">Create a link to satisfy FHS requirements:</para>

<screen os="x"><userinput>ln -sv ../usr/bin/cpp /lib</userinput></screen>

    <para os="y">Many packages use the name <command>cc</command> to call the C
    compiler. To satisfy those packages, create a symlink:</para>

<screen os="z"><userinput>ln -sv gcc /usr/bin/cc</userinput></screen>

    <para os="aa">Finally, move a misplaced file:</para>

<screen os="ab"><userinput>mv -v /usr/lib/libstdc++*gdb.py /usr/share/gdb/auto-load/usr/lib</userinput></screen>

  </sect2>

  <sect2 id="contents-gcc" role="content">
    <title>Contents of GCC</title>

    <segmentedlist>
      <segtitle>Installed programs</segtitle>
      <segtitle>Installed libraries</segtitle>
      <segtitle>Installed directories</segtitle>

      <seglistitem>
        <seg>c++, cc (link to gcc), cpp, g++, gcc, gcov, gcov-tool</seg>
        <seg>libasan.[a,so], libatomic.[a,so], libcc1.so, libcilkrts.[a,so],
        libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.[a,so],
        libiberty.a, libitm.[a,so], liblsan.[a,so], liblto_plugin.so,
        libquadmath.[a,so], libssp.[a,so], libssp_nonshared.a,
        libstdc++.[a,so], libsupc++.a, libtsan.[a,so], libubsan.[a,so],
        libvtv.[a,so]</seg>
        <seg>/usr/include/[c++,libiberty], /usr/lib/gcc,
        /usr/share/gcc-&gcc-version;</seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">Short Descriptions</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="cc">
        <term><command>cc</command></term>
        <listitem>
          <para>The C compiler</para>
          <indexterm zone="ch-system-gcc cc">
            <primary sortas="b-cc">cc</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="cpp">
        <term><command>cpp</command></term>
        <listitem>
          <para>The C preprocessor; it is used by the compiler to expand the
          #include, #define, and similar statements in the source files</para>
          <indexterm zone="ch-system-gcc cpp">
            <primary sortas="b-cpp">cpp</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="c">
        <term><command>c++</command></term>
        <listitem>
          <para>The C++ compiler</para>
          <indexterm zone="ch-system-gcc c">
            <primary sortas="b-c++">c++</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="g">
        <term><command>g++</command></term>
        <listitem>
          <para>The C++ compiler</para>
          <indexterm zone="ch-system-gcc g">
            <primary sortas="b-g++">g++</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="gcc">
        <term><command>gcc</command></term>
        <listitem>
          <para>The C compiler</para>
          <indexterm zone="ch-system-gcc gcc">
            <primary sortas="b-gcc">gcc</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="gcov">
        <term><command>gcov</command></term>
        <listitem>
          <para>A coverage testing tool; it is used to analyze programs to
          determine where optimizations will have the most effect</para>
          <indexterm zone="ch-system-gcc gcov">
            <primary sortas="b-gcov">gcov</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="gcovtool">
        <term><command>gcov-tool</command></term>
        <listitem>
          <para>An offline tool to handle gcda counts</para>
          <indexterm zone="ch-system-gcc gcovtool">
            <primary sortas="b-gcov-tool">gcov-tool</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libasan">
        <term><filename class="libraryfile">libasan</filename></term>
        <listitem>
          <para>The Address Sanitizer runtime library</para>
          <indexterm zone="ch-system-gcc libasan">
            <primary sortas="c-libasan">libasan</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libatomic">
        <term><filename class="libraryfile">libatomic</filename></term>
        <listitem>
          <para>A GCC support runtime library for atomic operations not
          supported by hardware</para>
          <indexterm zone="ch-system-gcc libatomic">
            <primary sortas="c-libatomic">libatomic</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libcc1">
        <term><filename class="libraryfile">libcc1</filename></term>
        <listitem>
          <para>Translates API into RPC calls</para>
          <indexterm zone="ch-system-gcc libcc1">
            <primary sortas="c-libcc1">libcc1</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libcilkrts">
        <term><filename class="libraryfile">libcilkrts</filename></term>
        <listitem>
          <para>Intel&reg; Cilk&trade; Plus runtime library</para>
          <indexterm zone="ch-system-gcc libcilkrts">
            <primary sortas="c-libcilkrts">libcilkrts</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libgcc">
        <term><filename class="libraryfile">libgcc</filename></term>
        <listitem>
          <para>Contains run-time support for <command>gcc</command></para>
          <indexterm zone="ch-system-gcc libgcc">
            <primary sortas="c-libgcc*">libgcc*</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libgcov">
        <term><filename class="libraryfile">libgcov</filename></term>
        <listitem>
          <para>Library that is linked into a program when
          <command>gcc</command> is instructed to enable profiling</para>
          <indexterm zone="ch-system-gcc libgcov">
            <primary sortas="c-libgcov">libgcov</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libgomp">
        <term><filename class="libraryfile">libgomp</filename></term>
        <listitem>
          <para>GNU implementation of the OpenMP API for multi-platform
          shared-memory parallel programming in C/C++ and Fortran</para>
          <indexterm zone="ch-system-gcc libgomp">
            <primary sortas="c-libgomp">libgomp</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libiberty">
        <term><filename class="libraryfile">libiberty</filename></term>
        <listitem>
          <para>Contains routines used by various GNU programs, including
          <command>getopt</command>, <command>obstack</command>,
          <command>strerror</command>, <command>strtol</command>, and
          <command>strtoul</command></para>
          <indexterm zone="ch-system-gcc libiberty">
            <primary sortas="c-libiberty">libiberty</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libitm">
        <term><filename class="libraryfile">libitm</filename></term>
        <listitem>
          <para>The GNU Transactional Memory Library, which provides
          transaction support for accesses to a process's memory</para>
          <indexterm zone="ch-system-gcc libitm">
            <primary sortas="c-libitm*">libitm*</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="liblsan">
        <term><filename class="libraryfile">liblsan</filename></term>
        <listitem>
          <para>The Leak Sanitizer runtime library</para>
          <indexterm zone="ch-system-gcc liblsan">
            <primary sortas="c-liblsan">liblsan</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="liblto_plugin">
        <term><filename class="libraryfile">liblto_plugin</filename></term>
        <listitem>
          <para>Runtime library for GCC's link-time optimization plugin</para>
          <indexterm zone="ch-system-gcc liblto_plugin">
            <primary sortas="c-liblto_plugin">liblto_plugin</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libquadmath">
        <term><filename class="libraryfile">libquadmath</filename></term>
        <listitem>
          <para>The GCC Quad-Precision Math Libarary API</para>
          <indexterm zone="ch-system-gcc libquadmath">
            <primary sortas="c-libquadmath*">libquadmath*</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libssp">
        <term><filename class="libraryfile">libssp</filename></term>
        <listitem>
          <para>Contains routines supporting GCC's stack-smashing protection
          functionality</para>
          <indexterm zone="ch-system-gcc libssp">
            <primary sortas="c-libssp*">libssp*</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libstdc">
        <term><filename class="libraryfile">libstdc++</filename></term>
        <listitem>
          <para>The standard C++ library</para>
          <indexterm zone="ch-system-gcc libstdc">
            <primary sortas="c-libstdc++">libstdc++</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libsupc">
        <term><filename class="libraryfile">libsupc++</filename></term>
        <listitem>
          <para>Provides supporting routines for the C++ programming
          language</para>
          <indexterm zone="ch-system-gcc libsupc">
            <primary sortas="c-libsupc++">libsupc++</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libtsan">
        <term><filename class="libraryfile">libtsan</filename></term>
        <listitem>
          <para>The Thread Sanitizer runtime library</para>
          <indexterm zone="ch-system-gcc libtsan">
            <primary sortas="c-libtsan">libtsan</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libubsan">
        <term><filename class="libraryfile">libubsan</filename></term>
        <listitem>
          <para>The Undefined Behavior Sanitizer runtime library</para>
          <indexterm zone="ch-system-gcc libubsan">
            <primary sortas="c-libubsan">libubsan</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libvtv">
        <term><filename class="libraryfile">libvtv</filename></term>
        <listitem>
          <para>The Virtual Table Verification runtime library</para>
          <indexterm zone="ch-system-gcc libvtv">
            <primary sortas="c-libvtv">libvtv</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>
