title: How to build a reliable toolchain
body: <p>Please guide me through the <strong>steps required to build a basic toolchain</strong> sufficient to build a bootable linux image and <strong>discuss why things should be done the way you suggest</strong>.</p>
  
  <p>Pointers to <strong>existing documentation</strong> is also very much appreciated. I have looked into Linux from Scratch and have some experience building Gentoo images using the distribution specific tools.  I have also looked at the documentation of various tools used to build cross-compiling toolchains for embedded devices.</p>
  
  <p>However the documentation of these tools only discuss compiling toolchains actually using these tools not how they do it, and why not differently.  Often the these resources also mention that other tools do it differently (and of course worse), so I get a feeling simply reading the source will only help me learn how the given build tool works rather than provide insight into the actual process and it's possible variation.</p>
  
  <p>So I am not much interested in discussions about tools to automate building a toolchain but instead in <strong>commented instructions on how to do it manually</strong>.  Also note that for now I plan to build and run the image on the same machine so I do not need to cross-compile.  But I am still interested in discussions about cross-compiling, but the focus should probably be elsewhere. What else is needed on and to build a bootable image is not part of this question - just building the toolchain to get there it is.</p>
  
  <p><em>To help you understand where I stand here are some questions I have and some things I believe to know:
  I understand that even when building natively it is important to separate the toolchain used to build the image from that of the host to avoid linking to libraries which might not be available later (other reasons?).  I don't know whether it is sufficient to adjust environment variables accordingly (which?) or if it is best to build a toolchain, chroot and the rebuild (what do I gain from rebuilding?). What could go wrong if doing the former? I have read that building gcc twice (using the first to build the second) is overkill since it's build system does this anyway.  If so what differences in the two builds can it detect, why do they matter?  Has necessarily something gone wrong if the two builds differ and what is done about it if they do.  Does cross-compiling when done properly result in exactly the same binaries as when done natively? And if not, why is that not so bad after all and many projects choose that way never-the-less?</em></p>