%general-entities; ]> glibc &glibc-version;
&glibc-url;
Glibc-&glibc-version; Glibc tools <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../chapter06/glibc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/> <segmentedlist> <segtitle>&buildtime;</segtitle> <segtitle>&diskspace;</segtitle> <seglistitem> <seg>&glibc-ch5-sbu;</seg> <seg>&glibc-ch5-du;</seg> </seglistitem> </segmentedlist> </sect2> <sect2 role="installation"> <title>Installation of Glibc The Glibc documentation recommends building Glibc in a dedicated build directory: mkdir -v build cd build Next, prepare Glibc for compilation: ../configure \ --prefix=/tools \ --host=$LFS_TGT \ --build=$(../scripts/config.guess) \ --enable-kernel=&min-kernel; \ --with-headers=/tools/include The meaning of the configure options: --host=$LFS_TGT, --build=$(../scripts/config.guess) The combined effect of these switches is that Glibc's build system configures itself to cross-compile, using the cross-linker and cross-compiler in /tools. --enable-kernel=&min-kernel; This tells Glibc to compile the library with support for &min-kernel; and later Linux kernels. Workarounds for older kernels are not enabled. --enable-multi-arch Enables glibc for multiarch environments. --with-headers=/tools/include This tells Glibc to compile itself against the headers recently installed to the tools directory, so that it knows exactly what features the kernel has and can optimize itself accordingly. During this stage the following warning might appear:
configure: WARNING: *** These auxiliary programs are missing or *** incompatible versions: msgfmt *** some features will be disabled. *** Check the INSTALL file for required versions.
The missing or incompatible msgfmt program is generally harmless. This msgfmt program is part of the Gettext package which the host distribution should provide. There have been reports that this package may fail when building as a "parallel make". If this occurs, rerun the make command with a "-j1" option. Compile the package: make Install the package: make install At this point, it is imperative to stop and ensure that the basic functions (compiling and linking) of the new toolchain are working as expected. To perform a sanity check, run the following commands: echo 'int main(){}' > dummy.c $LFS_TGT-gcc dummy.c readelf -l a.out | grep ': /tools' If everything is working correctly, there should be no errors, and the output of the last command will be of the form: [Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2] Note that for 32-bit machines, the interpreter name will be /tools/lib/ld-linux.so.2. If the output is not shown as above or there was no output at all, then something is wrong. Investigate and retrace the steps to find out where the problem is and correct it. This issue must be resolved before continuing on. Once all is well, clean up the test files: rm -v dummy.c a.out Building Binutils in the section after next will serve as an additional check that the toolchain has been built properly. If Binutils fails to build, it is an indication that something has gone wrong with the previous Binutils, GCC, or Glibc installations.
Installation of Glibc 32-bit Clean the build directory for redoing glibc for 32-bit: mkdir ../build32 cd ../build32 Rebuild glibc for 32-bit: echo slibdir=/tools/lib32 > configparms BUILD_CC="gcc -m32" \ CC="${LFS_TGT}-gcc -m32" \ CXX="${LFS_TGT}-g++ -m32" \ AR="${LFS_TGT}-ar" \ RANLIB="${LFS_TGT}-ranlib" \ ../configure --prefix=/tools \ --build=$(../scripts/config.guess) \ --host=${LFS_TGT32} \ --enable-kernel=&min-kernel; \ --enable-multi-arch \ --libdir=/tools/lib32 \ --libexecdir=/tools/lib32 \ --with-headers=/tools/include \ --with-binutils=/tools/bin \ libc_cv_forced_unwind=yes \ libc_cv_c_cleanup=yes Now compile the 32-bit version of glibc: make Install 32-bit version of glibc: make install_root="${PWD}/DESTDIR" install install -vdm755 /tools/lib32 cp -Rv DESTDIR/tools/lib32/* /tools/lib32 install -vm644 DESTDIR/tools/include/gnu/{lib-names,stubs}-32.h \ /tools/include/gnu/ ln -svf /tools/lib32/ld-linux.so.2 /tools/lib/ cd .. Installation of Glibc x32-bit Create a build directory for redoing glibc for x32-bit: mkdir build32x cd build32x Rebuild glibc for x32-bit: echo slibdir=/tools/libx32 > configparms BUILD_CC="gcc -mx32" \ CC="${LFS_TGT}-gcc -mx32" \ CXX="${LFS_TGT}-g++ -mx32" \ AR="${LFS_TGT}-ar" \ RANLIB="${LFS_TGT}-ranlib" \ ../configure --prefix=/tools \ --build=$(../scripts/config.guess) \ --host=${LFS_TGTX32} \ --enable-kernel=&min-kernel; \ --enable-multi-arch \ --libdir=/tools/libx32 \ --libexecdir=/tools/libx32 \ --with-headers=/tools/include \ --with-binutils=/tools/bin \ libc_cv_forced_unwind=yes \ libc_cv_c_cleanup=yes Now compile the x32-bit version of glibc: make Install x32-bit version of glibc: make install_root="${PWD}/DESTDIR" install install -vdm755 /tools/libx32 cp -Rv DESTDIR/tools/libx32/* /tools/libx32 install -vm644 DESTDIR/tools/include/gnu/lib-names-x32.h \ /tools/include/gnu/ [ -e DESTDIR/tools/include/gnu/stubs-x32.h ] \ && install -vm644 DESTDIR/tools/include/gnu/stubs-x32.h /tools/include/gnu/ \ || ln -v /tools/include/gnu/stubs-64.h /tools/include/gnu/stubs-x32.h ln -svf /tools/libx32/ld-linux-x32.so.2 /tools/lib/ At this point, it is imperative to stop and ensure that the basic functions (compiling and linking) of the new toolchain are working as expected. To perform a sanity check, run the following commands: echo 'int main(){}' > dummy.c $LFS_TGT-gcc -m32 dummy.c readelf -l a.out | grep ': /tools' If everything is working correctly, there should be no errors, and the output of the last command will be of the form: [Requesting program interpreter: /tools/lib/ld-linux.so.2] Redo test for x32-ABI: echo 'int main(){}' > dummy.c $LFS_TGT-gcc -mx32 dummy.c readelf -l a.out | grep ': /tools' Output should be like: [Requesting program interpreter: /tools/lib/ld-linux-x32.so.2] If the output is not shown as above or there was no output at all, then something is wrong. Investigate and retrace the steps to find out where the problem is and correct it. This issue must be resolved before continuing on. Once all is well, clean up the test files: rm -v dummy.c a.out <para>Details on this package are located in <xref linkend="contents-glibc" role="."/></para> </sect2> </sect1>