If 'bootstrapping' is not a familiar concept in the realm of operating systems, please read on for a gentle introduction to this madness and a few reasons why you might want to give it a go. If you're ready to jump in, skip ahead to the next section to start building the toolchain.

What is 'bootstrapping'?

'Bootstrapping' in this context refers to the process by which an operating system's components compile each other and themselves from their programmers' original source code. The term is derived from the folksy expression: "to pull oneself up by the bootstraps". Whereas the original phrase concerns the apparent futility of lifting oneself out of poverty and other adverse circumstances, here it refers to the apparent futility of compiling an operating system that doesn't have so much as a compiler. So, how does one go from endless reams of source code to a complete, fully-functional system with which you may view cat videos?

How does bootstrapping work?

In a tedious, redundant and agonizingly slow manner.

That's not what I meant.

I know, I know. Here's how it really works. If we envision the GNU/Linux system as a pyramid with cat video playback at the top, then the heavy slabs at the bottom are the tools needed to compile and run the most basic system components. These interdependent tools are referred to as the 'toolchain'. To assemble a working toolchain from its source code, it's necessary to build it in phases using existing tools from another operating system. We'll start by compiling the assembler and linker - the lowest-level programming tools available - using another's operating system's compiler. We then build our toolchain's compiler using using the other system's compiler plus our newly compiled assembler and linker. When we have that, we can go back and build our assembler and linker with our new compiler, and so on and so forth. Confusing? You bet! But without this process, it would be nearly impossible to cleanly birth the next generation of systems from those that exist today.

So wait, if you have to already have an operating system to make a new one, how did the first operating systems come about?

I'm glad you asked! Back in the day, devoted loonies such as Apple co-founder, Steve Wozniak, would write the assembly language code for their primitive 'monitor' systems on paper, convert that into numeric machine code by referencing technical documents, and then enter them into machines using toggle switches, paper tape or, if sufficient built-in functionality was present, by typing on keyboard. As tedious and error-prone as modern bootstrapping is, it's a breeze compared to what the pioneers of personal computing went through.

So why would anyone want to do this?

Returning to the pyramid analogy, if you want to change out the lowest tier of stones, perhaps go for something a bit smaller or hexagonal, then you're probably going to end up building a whole new pyramid. Just as the uppers layer of the pyramid are supported by its base, the web browsers, games and video editing suites at the top of the system are supported by low-level system components and toolchain at the bottom. The process described here will not only allow you to create the standard Shedbuilt system from scratch, but whatever system you desire. Want to see swapping out the standard GNU C Library with the lightweight musl libc improves performance? Go for it!