source: chapter05/gcc-pass1.xml@ ee1a413

multilib-10.1 multilib-before-cross
Last change on this file since ee1a413 was ee1a413, checked in by Thomas Trepl <thomas@…>, 3 years ago

Change profiling attribute to enable selection of m32 and/or mx32. Fixes #4452.

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

  • Property mode set to 100644
File size: 14.5 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</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="../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
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
52 <para arch="ml_32,ml_x32,ml_all">GCC now requires the GMP, ISL, MPFR, and MPC packages.
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>
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
64<screen arch="default"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
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>
70<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
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>
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}
88 sed -e 's@/lib\(64\)\?\(32\)\?\(x32\)\?/ld@/tools&amp;@g' \
89 -e 's@/usr@/tools@g' $file.orig &gt; $file
90 echo '
91#undef STANDARD_STARTFILE_PREFIX_1
92#undef STANDARD_STARTFILE_PREFIX_2
93#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
94#define STANDARD_STARTFILE_PREFIX_2 ""' &gt;&gt; $file
95 touch $file.orig
96done</userinput></screen>
97
98 <para>In case the above seems hard to follow, let's break it down a bit.
99 First we copy the files <filename>gcc/config/linux.h</filename>,
100 <filename>gcc/config/i386/linux.h</filename>, and
101 <filename>gcc/config/i368/linux64.h</filename> to a file of
102 the same name but with an added suffix of <quote>.orig</quote>. Then the
103 first sed expression prepends <quote>/tools</quote> to every instance of
104 <quote>/lib/ld</quote>, <quote>/lib64/ld</quote> or
105 <quote>/lib32/ld</quote>, while the second one replaces hard-coded
106 instances of <quote>/usr</quote>. Next, we add our define statements which
107 alter the default startfile prefix to the end of the file. Note that the
108 trailing <quote>/</quote> in <quote>/tools/lib/</quote> is required.
109 Finally, we use <command>touch</command> to update the timestamp on the
110 copied files. When used in conjunction with <command>cp -u</command>, this
111 prevents unexpected changes to the original files in case the commands are
112 inadvertently run twice.</para>
113
114 <para arch="default">Finally, on x86_64 hosts, set the default directory
115 name for 64-bit libraries to <quote>lib</quote>:</para>
116
117<screen arch="default"><userinput remap="pre">case $(uname -m) in
118 x86_64)
119 sed -e '/m64=/s/lib64/lib/' \
120 -i.orig gcc/config/i386/t-linux64
121 ;;
122esac</userinput></screen>
123
124<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">sed -e '/m64=/s/lib64/lib/' \
125 -i.orig gcc/config/i386/t-linux64
126cat > gcc/config/i386/t-linux64 &lt;&lt;"EOF"
127comma=,
128MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
129MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
130MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu)
131MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu)
132MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
133EOF</userinput></screen>
134
135<!--
136 <para>GCC doesn't detect stack protection correctly, which causes problems
137 for the build of Glibc-&glibc-version;, so fix that by issuing the following
138 command:</para>
139
140<screen><userinput remap="pre">sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure</userinput></screen>
141-->
142
143<!--
144 <para>Also fix a problem identified upstream:</para>
145
146<screen><userinput remap="pre">sed -i 's/if \((code.*))\)/if (\1 \&amp;\&amp; \!DEBUG_INSN_P (insn))/' gcc/sched-deps.c</userinput></screen>
147-->
148
149 <!-- Following patch might be obsolete with gcc >= 8.2.1 -->
150 <!-- see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86724 -->
151 <!-- Fix applied in ch5-gcc-pass{1,2}, ch6-gcc -->
152 <para arch="ml_32,ml_x32,ml_all">Fix an issue with isl-&isl-version;:</para>
153
154<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;" \
155 -i gcc/graphite.h</userinput></screen>
156
157 <para>The GCC documentation recommends building GCC
158 in a dedicated build directory:</para>
159
160<screen><userinput remap="pre">mkdir -v build
161cd build</userinput></screen>
162
163 <para>Prepare GCC for compilation:</para>
164
165<screen arch="default"><userinput remap="configure">../configure \
166 --target=$LFS_TGT \
167 --prefix=/tools \
168 --with-glibc-version=2.11 \
169 --with-sysroot=$LFS \
170 --with-newlib \
171 --without-headers \
172 --with-local-prefix=/tools \
173 --with-native-system-header-dir=/tools/include \
174 --disable-nls \
175 --disable-shared \
176 --disable-multilib \
177 --disable-decimal-float \
178 --disable-threads \
179 --disable-libatomic \
180 --disable-libgomp \
181 --disable-libmpx \
182 --disable-libquadmath \
183 --disable-libssp \
184 --disable-libvtv \
185 --disable-libstdcxx \
186 --enable-languages=c,c++</userinput></screen>
187
188<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">mlist="m64"</userinput>
189<userinput arch="ml_32,ml_all" remap="configure">mlist="$mlist,m32"</userinput>
190<userinput arch="ml_x32,ml_all" remap="configure">mlist="$mlist,mx32"</userinput>
191<userinput remap="configure">../configure \
192 --target=$LFS_TGT \
193 --prefix=/tools \
194 --with-glibc-version=2.11 \
195 --with-sysroot=$LFS \
196 --with-newlib \
197 --without-headers \
198 --with-local-prefix=/tools \
199 --with-native-system-header-dir=/tools/include \
200 --disable-nls \
201 --disable-shared \
202 --enable-multilib \
203 --with-multilib-list=$mlist \
204 --disable-decimal-float \
205 --disable-threads \
206 --disable-libatomic \
207 --disable-libgomp \
208 --disable-libmpx \
209 --disable-libquadmath \
210 --disable-libssp \
211 --disable-libvtv \
212 --disable-libstdcxx \
213 --enable-languages=c,c++</userinput></screen>
214
215 <variablelist>
216 <title>The meaning of the configure options:</title>
217
218 <varlistentry>
219 <term><parameter>--with-newlib</parameter></term>
220 <listitem>
221 <para>Since a working C library is not yet available, this ensures
222 that the inhibit_libc constant is defined when building libgcc. This prevents
223 the compiling of any code that requires libc support.</para>
224 </listitem>
225 </varlistentry>
226
227 <varlistentry>
228 <term><parameter>--without-headers</parameter></term>
229 <listitem>
230 <para>When creating a complete cross-compiler, GCC requires
231 standard headers compatible with the target system. For our
232 purposes these headers will not be needed. This switch prevents
233 GCC from looking for them.</para>
234 </listitem>
235 </varlistentry>
236
237 <varlistentry>
238 <term><parameter>--with-local-prefix=/tools</parameter></term>
239 <listitem>
240 <para>The local prefix is the location in the system that GCC will search
241 for locally installed include files. The default is <filename>/usr/local</filename>.
242 Setting this to <filename>/tools</filename> helps keep the host location of
243 <filename>/usr/local</filename> out of this GCC's search path.</para>
244 </listitem>
245 </varlistentry>
246
247 <varlistentry>
248 <term><parameter>--with-native-system-header-dir=/tools/include</parameter></term>
249 <listitem>
250 <para>By default GCC searches <filename>/usr/include</filename> for
251 system headers. In conjunction with the sysroot switch, this would
252 normally translate to <filename>$LFS/usr/include</filename>. However
253 the headers that will be installed in the next two sections will go
254 to <filename>$LFS/tools/include</filename>. This switch ensures that
255 gcc will find them correctly. In the second pass of GCC, this same
256 switch will ensure that no headers from the host system are
257 found.</para>
258 </listitem>
259 </varlistentry>
260
261 <varlistentry>
262 <term><parameter>--disable-shared</parameter></term>
263 <listitem>
264 <para>This switch forces GCC to link its internal libraries
265 statically. We do this to avoid possible issues with the host
266 system.</para>
267 </listitem>
268 </varlistentry>
269
270 <varlistentry>
271 <term><parameter>--disable-decimal-float, --disable-threads,
272 --disable-libatomic, --disable-libgomp, --disable-libmpx,
273 --disable-libquadmath, --disable-libssp, --disable-libvtv,
274 --disable-libstdcxx</parameter></term>
275 <listitem>
276 <para>These switches disable support for the decimal floating point
277 extension, threading, libatomic, libgomp, libmpx, libquadmath, libssp,
278 libvtv, and the C++ standard library respectively. These features
279 will fail to compile when building a cross-compiler and are not
280 necessary for the task of cross-compiling the temporary libc.</para>
281 </listitem>
282 </varlistentry>
283
284 <varlistentry arch="default">
285 <term><parameter>--disable-multilib</parameter></term>
286 <listitem>
287 <para>On x86_64, LFS does not yet support a multilib configuration.
288 This switch is harmless for x86.</para>
289 </listitem>
290 </varlistentry>
291
292 <varlistentry arch="ml_32,ml_x32,ml_all">
293 <term><parameter>--enable-multilib,
294 --with-multilib-list=m32,m64,mx32</parameter></term>
295 <listitem>
296 <para>LFS now supports a multilib configuration. Enable it for the
297 32bit, the 64-bit, and the mixed mode.</para>
298 </listitem>
299 </varlistentry>
300
301 <varlistentry>
302 <term><parameter>--enable-languages=c,c++</parameter></term>
303 <listitem>
304 <para>This option ensures that only the C and C++ compilers are built.
305 These are the only languages needed now.</para>
306 </listitem>
307 </varlistentry>
308
309 </variablelist>
310
311 <para>Compile GCC by running:</para>
312
313<screen><userinput remap="make">make</userinput></screen>
314
315 <para>Compilation is now complete. At this point, the test suite would
316 normally be run, but, as mentioned before, the test suite framework is
317 not in place yet. The benefits of running the tests at this point
318 are minimal since the programs from this first pass will soon be
319 replaced.</para>
320
321 <para>Install the package:</para>
322
323<screen><userinput remap="install">make install</userinput></screen>
324<!--
325 <para>Using <parameter>- -disable-shared</parameter> means that the
326 <filename>libgcc_eh.a</filename> file isn't created and installed. The
327 Glibc package depends on this library as it uses
328 <parameter>-lgcc_eh</parameter> within its build system. This dependency
329 can be satisfied by creating a symlink to <filename>libgcc.a</filename>,
330 since that file will end up containing the objects normally contained in
331 <filename>libgcc_eh.a</filename>:</para>
332
333<screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&amp;_eh/'`</userinput></screen>
334-->
335 </sect2>
336
337 <sect2 role="content">
338 <title/>
339
340 <para>Details on this package are located in
341 <xref linkend="contents-gcc" role="."/></para>
342
343 </sect2>
344
345</sect1>
Note: See TracBrowser for help on using the repository browser.