How can the Linux kernel compile itself?(stackoverflow.com) |
How can the Linux kernel compile itself?(stackoverflow.com) |
Short answer: it can't. Each software system relies for its own existence on a predecessor, usually one of smaller scope. Sort of like biology and evolution.
When I wrote Apple Writer in 1978, there were no high-level development tools available, just a primitive assembler built into the Apple II BIOS. By making direct hand entries, I used the BIOS assembler to write a better, faster assembler that supported alphabetic labels. Then I used that assembler to write a better one, and eventually I had a development tool suitable for writing applications.
Linux development has relied on a similar bootstrap process, on a larger scale.
Thanks for this suggestion! I write a lot of articles, but I haven't written much about that period, possibly because other people were writing it for me. But I think it might be interesting to write about that time, how we created software before we had access to high-level languages.
In the meantime, here's an old piece I wrote in those days, even though not quite what you have in mind:
http://www.atariarchives.org/deli/cottage_computer_programmi...
Point being: both relate to compiling compilers.
The answer is that somebody punched in a program from a computer's console, probably somewhere in the early 1960s, but possibly earlier. That program was used to make it easier to enter other programs, etc.
Given that copying working code is so simple, chances are that most of the currently running hardware can be traced back to a few persons entering a boot loader by hand.
That might even be one person. For example, Windows NT was initially developed for Intel's i860 (http://en.wikipedia.org/wiki/Windows_NT#Development), so chances are that it was bootstrapped from a Unix machine. Because of that, it may trace back to the same initial boot loader as, for example, Mac OS X.
It seems like it would be relevant if a new architecture was developed at least.
If we'd really need to bootstrap a compiler from scratch, then a possibility would be to hand-code a Forth system, and then find/modify/make an assembler written in forth; then write a compiler for some small language (scheme?) in that assembler, and then from scheme you can easily get to some C compiler that can compile the full GCC.
Yes. In fact, this is how gcc is built - in stages. First stage: build a compiler that can build the compiler. Recompile the compiler with the newly built compiler. Do it again. Repeat until completion. ;)
The chicken or egg problem shows that at some point you lose the connection to the predecessor and the process goes around in endless circles.
Then you might wonder how it ever came to be when the first thing depends on the second and the second depends on the first.
No, this isn't so. It's a myth about biology that's repeated by people who don't understand natural selection. An egg is a chicken's way to make an insurance salesman.
Ultimately you don't need life to create life, and ultimately you don't need a computer program to build a computer program. There are other methods, even though we don't see those methods executed today.
That's not what a kernel does...
"The kernel is written in C, however how did the kernel get compiled without a compiler installed?"
And...
"If the C compiler is installed on my machine before the kernel is compiled, how can the compiler itself get compiled without a compiler installed?"