source: chapter05/glibc.xml@ 5f3a328

multilib xry111/multilib
Last change on this file since 5f3a328 was 8c586d2, checked in by Thomas Trepl (Moody) <thomas@…>, 23 months ago

Automatic merge of trunk into multilib

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