<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 17, 2016 at 11:28 AM, Renato Golin via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 17 October 2016 at 19:09, Flamedoge via llvm-dev<br>
<span class=""><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> Just for the interest of discussion, I find it completely weird and<br>
> interesting that GCC needs to build itself 3 times to fully bootstrap. Has<br>
> there been any interest in looking at a single compile build?</span></blockquote><div><br></div><div>(I know renato did not write this, but i'll just answer this here)</div><div>This is deliberate and necessary if you want to be sure.</div><div>You can do a single compile build by just "not bootstrapping".</div><div><br></div><div>The reason boostrapping is 3 stages is to find optimizer bugs.</div><div><br></div><div>stage 1: Compile new compiler</div><div>stage 2: Compile self with new compiler // IE detect any obvious bugs in new compiler, like ICE, etc</div><div>stage 3: Compiler self with stage 2 compiler // IE detect  miscompiles caused by new compiler being broken</div><div><br></div><div>Stage 2 and 3 should be identical, if they aren't, you have a minimum of non-determinism, and more likely, a codegen bug somewhere.</div><div><br></div><div>Otherwise, stage2 could be very broken and you may not notice, because the compiler has relatively few compile + execute tests (since they are very hard to write)</div><div>Instead, they rely on the one large execution test they know they can use: the compiler itself.</div><div><br></div><div>Note that 3 stage bootstraps are a technique that predates gcc :)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""> I don't<br>
> exactly know the limitations, but my naive thinking is that C++14 compiler<br>
> source parsed by C++14 capable compiler and codegen'd to C99 (or older)<br>
> source should make it compilable by older compilers. Is this just a delusion<br>
> or an actually useful idea?<br>
<br>
</span>Far from being an expert, my understanding is that this is largely due<br>
to the libraries and tools.<br>
<br>
GCC has a reduced sub-set of the compiler that works with many old<br>
compilers, and they build that one first, then use that one to build<br>
the required libraries, tools, and the complete compiler, than use the<br>
complete compiler to bootstrap. </blockquote><div><br></div><div>This is not correct :)</div><div> </div><div>First stage of gcc is the entire compiler, not a subset or a different compoiler.</div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can also have cross-bootstrap, or<br>
Canadian cross, which increase the complexity of the builds by a<br>
reasonable margin.<br>
<br>
LLVM doesn't do that because we rely on the system's libraries, which<br>
honestly is a bad habit. This bad habit made the edges between RT,<br>
libc++ and LLVM a bit rough, especially when cross compiling and<br>
re-using those tools to bootstrap. It also makes it very hard to have<br>
stable tests, especially in between "package upgrades".<br>
<br>
It should be possible to bootstrap Clang in only two stages, but that<br>
requires a lot of CMake magic if we want to get *all* components<br>
built, including RT, libc++ and lld.<br>
<br>
However, none of that mentions the C library, which is a whole new<br>
problem if Clang can't compile it. I believe we still can't compile<br>
the GNU C library, but we can compile Musl (at least for some<br>
targets), so we could include Musl on such a two-stage magical<br>
bootstrap...<br>
<br>
But that's a lot of work... :)<br>
<div class="HOEnZb"><div class="h5"><br>
cheers,<br>
--renato<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div></div>