How can the Linux kernel compile itself?

2020-02-07 14:09发布

I don't quite understand the compiling process of the Linux kernel when I install a Linux system on my machine.

Here are some things that confused me:

  1. The kernel is written in C, however how did the kernel get compiled without a compiler installed?
  2. 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?

I was so confused for a couple of days, thanks for the response.

7条回答
Lonely孤独者°
2楼-- · 2020-02-07 14:52

The term describing this phenomenon is bootstrapping, it's an interesting concept to read up on. If you think about embedded development, it becomes clear that a lot of devices, say alarm clocks, microwaves, remote controls, that require software aren't powerful enough to compile their own software. In fact, these sorts of devices typically don't have enough resources to run anything remotely as complicated as a compiler.

Their software is developed on a desktop machine and then copied once it's been compiled.

If this sort of thing interests you, an article that comes to mind off the top of my head is: Reflections on Trusting Trust (pdf), it's a classic and a fun read.

查看更多
登录 后发表回答