The LFS temporary toolchain is going to take a while to cover completely, so I’m breaking it up into several parts for readability.
Binutils (Pass 2)
Binutils contains some of the closest “to the metal” utilities that Linux needs, providing low-level translation of programmer intent into machine-readable binary code. Binutils gets built first as GCC and Glibc will need these lower-level utilities in order to function properly themselves.
The first pass of Binutils was a cross-compile, and this second pass uses a few extra options to use only the first pass (cross-compiled) Binutil’s tools and libraries. This removes any traces of library or settings contamination from the build environment (I’m using the LFS live CD). The second pass of Binutils is installed to the
/tools directory (in the temporary toolchain,
/mnt/lfs/tools), overwriting the first pass version of Binutils.
I estimated Pass #2 of Binutils to take 1 hour and 4 minutes to build, and Pressie breezed through in only 58 minutes.
Not quite everything is right yet: the library linker (
ld) I just compiled would incorrectly look in
/tools for libraries to build against. To remove the contamination of the temporary toolchain itself, I cleaned out the
ld subdirectory and recompiled
ld to point to
/lib (which is where libraries will be on my final LFS system). Then I copied the new
/tools/bin (in the temporary toolchain,
GCC (Pass 2)
To review again:
GCC is the GNU Compiler Collection, and it is the main utility on a Linux box for compiling programs written in C and C++ (and a host of others that are irrelevant to LFS for now).
The first pass of GCC was a cross-compile, and the second pass of GCC will be an uncontaminated build. GCC required a patch and several tweaks to prepare it for building the final LFS system, mostly by changing various build scripts to use the
/tools Glibc libraries rather than the live CD Glibc libraries. These tweaks took quite a bit of typing, so be sure to check several times for any typos before hitting that last Enter. Since Pressie is based on a i586 CPU, I skipped a step that is intended to prevent GCC from linking to x86_64 libraries on a 64-bit host environment. Next, I extracted GMP, MPFR, and MPC into GCC’s source directory for the build process. I needed both the C and C++ compilers to be built, so there are some extra C++-specific configure options that were unnecessary in the first pass. The second pass of GCC installed to
/mnt/lfs/tools in the temporary toolchain), overwriting the first pass version.
I expected GCC to build in 7 hours and 21 minutes, but it took 8 hours and 12 minutes.
Finally, since many programs link to
cc (a generic C compiler) instead of to
gcc specifically, I created a
cc symlink to
LFS recommends doing a basic sanity check on the temporary toolchain before going further. Essentially, I compiled an empty C program and made sure I was using the correct program linker (the new one in
/tools, and not the one from the live CD environment), then deleted the test output. At this point, everything is A-OK to-the-letter perfect. Now I’m ready to build the rest of the utilities in the temporary toolchain!