%general-entities; ]> glibc &glibc-version;
&glibc-url;
Glibc-&glibc-version; Glibc tools <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../chapter08/glibc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/> <segmentedlist> <segtitle>&buildtime;</segtitle> <segtitle>&diskspace;</segtitle> <seglistitem> <seg>&glibc-tmp-sbu;</seg> <seg>&glibc-tmp-du;</seg> </seglistitem> </segmentedlist> </sect2> <sect2 role="installation"> <title>Installation of Glibc First, create a symbolic link for LSB compliance. Additionally, for x86_64, create a compatibility symbolic link required for proper operation of the dynamic library loader: case $(uname -m) in i?86) ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3 ;; x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64 ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3 ;; esac ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64 ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3 Some of the Glibc programs use the non-FHS compliant /var/db directory to store their runtime data. Apply the following patch to make such programs store their runtime data in the FHS-compliant locations: patch -Np1 -i ../glibc-&glibc-version;-fhs-1.patch Fix a build issue with gcc-11.1: sed 's/amx_/amx-/' -i sysdeps/x86/tst-cpu-features-supports.c The Glibc documentation recommends building Glibc in a dedicated build directory: mkdir -v build cd build Next, prepare Glibc for compilation: ../configure \ --prefix=/usr \ --host=$LFS_TGT \ --build=$(../scripts/config.guess) \ --enable-kernel=&min-kernel; \ --with-headers=$LFS/usr/include \ libc_cv_slibdir=/usr/lib \ libc_cv_rtlddir=/usr/lib ../configure \ --prefix=/usr \ --host=$LFS_TGT \ --build=$(../scripts/config.guess) \ --enable-kernel=&min-kernel; \ --with-headers=$LFS/usr/include \ --enable-multi-arch \ libc_cv_slibdir=/usr/lib \ libc_cv_rtlddir=/usr/lib 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 be cross-compiled, using the cross-linker and cross-compiler in $LFS/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. --with-headers=$LFS/usr/include This tells Glibc to compile itself against the headers recently installed to the $LFS/usr/include directory, so that it knows exactly what features the kernel has and can optimize itself accordingly. libc_cv_slibdir=/usr/lib This ensures that the library is installed in /usr/lib instead of the default /lib64 on 64 bit machines. libc_cv_rtlddir=/usr/lib Fix hardcoded path to the executable loader in the ldd script. This disables x86 ISA needed property in Glibc libraries. Use it if you are building Glibc with option in CFLAGS, to workaround an issue in Glibc-2.33 breaking it. 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: If LFS is not properly set, and despite the recommendations, you are building as root, the next command will install the newly built glibc to your host system, which most likely will render it unusable. So double check that the environment is correctly set, before running the following command. make DESTDIR=$LFS install The meaning of the <command>make install</command> option: DESTDIR=$LFS The DESTDIR make variable is used by almost all packages to define the location where the package should be installed. If it is not set, it defaults to the root (/) directory. Here we specify that the package be installed in $LFS , which will become the root after . Fix hardcoded path to the executable loader in ldd script: sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd 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 '/ld-linux' 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: /lib64/ld-linux-x86-64.so.2] Note that for 32-bit machines, the interpreter name will be /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 packages in the next chapter will serve as an additional check that the toolchain has been built properly. If some package, especially binutils-pass2 or gcc-pass2, fails to build, it is an indication that something has gone wrong with the previous Binutils, GCC, or Glibc installations. Now that our cross-toolchain is complete, finalize the installation of the limits.h header. For doing so, run a utility provided by the GCC developers: $LFS/tools/libexec/gcc/$LFS_TGT/&gcc-version;/install-tools/mkheaders
Building Glibc - 32bit Now recompile for m32. The extracted source can be reused but needs to be cleaned before installing the m32 version of Glibc. Clear the build directory and remove artefacts from previous build: make clean find .. -name "*.a" -delete Configure Glibc for m32 with the following commands: CC="$LFS_TGT-gcc -m32" \ CXX="$LFS_TGT-g++ -m32" \ ../configure \ --prefix=/usr \ --host=$LFS_TGT32 \ --build=$(../scripts/config.guess) \ --enable-kernel=&min-kernel; \ --with-headers=$LFS/usr/include \ --enable-multi-arch \ --libdir=/usr/lib32 \ --libexecdir=/usr/lib32 \ libc_cv_slibdir=/usr/lib32 \ libc_cv_rtlddir=/usr/lib32 Compile the package: make Install the package: make DESTDIR=$PWD/DESTDIR install cp -a DESTDIR/usr/lib32 $LFS/usr/ install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-32.h \ $LFS/usr/include/gnu/ ln -svf ../lib32/ld-linux.so.2 $LFS/lib/ld-linux.so.2 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 '/ld-linux' 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: /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 Glibc - x32bit Now recompile for mx32. The extracted source can be reused but needs to be cleaned before installing the mx32 version of Glibc. Clear the build directory and remove artefacts from previous build: make clean find .. -name "*.a" -delete Configure Glibc for mx32 with the following commands: CC="$LFS_TGT-gcc -mx32" \ CXX="$LFS_TGT-g++ -mx32" \ ../configure \ --prefix=/usr \ --host=$LFS_TGTX32 \ --build=$(../scripts/config.guess) \ --enable-kernel=&min-kernel; \ --with-headers=$LFS/usr/include \ --enable-multi-arch \ --libdir=/usr/libx32 \ --libexecdir=/usr/libx32 \ libc_cv_slibdir=/usr/libx32 \ libc_cv_rtlddir=/usr/libx32 Compile the package: make Install the package: make DESTDIR=$PWD/DESTDIR install cp -a DESTDIR/usr/libx32 $LFS/usr/ install -vm644 DESTDIR/usr/include/gnu/{lib-names,stubs}-x32.h \ $LFS/usr/include/gnu/ ln -svf ../libx32/ld-linux-x32.so.2 $LFS/lib/ld-linux-x32.so.2 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 -mx32 dummy.c readelf -l a.out | grep '/ld-linux-x32' 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: /libx32/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>