source: chapter05/glibc.xml@ 31a18d02

multilib
Last change on this file since 31a18d02 was 31a18d02, checked in by Thomas Trepl <thomas@…>, 5 months ago

Automatic merge of trunk into multilib

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