5

I followed LFS doc.

I'm not quite understand why it needs 2 pass of compilation.

My guess:

We need target system's glibc, if we compile by host's gcc, it will not be able to separate with host anymore. So we need to build new system's binutils and gcc first to build target system's glibc let glibc connect with target's binutils and gcc. But first pass of binutils and gcc is using host's glibc, so we need second pass of compilation of target's binutils and gcc.

Are those right?

Is anything I'm missing or misunderstanding?

Thank you~

1 Answer 1

5

Correct. As the Dragon Book explains, you must first build a host binary that builds for the target, and then you use that to build a target binary that builds for the target.

2
  • That isn't really only on LFS, that is the standard way GCC is built. The first round builds just the tools required to compile the second round. And for testing a third round is build and compared to the second one: This is the final GCC compiled with the final GCC, so they should be bit by bit identical (save timestamps).
    – vonbrand
    Jan 28, 2013 at 15:37
  • It is also possible to build them in one go from the GCC tree: stackoverflow.com/questions/1726042/… || gcc.gnu.org/simtest-howto.html Jun 8, 2015 at 14:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .