5.9. Binutils-2.34 - Pass 2

The Binutils package contains a linker, an assembler, and other tools for handling object files.

Approximate build time: 1.1 SBU
Required disk space: 651 MB

5.9.1. Installation of Binutils

Create a separate build directory again:

mkdir -v build
cd       build

Prepare Binutils for compilation:

CC=$LFS_TGT-gcc                \
AR=$LFS_TGT-ar                 \
RANLIB=$LFS_TGT-ranlib         \
../configure                   \
    --prefix=/tools            \
    --disable-nls              \
    --disable-werror           \
    --with-lib-path=/tools/lib \

The meaning of the new configure options:


Because this is really a native build of Binutils, setting these variables ensures that the build system uses the cross-compiler and associated tools instead of the ones on the host system.


This tells the configure script to specify the library search path during the compilation of Binutils, resulting in /tools/lib being passed to the linker. This prevents the linker from searching through library directories on the host.


This defines a default (non-existent) sysroot directory /tools/$LFS_TGT/sys-root. It is useful when looking for shared objects which are required by other shared objects explicitly included on the linker's command line. Those objects are searched into the directories listed in <sysroot>/etc/ld.so.conf, and failing that, into the linker search path, which is right. If this switch is not given, /etc/ld.so.conf on the host is used, that is, programs may be linked to libraries on the host, which we want to avoid.

Compile the package:


Install the package:

make install

Now prepare the linker for the Re-adjusting phase in the next chapter:

make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin

The meaning of the make parameters:

-C ld clean

This tells the make program to remove all compiled files in the ld subdirectory.

-C ld LIB_PATH=/usr/lib:/lib

This option rebuilds everything in the ld subdirectory. Specifying the LIB_PATH Makefile variable on the command line allows us to override the default value of the temporary tools and point it to the proper final path. The value of this variable specifies the linker's default library search path. This preparation is used in the next chapter.

Details on this package are located in Section 6.18.2, “Contents of Binutils.”