Sunday, December 27, 2020

Chapter 15 : Compile and Install Glibc - Compiling a Cross-Toolchain

Hi,

In this chapter, we are going to compile Glibc package.

Note :
- Please check the version of the package when you compile and install, at the time of writing the package was at version 2.32
- You should be logged in as lfs user, when you perform the actions described here.
- Change directory to the sources folder (/mnt/lfs/sources)

Before we compile the package, there are certain directories to be created at the location /mnt/lfs.

Use the following command to create the required directories, along with creating the directories we have change the ownership of the directories created.

$ sudo mkdir lib
$ sudo chown lfs lib

$ sudo mkdir etc
$ sudo chown lfs etc

$ sudo mkdir var
$ sudo chown lfs var

$ sudo mkdir lib64
$ sudo chown lfs lib64

Now extract the glibc package using the following command.

$ sudo cd $LFS/sources
$ tar -xvf glibc-2.32.tar.xz

After successful extraction, change directory to glibc-2.32
$ cd glibc-2.32

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

Command to apply the patch to make some of the glibc programs use the non-FHS compliant /var/db directory to store their runtime data

$ patch -Np1 -i ../glibc-2.32-fhs-1.patch

Creating the build directory.

$ mkdir -v build
$ cd build

Preparing glibc for compilation...

$ ../configure                             \
      --prefix=/usr                      \
      --host=$LFS_TGT                    \
      --build=$(../scripts/config.guess) \
      --enable-kernel=3.2                \
      --with-headers=$LFS/usr/include    \
      libc_cv_slibdir=/lib

Compiling the package...

$ make -j4

Installing the package...

$ make DESTDIR=$LFS install

If you would like to have a sanity check on the glibc package, you can make use of the following instructions...

echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep '/ld-linux'

The execution of the above commands should result like the one given below...

[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

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/10.2.0/install-tools/mkheaders




1 comment:

  1. You are god. I tried this exactly and it worked like YKW...

    ReplyDelete

Changing the password of the root user of mysql in Ubuntu

Hi all,    In this post we are going to see how to reset the password of root user in mysql As we all know the root user of mysql is some...