Hacker News new | ask | show | jobs
by robbrown451 4181 days ago
So you need 1.4 to build 1.5....can you then rebuild 1.5 from 1.5? Would it be different? Would it make a difference if you then rebuilt 1.5 using 1.5 built using 1.5 rather than 1.5 built using 1.4?
3 comments

> So you need 1.4 to build 1.5....can you then rebuild 1.5 from 1.5?

If the language is forward-compatible, yes. It could be different if new optimisations have been added, or the code generator has changed.

> Would it make a difference if you then rebuilt 1.5 using 1.5 built using 1.5 rather than 1.5 built using 1.4?

It should not, the 1.5 compiler should be stable and yield the same result whether it was built using a 1.4 compiler or a 1.5 compiler.

That's actually a common technique to look for regressions and validate the bootstrapped compiler. For instance to compile rustc you download a "stage 0" compiler at Vx which compiles a "stage 1" compiler using Vy > Vx source. That stage 1 compiler is then used to compile the stage 2 compiler from the same source. Stage 1 and stage 2 may not be identical since stage 0 and stage 1 may have different optimisations &al, so the stage 2 compiler is used to compile rust a third time, and that compilation is checked against the original stage 2 (and should be a fixpoint).

That's actually a step in bootstrapping the system. Generally, to bootstrap a language a new language involves building a minimal bootstrap compiler/runtime that is just enough to be able to rebuild the full system:

1. build bootstrap system with existing tools 2. compile full system with bootstrap 3. compile full system again with new compiler

Or something like that.

Edit/Note: The OP linked document is a pretty good explaination of the whole process as well as the implications ...

If both compilers are correct, which compiler you compiled the program (compiler in this case) with shouldn't matter for the correctness of the code; but the generated code would be different. There should be no difference in the code generated by instances of the same compiler version, although the code of the compiler programs itself would be different (i.e. different performance, time of exec...) if they were compiled with different compiler versions.

Edit: That's all assuming same version of the language being compiled. That's why they say the go1.x compilers may need to stay restricted to go 1.4 for their code.

P.S. See Linux From Scratch or osdev.org for more about this