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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
<?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" xreflabel="gcc-pass1">
<?dbhtml filename="gcc-pass1.html"?>
<sect1info condition="script">
<productname>gcc-pass1</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="../chapter08/gcc.xml"
xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
<segmentedlist>
<segtitle>&buildtime;</segtitle>
<segtitle>&diskspace;</segtitle>
<seglistitem>
<seg>&gcc-tmpp1-sbu;</seg>
<seg>&gcc-tmpp1-du;</seg>
</seglistitem>
</segmentedlist>
</sect2>
<sect2 role="installation">
<title>Installation of Cross GCC</title>
<para>GCC 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 -xf ../mpfr-&mpfr-version;.tar.xz
mv -v mpfr-&mpfr-version; mpfr
tar -xf ../gmp-&gmp-version;.tar.xz
mv -v gmp-&gmp-version; gmp
tar -xf ../mpc-&mpc-version;.tar.gz
mv -v mpc-&mpc-version; mpc</userinput>
<userinput remap="pre" arch="ml_32,ml_x32,ml_all">tar -xf ../isl-&isl-version;.tar.xz
mv -v isl-&isl-version; isl</userinput></screen>
<para arch="default">On x86_64 hosts, set the default directory name for
64-bit libraries to <quote>lib</quote>:</para>
<screen arch="default"><userinput remap="pre">case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
esac</userinput></screen>
<para arch="ml_32,ml_x32,ml_all">Change the default directory name for
libraries:</para>
<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
-e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \
-i.orig gcc/config/i386/t-linux64
</userinput></screen>
<para>The GCC documentation recommends building GCC
in a dedicated build directory:</para>
<screen><userinput remap="pre">mkdir -v build
cd build</userinput></screen>
<para>Prepare GCC for compilation:</para>
<screen arch="default"><userinput remap="configure">../configure \
--target=$LFS_TGT \
--prefix=$LFS/tools \
--with-glibc-version=2.11 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
--enable-initfini-array \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++</userinput></screen>
<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure"
arch="ml_32">mlist=m64,m32</userinput><userinput remap="configure"
arch="ml_x32">mlist=m64,mx32</userinput><userinput remap="configure"
arch="ml_all">mlist=m64,m32,mx32</userinput>
<userinput remap="configure">../configure \
--target=$LFS_TGT \
--prefix=$LFS/tools \
--with-glibc-version=2.11 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
--enable-initfini-array \
--disable-nls \
--disable-shared \
--enable-multilib --with-multilib-list=$mlist \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++</userinput></screen>
<variablelist>
<title>The meaning of the configure options:</title>
<varlistentry>
<term><parameter>--with-glibc-version=2.11</parameter></term>
<listitem>
<para>This option ensures the package will be compatible with the host's
version of glibc. It is set to the minimum glibc requirement
specified in the <xref linkend="ch-partitioning-hostreqs"/>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--with-newlib</parameter></term>
<listitem>
<para>Since a working C library is not yet available, this ensures
that the inhibit_libc constant is defined when building libgcc. This prevents
the compiling of any code that requires libc support.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--without-headers</parameter></term>
<listitem>
<para>When creating a complete cross-compiler, GCC requires
standard headers compatible with the target system. For our
purposes these headers will not be needed. This switch prevents
GCC from looking for them.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--enable-initfini-array</parameter></term>
<listitem>
<para>This switch forces the use of some internal data structures
that are needed but cannot be detected when building a cross
compiler.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--disable-shared</parameter></term>
<listitem>
<para>This switch forces GCC to link its internal libraries
statically. We need this because the shared libraries require glibc,
which is not yet installed on the target system.</para>
</listitem>
</varlistentry>
<varlistentry arch="default">
<term><parameter>--disable-multilib</parameter></term>
<listitem>
<para>On x86_64, LFS does not support a multilib configuration.
This switch is harmless for x86.</para>
</listitem>
</varlistentry>
<varlistentry arch="ml_32,ml_x32,ml_all">
<term><parameter>--enable-multilib --with-multilib-list=...</parameter></term>
<listitem>
<para>LFS canbe used to support multilib. Which they are is
specified in the multilib list.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>--disable-decimal-float, --disable-threads,
--disable-libatomic, --disable-libgomp,
--disable-libquadmath, --disable-libssp, --disable-libvtv,
--disable-libstdcxx</parameter></term>
<listitem>
<para>These switches disable support for the decimal floating point
extension, threading, libatomic, libgomp, libquadmath, libssp,
libvtv, and the C++ standard library 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>--enable-languages=c,c++</parameter></term>
<listitem>
<para>This option ensures that only the C and C++ compilers are built.
These are the only languages needed now.</para>
</listitem>
</varlistentry>
</variablelist>
<para>Compile GCC by running:</para>
<screen><userinput remap="make">make</userinput></screen>
<para>Install the package:</para>
<screen><userinput remap="install">make install</userinput></screen>
<para>This build of GCC has installed a couple of internal system
headers. Normally one of them, <filename>limits.h</filename>, would in turn
include the corresponding system <filename>limits.h</filename> header, in
this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
does not exist, so the internal header that has just been installed is a
partial, self-contained file and does not include the extended features of
the system header. This is adequate for building glibc, but the full
internal header will be needed later. Create a full version of the internal
header using a command that is identical to what the GCC build system does
in normal circumstances:</para>
<screen><userinput remap="install">cd ..
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
</sect2>
<sect2 role="content">
<title/>
<para>Details on this package are located in
<xref linkend="contents-gcc" role="."/></para>
</sect2>
</sect1>
|