Xv6, if you haven’t heard about it, is a reimplementation of Version 6 Unix in ANSI C for x86 processors for an operating systems class at MIT. When I first came across it a while back I wanted to play with it, but unfortunately it’s rather harder to get working under OS X because xv6 uses ELF for its executables while OS X uses
COFF Mach-O (update: I’m not sure how I horked that one up. I must have either been thinking of COFF for some reason, or read something else that claimed OS X used COFF, or I don’t even know what. Fixed, in any case.). You have to build a cross compiler to get xv6 building under OS X. Unfortunately that isn’t a very straightforward process, and I wasn’t real interested in devoting tons of time getting it to all work right. I had found instructions for getting xv6 to build on OS X using MacPorts (and other instructions too), but never had any luck with the assembler actually building anything.
The other day, though, I bumped into xv6 again and decided to take a look once more. Someone out there was trying to build xv6 with clang somehow, and it got me thinking about the cross compiler thing again. Googling a little, I saw that someone made just the homebrew formulas for the cross compilers that I needed, so I downloaded those, put them in with my homebrew formulas, and ran
brew install i386-elf-gcc and
brew install i386-elf-gdb. I had already installed qemu and the prerequisites mentioned on that gist about trying to build xv6 with clang, so after making some little changes to the Makefile (seen here, between lines 32 and 78) xv6 finally built and started up for me.
Of course, xv6 doesn’t actually do much. I’ve been dinking around with it some though (because obviously what I need is another project), adding some simple utilities and whatnot, that I’ve tossed up on github. So far all I’ve done is add some simple versions of basic utilities, but I’m exploring. Even if it doesn’t do much, it’s pretty interesting.