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~

sam
  • 977
  • 1
  • 9
  • 11

1 Answers1

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.

Ignacio Vazquez-Abrams
  • 44,857
  • 7
  • 93
  • 100
  • 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 '13 at 15:37
  • It is also possible to build them in one go from the GCC tree: http://stackoverflow.com/questions/1726042/recipe-for-compiling-binutils-gcc-together || https://gcc.gnu.org/simtest-howto.html – Ciro Santilli OurBigBook.com Jun 08 '15 at 14:48