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

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

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

  <indexterm zone="ch-cross-tools-gcc-static">
    <primary sortas="a-GCC">GCC</primary>
    <secondary>cross tools, static</secondary>
  </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 Cross GCC Compiler with Static libgcc
    and no Threads</title>

    <para os="p1">To make sure that a couple of tools use the proper syntax,
    apply the following patch:</para>

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

    <para os="p3">Now since we using uClibc, we need to patch GCC to recognize
    this fact:</para>

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

    <para os="p5">The following patch fixes the searching of multilib dirs for
    specs file.The patch standardizes the gcc drivers path iteration functions,
    ensuring multilib directories are searched in the correct order. This fixes
    various issues, most noticably with libtool on multilib systems:</para>

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

    <para os="p7">The following patch ensures that <command>gcc</command> does not
    search the <filename class="directory">/usr</filename> directory for
    <filename class="libraryfile">libgcc_s.so</filename> when
    cross-compiling:</para>

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

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

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

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

<screen os="ae"><userinput>../gcc-&gcc-version;/configure --prefix=${CLFS}/cross-tools \
    --host=${CLFS_HOST} --target=${CLFS_TARGET} --disable-multilib \
    --with-sysroot=${CLFS} --disable-nls --disable-shared \
    --enable-languages=c</userinput></screen>

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

      <varlistentry>
        <term><parameter>--disable-shared</parameter></term>
        <listitem>
          <para>Disables the creation of the shared libraries.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--disable-threads</parameter></term>
        <listitem>
          <para>This will prevent GCC from looking for the multi-thread
          include files, since they haven't been created for this architecture
          yet. GCC will be able to find the multi-thread information after
          the Glibc headers are created.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--enable-languages=c</parameter></term>
        <listitem>
          <para>This option ensures that only the C compiler is built.</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para os="ag">Continue with compiling the package:</para>

<screen os="ah"><userinput>make all-gcc</userinput></screen>

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

<screen os="aj"><userinput>make install-gcc</userinput></screen>

  </sect2>

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

    <para>Details on this package are located in <xref
    linkend="contents-gcc" role="."/></para>

  </sect2>

</sect1>
