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

> Who knows how far down the stack this could go?

Seems to be like the obvious initial way to up the ante would be to get rid of the compiler. How would you go about bootstrapping your way out if all you had was the Linux kernel, glibc, and the Bourne shell?



The stage0 bootstrap is seriously interesting:

https://github.com/oriansj/stage0

It starts with a system without firmware and an OS, just a <=1KB hex monitor that assembles special hex0 programs. In the next stage it bootstraps a more comfortable assembler. Then it uses this assembler to bootstrap a small C compiler written in assembly. And then it uses this C compiler to compile a C compiler written in C. All the way up to gcc.


This and the other projects by the Bootstrappable Builds project are really interesting:

https://bootstrappable.org/

I wonder how many of the upper layers have cyclic build dependencies. I know Scala and sbt do but what else?


You basically just have to know the tricks of inputting binary data through the shell. Learn how the ASCII table works, what the ctrl and shift keys do (setting/unsetting bits 5-7, in particular), and how the Alt key enables the 8-bit.

You could even go a little further. the printf command should be a built-in with just about any shell, so even lacking the `cat` program, you can output arbitrary data to a file.

Almost seems cheating to just hand-craft an ELF executable from the keyboard, but who's making the rules?


If you have a shell or standard POSIX tools you'll have printf, which supports hex and octal formatting, and often C modifiers, so you can encode it as one long-ass integer and save keystrokes.


Minimal Linux Live has a nice small script where you see what is being set up. It does include Busybox though, which might already have too many tools.

https://github.com/ivandavidov/minimal-linux-script


> How would you go about bootstrapping your way out if all you had was the Linux kernel, glibc, and the Bourne shell?

You're fully aware that you're describing a complete programming environment and then some, correct?

Bourne's shell (assuming you mean the original, not the GNU 'remake', but GNU bash would practically make this effortless as well although for a different reason) is fantastic for almost any purpose. You can do virtually anything you'd like with it.


Well yes, I know it can be done, but the point is that it's considerably harder than the original challenge because you can't just output a simple program using the Linux kernel APIs or libc without having a compiler.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: