Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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~

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
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: stackoverflow.com/questions/1726042/… || gcc.gnu.org/simtest-howto.html – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Jun 8 '15 at 14:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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