source: chapter05/glibc.xml@ 219e404

multilib
Last change on this file since 219e404 was 8c586d2, checked in by Thomas Trepl (Moody) <thomas@…>, 20 months ago

Automatic merge of trunk into multilib

  • Property mode set to 100644
File size: 14.9 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-glibc" role="wrap">
9 <?dbhtml filename="glibc.html"?>
10
11 <sect1info condition="script">
12 <productname>glibc</productname>
13 <productnumber>&glibc-version;</productnumber>
14 <address>&glibc-url;</address>
15 </sect1info>
16
17 <title>Glibc-&glibc-version;</title>
18
19 <indexterm zone="ch-tools-glibc">
20 <primary sortas="a-Glibc">Glibc</primary>
21 <secondary>tools</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/glibc.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>&glibc-tmp-sbu;</seg>
37 <seg>&glibc-tmp-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Glibc</title>
45
46 <para>First, create a symbolic link for LSB compliance. Additionally,
47 for x86_64, create a compatibility symbolic link required for proper
48 operation of the dynamic library loader:</para>
49
50<screen arch="default"><userinput remap="pre">case $(uname -m) in
51 i?86) ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
52 ;;
53 x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
54 ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
55 ;;
56esac</userinput></screen>
57<!-- no ld-linux.so.2 here as multilib is based on x86_64, not on i686 -->
58<screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
59ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3</userinput></screen>
60
61 <note>
62 <para>
63 The above command is correct. The <command>ln</command> command has
64 several syntactic versions, so be sure to check
65 <command>info coreutils ln</command> and <filename>ln(1)</filename>
66 before reporting what may appear to be an error.
67 </para>
68 </note>
69
70 <para>Fix an issue building Glibc with parallel jobs and make-4.4
71 or later:</para>
72
73<screen><userinput remap="pre">sed '/MAKEFLAGS :=/s/)r/) -r/' -i Makerules</userinput></screen>
74
75 <para>Some of the Glibc programs use the non-FHS-compliant
76 <filename class="directory">/var/db</filename> directory to store their
77 runtime data. Apply the following patch to make such programs store their
78 runtime data in the FHS-compliant locations:</para>
79
80<screen><userinput remap="pre">patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch</userinput></screen>
81
82 <para>The Glibc documentation recommends building Glibc
83 in a dedicated build directory:</para>
84
85<screen><userinput remap="pre">mkdir -v build
86cd build</userinput></screen>
87
88 <para>Ensure that the <command>ldconfig</command> and <command>sln</command>
89 utilities are installed into
90 <filename class="directory">/usr/sbin</filename>:</para>
91
92<screen><userinput remap="pre">echo "rootsbindir=/usr/sbin" &gt; configparms</userinput></screen>
93
94 <para>Next, prepare Glibc for compilation:</para>
95
96<screen arch="default"><userinput remap="configure">../configure \
97 --prefix=/usr \
98 --host=$LFS_TGT \
99 --build=$(../scripts/config.guess) \
100 --enable-kernel=&min-kernel; \
101 --with-headers=$LFS/usr/include \
102 libc_cv_slibdir=/usr/lib</userinput></screen>
103<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure \
104 --prefix=/usr \
105 --host=$LFS_TGT \
106 --build=$(../scripts/config.guess) \
107 --enable-kernel=&min-kernel; \
108 --with-headers=$LFS/usr/include \
109 --enable-multi-arch \
110 libc_cv_slibdir=/usr/lib</userinput></screen>
111
112 <variablelist>
113 <title>The meaning of the configure options:</title>
114
115 <varlistentry>
116 <term><parameter>--host=$LFS_TGT, --build=$(../scripts/config.guess)</parameter></term>
117 <listitem>
118 <para>The combined effect of these switches is that Glibc's build system
119 configures itself to be cross-compiled, using the cross-linker and
120 cross-compiler in <filename class="directory">$LFS/tools</filename>.</para>
121 </listitem>
122 </varlistentry>
123
124 <varlistentry>
125 <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
126 <listitem>
127 <para>This tells Glibc to compile the library with support
128 for &min-kernel; and later Linux kernels. Workarounds for older
129 kernels are not enabled.</para>
130 </listitem>
131 </varlistentry>
132
133 <varlistentry>
134 <term><parameter>--with-headers=$LFS/usr/include</parameter></term>
135 <listitem>
136 <para>This tells Glibc to compile itself against the headers
137 recently installed to the $LFS/usr/include directory, so that
138 it knows exactly what features the kernel has and can optimize
139 itself accordingly.</para>
140 </listitem>
141 </varlistentry>
142
143 <varlistentry>
144 <term><parameter>libc_cv_slibdir=/usr/lib</parameter></term>
145 <listitem>
146 <para>This ensures that the library is installed in /usr/lib instead
147 of the default /lib64 on 64-bit machines.</para>
148 </listitem>
149 </varlistentry>
150
151 </variablelist>
152
153 <para>During this stage the following warning might appear:</para>
154
155 <blockquote>
156<screen><computeroutput>configure: WARNING:
157*** These auxiliary programs are missing or
158*** incompatible versions: msgfmt
159*** some features will be disabled.
160*** Check the INSTALL file for required versions.</computeroutput></screen>
161 </blockquote>
162
163 <para>The missing or incompatible <command>msgfmt</command> program is
164 generally harmless. This <command>msgfmt</command> program is part of the
165 Gettext package, which the host distribution should provide.</para>
166
167 <note><para>There have been reports that this package may fail when
168 building as a "parallel make". If that occurs, rerun the make command
169 with the "-j1" option.</para></note>
170
171 <para>Compile the package:</para>
172
173<screen><userinput remap="make">make</userinput></screen>
174
175 <para>Install the package:</para>
176
177 <warning><para>If <envar>LFS</envar> is not properly set, and despite the
178 recommendations, you are building as
179 <systemitem class="username">root</systemitem>, the next command will
180 install the newly built Glibc to your host system, which will almost
181 certainly render it unusable. So double-check that the environment is
182 correctly set, and that you are not &root;, before running the following command.</para></warning>
183
184<screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen>
185
186 <variablelist>
187 <title>The meaning of the <command>make install</command> option:</title>
188
189 <varlistentry>
190 <term><parameter>DESTDIR=$LFS</parameter></term>
191 <listitem>
192 <para>The <envar>DESTDIR</envar> make variable is used by almost all
193 packages to define the location where the package should be
194 installed. If it is not set, it defaults to the root (<filename
195 class="directory">/</filename>) directory. Here we specify that
196 the package is installed in <filename class="directory">$LFS
197 </filename>, which will become the root directory in <xref linkend=
198 "ch-tools-chroot"/>.</para>
199 </listitem>
200 </varlistentry>
201
202 </variablelist>
203
204 <para>Fix a hard coded path to the executable loader in the
205 <command>ldd</command> script:</para>
206
207<screen><userinput remap="install">sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd</userinput></screen>
208
209 <caution>
210 <para>At this point, it is imperative to stop and ensure that the basic
211 functions (compiling and linking) of the new toolchain are working as
212 expected. To perform a sanity check, run the following commands:</para>
213
214<screen><userinput>echo 'int main(){}' | $LFS_TGT-gcc -xc -
215readelf -l a.out | grep ld-linux</userinput></screen>
216
217 <para>If everything is working correctly, there should be no errors,
218 and the output of the last command will be of the form:</para>
219
220<screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
221
222 <para arch="default">Note that for 32-bit machines, the interpreter name will be
223 <filename>/lib/ld-linux.so.2</filename>.</para>
224
225 <para>If the output is not as shown above, or there is no output at all,
226 then something is wrong. Investigate and retrace the steps to find out
227 where the problem is and correct it. This issue must be resolved before
228 continuing.</para>
229
230 <para>Once all is well, clean up the test file:</para>
231
232<screen><userinput>rm -v a.out</userinput></screen>
233
234 </caution>
235
236 <note><para>Building the packages in the next chapter will serve as an
237 additional check that the toolchain has been built properly. If some
238 package, especially Binutils-pass2 or GCC-pass2, fails to build, it is
239 an indication that something has gone wrong with the
240 preceding Binutils, GCC, or Glibc installations.</para></note>
241
242 <para>Now that our cross-toolchain is complete, finalize the installation
243 of the limits.h header. To do this, run a utility provided by the GCC
244 developers:</para>
245
246<screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>
247
248 </sect2>
249
250 <!-- - - - - - - - - - -->
251 <!-- Multilib - 32bit -->
252 <!-- - - - - - - - - - -->
253 <sect2 arch="ml_32,ml_all">
254 <title>Building Glibc - 32bit</title>
255
256 <para>Now recompile for m32. The extracted source can be
257 reused but needs to be cleaned before installing the m32
258 version of Glibc.</para>
259
260 <para>Clear the build directory and remove artefacts from
261 previous build:</para>
262
263<screen><userinput remap="pre">make clean
264find .. -name "*.a" -delete</userinput></screen>
265
266 <para>Configure Glibc for m32 with the following commands:</para>
267
268<screen><userinput remap="configure">CC="$LFS_TGT-gcc -m32" \
269CXX="$LFS_TGT-g++ -m32" \
270../configure \
271 --prefix=/usr \
272 --host=$LFS_TGT32 \
273 --build=$(../scripts/config.guess) \
274 --enable-kernel=&min-kernel; \
275 --with-headers=$LFS/usr/include \
276 --enable-multi-arch \
277 --libdir=/usr/lib32 \
278 --libexecdir=/usr/lib32 \
279 libc_cv_slibdir=/usr/lib32</userinput></screen>
280
281 <para>Compile the package:</para>
282
283<screen><userinput remap="make">make</userinput></screen>
284
285 <para>Install the package:</para>
286
287<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
288cp -a DESTDIR/usr/lib32 $LFS/usr/
289install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
290 $LFS/usr/include/gnu/
291ln -svf ../lib32/ld-linux.so.2 $LFS/lib/ld-linux.so.2</userinput></screen>
292
293
294 <caution>
295 <para>At this point, it is imperative to stop and ensure that the basic
296 functions (compiling and linking) of the new toolchain are working as
297 expected. To perform a sanity check, run the following commands:</para>
298
299<screen><userinput>echo 'int main(){}' &gt; dummy.c
300$LFS_TGT-gcc -m32 dummy.c
301readelf -l a.out | grep '/ld-linux'</userinput></screen>
302
303 <para>If everything is working correctly, there should be no errors,
304 and the output of the last command will be of the form:</para>
305
306<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
307
308 <para>If the output is not shown as above or there was no output at all,
309 then something is wrong. Investigate and retrace the steps to find out
310 where the problem is and correct it. This issue must be resolved before
311 continuing on.</para>
312
313 <para>Once all is well, clean up the test files:</para>
314
315<screen><userinput>rm -v dummy.c a.out</userinput></screen>
316
317 </caution>
318
319 </sect2><!-- m32 -->
320
321 <!-- - - - - - - - - - -->
322 <!-- Multilib - x32bit -->
323 <!-- - - - - - - - - - -->
324
325 <sect2 arch="ml_x32,ml_all">
326 <title>Building Glibc - x32bit</title>
327
328 <para>Now recompile for mx32. The extracted source can be
329 reused but needs to be cleaned before installing the mx32
330 version of Glibc.</para>
331
332 <para>Clear the build directory and remove artefacts from
333 previous build:</para>
334
335<screen><userinput remap="pre">make clean
336find .. -name "*.a" -delete</userinput></screen>
337
338 <para>Configure Glibc for mx32 with the following commands:</para>
339
340<screen><userinput remap="configure">CC="$LFS_TGT-gcc -mx32" \
341CXX="$LFS_TGT-g++ -mx32" \
342../configure \
343 --prefix=/usr \
344 --host=$LFS_TGTX32 \
345 --build=$(../scripts/config.guess) \
346 --enable-kernel=&min-kernel; \
347 --with-headers=$LFS/usr/include \
348 --enable-multi-arch \
349 --libdir=/usr/libx32 \
350 --libexecdir=/usr/libx32 \
351 libc_cv_slibdir=/usr/libx32</userinput></screen>
352
353 <para>Compile the package:</para>
354
355<screen><userinput remap="make">make</userinput></screen>
356
357 <para>Install the package:</para>
358
359<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
360cp -a DESTDIR/usr/libx32 $LFS/usr/
361install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \
362 $LFS/usr/include/gnu/
363ln -svf ../libx32/ld-linux-x32.so.2 $LFS/lib/ld-linux-x32.so.2</userinput></screen>
364
365 <caution>
366 <para>At this point, it is imperative to stop and ensure that the basic
367 functions (compiling and linking) of the new toolchain are working as
368 expected. To perform a sanity check, run the following commands:</para>
369
370<screen><userinput>echo 'int main(){}' &gt; dummy.c
371$LFS_TGT-gcc -mx32 dummy.c
372readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
373
374 <para>If everything is working correctly, there should be no errors,
375 and the output of the last command will be of the form:</para>
376
377<screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
378
379 <para>If the output is not shown as above or there was no output at all,
380 then something is wrong. Investigate and retrace the steps to find out
381 where the problem is and correct it. This issue must be resolved before
382 continuing on.</para>
383
384 <para>Once all is well, clean up the test files:</para>
385
386<screen><userinput>rm -v dummy.c a.out</userinput></screen>
387
388 </caution>
389
390 </sect2><!-- mx32 -->
391
392 <sect2 role="content">
393 <title/>
394
395 <para>Details on this package are located in
396 <xref linkend="contents-glibc" role="."/></para>
397
398 </sect2>
399
400</sect1>
Note: See TracBrowser for help on using the repository browser.