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-tools-gcc-pass1" role="wrap" xreflabel="gcc-pass1">
9 <?dbhtml filename="gcc-pass1.html"?>
11 <sect1info condition="script">
12 <productname>gcc-pass1</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
17 <title>GCC-&gcc-version; - Pass 1</title>
19 <indexterm zone="ch-tools-gcc-pass1">
20 <primary sortas="a-GCC">GCC</primary>
21 <secondary>tools, pass 1</secondary>
24 <sect2 role="package">
27 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
28 href="../chapter08/gcc.xml"
29 xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
32 <segtitle>&buildtime;</segtitle>
33 <segtitle>&diskspace;</segtitle>
36 <seg>&gcc-tmpp1-sbu;</seg>
37 <seg>&gcc-tmpp1-du;</seg>
43 <sect2 role="installation">
44 <title>Installation of Cross GCC</title>
46 <para>GCC requires the GMP, MPFR and MPC packages. As these packages may
47 not be included in your host distribution, they will be built with
48 GCC. Unpack each package into the GCC source directory and rename the
49 resulting directories so the GCC build procedures will automatically
52 <note><para>There are frequent misunderstandings about this chapter. The
53 procedures are the same as every other chapter as explained earlier (<xref
54 linkend='buildinstr'/>). First extract the gcc tarball from the sources
55 directory and then change to the directory created. Only then should you
56 proceed with the instructions below.</para></note>
58 <screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
59 mv -v mpfr-&mpfr-version; mpfr
60 tar -xf ../gmp-&gmp-version;.tar.xz
61 mv -v gmp-&gmp-version; gmp
62 tar -xf ../mpc-&mpc-version;.tar.gz
63 mv -v mpc-&mpc-version; mpc</userinput></screen>
65 <para>On x86_64 hosts, set the default directory name for
66 64-bit libraries to <quote>lib</quote>:</para>
68 <screen><userinput remap="pre">case $(uname -m) in
70 sed -e '/m64=/s/lib64/lib/' \
71 -i.orig gcc/config/i386/t-linux64
73 esac</userinput></screen>
75 <para>The GCC documentation recommends building GCC
76 in a dedicated build directory:</para>
78 <screen><userinput remap="pre">mkdir -v build
79 cd build</userinput></screen>
81 <para>Prepare GCC for compilation:</para>
83 <screen><userinput remap="configure">../configure \
86 --with-glibc-version=2.11 \
90 --enable-initfini-array \
94 --disable-decimal-float \
98 --disable-libquadmath \
101 --disable-libstdcxx \
102 --enable-languages=c,c++</userinput></screen>
104 <title>The meaning of the configure options:</title>
107 <term><parameter>--with-glibc-version=2.11</parameter></term>
109 <para>This option ensures the package will be compatible with the host's
110 version of glibc. It is set to the minimum glibc requirement
111 specified in the <xref linkend="ch-partitioning-hostreqs"/>.</para>
116 <term><parameter>--with-newlib</parameter></term>
118 <para>Since a working C library is not yet available, this ensures
119 that the inhibit_libc constant is defined when building libgcc. This prevents
120 the compiling of any code that requires libc support.</para>
125 <term><parameter>--without-headers</parameter></term>
127 <para>When creating a complete cross-compiler, GCC requires
128 standard headers compatible with the target system. For our
129 purposes these headers will not be needed. This switch prevents
130 GCC from looking for them.</para>
135 <term><parameter>--enable-initfini-array</parameter></term>
137 <para>This switch forces the use of some internal data structures
138 that are needed but cannot be detected when building a cross
144 <term><parameter>--disable-shared</parameter></term>
146 <para>This switch forces GCC to link its internal libraries
147 statically. We need this because the shared libraries require glibc,
148 which is not yet installed on the target system.</para>
153 <term><parameter>--disable-multilib</parameter></term>
155 <para>On x86_64, LFS does not support a multilib configuration.
156 This switch is harmless for x86.</para>
161 <term><parameter>--disable-decimal-float, --disable-threads,
162 --disable-libatomic, --disable-libgomp,
163 --disable-libquadmath, --disable-libssp, --disable-libvtv,
164 --disable-libstdcxx</parameter></term>
166 <para>These switches disable support for the decimal floating point
167 extension, threading, libatomic, libgomp, libquadmath, libssp,
168 libvtv, and the C++ standard library respectively. These features
169 will fail to compile when building a cross-compiler and are not
170 necessary for the task of cross-compiling the temporary libc.</para>
175 <term><parameter>--enable-languages=c,c++</parameter></term>
177 <para>This option ensures that only the C and C++ compilers are built.
178 These are the only languages needed now.</para>
184 <para>Compile GCC by running:</para>
186 <screen><userinput remap="make">make</userinput></screen>
188 <para>Install the package:</para>
190 <screen><userinput remap="install">make install</userinput></screen>
192 <para>This build of GCC has installed a couple of internal system
193 headers. Normally one of them, <filename>limits.h</filename>, would in turn
194 include the corresponding system <filename>limits.h</filename> header, in
195 this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
196 time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
197 does not exist, so the internal header that has just been installed is a
198 partial, self-contained file and does not include the extended features of
199 the system header. This is adequate for building glibc, but the full
200 internal header will be needed later. Create a full version of the internal
201 header using a command that is identical to what the GCC build system does
202 in normal circumstances:</para>
204 <screen><userinput remap="install">cd ..
205 cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
206 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
209 <sect2 role="content">
212 <para>Details on this package are located in
213 <xref linkend="contents-gcc" role="."/></para>