source: chapter05/gcc-pass1.xml@ 788f897

multilib-10.1
Last change on this file since 788f897 was 788f897, checked in by Thomas Trepl <thomas@…>, 4 years ago

MultiLib: Merge changes from trunk

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@11757 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 13.4 KB
RevLine 
[1fa2099]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">
[60970f9]12 <productname>gcc-pass1</productname>
[1fa2099]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="../chapter06/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-ch5p1-sbu;</seg>
37 <seg>&gcc-ch5p1-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Cross GCC</title>
45
[8eb3fe4]46 <para arch="default">GCC now requires the GMP, MPFR, and MPC packages. As
47 these packages may not be included in your host distribution, they will be
48 built with GCC. Unpack each package into the GCC source directory and
49 rename the resulting directories so the GCC build procedures will
50 automatically use them:</para>
51
[ee1a413]52 <para arch="ml_32,ml_x32,ml_all">GCC now requires the GMP, ISL, MPFR, and MPC packages.
[8eb3fe4]53 As these packages may not be included in your host distribution, they will
54 be built with GCC. Unpack each package into the GCC source directory and
55 rename the resulting directories so the GCC build procedures will
56 automatically use them:</para>
[1fa2099]57
58 <note><para>There are frequent misunderstandings about this chapter. The
59 procedures are the same as every other chapter as explained earlier (<xref
60 linkend='buildinstr'/>). First extract the gcc tarball from the sources
61 directory and then change to the directory created. Only then should you
62 proceed with the instructions below.</para></note>
63
[8eb3fe4]64<screen arch="default"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
[1fa2099]65mv -v mpfr-&mpfr-version; mpfr
66tar -xf ../gmp-&gmp-version;.tar.xz
67mv -v gmp-&gmp-version; gmp
68tar -xf ../mpc-&mpc-version;.tar.gz
69mv -v mpc-&mpc-version; mpc</userinput></screen>
[ee1a413]70<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
[8eb3fe4]71mv -v mpfr-&mpfr-version; mpfr
72tar -xf ../gmp-&gmp-version;.tar.xz
73mv -v gmp-&gmp-version; gmp
74tar -xf ../mpc-&mpc-version;.tar.gz
75mv -v mpc-&mpc-version; mpc
76tar -xf ../isl-&isl-version;.tar.xz
77mv -v isl-&isl-version; isl</userinput></screen>
[1fa2099]78
79 <para>The following command will change the location of GCC's default
80 dynamic linker to use the one installed in <filename
81 class="directory">/tools</filename>. It also removes <filename
82 class="directory">/usr/include</filename> from GCC's include search path.
83 Issue:</para>
84
85<screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
86do
87 cp -uv $file{,.orig}
[8eb3fe4]88 sed -e 's@/lib\(64\)\?\(32\)\?\(x32\)\?/ld@/tools&amp;@g' \
[1fa2099]89 -e 's@/usr@/tools@g' $file.orig &gt; $file
90 touch $file.orig
[a3df607]91done
92sed -e "/^#define[[:blank:]]*STANDARD_STARTFILE_PREFIX_1/ s;\".*\";\"/tools/lib/\";" \
93 -e "/^#define[[:blank:]]*STANDARD_STARTFILE_PREFIX_2/ s;\".*\";\"\";" \
94 -i gcc/gcc.c</userinput></screen>
[1fa2099]95
96 <para>In case the above seems hard to follow, let's break it down a bit.
97 First we copy the files <filename>gcc/config/linux.h</filename>,
98 <filename>gcc/config/i386/linux.h</filename>, and
99 <filename>gcc/config/i368/linux64.h</filename> to a file of
100 the same name but with an added suffix of <quote>.orig</quote>. Then the
101 first sed expression prepends <quote>/tools</quote> to every instance of
102 <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or
103 <quote>/lib32/ld</quote>, while the second one replaces hard-coded
104 instances of <quote>/usr</quote>. Next, we add our define statements which
105 alter the default startfile prefix to the end of the file. Note that the
106 trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required.
107 Finally, we use <command>touch</command> to update the timestamp on the
108 copied files. When used in conjunction with <command>cp -u</command>, this
109 prevents unexpected changes to the original files in case the commands are
110 inadvertently run twice.</para>
111
[8eb3fe4]112 <para arch="default">Finally, on x86_64 hosts, set the default directory
113 name for 64-bit libraries to <quote>lib</quote>:</para>
[1fa2099]114
[8eb3fe4]115<screen arch="default"><userinput remap="pre">case $(uname -m) in
[1fa2099]116 x86_64)
117 sed -e '/m64=/s/lib64/lib/' \
118 -i.orig gcc/config/i386/t-linux64
119 ;;
120esac</userinput></screen>
121
[058c7ef]122<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
123 -e '/m32=/s/m32=.*/m32=..\/lib32$(call if_multiarch,:i386-linux-gnu)/' \
124 -i.orig gcc/config/i386/t-linux64</userinput></screen>
[8eb3fe4]125
[1fa2099]126<!--
127 <para>GCC doesn't detect stack protection correctly, which causes problems
128 for the build of Glibc-&glibc-version;, so fix that by issuing the following
129 command:</para>
130
131<screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>
132-->
133
134<!--
135 <para>Also fix a problem identified upstream:</para>
136
137<screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&amp;\&amp; \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
138-->
[8eb3fe4]139
140 <!-- Following patch might be obsolete with gcc >= 8.2.1 -->
141 <!-- see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86724 -->
142 <!-- Fix applied in ch5-gcc-pass{1,2}, ch6-gcc -->
[ee1a413]143 <para arch="ml_32,ml_x32,ml_all">Fix an issue with isl-&isl-version;:</para>
[8eb3fe4]144
[ee1a413]145<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e "/#include &lt;isl\/schedule_node.h&gt;/ a#include &lt;isl/id.h&gt;\n#include &lt;isl/space.h&gt;" \
[8eb3fe4]146 -i gcc/graphite.h</userinput></screen>
147
[1fa2099]148 <para>The GCC documentation recommends building GCC
149 in a dedicated build directory:</para>
150
151<screen><userinput remap="pre">mkdir -v build
152cd build</userinput></screen>
153
154 <para>Prepare GCC for compilation:</para>
155
[01ffc23]156<screen><userinput arch="default" remap="configure">mloptions="--disable-multilib"</userinput>
157<userinput arch="ml_32,ml_x32,ml_all" remap="configure">mloptions="--enable-multilib --with-multilib-list=m64"</userinput>
158<userinput arch="ml_32,ml_all" remap="configure">mloptions="$mloptions,m32"</userinput>
159<userinput arch="ml_x32,ml_all" remap="configure">mloptions="$mloptions,mx32"</userinput>
[ee1a413]160<userinput remap="configure">../configure \
[8eb3fe4]161 --target=$LFS_TGT \
162 --prefix=/tools \
163 --with-glibc-version=2.11 \
164 --with-sysroot=$LFS \
165 --with-newlib \
166 --without-headers \
167 --with-local-prefix=/tools \
168 --with-native-system-header-dir=/tools/include \
169 --disable-nls \
170 --disable-shared \
171 --disable-decimal-float \
172 --disable-threads \
173 --disable-libatomic \
174 --disable-libgomp \
175 --disable-libquadmath \
176 --disable-libssp \
177 --disable-libvtv \
178 --disable-libstdcxx \
[01ffc23]179 --enable-languages=c,c++ \
180 $mloptions</userinput></screen>
[8eb3fe4]181
[1fa2099]182 <variablelist>
183 <title>The meaning of the configure options:</title>
184
[788f897]185 <varlistentry>
186 <term><parameter>--with-glibc-version=2.11</parameter></term>
187 <listitem>
188 <para>This option ensures the package will be compatible with the host's
189 version of glibc. It is set to the minimum glibc requirement
190 specified in the <xref linkend="ch-partitioning-hostreqs"/>.</para>
191 </listitem>
192 </varlistentry>
193
[1fa2099]194 <varlistentry>
195 <term><parameter>--with-newlib</parameter></term>
196 <listitem>
197 <para>Since a working C library is not yet available, this ensures
198 that the inhibit_libc constant is defined when building libgcc. This prevents
199 the compiling of any code that requires libc support.</para>
200 </listitem>
201 </varlistentry>
202
203 <varlistentry>
204 <term><parameter>--without-headers</parameter></term>
205 <listitem>
206 <para>When creating a complete cross-compiler, GCC requires
207 standard headers compatible with the target system. For our
208 purposes these headers will not be needed. This switch prevents
209 GCC from looking for them.</para>
210 </listitem>
211 </varlistentry>
212
213 <varlistentry>
214 <term><parameter>--with-local-prefix=/tools</parameter></term>
215 <listitem>
216 <para>The local prefix is the location in the system that GCC will search
217 for locally installed include files. The default is <filename>/usr/local</filename>.
218 Setting this to <filename>/tools</filename> helps keep the host location of
219 <filename>/usr/local</filename> out of this GCC's search path.</para>
220 </listitem>
221 </varlistentry>
222
223 <varlistentry>
224 <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>
225 <listitem>
226 <para>By default GCC searches <filename>/usr/include</filename> for
227 system headers. In conjunction with the sysroot switch, this would
228 normally translate to <filename>$LFS/usr/include</filename>. However
229 the headers that will be installed in the next two sections will go
230 to <filename>$LFS/tools/include</filename>. This switch ensures that
231 gcc will find them correctly. In the second pass of GCC, this same
232 switch will ensure that no headers from the host system are
233 found.</para>
234 </listitem>
235 </varlistentry>
236
237 <varlistentry>
238 <term><parameter>--disable-shared</parameter></term>
239 <listitem>
240 <para>This switch forces GCC to link its internal libraries
241 statically. We do this to avoid possible issues with the host
242 system.</para>
243 </listitem>
244 </varlistentry>
245
246 <varlistentry>
247 <term><parameter>--disable-decimal-float, --disable-threads,
[8c5e7286]248 --disable-libatomic, --disable-libgomp, <!--- -disable-libmpx,-->
[1fa2099]249 --disable-libquadmath, --disable-libssp, --disable-libvtv,
250 --disable-libstdcxx</parameter></term>
251 <listitem>
252 <para>These switches disable support for the decimal floating point
[8c5e7286]253 extension, threading, libatomic, libgomp, <!--libmpx, --> libquadmath, libssp,
[1fa2099]254 libvtv, and the C++ standard library respectively. These features
255 will fail to compile when building a cross-compiler and are not
256 necessary for the task of cross-compiling the temporary libc.</para>
257 </listitem>
258 </varlistentry>
259
[8eb3fe4]260 <varlistentry arch="default">
[1fa2099]261 <term><parameter>--disable-multilib</parameter></term>
262 <listitem>
263 <para>On x86_64, LFS does not yet support a multilib configuration.
264 This switch is harmless for x86.</para>
265 </listitem>
266 </varlistentry>
267
[ee1a413]268 <varlistentry arch="ml_32,ml_x32,ml_all">
[8eb3fe4]269 <term><parameter>--enable-multilib,
270 --with-multilib-list=m32,m64,mx32</parameter></term>
271 <listitem>
272 <para>LFS now supports a multilib configuration. Enable it for the
273 32bit, the 64-bit, and the mixed mode.</para>
274 </listitem>
275 </varlistentry>
276
[1fa2099]277 <varlistentry>
278 <term><parameter>--enable-languages=c,c++</parameter></term>
279 <listitem>
280 <para>This option ensures that only the C and C++ compilers are built.
281 These are the only languages needed now.</para>
282 </listitem>
283 </varlistentry>
284
285 </variablelist>
286
287 <para>Compile GCC by running:</para>
288
289<screen><userinput remap="make">make</userinput></screen>
290
291 <para>Compilation is now complete. At this point, the test suite would
292 normally be run, but, as mentioned before, the test suite framework is
293 not in place yet. The benefits of running the tests at this point
294 are minimal since the programs from this first pass will soon be
295 replaced.</para>
296
297 <para>Install the package:</para>
298
299<screen><userinput remap="install">make install</userinput></screen>
300<!--
301 <para>Using <parameter>- -disable-shared</parameter> means that the
302 <filename>libgcc_eh.a</filename> file isn't created and installed. The
303 Glibc package depends on this library as it uses
304 <parameter>-lgcc_eh</parameter> within its build system. This dependency
305 can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
306 since that file will end up containing the objects normally contained in
307 <filename>libgcc_eh.a</filename>:</para>
308
309<screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&amp;_eh/'`</userinput></screen>
310-->
311 </sect2>
312
313 <sect2 role="content">
314 <title/>
315
316 <para>Details on this package are located in
317 <xref linkend="contents-gcc" role="."/></para>
318
319 </sect2>
320
321</sect1>
Note: See TracBrowser for help on using the repository browser.