Changeset 37e35d2 for chapter05/glibc.xml
- Timestamp:
- 06/29/2020 07:55:01 AM (4 years ago)
- Branches:
- multilib-10.1
- Children:
- c4804e8
- Parents:
- d4fdde6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
chapter05/glibc.xml
rd4fdde6 r37e35d2 26 26 27 27 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" 28 href="../chapter0 6/glibc.xml"28 href="../chapter08/glibc.xml" 29 29 xpointer="xpointer(/sect1/sect2[1]/para[1])"/> 30 30 … … 34 34 35 35 <seglistitem> 36 <seg>&glibc- ch5-sbu;</seg>37 <seg>&glibc- ch5-du;</seg>36 <seg>&glibc-tmp-sbu;</seg> 37 <seg>&glibc-tmp-du;</seg> 38 38 </seglistitem> 39 39 </segmentedlist> … … 44 44 <title>Installation of Glibc</title> 45 45 46 <para arch="default">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 ;; 56 esac</userinput></screen> 57 58 <para arch="ml_32,ml_x32,ml_all">First, create symbolic links for LSB compliance 59 and compatibility symbolic links required for proper 60 operation of the dynamic library loader:</para> 61 62 <!-- no ld-linux.so.2 here as multilib is based on x86_64, not on i686 --> 63 <screen arch="ml_32,ml_x32,ml_all"><userinput remap="pre">ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64 64 ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3</userinput></screen> 65 66 <para>Some of the Glibc programs use the non-FHS compliant 67 <filename class="directory">/var/db</filename> directory to store their 68 runtime data. Apply the following patch to make such programs store their 69 runtime data in the FHS-compliant locations:</para> 70 71 <screen><userinput remap="pre">patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch</userinput></screen> 72 46 73 <para>The Glibc documentation recommends building Glibc 47 74 in a dedicated build directory:</para> … … 53 80 54 81 <screen arch="default"><userinput remap="configure">../configure \ 55 --prefix=/ tools\82 --prefix=/usr \ 56 83 --host=$LFS_TGT \ 57 84 --build=$(../scripts/config.guess) \ 58 85 --enable-kernel=&min-kernel; \ 59 --with-headers=/tools/include</userinput></screen> 86 --with-headers=$LFS/usr/include \ 87 libc_cv_slibdir=/lib</userinput></screen> 60 88 <screen arch="ml_32,ml_x32,ml_all"><userinput remap="configure">../configure \ 61 --prefix=/ tools\89 --prefix=/usr \ 62 90 --host=$LFS_TGT \ 63 91 --build=$(../scripts/config.guess) \ 64 92 --enable-kernel=&min-kernel; \ 93 --with-headers=$LFS/usr/include \ 65 94 --enable-multi-arch \ 66 --with-headers=/tools/include</userinput></screen> 95 --libdir=/usr/lib \ 96 --libexecdir=/usr/lib \ 97 libc_cv_slibdir=/lib</userinput></screen> 67 98 <!-- 68 99 libc_cv_forced_unwind=yes \ … … 76 107 <listitem> 77 108 <para>The combined effect of these switches is that Glibc's build system 78 configures itself to cross-compile, using the cross-linker and79 cross-compiler in <filename class="directory"> /tools</filename>.</para>109 configures itself to be cross-compiled, using the cross-linker and 110 cross-compiler in <filename class="directory">$LFS/tools</filename>.</para> 80 111 </listitem> 81 112 </varlistentry> … … 90 121 </varlistentry> 91 122 92 <varlistentry arch="ml_32,ml_x32,ml_all"> 93 <term><parameter>--enable-multi-arch</parameter></term> 94 <listitem> 95 <para>Enables glibc for multiarch environments.</para> 96 </listitem> 97 </varlistentry> 98 99 <varlistentry> 100 <term><parameter>--with-headers=/tools/include</parameter></term> 101 <listitem> 102 <para>This tells Glibc to compile itself against the headers recently 103 installed to the tools directory, so that it knows exactly what 104 features the kernel has and can optimize itself accordingly.</para> 105 </listitem> 106 </varlistentry> 107 <!-- 108 <varlistentry> 109 <term><parameter>libc_cv_forced_unwind=yes</parameter></term> 110 <listitem> 111 <para>The linker installed during 112 <xref linkend="ch-tools-binutils-pass1"/> was cross-compiled and as 113 such cannot be used until Glibc has been installed. This means that 114 the configure test for force-unwind support will fail, as it relies on 115 a working linker. The libc_cv_forced_unwind=yes variable is passed in 116 order to inform <command>configure</command> that force-unwind 117 support is available without it having to run the test.</para> 118 </listitem> 119 </varlistentry> 120 <varlistentry> 121 <term><parameter>libc_cv_c_cleanup=yes</parameter></term> 122 <listitem> 123 <para>Similarly, we pass libc_cv_c_cleanup=yes through to the 124 <command>configure</command> script so that the test is skipped and C 125 cleanup handling support is configured.</para> 126 </listitem> 127 </varlistentry> 128 --> 129 <!-- <varlistentry> 130 <term><parameter>libc_cv_ctors_header=yes</parameter></term> 131 <listitem> 132 <para>Similarly, we pass libc_cv_ctors_header=yes through to the 133 <command>configure</command> script so that the test is skipped and 134 gcc constructor support is configured.</para> 135 </listitem> 136 </varlistentry>--> 123 <varlistentry> 124 <term><parameter>--with-headers=$LFS/usr/include</parameter></term> 125 <listitem> 126 <para>This tells Glibc to compile itself against the headers 127 recently installed to the $LFS/usr/include directory, so that 128 it knows exactly what features the kernel has and can optimize 129 itself accordingly.</para> 130 </listitem> 131 </varlistentry> 132 133 <varlistentry> 134 <term><parameter>libc_cv_slibdir=/lib</parameter></term> 135 <listitem> 136 <para>This ensures that the library is installed in /lib instead 137 of the default /lib64 on 64 bit machines.</para> 138 </listitem> 139 </varlistentry> 137 140 138 141 </variablelist> … … 162 165 <para>Install the package:</para> 163 166 164 <screen><userinput remap="install">make install</userinput></screen> 165 166 <caution> 167 <para>At this point, it is imperative to stop and ensure that the basic 168 functions (compiling and linking) of the new toolchain are working as 169 expected. To perform a sanity check, run the following commands:</para> 167 <warning><para>If <envar>LFS</envar> is not properly set, and despite the 168 recommendations, you are building as root, the next command will install 169 the newly built glibc to your host system, which most likely will render it 170 unusable. So double check that the environment is correctly set for user 171 <systemitem class="username">lfs</systemitem>.</para></warning> 172 173 <screen><userinput remap="install">make DESTDIR=$LFS install</userinput></screen> 174 175 <variablelist> 176 <title>The meaning of the <command>make install</command> option:</title> 177 178 <varlistentry> 179 <term><parameter>DESTDIR=$LFS</parameter></term> 180 <listitem> 181 <para>The <envar>DESTDIR</envar> make variable is used by almost all 182 packages to define the location where the package should be 183 installed. If it is not set, it defaults to the root (<filename 184 class="directory">/</filename>) directory. Here we specify that 185 the package be installed in <filename class="directory">$LFS 186 </filename>, which will become the root after <xref linkend= 187 "ch-tools-chroot"/>.</para> 188 </listitem> 189 </varlistentry> 190 191 </variablelist> 192 193 <caution> 194 <para>At this point, it is imperative to stop and ensure that the basic 195 functions (compiling and linking) of the new toolchain are working as 196 expected. To perform a sanity check, run the following commands:</para> 170 197 171 198 <screen><userinput>echo 'int main(){}' > dummy.c 172 199 $LFS_TGT-gcc dummy.c 173 readelf -l a.out | grep ' : /tools'</userinput></screen>174 175 <para>If everything is working correctly, there should be no errors,176 and the output of the last command will be of the form:</para>177 178 <screen><computeroutput>[Requesting program interpreter: / tools/lib64/ld-linux-x86-64.so.2]</computeroutput></screen>179 180 <para>Note that for 32-bit machines, the interpreter name will be181 <filename>/tools/lib/ld-linux.so.2</filename>.</para>182 183 <para>If the output is not shown as above or there was no output at all,184 then something is wrong. Investigate and retrace the steps to find out185 where the problem is and correct it. This issue must be resolved before186 continuing on.</para>187 188 <para>Once all is well, clean up the test files:</para>200 readelf -l a.out | grep '/ld-linux'</userinput></screen> 201 202 <para>If everything is working correctly, there should be no errors, 203 and the output of the last command will be of the form:</para> 204 205 <screen><computeroutput>[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]</computeroutput></screen> 206 207 <para arch="default">Note that for 32-bit machines, the interpreter name will be 208 <filename>/lib/ld-linux.so.2</filename>.</para> 209 210 <para>If the output is not shown as above or there was no output at all, 211 then something is wrong. Investigate and retrace the steps to find out 212 where the problem is and correct it. This issue must be resolved before 213 continuing on.</para> 214 215 <para>Once all is well, clean up the test files:</para> 189 216 190 217 <screen><userinput>rm -v dummy.c a.out</userinput></screen> 191 218 192 </caution> 193 194 <note><para>Building Binutils in the section after next will serve as an 195 additional check that the toolchain has been built properly. If Binutils 196 fails to build, it is an indication that something has gone wrong with the 197 previous Binutils, GCC, or Glibc installations.</para></note> 219 </caution> 220 221 <note><para>Building packages in the next chapter will serve as an 222 additional check that the toolchain has been built properly. If some 223 package, especially binutils-pass2 or gcc-pass2, fails to build, it is 224 an indication that something has gone wrong with the 225 previous Binutils, GCC, or Glibc installations.</para></note> 226 227 <para>Now that our cross-toolchain is complete, finalize the installation 228 of the limits.h header. For doing so, run a utility provided by the GCC 229 developers:</para> 230 231 <screen><userinput>$LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders</userinput></screen> 198 232 199 233 </sect2> 200 234 201 <sect2 arch="ml_32,ml_all" role="installation"> 202 <title>Installation of Glibc 32-bit</title> 203 204 <para>Clean the build directory for redoing glibc for 32-bit:</para> 205 <screen><userinput remap="pre">mkdir ../build32 206 cd ../build32</userinput></screen> 207 208 <para>Rebuild glibc for 32-bit:</para> 209 <screen><userinput remap="configure">echo slibdir=/tools/lib32 > configparms 210 BUILD_CC="gcc -m32" \ 211 CC="${LFS_TGT}-gcc -m32" \ 212 CXX="${LFS_TGT}-g++ -m32" \ 213 AR="${LFS_TGT}-ar" \ 214 RANLIB="${LFS_TGT}-ranlib" \ 215 ../configure --prefix=/tools \ 216 --build=$(../scripts/config.guess) \ 217 --host=${LFS_TGT32} \ 218 --enable-kernel=&min-kernel; \ 219 --with-headers=/tools/include \ 220 --with-binutils=/tools/bin \ 221 --enable-multi-arch \ 222 --libdir=/tools/lib32 \ 223 --libexecdir=/tools/lib32</userinput></screen> 224 <!-- \ 225 libc_cv_forced_unwind=yes \ 226 libc_cv_c_cleanup=yes</userinput></screen> --> 227 228 <variablelist> 229 <title>The meaning of the extra configure options:</title> 230 231 <varlistentry> 232 <term><parameter>--enable-multi-arch</parameter></term> 233 <listitem> 234 <para>Enables glibc for multiarch environments.</para> 235 </listitem> 236 </varlistentry> 237 238 <varlistentry> 239 <term><parameter>--libdir=/tools/lib32, --libexecdir=/tools/lib32</parameter></term> 240 <listitem> 241 <para>Overrides location for installing 32-bit files.</para> 242 </listitem> 243 </varlistentry> 244 245 <varlistentry> 246 <term><parameter>--with-binutils=/tools/bin</parameter></term> 247 <listitem> 248 <para>This tells Glibc to compile itself against the utilities 249 found within our "tools" heirachy, because otherwise...</para> 250 </listitem> 251 </varlistentry> 252 253 </variablelist> 254 255 <para>Now compile the 32-bit version of glibc:</para> 235 <!-- - - - - - - - - - --> 236 <!-- Multilib - 32bit --> 237 <!-- - - - - - - - - - --> 238 <sect2 arch="ml_32,ml_all"> 239 <title>Building Glibc - 32bit</title> 240 241 <para>Now recompile for m32. The extracted source can be 242 reused but needs to cleaned before installing the m32 243 version of Glibc.</para> 244 245 <para>Clear the build directory and remove artefacts from 246 previous build:</para> 247 248 <screen><userinput remap="pre">make clean 249 find .. -name "*.a" -delete</userinput></screen> 250 251 <para>Configure Glibc for m32 with the following commands:</para> 252 253 <screen><userinput remap="configure">CC="$LFS_TGT-gcc -m32" \ 254 CXX="$LFS_TGT-g++ -m32" \ 255 ../configure \ 256 --prefix=/usr \ 257 --host=$LFS_TGT32 \ 258 --build=$(../scripts/config.guess) \ 259 --enable-kernel=&min-kernel; \ 260 --with-headers=$LFS/usr/include \ 261 --enable-multi-arch \ 262 --libdir=&usr-lib-m32; \ 263 --libexecdir=&usr-lib-m32; \ 264 libc_cv_slibdir=&lib-m32;</userinput></screen> 265 266 <para>Compile the package:</para> 267 256 268 <screen><userinput remap="make">make</userinput></screen> 257 269 258 <para>Install 32-bit version of glibc:</para> 259 <screen><userinput remap="install">make install_root="${PWD}/DESTDIR" install 260 install -vdm755 /tools/lib32 261 cp -Rv DESTDIR/tools/lib32/* /tools/lib32 262 install -vm644 DESTDIR/tools/include/gnu/{lib-names,stubs}-32.h \ 263 /tools/include/gnu/ 264 ln -svf /tools/lib32/ld-linux.so.2 /tools/lib/</userinput></screen> 265 266 </sect2> 267 268 <sect2 arch="ml_x32,ml_all" role="installation"> 269 <title>Installation of Glibc x32-bit</title> 270 271 <para>Create a build directory for redoing glibc for x32-bit:</para> 272 <screen><userinput remap="pre">mkdir ../build32x 273 cd ../build32x</userinput></screen> 274 275 <para>Rebuild glibc for x32-bit:</para> 276 <screen><userinput remap="configure">echo slibdir=/tools/libx32 > configparms 277 BUILD_CC="gcc -mx32" \ 278 CC="${LFS_TGT}-gcc -mx32" \ 279 CXX="${LFS_TGT}-g++ -mx32" \ 280 AR="${LFS_TGT}-ar" \ 281 RANLIB="${LFS_TGT}-ranlib" \ 282 ../configure --prefix=/tools \ 283 --build=$(../scripts/config.guess) \ 284 --host=${LFS_TGTX32} \ 285 --enable-kernel=&min-kernel; \ 286 --with-headers=/tools/include \ 287 --with-binutils=/tools/bin \ 288 --enable-multi-arch \ 289 --libdir=/tools/libx32 \ 290 --libexecdir=/tools/libx32</userinput></screen> 291 <!-- \ 292 libc_cv_forced_unwind=yes \ 293 libc_cv_c_cleanup=yes</userinput></screen> --> 294 295 <variablelist> 296 <title>The meaning of the extra configure options:</title> 297 298 <varlistentry> 299 <term><parameter>--enable-multi-arch</parameter></term> 300 <listitem> 301 <para>Enables glibc for multiarch environments.</para> 302 </listitem> 303 </varlistentry> 304 305 <varlistentry> 306 <term><parameter>--libdir=/tools/libx32, --libexecdir=/tools/libx32</parameter></term> 307 <listitem> 308 <para>Overrides location for installing x32-bit files.</para> 309 </listitem> 310 </varlistentry> 311 312 <varlistentry> 313 <term><parameter>--with-binutils=/tools/bin</parameter></term> 314 <listitem> 315 <para>This tells Glibc to compile itself against the utilities 316 found within our "tools" heirachy, because otherwise...</para> 317 </listitem> 318 </varlistentry> 319 320 </variablelist> 321 322 <para>Now compile the x32-bit version of glibc:</para> 323 <screen><userinput remap="make">make</userinput></screen> 324 325 <para>Install x32-bit version of glibc:</para> 326 <screen><userinput remap="install">make install_root="${PWD}/DESTDIR" install 327 install -vdm755 /tools/libx32 328 cp -Rv DESTDIR/tools/libx32/* /tools/libx32 329 install -vm644 DESTDIR/tools/include/gnu/lib-names-x32.h \ 330 /tools/include/gnu/ 331 [ -e DESTDIR/tools/include/gnu/stubs-x32.h ] \ 332 && install -vm644 DESTDIR/tools/include/gnu/stubs-x32.h /tools/include/gnu/ \ 333 || ln -v /tools/include/gnu/stubs-64.h /tools/include/gnu/stubs-x32.h 334 ln -svf /tools/libx32/ld-linux-x32.so.2 /tools/lib/</userinput></screen> 335 <!-- For whatever reason the stubs-x32.h doesn't get created. The 'ln' above is 336 just a "brute force" workaraound - by copying the stubs-64.h file. --> 337 338 <caution> 339 <para>At this point, it is imperative to stop and ensure that the basic 340 functions (compiling and linking) of the new toolchain are working as 341 expected. To perform a sanity check, run the following commands:</para> 270 <para>Install the package:</para> 271 272 <screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install 273 cp -a DESTDIR&lib-m32;/* $LFS&lib-m32;/ 274 cp -a DESTDIR&usr-lib-m32; $LFS/usr/ 275 install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \ 276 $LFS/usr/include/gnu/ 277 ln -svf ..&lib-m32;/ld-linux.so.2 $LFS/lib/ld-linux.so.2</userinput></screen> 278 279 <caution> 280 <para>At this point, it is imperative to stop and ensure that the basic 281 functions (compiling and linking) of the new toolchain are working as 282 expected. To perform a sanity check, run the following commands:</para> 342 283 343 284 <screen><userinput>echo 'int main(){}' > dummy.c 344 285 $LFS_TGT-gcc -m32 dummy.c 345 readelf -l a.out | grep ': /tools'</userinput></screen> 346 347 <para>If everything is working correctly, there should be no errors, 348 and the output of the last command will be of the form:</para> 349 350 <screen><computeroutput>[Requesting program interpreter: /tools/lib/ld-linux.so.2]</computeroutput></screen> 351 352 <para>Redo test for x32-ABI:</para> 286 readelf -l a.out | grep '/ld-linux'</userinput></screen> 287 288 <para>If everything is working correctly, there should be no errors, 289 and the output of the last command will be of the form:</para> 290 291 <screen><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen> 292 293 <para>If the output is not shown as above or there was no output at all, 294 then something is wrong. Investigate and retrace the steps to find out 295 where the problem is and correct it. This issue must be resolved before 296 continuing on.</para> 297 298 <para>Once all is well, clean up the test files:</para> 299 300 <screen><userinput>rm -v dummy.c a.out</userinput></screen> 301 302 </caution> 303 304 </sect2><!-- m32 --> 305 306 <!-- - - - - - - - - - --> 307 <!-- Multilib - x32bit --> 308 <!-- - - - - - - - - - --> 309 310 <sect2 arch="ml_x32,ml_all"> 311 <title>Building Glibc - x32bit</title> 312 313 <para>Now recompile for mx32. The extracted source can be 314 reused but needs to cleaned before installing the mx32 315 version of Glibc.</para> 316 317 <para>Clear the build directory and remove artefacts from 318 previous build:</para> 319 320 <screen><userinput remap="pre">make clean 321 find .. -name "*.a" -delete</userinput></screen> 322 323 <para>Configure Glibc for mx32 with the following commands:</para> 324 325 <screen><userinput remap="configure">CC="$LFS_TGT-gcc -mx32" \ 326 CXX="$LFS_TGT-g++ -mx32" \ 327 ../configure \ 328 --prefix=/usr \ 329 --host=$LFS_TGTX32 \ 330 --build=$(../scripts/config.guess) \ 331 --enable-kernel=&min-kernel; \ 332 --with-headers=$LFS/usr/include \ 333 --enable-multi-arch \ 334 --libdir=&usr-lib-mx32; \ 335 --libexecdir=&usr-lib-mx32; \ 336 libc_cv_slibdir=&lib-mx32;</userinput></screen> 337 338 <para>Compile the package:</para> 339 340 <screen><userinput remap="make">make</userinput></screen> 341 342 <para>Install the package:</para> 343 344 <screen><userinput remap="install">make DESTDIR=$PWD/DESTDIR install 345 cp -a DESTDIR&lib-mx32;/* $LFS&lib-mx32;/ 346 cp -a DESTDIR&usr-lib-mx32; $LFS/usr/ 347 install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \ 348 $LFS/usr/include/gnu/ 349 ln -svf ..&lib-mx32;/ld-linux-x32.so.2 $LFS/lib/ld-linux-x32.so.2</userinput></screen> 350 351 <caution> 352 <para>At this point, it is imperative to stop and ensure that the basic 353 functions (compiling and linking) of the new toolchain are working as 354 expected. To perform a sanity check, run the following commands:</para> 353 355 354 356 <screen><userinput>echo 'int main(){}' > dummy.c 355 357 $LFS_TGT-gcc -mx32 dummy.c 356 readelf -l a.out | grep ': /tools'</userinput></screen> 357 358 <para>Output should be like:</para> 359 360 <screen><computeroutput>[Requesting program interpreter: /tools/libx32/ld-linux-x32.so.2]</computeroutput></screen> 361 362 <para>If the output is not shown as above or there was no output at all, 363 then something is wrong. Investigate and retrace the steps to find out 364 where the problem is and correct it. This issue must be resolved before 365 continuing on.</para> 366 367 <para>Once all is well, clean up the test files:</para> 358 readelf -l a.out | grep '/ld-linux-x32'</userinput></screen> 359 360 <para>If everything is working correctly, there should be no errors, 361 and the output of the last command will be of the form:</para> 362 363 <screen><computeroutput>[Requesting program interpreter: /lib/ld-linux-x32.so.2]</computeroutput></screen> 364 365 <para>If the output is not shown as above or there was no output at all, 366 then something is wrong. Investigate and retrace the steps to find out 367 where the problem is and correct it. This issue must be resolved before 368 continuing on.</para> 369 370 <para>Once all is well, clean up the test files:</para> 368 371 369 372 <screen><userinput>rm -v dummy.c a.out</userinput></screen> 370 373 371 </caution> 372 </sect2> 373 374 </caution> 375 376 </sect2><!-- mx32 --> 377 374 378 <sect2 role="content"> 375 379 <title/>
Note:
See TracChangeset
for help on using the changeset viewer.