source: chapter05/glibc.xml@ ceebda5

ml-11.0 multilib
Last change on this file since ceebda5 was ceebda5, checked in by Xℹ Ruoyao <xry111@…>, 3 years ago

Merge changes from trunk to multilib

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@12176 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • 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
[ceebda5]61 <note>
62 <para>
63 The above command is correct. The <command>ln</command> command has
64 a few syntactic versions, so be sure to check
65 <command>info coreutils ln</command> and <filename>ln(1)</filename>
66 before reporting what you may think is an error.
67 </para>
68 </note>
69
[6dfcfecc]70 <para>Some of the Glibc programs use the non-FHS compliant
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
[f1dd547]77 <para>The Glibc documentation recommends building Glibc
78 in a dedicated build directory:</para>
[9bda40d]79
[f1dd547]80<screen><userinput remap="pre">mkdir -v build
81cd build</userinput></screen>
[f1c177f]82
[1f7ca93]83 <para>Next, prepare Glibc for compilation:</para>
[73aedd1d]84
[9c31d62]85<screen arch="default"><userinput remap="configure">../configure \
[6dfcfecc]86 --prefix=/usr \
[63df8c7]87 --host=$LFS_TGT \
88 --build=$(../scripts/config.guess) \
[c10c983]89 --enable-kernel=&min-kernel; \
[6dfcfecc]90 --with-headers=$LFS/usr/include \
91 libc_cv_slibdir=/lib</userinput></screen>
[9c31d62]92<screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure \
[6dfcfecc]93 --prefix=/usr \
[9c31d62]94 --host=$LFS_TGT \
95 --build=$(../scripts/config.guess) \
96 --enable-kernel=&min-kernel; \
[6dfcfecc]97 --with-headers=$LFS/usr/include \
[9c31d62]98 --enable-multi-arch \
[6dfcfecc]99 --libdir=/usr/lib \
100 --libexecdir=/usr/lib \
101 libc_cv_slibdir=/lib</userinput></screen>
[c10c983]102<!--
[63df8c7]103 libc_cv_forced_unwind=yes \
[c10c983]104 libc_cv_c_cleanup=yes</userinput></screen> -->
[73aedd1d]105
[1f7ca93]106 <variablelist>
107 <title>The meaning of the configure options:</title>
108
[4e82d47]109 <varlistentry>
[418b038]110 <term><parameter>--host=$LFS_TGT, --build=$(../scripts/config.guess)</parameter></term>
[4e82d47]111 <listitem>
112 <para>The combined effect of these switches is that Glibc's build system
[6dfcfecc]113 configures itself to be cross-compiled, using the cross-linker and
114 cross-compiler in <filename class="directory">$LFS/tools</filename>.</para>
[4e82d47]115 </listitem>
116 </varlistentry>
[1118b17]117
[1f7ca93]118 <varlistentry>
[70cd9f32]119 <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
[1f7ca93]120 <listitem>
121 <para>This tells Glibc to compile the library with support
[70cd9f32]122 for &min-kernel; and later Linux kernels. Workarounds for older
[3532721]123 kernels are not enabled.</para>
[1f7ca93]124 </listitem>
125 </varlistentry>
[1118b17]126
[1f7ca93]127 <varlistentry>
[6dfcfecc]128 <term><parameter>--with-headers=$LFS/usr/include</parameter></term>
[1f7ca93]129 <listitem>
[6dfcfecc]130 <para>This tells Glibc to compile itself against the headers
131 recently installed to the $LFS/usr/include directory, so that
132 it knows exactly what features the kernel has and can optimize
133 itself accordingly.</para>
[4e82d47]134 </listitem>
135 </varlistentry>
[6dfcfecc]136
[4e82d47]137 <varlistentry>
[6dfcfecc]138 <term><parameter>libc_cv_slibdir=/lib</parameter></term>
[4e82d47]139 <listitem>
[6dfcfecc]140 <para>This ensures that the library is installed in /lib instead
141 of the default /lib64 on 64 bit machines.</para>
[1f7ca93]142 </listitem>
143 </varlistentry>
144
[4c8c128]145 <varlistentry>
146 <term><option>libc_cv_include_x86_isa_level=no</option></term>
147 <listitem>
148 <para>This disables <quote>x86 ISA needed</quote> property in
149 Glibc libraries. Use it <emphasis role="bold">if</emphasis>
150 you are building Glibc with <option>-march</option> option in
151 <envar>CFLAGS</envar>, to workaround an issue in Glibc-2.33
152 breaking it.</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
170 Gettext package which the host distribution should provide.</para>
[81fd230]171
[7b1923d]172 <note><para>There have been reports that this package may fail when
173 building as a "parallel make". If this occurs, rerun the make command
174 with a "-j1" option.</para></note>
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
185 install the newly built glibc to your host system, which most likely
186 will render it unusable. So double check that the environment is
187 correctly set, 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
201 the package be installed in <filename class="directory">$LFS
202 </filename>, which will become the root after <xref linkend=
203 "ch-tools-chroot"/>.</para>
204 </listitem>
205 </varlistentry>
[73aedd1d]206
[6dfcfecc]207 </variablelist>
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>
[1a3e6a3]213
[3d56263]214<screen><userinput>echo 'int main(){}' &gt; dummy.c
[1a3e6a3]215$LFS_TGT-gcc dummy.c
[6dfcfecc]216readelf -l a.out | grep '/ld-linux'</userinput></screen>
[1a3e6a3]217
[6dfcfecc]218 <para>If everything is working correctly, there should be no errors,
219 and the output of the last command will be of the form:</para>
[1a3e6a3]220
[6dfcfecc]221<screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
[1a3e6a3]222
[6dfcfecc]223 <para arch="default">Note that for 32-bit machines, the interpreter name will be
224 <filename>/lib/ld-linux.so.2</filename>.</para>
[1a3e6a3]225
[6dfcfecc]226 <para>If the output is not shown as above or there was no output at all,
227 then something is wrong. Investigate and retrace the steps to find out
228 where the problem is and correct it. This issue must be resolved before
229 continuing on.</para>
[1a3e6a3]230
[6dfcfecc]231 <para>Once all is well, clean up the test files:</para>
[1a3e6a3]232
233<screen><userinput>rm -v dummy.c a.out</userinput></screen>
234
[6dfcfecc]235 </caution>
[1a3e6a3]236
[6dfcfecc]237 <note><para>Building packages in the next chapter will serve as an
238 additional check that the toolchain has been built properly. If some
239 package, especially binutils-pass2 or gcc-pass2, fails to build, it is
240 an indication that something has gone wrong with the
241 previous Binutils, GCC, or Glibc installations.</para></note>
[1a3e6a3]242
[6dfcfecc]243 <para>Now that our cross-toolchain is complete, finalize the installation
244 of the limits.h header. For doing so, run a utility provided by the GCC
245 developers:</para>
[bc82645e]246
[6dfcfecc]247<screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>
[b3f1ebb3]248
[6dfcfecc]249 </sect2>
[e2ccc32]250
[6dfcfecc]251 <!-- - - - - - - - - - -->
252 <!-- Multilib - 32bit -->
253 <!-- - - - - - - - - - -->
254 <sect2 arch="ml_32,ml_all">
255 <title>Building Glibc - 32bit</title>
256
257 <para>Now recompile for m32. The extracted source can be
258 reused but needs to cleaned before installing the m32
259 version of Glibc.</para>
260
261 <para>Clear the build directory and remove artefacts from
262 previous build:</para>
263
264<screen><userinput remap="pre">make clean
265find .. -name "*.a" -delete</userinput></screen>
266
267 <para>Configure Glibc for m32 with the following commands:</para>
268
269<screen><userinput remap="configure">CC="$LFS_TGT-gcc -m32" \
270CXX="$LFS_TGT-g++ -m32" \
271../configure \
272 --prefix=/usr \
273 --host=$LFS_TGT32 \
274 --build=$(../scripts/config.guess) \
275 --enable-kernel=&min-kernel; \
276 --with-headers=$LFS/usr/include \
277 --enable-multi-arch \
278 --libdir=&usr-lib-m32; \
279 --libexecdir=&usr-lib-m32; \
280 libc_cv_slibdir=&lib-m32;</userinput></screen>
[e2ccc32]281
[6dfcfecc]282 <para>Compile the package:</para>
[e2ccc32]283
[6dfcfecc]284<screen><userinput remap="make">make</userinput></screen>
[e2ccc32]285
[6dfcfecc]286 <para>Install the package:</para>
[e2ccc32]287
[6dfcfecc]288<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
289cp -a DESTDIR&lib-m32;/* $LFS&lib-m32;/
290cp -a DESTDIR&usr-lib-m32; $LFS/usr/
291install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \
292 $LFS/usr/include/gnu/
293ln -svf ..&lib-m32;/ld-linux.so.2 $LFS/lib/ld-linux.so.2</userinput></screen>
[b3f1ebb3]294
[6dfcfecc]295 <caution>
296 <para>At this point, it is imperative to stop and ensure that the basic
297 functions (compiling and linking) of the new toolchain are working as
298 expected. To perform a sanity check, run the following commands:</para>
[b3f1ebb3]299
[6dfcfecc]300<screen><userinput>echo 'int main(){}' &gt; dummy.c
301$LFS_TGT-gcc -m32 dummy.c
302readelf -l a.out | grep '/ld-linux'</userinput></screen>
[b3f1ebb3]303
[6dfcfecc]304 <para>If everything is working correctly, there should be no errors,
305 and the output of the last command will be of the form:</para>
[b3f1ebb3]306
[6dfcfecc]307<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
[e2ccc32]308
[6dfcfecc]309 <para>If the output is not shown as above or there was no output at all,
310 then something is wrong. Investigate and retrace the steps to find out
311 where the problem is and correct it. This issue must be resolved before
312 continuing on.</para>
[e2ccc32]313
[6dfcfecc]314 <para>Once all is well, clean up the test files:</para>
[e2ccc32]315
[6dfcfecc]316<screen><userinput>rm -v dummy.c a.out</userinput></screen>
[e2ccc32]317
[6dfcfecc]318 </caution>
[e2ccc32]319
[6dfcfecc]320 </sect2><!-- m32 -->
[b3f1ebb3]321
[6dfcfecc]322 <!-- - - - - - - - - - -->
323 <!-- Multilib - x32bit -->
324 <!-- - - - - - - - - - -->
325
326 <sect2 arch="ml_x32,ml_all">
327 <title>Building Glibc - x32bit</title>
328
329 <para>Now recompile for mx32. The extracted source can be
330 reused but needs to cleaned before installing the mx32
331 version of Glibc.</para>
332
333 <para>Clear the build directory and remove artefacts from
334 previous build:</para>
335
336<screen><userinput remap="pre">make clean
337find .. -name "*.a" -delete</userinput></screen>
338
339 <para>Configure Glibc for mx32 with the following commands:</para>
340
341<screen><userinput remap="configure">CC="$LFS_TGT-gcc -mx32" \
342CXX="$LFS_TGT-g++ -mx32" \
343../configure \
344 --prefix=/usr \
345 --host=$LFS_TGTX32 \
346 --build=$(../scripts/config.guess) \
347 --enable-kernel=&min-kernel; \
348 --with-headers=$LFS/usr/include \
349 --enable-multi-arch \
350 --libdir=&usr-lib-mx32; \
351 --libexecdir=&usr-lib-mx32; \
352 libc_cv_slibdir=&lib-mx32;</userinput></screen>
[b3f1ebb3]353
[6dfcfecc]354 <para>Compile the package:</para>
355
356<screen><userinput remap="make">make</userinput></screen>
[b3f1ebb3]357
[6dfcfecc]358 <para>Install the package:</para>
[b3f1ebb3]359
[6dfcfecc]360<screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install
361cp -a DESTDIR&lib-mx32;/* $LFS&lib-mx32;/
362cp -a DESTDIR&usr-lib-mx32; $LFS/usr/
363install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \
364 $LFS/usr/include/gnu/
365ln -svf ..&lib-mx32;/ld-linux-x32.so.2 $LFS/lib/ld-linux-x32.so.2</userinput></screen>
[b3f1ebb3]366
[6dfcfecc]367 <caution>
368 <para>At this point, it is imperative to stop and ensure that the basic
369 functions (compiling and linking) of the new toolchain are working as
370 expected. To perform a sanity check, run the following commands:</para>
[b3f1ebb3]371
372<screen><userinput>echo 'int main(){}' &gt; dummy.c
373$LFS_TGT-gcc -mx32 dummy.c
[6dfcfecc]374readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
[b3f1ebb3]375
[6dfcfecc]376 <para>If everything is working correctly, there should be no errors,
377 and the output of the last command will be of the form:</para>
[b3f1ebb3]378
[d7e0db5]379<screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
[b3f1ebb3]380
[6dfcfecc]381 <para>If the output is not shown as above or there was no output at all,
382 then something is wrong. Investigate and retrace the steps to find out
383 where the problem is and correct it. This issue must be resolved before
384 continuing on.</para>
[b3f1ebb3]385
[6dfcfecc]386 <para>Once all is well, clean up the test files:</para>
[b3f1ebb3]387
388<screen><userinput>rm -v dummy.c a.out</userinput></screen>
389
[6dfcfecc]390 </caution>
391
392 </sect2><!-- mx32 -->
393
[1f7ca93]394 <sect2 role="content">
395 <title/>
[81fd230]396
[1f7ca93]397 <para>Details on this package are located in
398 <xref linkend="contents-glibc" role="."/></para>
399
400 </sect2>
[81fd230]401
[1f7ca93]402</sect1>
Note: See TracBrowser for help on using the repository browser.