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
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
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 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
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
77 <para>The Glibc documentation recommends building Glibc
78 in a dedicated build directory:</para>
79
80<screen><userinput remap="pre">mkdir -v build
81cd build</userinput></screen>
82
83 <para>Next, prepare Glibc for compilation:</para>
84
85<screen arch="default"><userinput remap="configure">../configure \
86 --prefix=/usr \
87 --host=$LFS_TGT \
88 --build=$(../scripts/config.guess) \
89 --enable-kernel=&min-kernel; \
90 --with-headers=$LFS/usr/include \
91 libc_cv_slibdir=/lib</userinput></screen>
92<screen arch="ml_32,ml_x32,ml_all"><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 --enable-multi-arch \
99 --libdir=/usr/lib \
100 --libexecdir=/usr/lib \
101 libc_cv_slibdir=/lib</userinput></screen>
102<!--
103 libc_cv_forced_unwind=yes \
104 libc_cv_c_cleanup=yes</userinput></screen> -->
105
106 <variablelist>
107 <title>The meaning of the configure options:</title>
108
109 <varlistentry>
110 <term><parameter>--host=$LFS_TGT, --build=$(../scripts/config.guess)</parameter></term>
111 <listitem>
112 <para>The combined effect of these switches is that Glibc's build system
113 configures itself to be cross-compiled, using the cross-linker and
114 cross-compiler in <filename class="directory">$LFS/tools</filename>.</para>
115 </listitem>
116 </varlistentry>
117
118 <varlistentry>
119 <term><parameter>--enable-kernel=&min-kernel;</parameter></term>
120 <listitem>
121 <para>This tells Glibc to compile the library with support
122 for &min-kernel; and later Linux kernels. Workarounds for older
123 kernels are not enabled.</para>
124 </listitem>
125 </varlistentry>
126
127 <varlistentry>
128 <term><parameter>--with-headers=$LFS/usr/include</parameter></term>
129 <listitem>
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>
134 </listitem>
135 </varlistentry>
136
137 <varlistentry>
138 <term><parameter>libc_cv_slibdir=/lib</parameter></term>
139 <listitem>
140 <para>This ensures that the library is installed in /lib instead
141 of the default /lib64 on 64 bit machines.</para>
142 </listitem>
143 </varlistentry>
144
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
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 this occurs, rerun the make command
174 with a "-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 most likely
186 will render it unusable. So double check that the environment is
187 correctly set, 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 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>
206
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>
213
214<screen><userinput>echo 'int main(){}' &gt; dummy.c
215$LFS_TGT-gcc dummy.c
216readelf -l a.out | grep '/ld-linux'</userinput></screen>
217
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>
220
221<screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen>
222
223 <para arch="default">Note that for 32-bit machines, the interpreter name will be
224 <filename>/lib/ld-linux.so.2</filename>.</para>
225
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>
230
231 <para>Once all is well, clean up the test files:</para>
232
233<screen><userinput>rm -v dummy.c a.out</userinput></screen>
234
235 </caution>
236
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>
242
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>
246
247<screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen>
248
249 </sect2>
250
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>
281
282 <para>Compile the package:</para>
283
284<screen><userinput remap="make">make</userinput></screen>
285
286 <para>Install the package:</para>
287
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>
294
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>
299
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>
303
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>
306
307<screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>
308
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>
313
314 <para>Once all is well, clean up the test files:</para>
315
316<screen><userinput>rm -v dummy.c a.out</userinput></screen>
317
318 </caution>
319
320 </sect2><!-- m32 -->
321
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>
353
354 <para>Compile the package:</para>
355
356<screen><userinput remap="make">make</userinput></screen>
357
358 <para>Install the package:</para>
359
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>
366
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>
371
372<screen><userinput>echo 'int main(){}' &gt; dummy.c
373$LFS_TGT-gcc -mx32 dummy.c
374readelf -l a.out | grep '/ld-linux-x32'</userinput></screen>
375
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>
378
379<screen><computeroutput>[Requesting program interpreter: /libx32/ld-linux-x32.so.2]</computeroutput></screen>
380
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>
385
386 <para>Once all is well, clean up the test files:</para>
387
388<screen><userinput>rm -v dummy.c a.out</userinput></screen>
389
390 </caution>
391
392 </sect2><!-- mx32 -->
393
394 <sect2 role="content">
395 <title/>
396
397 <para>Details on this package are located in
398 <xref linkend="contents-glibc" role="."/></para>
399
400 </sect2>
401
402</sect1>
Note: See TracBrowser for help on using the repository browser.