source: chapter05/glibc.xml@ d8cf919

multilib
Last change on this file since d8cf919 was f6a43f6, checked in by Thomas Trepl <thomas@…>, 6 months ago

Automatic merge of trunk into multilib

  • Property mode set to 100644
File size: 15.0 KB
RevLine 
[7152faa]1<?xml version="1.0" encoding="UTF-8"?>
[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
[ea93c11]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.
[0fc1b27]68 </para>
69 </note>
70
[f6820bb6]71 <para>Some of the Glibc programs use the non-FHS-compliant
[6dfcfecc]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
[a26f29f]78 <para>The Glibc documentation recommends building Glibc
[f1dd547]79 in a dedicated build directory:</para>
[9bda40d]80
[f1dd547]81<screen><userinput remap="pre">mkdir -v build
82cd build</userinput></screen>
[f1c177f]83
[4eee9cc]84 <para>Ensure that the <command>ldconfig</command> and <command>sln</command>
[bcb20b4]85 utilities are installed into
[4eee9cc]86 <filename class="directory">/usr/sbin</filename>:</para>
87
88<screen><userinput remap="pre">echo "rootsbindir=/usr/sbin" &gt; configparms</userinput></screen>
89
[1f7ca93]90 <para>Next, prepare Glibc for compilation:</para>
[73aedd1d]91
[9c31d62]92<screen arch="default"><userinput remap="configure">../configure \
[6dfcfecc]93 --prefix=/usr \
[63df8c7]94 --host=$LFS_TGT \
95 --build=$(../scripts/config.guess) \
[0f18f2b]96 --enable-kernel=&min-kernel; \
[6dfcfecc]97 --with-headers=$LFS/usr/include \
[25b3c0f]98 --disable-nscd \
[d4b5218]99 libc_cv_slibdir=/usr/lib</userinput></screen>
[9c31d62]100<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure \
[6dfcfecc]101 --prefix=/usr \
[9c31d62]102 --host=$LFS_TGT \
103 --build=$(../scripts/config.guess) \
104 --enable-kernel=&min-kernel; \
[6dfcfecc]105 --with-headers=$LFS/usr/include \
[9c31d62]106 --enable-multi-arch \
[d4b5218]107 libc_cv_slibdir=/usr/lib</userinput></screen>
[73aedd1d]108
[1f7ca93]109 <variablelist>
110 <title>The meaning of the configure options:</title>
111
[4e82d47]112 <varlistentry>
[418b038]113 <term><parameter>--host=$LFS_TGT, --build=$(../scripts/config.guess)</parameter></term>
[4e82d47]114 <listitem>
115 <para>The combined effect of these switches is that Glibc's build system
[6dfcfecc]116 configures itself to be cross-compiled, using the cross-linker and
117 cross-compiler in <filename class="directory">$LFS/tools</filename>.</para>
[4e82d47]118 </listitem>
119 </varlistentry>
[1118b17]120
[1f7ca93]121 <varlistentry>
[70cd9f32]122 <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
[1f7ca93]123 <listitem>
124 <para>This tells Glibc to compile the library with support
[70cd9f32]125 for &min-kernel; and later Linux kernels. Workarounds for older
[3532721]126 kernels are not enabled.</para>
[1f7ca93]127 </listitem>
128 </varlistentry>
[1118b17]129
[1f7ca93]130 <varlistentry>
[6dfcfecc]131 <term><parameter>--with-headers=$LFS/usr/include</parameter></term>
[1f7ca93]132 <listitem>
[6dfcfecc]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>
[4e82d47]137 </listitem>
138 </varlistentry>
[6dfcfecc]139
[4e82d47]140 <varlistentry>
[d7a9421]141 <term><parameter>libc_cv_slibdir=/usr/lib</parameter></term>
[4e82d47]142 <listitem>
[d7a9421]143 <para>This ensures that the library is installed in /usr/lib instead
[f6820bb6]144 of the default /lib64 on 64-bit machines.</para>
[1f7ca93]145 </listitem>
146 </varlistentry>
147
[25b3c0f]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
[1f7ca93]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
[81fd230]163*** incompatible versions: msgfmt
164*** some features will be disabled.
[1f7ca93]165*** Check the INSTALL file for required versions.</computeroutput></screen>
166 </blockquote>
[81fd230]167
[1f7ca93]168 <para>The missing or incompatible <command>msgfmt</command> program is
[5f7456b]169 generally harmless. This <command>msgfmt</command> program is part of the
[f6820bb6]170 Gettext package, which the host distribution should provide.</para>
[81fd230]171
[a26f29f]172 <note><para>There have been reports that this package may fail when
[360fdfca]173 building as a <quote>parallel make.</quote> If that occurs, rerun the make command
174 with the <option>-j1</option> option.</para></note>
[7b1923d]175
[1f7ca93]176 <para>Compile the package:</para>
[73aedd1d]177
[0445a3d]178<screen><userinput remap="make">make</userinput></screen>
[73aedd1d]179
[1f7ca93]180 <para>Install the package:</para>
[73aedd1d]181
[6dfcfecc]182 <warning><para>If <envar>LFS</envar> is not properly set, and despite the
[38de42d]183 recommendations, you are building as
184 <systemitem class="username">root</systemitem>, the next command will
[f6820bb6]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>
[6dfcfecc]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
[f6820bb6]201 the package is installed in <filename class="directory">$LFS
202 </filename>, which will become the root directory in <xref linkend=
[6dfcfecc]203 "ch-tools-chroot"/>.</para>
204 </listitem>
205 </varlistentry>
[73aedd1d]206
[6dfcfecc]207 </variablelist>
208
[f6820bb6]209 <para>Fix a hard coded path to the executable loader in the
[0ebda11]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
[6dfcfecc]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>
[1a3e6a3]218
[793f9087]219<screen><userinput>echo 'int main(){}' | $LFS_TGT-gcc -xc -
[b3f157c6]220readelf -l a.out | grep ld-linux</userinput></screen>
[1a3e6a3]221
[6dfcfecc]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>
[1a3e6a3]224
[6dfcfecc]225<screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
[1a3e6a3]226
[6dfcfecc]227 <para arch="default">Note that for 32-bit machines, the interpreter name will be
228 <filename>/lib/ld-linux.so.2</filename>.</para>
[1a3e6a3]229
[f6820bb6]230 <para>If the output is not as shown above, or there is no output at all,
[6dfcfecc]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
[f6820bb6]233 continuing.</para>
[1a3e6a3]234
[b3f157c6]235 <para>Once all is well, clean up the test file:</para>
[1a3e6a3]236
[b3f157c6]237<screen><userinput>rm -v a.out</userinput></screen>
[1a3e6a3]238
[6dfcfecc]239 </caution>
[1a3e6a3]240
[f6820bb6]241 <note><para>Building the packages in the next chapter will serve as an
[6dfcfecc]242 additional check that the toolchain has been built properly. If some
[f6820bb6]243 package, especially Binutils-pass2 or GCC-pass2, fails to build, it is
[6dfcfecc]244 an indication that something has gone wrong with the
[f6820bb6]245 preceding Binutils, GCC, or Glibc installations.</para></note>
[bd5b888]246<!--
[6dfcfecc]247 <para>Now that our cross-toolchain is complete, finalize the installation
[f6820bb6]248 of the limits.h header. To do this, run a utility provided by the GCC
[6dfcfecc]249 developers:</para>
[bc82645e]250
[6dfcfecc]251<screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>
[bd5b888]252-->
[6dfcfecc]253 </sect2>
[e2ccc32]254
[6dfcfecc]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
[0ebda11]262 reused but needs to be cleaned before installing the m32
[6dfcfecc]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 \
[0ebda11]282 --libdir=/usr/lib32 \
283 --libexecdir=/usr/lib32 \
[d4b5218]284 libc_cv_slibdir=/usr/lib32</userinput></screen>
[e2ccc32]285
[6dfcfecc]286 <para>Compile the package:</para>
[e2ccc32]287
[6dfcfecc]288<screen><userinput remap="make">make</userinput></screen>
[e2ccc32]289
[6dfcfecc]290 <para>Install the package:</para>
[e2ccc32]291
[6dfcfecc]292<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
[0ebda11]293cp -a DESTDIR/usr/lib32 $LFS/usr/
[6dfcfecc]294install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
295 $LFS/usr/include/gnu/
[0ebda11]296ln -svf ../lib32/ld-linux.so.2 $LFS/lib/ld-linux.so.2</userinput></screen>
297
[b3f1ebb3]298
[6dfcfecc]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>
[b3f1ebb3]303
[6dfcfecc]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>
[b3f1ebb3]307
[6dfcfecc]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>
[b3f1ebb3]310
[6dfcfecc]311<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
[e2ccc32]312
[6dfcfecc]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>
[e2ccc32]317
[6dfcfecc]318 <para>Once all is well, clean up the test files:</para>
[e2ccc32]319
[6dfcfecc]320<screen><userinput>rm -v dummy.c a.out</userinput></screen>
[e2ccc32]321
[6dfcfecc]322 </caution>
[e2ccc32]323
[6dfcfecc]324 </sect2><!-- m32 -->
[b3f1ebb3]325
[6dfcfecc]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
[0ebda11]334 reused but needs to be cleaned before installing the mx32
[6dfcfecc]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 \
[0ebda11]354 --libdir=/usr/libx32 \
355 --libexecdir=/usr/libx32 \
[d4b5218]356 libc_cv_slibdir=/usr/libx32</userinput></screen>
[b3f1ebb3]357
[6dfcfecc]358 <para>Compile the package:</para>
359
360<screen><userinput remap="make">make</userinput></screen>
[b3f1ebb3]361
[6dfcfecc]362 <para>Install the package:</para>
[b3f1ebb3]363
[6dfcfecc]364<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
[0ebda11]365cp -a DESTDIR/usr/libx32 $LFS/usr/
[6dfcfecc]366install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \
367 $LFS/usr/include/gnu/
[0ebda11]368ln -svf ../libx32/ld-linux-x32.so.2 $LFS/lib/ld-linux-x32.so.2</userinput></screen>
[b3f1ebb3]369
[6dfcfecc]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>
[b3f1ebb3]374
375<screen><userinput>echo 'int main(){}' &gt; dummy.c
376$LFS_TGT-gcc -mx32 dummy.c
[6dfcfecc]377readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
[b3f1ebb3]378
[6dfcfecc]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>
[b3f1ebb3]381
[d7e0db5]382<screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
[b3f1ebb3]383
[6dfcfecc]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>
[b3f1ebb3]388
[6dfcfecc]389 <para>Once all is well, clean up the test files:</para>
[b3f1ebb3]390
391<screen><userinput>rm -v dummy.c a.out</userinput></screen>
392
[6dfcfecc]393 </caution>
394
395 </sect2><!-- mx32 -->
396
[1f7ca93]397 <sect2 role="content">
398 <title/>
[81fd230]399
[1f7ca93]400 <para>Details on this package are located in
401 <xref linkend="contents-glibc" role="."/></para>
402
403 </sect2>
[81fd230]404
[1f7ca93]405</sect1>
Note: See TracBrowser for help on using the repository browser.