%general-entities; ]> 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 , but with the adjustments reversed. In , 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, amend the GCC specs file so that it points to the new dynamic linker. A sed command accomplishes this: SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs && gcc -dumpspecs > $SPECFILE && sed -i 's@^/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE && unset SPECFILE It is a good idea to visually inspect the specs file to verify the intended change was actually made. 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 above commands. Refer back to if necessary. Now create temporary wrapper scripts for gcc and ld. These scripts will point to their real counterparts in /tools but with adjusted parameters to ensure that GCC in the next section links to our newly installed Glibc. cat > /usr/bin/gcc << "EOF" #!/bin/bash /tools/bin/gcc -B/usr/lib $@ EOF cat > /usr/bin/ld << "EOF" #!/bin/bash /tools/bin/ld -nostdlib -L/usr/lib -L/lib $@ EOF chmod 755 /usr/bin/{ld,gcc} ln -s gcc /usr/bin/cc It is imperative at this point to stop and ensure that the basic functions (compiling and linking) of the adjusted toolchain are working as expected. To do this, perform a sanity check: echo 'main(){}' > dummy.c cc dummy.c readelf -l a.out | grep ': /lib' 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): [Requesting program interpreter: /lib/ld-linux.so.2] Note that /lib is now the prefix of our dynamic linker. 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 amendment above. Any issues will need to be resolved before continuing on with the process. Once everything is working correctly, clean up the test files: rm -v dummy.c a.out