source: chapter05/glibc.xml@ 4a9c50a

multilib
Last change on this file since 4a9c50a was f8a76cb, checked in by Thomas Trepl <thomas@…>, 11 months ago

Automatic merge of trunk into multilib

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