2

I am trying to follow the LFS book, and couldn't get my mind around this question: we built the GCC compiler in chapter 5 in the target partition, why do we do that again after entering the chroot mode? what's the point, why not use the previous build. Same thing for the GlibC.

2

I believe that the build in the chroot would check to see that all of the ancillary files and programs to build GCC and GlibC are present, and independent of the "build system". Compiling a compiler isn't simple at all, usually. I believe that GCC will require bison and flex and all kinds of header files, config files and who knows what else. The chroot build is just an intermediate step between the build system (which is not LFS) and the final LFS installation, which is supposed to be self-hosting.

Because the run-time environment of GCC is complicated (PATH, LD_LIBRARY_PATH and other configuration items) it's also possible that some side effects will leak through from the initial GCC compiler. I cannot find the paper, but I recall that it can take as many as 5 generations of compiling a compiler with the previously-compiled generation to get all the weird bugs and dependencies to surface.

0

As you are entering a chroot, it means you have an empty system with nothing installed nor working for that matter, so you need tools to compile things which you do in chapter 5. It's also the reason why in chroot you are giving /tools/bin/env with a PATH pointing to the tools directory.

Chapter 6 is doing nothing more then populating chroot by downloading the packages and installing them including gcc and that's where you compile them using the tools from chapter 5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.