Live data from Hacker News

How can the Linux kernel compile itself?

stackoverflow.com

21–30 of 33 posts

Re: How can the Linux kernel compile itself?

#22
post #6

> How can the linux kernel compile itself? 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 bette…

Just out of curiosity, have you ever written a book about the process of bootstrapping an Apple II development environment and the little discoveries you made? I would read that in a heartbeat.

> Just out of curiosity, have you ever written a book about the process of bootstrapping an Apple II development environment and the little discoveries you made? I would read that in a heartbeat.

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...

Re: How can the Linux kernel compile itself?

#23
post #22

Earlier quoted context omitted.

Just out of curiosity, have you ever written a book about the process of bootstrapping an Apple II development environment and the little discoveries you made? I would read that in a heartbeat.

> Just out of curiosity, have you ever written a book about the process of bootstrapping an Apple II development environment and the little discoveries you made? I would read that in a heartbeat. 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…

The Atari Archives piece was part of what motivated me to ask about this. Another part is the series of books Jordan Mechner has released (in both print and electronically) about the development of Karateka and Prince of Persia. I've found that I enjoy following along the process of discovery almost as much as I enjoy the finished product. There is also a practical benefit: I gain more intellectual tools for tackling obstacles by learning the process others use to tackle obstacles.

Re: How can the Linux kernel compile itself?

#24

If he thinks that's weird, then he ought to read Ken Thompson's article about trusting compilers. http://cm.bell-labs.com/who/ken/trust.html

While I love the story, it's really amusing to watch how it gets re-discovered on HN every few years, blows everyone's minds, and then gets quoted all over the place, even where it is only mildly relevant. This might be our "does glass flow" meme.

Seemed relevant to me. The question asked about compilers and the kernel is what compiled the compiler. Ken Thompsons' talk related to hiding code by adding code to a compiler then compile the compiler, remove the code then continue to compile the compiler with the modified version that doesn't have the source code - your modification remains.

Point being: both relate to compiling compilers.

Re: How can the Linux kernel compile itself?

#26
post #12

Earlier quoted context omitted.

I'm not a programmer at all, and I found this answer quite obvious. Where else does new binary software come from, if not from a computer running older software?

If you think through, it is not _that_ obvious; it can't be turtles all the way down. So, where did the first binary software come from? 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 c…

Well, to be detailed, both the first kernel and the first compiler was probably entered from a stack of punchcards or punch tape made with mechanical "typewriters"; punching a program from console is rather unwieldy and generally you should do that only for the bootloader that loads the rest of the (manually compiled) code from some electromechanical device.

Re: How can the Linux kernel compile itself?

#27
post #16

This does make me wonder about something though: is there a crashplan for a compiler? Can a very minimal gcc be written which would be capable of bootstrapping the entire gcc compiler? It seems like it would be relevant if a new architecture was developed at least.

For any practical purposes, it is best to simply use the full complex software stack on another computer to generate binary code meant for that new architecture.

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.

Re: How can the Linux kernel compile itself?

#28
post #16

This does make me wonder about something though: is there a crashplan for a compiler? Can a very minimal gcc be written which would be capable of bootstrapping the entire gcc compiler? It seems like it would be relevant if a new architecture was developed at least.

>Can a very minimal gcc be written which would be capable of bootstrapping the entire gcc compiler?

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. ;)

Re: How can the Linux kernel compile itself?

#29

Earlier quoted context omitted.

While I love the story, it's really amusing to watch how it gets re-discovered on HN every few years, blows everyone's minds, and then gets quoted all over the place, even where it is only mildly relevant. This might be our "does glass flow" meme.

Seemed relevant to me. The question asked about compilers and the kernel is what compiled the compiler. Ken Thompsons' talk related to hiding code by adding code to a compiler then compile the compiler, remove the code then continue to compile the compiler with the modified version that doesn't have the source code - your modification remains. Point being: both relate to compiling compilers.

> the kernel is what compiled the compiler

That's not what a kernel does...

Re: How can the Linux kernel compile itself?

#30

Earlier quoted context omitted.

Seemed relevant to me. The question asked about compilers and the kernel is what compiled the compiler. Ken Thompsons' talk related to hiding code by adding code to a compiler then compile the compiler, remove the code then continue to compile the compiler with the modified version that doesn't have the source code - your modification remains. Point being: both relate to compiling compilers.

> the kernel is what compiled the compiler That's not what a kernel does...

[deleted]
Post reply on HN