开发者

Compiling the compiler - how many times?

If you compile a new version of compiler, how many times should you recompile it iteratively?

First: compile the new version of compiler[1] using the old version[0].

Second: compile the new version[2] using the newly compiled one[1], to apply new optimizations and fix bugs to the binary, not present in old[0] compiler.

Now third? Compile again, using [2] to remove any potential bugs that could have resulted from bugs in [1] as result of faulty compilation by buggy [0]...?

...but if you're paranoid, maybe the bugs introduced by [0] into [1] caused [2] to be somewhat buggy 开发者_StackOverflowtoo...?

Does going beyond [2] make sense at all?


I'd stop when the result of compilation n is identical to the result of compilation n - 1; at that point you've reached steady state.


The instructions for bootstrapping OCaml invite you to continue until you have reached a fixpoint, if you wish. Assuming the new compiler only fixes bugs and does not introduce new ones, you may need to bootstrap several times to make self-inducing compiler bugs disappear.

You may also reach a fixpoint without the bug you were trying to fix being fixed, because the presence of the bug in the bootstrap compiler perpetuates it in the bootstrapped version (a sort of involuntary Ken Thompson). This happened at least once in the history of OCaml. When they noticed this, the developers fixed the assembly code by hand in order to obtain a correct compiler that translated correct source into a correct compiler.


Typically you should compile once withouth the standard library and get a partially working version of the compiler. Subsequently you need to recompile with the standard library support: this enables you to get further functionality (like printf checking and libgcc stuff).

I didn't know about subsequent recompilations, but thanks for the info :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜