Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I thought very hard about this problem as I've developed Virgil [https://github.com/titzer/virgil] over the years. Bootstrapping any system, not the least of which a new programming language is a hard problem.

Virgil has an (almost) hermetic build. The compiler binaries for a stable version are checked into the repository. At any given revision, that stable compiler can compile the source code in the repo to produce a new compiler binary, for any of the supported platforms. That stable binary is therefore a cross-compiler. There are stable binaries for each of the supported stable platforms (x86-darwin, x86-linux, JVM), and there are more platforms that are in the works (x86-64-linux, wasm), but don't have stable binaries.

What do you need to run one of the stable binaries?

1. JVM: any Java 5 compliant JVM

2. x86-linux: a 32-bit Linux kernel

3. x86-darwin: a 32-bit Darwin kernel*

[*] sadly, no longer supported past Mavericks, thanks Apple

The (native) compiler binaries are statically-linked, so they don't need any runtime libraries, DLLs, .so, etc.

Also, nothing depends on having a compiler for any other language, or even much of a shell. There is test code in C, but no runtime system or other services. The entire system is self-hosted.

I think this is a decent solution, but it has limitations. For one, since stable executables absolutely need to be checked in, it's not good to rev stable too often, since it will bloat the git repo. Also, checking in binaries that are all cross-compilers for every platform grows like O(n^2). It would be better to check in just one binary per platform, that contains an interpreter capable of running the compiler from source to bootstrap itself. I guess I'll get to that at platform #4.



I’m wondering if bootstrapping from WebAssembly would make sense someday, under the assumption that everyone has a browser? (Though a stand-alone interpreter is preferable.)


That's not a bad long-term plan (if there is a lightweight standalone Wasm interpreter), but Wasm is not quite ubiquitous enough. Hopefully!


I think it would be much better to do Bootstrappable Builds instead of checking generated files into the repo. If no-one else can reproduce the builds of those files, then it will be hard to trust them.

http://bootstrappable.org/ http://reproducible-builds.org/


Question from a point of ignorance - why would you target 32bit for something that is being actively developed?

Are we not at a point where 64bit should be the expected target?


Webassembly for instance is a 32 bit target. So are most arm hobby boards (even if hw is 64 bit, they ship with 32 bit OSes)


A lot of "IoT" devices are 32bit. And there's no reason for them not to be. (There's 8bit ones too.)


I bootstrapped on the JVM first, and then the first native bootstrap was around 2011. I am almost finished with my x86-64-linux port.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: