Linux From Scratch - Version 6.3

Chapter 6. Installing Basic System Software

6.10.
Re-adjusting the Toolchain

Now that the final C libraries have been installed, it is time to
adjust the toolchain again. The toolchain will be adjusted so that it
will link any newly compiled program against these new libraries.
This is a similar process used in the “Adjusting” phase in the beginning of Chapter 5,
but with the adjustments reversed. In Chapter 5,
the chain was guided from the host's /{,usr/}lib directories to the new /tools/lib directory. Now, the chain will be guided
from that same /tools/lib directory to
the LFS /{,usr/}lib directories.

First, backup the /tools linker, and
replace it with the adjusted linker we made in chapter 5. We'll also
create a link to its counterpart in /tools/$(gcc -dumpmachine)/bin:

Next, amend the GCC specs file so that it points to the new dynamic
linker, and so that GCC knows where to find the correct headers and
Glibc start files. A sed command accomplishes this:

Important

If working on a platform where the name of the dynamic linker is
something other than ld-linux.so.2,
substitute “ld-linux.so.2”
with the name of the platform's dynamic linker in the following
commands. Refer to Section 5.2,
“Toolchain Technical Notes,” if necessary.

If everything is working correctly, there should be no errors, and
the output of the last command will be:

attempt to open /lib/libc.so.6 succeeded

Lastly, make sure GCC is using the correct dynamic linker:

grep found dummy.log

If everything is working correctly, there should be no errors, and
the output of the last command will be (allowing for
platform-specific differences in dynamic linker name):

found ld-linux.so.2 at /lib/ld-linux.so.2

If the output does not appear as shown above or is not received at
all, then something is seriously wrong. Investigate and retrace the
steps to find out where the problem is and correct it. The most
likely reason is that something went wrong with the specs file
adjustment. Any issues will need to be resolved before continuing on
with the process.