source: chapter05/gcc-pass2.xml@ 997d961

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

MultiLib: Merge changes from trunk

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

  • Property mode set to 100644
File size: 10.6 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-pass2" role="wrap">
9 <?dbhtml filename="gcc-pass2.html"?>
10
11 <sect1info condition="script">
12 <productname>gcc-pass2</productname>
13 <productnumber>&gcc-version;</productnumber>
14 <address>&gcc-url;</address>
15 </sect1info>
16
17 <title>GCC-&gcc-version; - Pass 2</title>
18
19 <indexterm zone="ch-tools-gcc-pass2">
20 <primary sortas="a-GCC">GCC</primary>
21 <secondary>tools, pass 2</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-ch5p2-sbu;</seg>
37 <seg>&gcc-ch5p2-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of GCC</title>
45
46 <para arch="default">As in the first build of GCC, the GMP, MPFR, and MPC packages are
47 required. Unpack the tarballs and move them into the required directory
48 names:</para>
49 <para arch="ml_32,ml_x32,ml_all">As in the first build of GCC, the GMP, MPFR, MPC and ISL packages are
50 required. Unpack the tarballs and move them into the required directory
51 names:</para>
52
53<screen arch="default"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
54mv -v mpfr-&mpfr-version; mpfr
55tar -xf ../gmp-&gmp-version;.tar.xz
56mv -v gmp-&gmp-version; gmp
57tar -xf ../mpc-&mpc-version;.tar.gz
58mv -v mpc-&mpc-version; mpc</userinput></screen>
59<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">tar -xf ../mpfr-&mpfr-version;.tar.xz
60mv -v mpfr-&mpfr-version; mpfr
61tar -xf ../gmp-&gmp-version;.tar.xz
62mv -v gmp-&gmp-version; gmp
63tar -xf ../mpc-&mpc-version;.tar.gz
64mv -v mpc-&mpc-version; mpc
65tar -xf ../isl-&isl-version;.tar.xz
66mv -v isl-&isl-version; isl</userinput></screen>
67
68 <para>Once again, change the location of GCC's default dynamic linker to
69 use the one installed in <filename
70 class="directory">/tools</filename>.</para>
71
72<screen><userinput remap="pre">for file in gcc/config/{linux,i386/linux{,64}}.h
73do
74 cp -uv $file{,.orig}
75 sed -e 's@/lib\(64\)\?\(32\)\?\(x32\)\?/ld@/tools&amp;@g' \
76 -e 's@/usr@/tools@g' $file.orig &gt; $file
77 touch $file.orig
78done
79sed -e "/^#define[[:blank:]]*STANDARD_STARTFILE_PREFIX_1/ s;\".*\";\"/tools/lib/\";" \
80 -e "/^#define[[:blank:]]*STANDARD_STARTFILE_PREFIX_2/ s;\".*\";\"\";" \
81 -i gcc/gcc.c</userinput></screen>
82
83 <para arch="default">If building on x86_64, change the default directory
84 name for 64-bit libraries to <quote>lib</quote>:</para>
85
86<screen arch="default"><userinput remap="pre">case $(uname -m) in
87 x86_64)
88 sed -e '/m64=/s/lib64/lib/' \
89 -i.orig gcc/config/i386/t-linux64
90 ;;
91esac</userinput></screen>
92
93 <para>Our first build of GCC has installed a couple of internal system
94 headers. Normally one of them, <filename>limits.h</filename>, will in turn
95 include the corresponding system <filename>limits.h</filename> header, in
96 this case, <filename>/tools/include/limits.h</filename>. However, at the
97 time of the first build of gcc <filename>/tools/include/limits.h</filename>
98 did not exist, so the internal header that GCC installed is a partial,
99 self-contained file and does not include the extended features of the
100 system header. This was adequate for building the temporary libc, but this
101 build of GCC now requires the full internal header. Create a full version
102 of the internal header using a command that is identical to what the GCC
103 build system does in normal circumstances:</para>
104
105<screen><userinput remap="pre">cat gcc/limitx.h gcc/glimits.h gcc/limity.h &gt; \
106 `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h</userinput></screen>
107<!--
108 <para>For x86 machines, the limited number of registers is a bottleneck
109 for the system. Free one up by not using a frame pointer that is not
110 needed:</para>
111
112<screen><userinput remap="pre">case `uname -m` in
113 i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in ;;
114esac</userinput></screen>
115-->
116 <para>Create a separate build directory again:</para>
117
118<screen><userinput remap="pre">mkdir -v build
119cd build</userinput></screen>
120
121 <para>Before starting to build GCC, remember to unset any environment
122 variables that override the default optimization flags.</para>
123
124 <para>Now prepare GCC for compilation:</para>
125
126<screen><userinput arch="default" remap="configure">mloptions="--disable-multilib"</userinput>
127<userinput arch="ml_32,ml_x32,ml_all" remap="configure">mloptions="--with-system-zlib --enable-multilib --with-multilib-list=m64"</userinput>
128<userinput arch="ml_32,ml_all" remap="configure">mloptions="$mloptions,m32"</userinput>
129<userinput arch="ml_x32,ml_all" remap="configure">mloptions="$mloptions,mx32"</userinput>
130<userinput remap="configure">CC=$LFS_TGT-gcc \
131CXX=$LFS_TGT-g++ \
132AR=$LFS_TGT-ar \
133RANLIB=$LFS_TGT-ranlib \
134../configure \
135 --prefix=/tools \
136 --with-local-prefix=/tools \
137 --with-native-system-header-dir=/tools/include \
138 --enable-languages=c,c++ \
139 --disable-libstdcxx-pch \
140 --disable-bootstrap \
141 --disable-libgomp \
142 $mloptions</userinput></screen>
143
144 <variablelist>
145 <title>The meaning of the new configure options:</title>
146
147 <varlistentry>
148 <term><parameter>--enable-languages=c,c++</parameter></term>
149 <listitem>
150 <para>This option ensures that both the C and C++ compilers are
151 built.</para>
152 </listitem>
153 </varlistentry>
154
155 <varlistentry>
156 <term><parameter>--disable-libstdcxx-pch</parameter></term>
157 <listitem>
158 <para>Do not build the pre-compiled header (PCH) for
159 <filename class="libraryfile">libstdc++</filename>. It takes up a
160 lot of space, and we have no use for it.</para>
161 </listitem>
162 </varlistentry>
163
164 <varlistentry>
165 <term><parameter>--disable-bootstrap</parameter></term>
166 <listitem>
167 <para>For native builds of GCC, the default is to do a "bootstrap"
168 build. This does not just compile GCC, but compiles it several times.
169 It uses the programs compiled in a first round to compile itself a
170 second time, and then again a third time. The second and third
171 iterations are compared to make sure it can reproduce itself
172 flawlessly. This also implies that it was compiled correctly.
173 However, the LFS build method should provide a solid compiler
174 without the need to bootstrap each time.</para>
175 </listitem>
176 </varlistentry>
177
178 </variablelist>
179
180 <para>Compile the package:</para>
181
182<screen><userinput remap="make">make</userinput></screen>
183
184 <para>Install the package:</para>
185
186<screen><userinput remap="install">make install</userinput></screen>
187
188 <para>As a finishing touch, create a symlink. Many programs and scripts
189 run <command>cc</command> instead of <command>gcc</command>, which is
190 used to keep programs generic and therefore usable on all kinds of UNIX
191 systems where the GNU C compiler is not always installed. Running
192 <command>cc</command> leaves the system administrator free to decide
193 which C compiler to install:</para>
194
195<screen><userinput remap="install">ln -sv gcc /tools/bin/cc</userinput></screen>
196
197 <caution>
198 <para>At this point, it is imperative to stop and ensure that the basic
199 functions (compiling and linking) of the new toolchain are working as
200 expected. To perform a sanity check, run the following commands:</para>
201
202<screen><userinput>echo 'int main(){}' &gt; dummy.c
203cc dummy.c
204readelf -l a.out | grep ': /tools'</userinput></screen>
205
206 <para>If everything is working correctly, there should be no errors,
207 and the output of the last command will be of the form:</para>
208
209<screen><computeroutput>[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
210
211
212 <para arch="ml_32,ml_all">Repeat the test for 32-bit:</para>
213
214<screen arch="ml_32,ml_all"><userinput>cc -m32 dummy.c
215readelf -l a.out | grep ': /tools'</userinput></screen>
216
217 <para arch="ml_32,ml_all">In this case, the output shoud be:</para>
218
219<screen arch="ml_32,ml_all"><computeroutput>[Requesting program interpreter: /tools/lib/ld-linux.so.2]</computeroutput></screen>
220
221 <para arch="ml_x32,ml_all">Repeat the test for x32-bit:</para>
222
223<screen arch="ml_x32,ml_all"><userinput>cc -mx32 dummy.c
224readelf -l a.out | grep ': /tools'</userinput></screen>
225
226 <para arch="ml_x32,ml_all">In this case, the output shoud be:</para>
227
228<screen arch="ml_x32,ml_all"><computeroutput>[Requesting program interpreter: /tools/libx32/ld-linux-x32.so.2]</computeroutput></screen>
229
230 <para arch="default">Note that the dynamic linker will be
231 /tools/lib/ld-linux.so.2 for 32-bit machines.</para>
232
233 <para>If the output is not shown as above or there was no output at all,
234 then something is wrong. Investigate and retrace the steps to find out
235 where the problem is and correct it. This issue must be resolved before
236 continuing on. First, perform the sanity check again, using
237 <command>gcc</command> instead of <command>cc</command>. If this works,
238 then the <filename class="symlink">/tools/bin/cc</filename> symlink is
239 missing. Install the symlink as per above.
240 Next, ensure that the <envar>PATH</envar> is correct. This
241 can be checked by running <command>echo $PATH</command> and verifying that
242 <filename class="directory">/tools/bin</filename> is at the head of the
243 list. If the <envar>PATH</envar> is wrong it could mean that you are not
244 logged in as user <systemitem class="username">lfs</systemitem> or that
245 something went wrong back in <xref linkend="ch-preps-settingenviron"
246 role="."/></para>
247
248 <para>Once all is well, clean up the test files:</para>
249
250<screen><userinput>rm -v dummy.c a.out</userinput></screen>
251
252 </caution>
253
254 </sect2>
255
256 <sect2 role="content">
257 <title/>
258
259 <para>Details on this package are located in
260 <xref linkend="contents-gcc" role="."/></para>
261
262 </sect2>
263
264</sect1>
Note: See TracBrowser for help on using the repository browser.