source: chapter05/gcc-pass1.xml@ 1a76da0

multilib
Last change on this file since 1a76da0 was 1a76da0, checked in by Thomas Trepl (Moody) <thomas@…>, 18 months ago

Automatic merge of trunk into multilib

  • Property mode set to 100644
File size: 10.3 KB
Line 
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">
5 %general-entities;
6]>
7
8<sect1 id="ch-tools-gcc-pass1" role="wrap" xreflabel="gcc-pass1">
9 <?dbhtml filename="gcc-pass1.html"?>
10
11 <sect1info condition="script">
12 <productname>gcc-pass1</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
15 </sect1info>
16
17 <title>GCC-&gcc-version; - Pass 1</title>
18
19 <indexterm zone="ch-tools-gcc-pass1">
20 <primary sortas="a-GCC">GCC</primary>
21 <secondary>tools, pass 1</secondary>
22 </indexterm>
23
24 <sect2 role="package">
25 <title/>
26
27 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
28 href="../chapter08/gcc.xml"
29 xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
30
31 <segmentedlist>
32 <segtitle>&buildtime;</segtitle>
33 <segtitle>&diskspace;</segtitle>
34
35 <seglistitem>
36 <seg>&gcc-tmpp1-sbu;</seg>
37 <seg>&gcc-tmpp1-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Cross GCC</title>
45
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
50 use them:</para>
51
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-&gcc-version; 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>
57
58<screen><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
59mv -v mpfr-&mpfr-version; mpfr
60tar -xf ../gmp-&gmp-version;.tar.xz
61mv -v gmp-&gmp-version; gmp
62tar -xf ../mpc-&mpc-version;.tar.gz
63mv -v mpc-&mpc-version; mpc</userinput></screen>
64
65 <para arch="default">On x86_64 hosts, set the default directory name for
66 64-bit libraries to <quote>lib</quote>:</para>
67
68<screen arch="default"><userinput remap="pre">case $(uname -m) in
69 x86_64)
70 sed -e '/m64=/s/lib64/lib/' \
71 -i.orig gcc/config/i386/t-linux64
72 ;;
73esac</userinput></screen>
74
75 <para arch="ml_32,ml_x32,ml_all">Change the default directory name for
76 libraries:</para>
77
78<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
79 -e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \
80 -i.orig gcc/config/i386/t-linux64
81</userinput></screen>
82
83 <para>The GCC documentation recommends building GCC
84 in a dedicated build directory:</para>
85
86<screen><userinput remap="pre">mkdir -v build
87cd build</userinput></screen>
88
89 <para>Prepare GCC for compilation:</para>
90
91<screen arch="default"><userinput remap="configure">../configure \
92 --target=$LFS_TGT \
93 --prefix=$LFS/tools \
94 --with-glibc-version=&glibc-version; \
95 --with-sysroot=$LFS \
96 --with-newlib \
97 --without-headers \
98 --enable-default-pie \
99 --enable-default-ssp \
100 --disable-nls \
101 --disable-shared \
102 --disable-multilib \
103 --disable-decimal-float \
104 --disable-threads \
105 --disable-libatomic \
106 --disable-libgomp \
107 --disable-libquadmath \
108 --disable-libssp \
109 --disable-libvtv \
110 --disable-libstdcxx \
111 --enable-languages=c,c++</userinput></screen>
112<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure"
113 arch="ml_32">mlist=m64,m32</userinput><userinput remap="configure"
114 arch="ml_x32">mlist=m64,mx32</userinput><userinput remap="configure"
115 arch="ml_all">mlist=m64,m32,mx32</userinput>
116<userinput remap="configure">../configure \
117 --target=$LFS_TGT \
118 --prefix=$LFS/tools \
119 --with-glibc-version=&glibc-version; \
120 --with-sysroot=$LFS \
121 --with-newlib \
122 --without-headers \
123 --enable-default-pie \
124 --enable-default-ssp \
125 --enable-initfini-array \
126 --disable-nls \
127 --disable-shared \
128 --enable-multilib --with-multilib-list=$mlist \
129 --disable-decimal-float \
130 --disable-threads \
131 --disable-libatomic \
132 --disable-libgomp \
133 --disable-libquadmath \
134 --disable-libssp \
135 --disable-libvtv \
136 --disable-libstdcxx \
137 --enable-languages=c,c++</userinput></screen>
138
139 <variablelist>
140 <title>The meaning of the configure options:</title>
141
142 <varlistentry>
143 <term><parameter>--with-glibc-version=&glibc-version;</parameter></term>
144 <listitem>
145 <para>This option specifies the version of Glibc which will be
146 used on the target. It is not relevant to the libc of the host
147 distro because everything compiled by pass1 GCC will run in the
148 chroot environment, which is isolated from libc of the host
149 distro.</para>
150 </listitem>
151 </varlistentry>
152
153 <varlistentry>
154 <term><parameter>--with-newlib</parameter></term>
155 <listitem>
156 <para>Since a working C library is not yet available, this ensures
157 that the inhibit_libc constant is defined when building libgcc. This prevents
158 the compiling of any code that requires libc support.</para>
159 </listitem>
160 </varlistentry>
161
162 <varlistentry>
163 <term><parameter>--without-headers</parameter></term>
164 <listitem>
165 <para>When creating a complete cross-compiler, GCC requires
166 standard headers compatible with the target system. For our
167 purposes these headers will not be needed. This switch prevents
168 GCC from looking for them.</para>
169 </listitem>
170 </varlistentry>
171
172 <varlistentry>
173 <term><parameter>--enable-default-pie and
174 --enable-default-ssp</parameter></term>
175 <listitem>
176 <para>Those switches allow GCC to compile programs with
177 some hardening security features (more information on those in
178 the <xref linkend="pie-ssp-info"/> in chapter 8) by default. The
179 are not strictly needed at this stage, since the compiler will
180 only produce temporary executables. But it is cleaner to have the
181 temporary packages be as close as possible to the final ones.
182 </para>
183 </listitem>
184 </varlistentry>
185
186 <varlistentry>
187 <term><parameter>--disable-shared</parameter></term>
188 <listitem>
189 <para>This switch forces GCC to link its internal libraries
190 statically. We need this because the shared libraries require Glibc,
191 which is not yet installed on the target system.</para>
192 </listitem>
193 </varlistentry>
194
195 <varlistentry arch="default">
196 <term><parameter>--disable-multilib</parameter></term>
197 <listitem>
198 <para>On x86_64, LFS does not support a multilib configuration.
199 This switch is harmless for x86.</para>
200 </listitem>
201 </varlistentry>
202 <varlistentry arch="ml_32,ml_x32,ml_all">
203 <term><parameter>--enable-multilib --with-multilib-list=...</parameter></term>
204 <listitem>
205 <para>LFS canbe used to support multilib. Which they are is
206 specified in the multilib list.</para>
207 </listitem>
208 </varlistentry>
209
210 <varlistentry>
211 <term><parameter>--disable-decimal-float, --disable-threads,
212 --disable-libatomic, --disable-libgomp,
213 --disable-libquadmath, --disable-libssp, --disable-libvtv,
214 --disable-libstdcxx</parameter></term>
215 <listitem>
216 <para>These switches disable support for the decimal floating point
217 extension, threading, libatomic, libgomp, libquadmath, libssp,
218 libvtv, and the C++ standard library respectively. These features
219 will fail to compile when building a cross-compiler and are not
220 necessary for the task of cross-compiling the temporary libc.</para>
221 </listitem>
222 </varlistentry>
223
224 <varlistentry>
225 <term><parameter>--enable-languages=c,c++</parameter></term>
226 <listitem>
227 <para>This option ensures that only the C and C++ compilers are built.
228 These are the only languages needed now.</para>
229 </listitem>
230 </varlistentry>
231
232 </variablelist>
233
234 <para>Compile GCC by running:</para>
235
236<screen><userinput remap="make">make</userinput></screen>
237
238 <para>Install the package:</para>
239
240 <screen><userinput remap="install">make install</userinput></screen>
241
242 <para>This build of GCC has installed a couple of internal system
243 headers. Normally one of them, <filename>limits.h</filename>, would in turn
244 include the corresponding system <filename>limits.h</filename> header, in
245 this case, <filename>$LFS/usr/include/limits.h</filename>. However, at the
246 time of this build of GCC <filename>$LFS/usr/include/limits.h</filename>
247 does not exist, so the internal header that has just been installed is a
248 partial, self-contained file and does not include the extended features of
249 the system header. This is adequate for building Glibc, but the full
250 internal header will be needed later. Create a full version of the internal
251 header using a command that is identical to what the GCC build system does
252 in normal circumstances:</para>
253
254<screen><userinput remap="install">cd ..
255cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
256 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h</userinput></screen>
257 </sect2>
258
259 <sect2 role="content">
260 <title/>
261
262 <para>Details on this package are located in
263 <xref linkend="contents-gcc" role="."/></para>
264
265 </sect2>
266
267</sect1>
Note: See TracBrowser for help on using the repository browser.