Saturday, December 26, 2020

Chapter 13 : Compile and Install GCC - Compiling a Cross-Toolchain

 Hi,

In this chapter, we are going to discuss on how to compile the GCC which GNU Compiler Collection and cross tool chain.

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

Change Directory to sources folder

$ cd $LFS/sources

Extract the gcc-10.2.0.tar.xz file in source folder

$ tar -xvf gcc-10.2.0.tar.xz

The above command would result in the creation of a new directory in /mnt/lfs/sources/ folder called gcc-10.2.0

Change directory to gcc-10.2.0

$ cd gcc-10.2.0

As you can see from the list of packages given above, the other packages has to be extracted inside gcc-10.2.0 folder, to extract those packages use the commands given below...

$ tar -xf ../mpfr-4.1.0.tar.xz
$ mv -v mpfr-4.1.0 mpfr

$ tar -xf ../gmp-6.2.0.tar.xz
$ mv -v gmp-6.2.0 gmp

$ tar -xf ../mpc-1.1.0.tar.gz
$ mv -v mpc-1.1.0 mpc

On x86_64 hosts, set the default directory name for 64-bit libraries to “lib”

case $(uname -m) in
  x86_64)
    sed -e '/m64=/s/lib64/lib/' \
        -i.orig gcc/config/i386/t-linux64
 ;;
esac

As suggested, the build process has to happen in a dedicated directory, hence creating a directory called build in gcc-10.2.0 folder.

$ mkdir build
$ cd build

Preparing GCC for compilation...

../configure                            \
    --target=$LFS_TGT          \
    --prefix=$LFS/tools           \
    --with-glibc-version=2.11  \
    --with-sysroot=$LFS          \
    --with-newlib                      \
    --without-headers                \
    --enable-initfini-array          \
    --disable-nls                         \
    --disable-shared                   \
    --disable-multilib                 \
    --disable-decimal-float        \
    --disable-threads                  \
    --disable-libatomic              \
    --disable-libgomp                \
    --disable-libquadmath         \
    --disable-libssp                    \
    --disable-libvtv                    \
    --disable-libstdcxx               \
    --enable-languages=c,c++

Compiling GCC
$ make -j4

Installing GCC
$ make install

Create a full version of the internal header using a command that is identical to what the GCC build system does in normal circumstances
$ cd ..
$ mkdir -p ./install-tools/include
$ touch ./install-tools/include/limits.h
$ cat gcc/limitx.h gcc/glimits.h gcc/limity.h > `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h




No comments:

Post a Comment

Addressing Modes of 8080 / 8085 MicroProcessor

Hi,   In this post I am going to talk about different addressing modes of 8080/8085...without much talking let us get into the topic.   Ther...