28 ms·
Thoughts on Bootstrapping GHC (2018)
- codeflo 5y agoAnother point about bootstrapping an ancient version of GHC first and using that to build more modern versions: you need to run the generated x86 code (that also targets an old OS version) to do that, and it’s increasingly not a given that you can do so natively.
- mtve 5y agowonder could https://www.ioccc.org/2019/lynn/hint.html https://www.ioccc.org/2019/lynn/hint.html help here?
- siraben 5y agoThis project[0] is a fork of Ben Lynn’s compiler that can be bootstrapped from a binary less than 1 KB in size. The dialect of Haskell it accepts is impressive for its size and GHC-compatible too. [0] https://github.com/oriansj/blynn-compiler https://github.com/oriansj/blynn-compiler
- dunham 5y agoIf you click through the link on that page (and click on Compiler), there are a series of articles on the development process - step by step bootstrapping stages and some further development past that point. It's a really interesting read: https://crypto.stanford.edu/~blynn/compiler/ https://crypto.stanford.edu/~blynn/compiler/ I learned about Mogensen-Scott encoding and some tricks for efficiently compiling to SKI from those articles.
- choeger 5y agoI think the only way to go is via an interpreter. That interpreter should be written in C, or some language trivially bootstrapped from C (that rules out C++, unfortunately, which has its own bootstrapping problems). The interpreter could target a much simpler version of Haskell and it could be slow as hell, as it would be used only once.
- yakubin 5y agoWhy an interpreter and not a compiler?
- jlokier 5y agoBecause you only intend to run it once, on one input, and ad-hoc interpreters are usually simpler to write than compilers.
- codeflo 5y agoSuch a one-off Haskell interpreter might even get away without or with less rigorous type checking.
- choeger 5y agoAn interpreter omits the target architecture/format question and thus is more portable than a compiler. Of course, you could compile to a higher-level language, for instance directly to C. But that's usually still a complication that only gives you performance. And performance is something you probably don't need during bootstrapping.
- pjmlp 5y agoThat is how P-Code was born for Pascal, its original purpose was only to help porting Pascal compilers not to become a widespread target format for environments like UCSD Pascal.
- yakubin 5y agoHere is an interesting story from pjmlp about how Wirth bootstrapped Pascal: <https://news.ycombinator.com/item?id=30487264 https://news.ycombinator.com/item?id=30487264>