March 27th, 2010

bish, smile

Compiling Linux From Scratch

I'm going to blog about compiling Linux From Scratch... It's likely to be rambling and long and technical. You have been warned.

Linux From Scratch is two things. First, and most literal, is that I'm building Linux from first principles. Download everything needed for a "real" Linux system and build it myself. Secondly, it's a book. The book is "Copylefted" via the Creative Commons and periodically updated to keep up with the latest and greatest. The website has a load of information including a set of books to help move beyond a basic Linux installation, a set of patches to help tweak things the way you want, and a pile of hints on how you might want to do things. It's a great resource for a roll-your-own Linux "distribution".

The LFS book does a great job of explaining why you're typing in each step. It doesn't just say type to in

CC="$LFS_TGT-gcc -B/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
 ../gcc-4.4.3/configure --prefix=/tools \
 --with-local-prefix=/tools --enable-clocale=gnu \
 --enable-shared --enable-threads=posix \
 --enable-__cxa_atexit --enable-languages=c,c++ \
 --disable-libstdcxx-pch --disable-multilib \
 --disable-bootstrap
It also bothers to tell you what each of those options is and usually why you need it. Very very useful stuff. For instance, skipping --enable-__cxa_atexit would change the C++ ABI and make the new system binary incompatable with C++ programs from most Linuxen.

The next thing a rational person might ask is "For the love of penguins, WHY?" The LFS website says a bit about this, but that doesn't say why I'm doing it. Well, because I want to know what makes it tick. I know a lot about Linux. Heck, most of my friends consider me an expert. But I let Debian and Ubuntu tell me what goes where and how things work. This should help me get an understanding of what each piece does, how they hook together, and what's actually needed to make it work.

Also, I've done a little embedded work. I was mostly working off a framework someone else made, but doing this would let me build it myself. I'm also hoping that after this I can make a simple little uClibc/busybox VM. Might need to keep around a "host" system that does things like compiling pacakages, but hopefully I can even write a basic "package management" system. Reinventing the wheel, I know. But as a programmer, knowing the deep magic is important.

I was inspired to look into this by GoboLinux, a Linux distro that has a bit of the "do it from scratch" mentality, but mostly a "let's do it right, not just how it's always been done." It's an interesting setup, and apparently one that causes them some issues from time to time (autoconf is easy, things like CMake, rubygems, and CPAN give them headaches). But I like the concept, it's a lot like what Apple tries to do and what I've thought of from time to time. Put each "package" into it's own little bin rather than installing everything on top of each other. Compelling. I'm going to try it out after my LFS experiment.

Collapse )
  • Current Music
    White Stripes: Under Great White Northern Lights (via NPR)
  • Tags
    ,