aboutsummaryrefslogtreecommitdiffstats
path: root/chapter05/gcc-pass1.xml
blob: 31703a1848b3d676db649c9d0b5cb1cfa31c658f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?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-tools-gcc-pass1" role="wrap">
  <?dbhtml filename="gcc-pass1.html"?>

  <sect1info condition="script">
    <productname>gcc</productname>
    <productnumber>&gcc-version;</productnumber>
    <address>&gcc-url;</address>
  </sect1info>

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

  <indexterm zone="ch-tools-gcc-pass1">
    <primary sortas="a-GCC">GCC</primary>
    <secondary>tools, pass 1</secondary>
  </indexterm>

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

    <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
    href="../chapter06/gcc.xml"
    xpointer="xpointer(/sect1/sect2[1]/para[1])"/>

    <segmentedlist>
      <segtitle>&buildtime;</segtitle>
      <segtitle>&diskspace;</segtitle>

      <seglistitem>
        <seg>&gcc-ch5p1-sbu;</seg>
        <seg>&gcc-ch5p1-du;</seg>
      </seglistitem>
    </segmentedlist>

  </sect2>

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

    <para>GCC now requires the GMP, MPFR and MPC packages. As these packages may
    not be included in your host distribution, they will be built with
    GCC.  Unpack each package into the GCC source directory and rename the
    resulting directories so the GCC build procedures will automatically
    use them:</para>

    <note><para>There are frequent misunderstandings about this chapter.  The
    procedures are the same as every other chapter as explained earlier (<xref
    linkend='buildinstr'/>).  First extract the gcc tarball from the sources
    directory and then change to the directory created.  Only then should you
    proceed with the instructions below.</para></note>

<screen><userinput remap="pre">tar -jxf ../mpfr-&mpfr-version;.tar.bz2
mv -v mpfr-&mpfr-version; mpfr
tar -Jxf ../gmp-&gmp-version;.tar.xz
mv -v gmp-&gmp-version; gmp
tar -zxf ../mpc-&mpc-version;.tar.gz
mv -v mpc-&mpc-version; mpc</userinput></screen>

<para>Apply a patch that will allow the building of the libiberty and zlib
target libraries to be disabled as these do not build correctly in a
cross-compiled environment:</para>

<screen><userinput remap="pre">patch -Np1 -i ../&gcc-crosscompile-patch;</userinput></screen>

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

<screen><userinput remap="pre">mkdir -v ../gcc-build
cd ../gcc-build</userinput></screen>

    <para>Prepare GCC for compilation:</para>

<screen><userinput remap="configure">../gcc-&gcc-version;/configure \
    --target=$LFS_TGT --prefix=/tools \
    --disable-nls --disable-shared --disable-multilib \
    --disable-decimal-float --disable-threads \
    --disable-libmudflap --disable-libssp \
    --disable-libgomp --disable-libquadmath \
    --disable-target-libiberty --disable-target-zlib \
    --enable-languages=c --without-ppl --without-cloog \
    --with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \
    --with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen>

    <variablelist>
      <title>The meaning of the configure options:</title>

      <varlistentry>
        <term><parameter>--disable-shared</parameter></term>
        <listitem>
          <para>This switch forces GCC to link its internal libraries
          statically. We do this to avoid possible issues with the host
          system.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--disable-decimal-float, --disable-threads, --disable-libmudflap, --disable-libssp, --disable-libgomp, --disable-libquadmath --disable-target-libiberty --disable-target-zlib</parameter></term>
        <listitem>
          <para>These switches disable support for the decimal floating point
          extension, threading, libmudflap, libssp and libgomp, libquadmath,
          libiberty and zlib respectively. These features will fail to compile
          when building a cross-compiler and are not necessary for the task of
          cross-compiling the temporary libc.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--disable-multilib</parameter></term>
        <listitem>
          <para>On x86_64, LFS does not yet support a multilib configuration.
          This switch is harmless for x86.</para>
        </listitem>
      </varlistentry>

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

      <varlistentry>
        <term><parameter>--without-ppl, --without-cloog</parameter></term>
        <listitem>
          <para>These switches prevent GCC from building against the PPL and
          CLooG libraries which may be present on the host system, but will not
          be available in the chroot environment.</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para>Compile GCC by running:</para>

<screen><userinput remap="make">make</userinput></screen>

    <para>Compilation is now complete. At this point, the test suite would
    normally be run, but, as mentioned before, the test suite framework is
    not in place yet. The benefits of running the tests at this point
    are minimal since the programs from this first pass will soon be
    replaced.</para>

    <para>Install the package:</para>

<screen><userinput remap="install">make install</userinput></screen>

    <para>Using <parameter>--disable-shared</parameter> means that the
    <filename>libgcc_eh.a</filename> file isn't created and installed. The
    Glibc package depends on this library as it uses
    <parameter>-lgcc_eh</parameter> within its build system. This dependency
    can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
    since that file will end up containing the objects normally contained in
    <filename>libgcc_eh.a</filename>:</para>

<screen><userinput remap="install">ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
    sed 's/libgcc/&amp;_eh/'`</userinput></screen>

  </sect2>

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

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

  </sect2>

</sect1>