I recently became interested in trying to write some OpenGL ES 2. My main machine is a MacBook pro, and does not have an GL ES drivers. I figured I would install Mesa3D, and that would be the end of it.

But it seems the Mesa3D devs are mostly Linux folks nowadays. I got decently far into the project, but I figured there had to be a better way. I own several devices capable of running OpenGL ES 2--an Android tablet, a Nexus 5 from my stint at Mozilla, an old and failing HP laptop that runs Arch Linux, and a Raspberry Pi that I installed Raspbian onto a year ago.

When I went back to see what Raspbian was like, I was kind of stumpted as to why it is considered the best (or at least the default) software distro for a Raspberry Pi. It has way, way too much installed by default. I don't want Wolfram, SuperCollider, TWO web browsers, or any number of other things installed by default on Raspbian, particularly on such a low power deivce with confined storage space.

After spending a couple minutes assessing what it would take to put Raspbian on a diet, I decided to try another distro altogether, or another OS.

In the last year or so I have been moving to BSD more and more, but since most Pis run Linux, I figured it would be best to at least try and get a stable and sane Linux setup on my Pi. I briefly considered Pidora, which doesn't have so many extra packages installed, but I would prefer a setup that does not have systemd.

I use Gentoo on my second laptop, and so I am well acquainted with how Gentoo compiles out unneeded functionality from packages. Think about that, particularly with a low power device with low storage. Normally, that's just a nice but largely unnoticed bit of efficiency. But here, I am attempting to run OpenGL ES on a device with a single-core processor and only 4 GB of storage. Being able to specify -Os to ALL packages at compile time, and being in tight control of what features a package is configured with could have a huge advantage.

Ignore for one minute what it actually means to compile an entire distro on a single-core, 700 MHz CPU--which is in-order, scalar, lacks any kind of vector units...

I began by following the Gentoo Raspberry Pi quick-install guide, which gave me the idea to steal a kernel from Raspbian. In reality, the guide doesn't specifically say to do this, but to download the kernel from github. But I already had a working boot partition from rasbian. Using the rpiupdate tools, I updated the kernel and included modules in Raspbian. Working on my FreeBSD virtual machine on my Mac, I copied the new kernel modules to the local drive, deleted the root partition of Raspbian leaving the FAT32 boot partition alone. I think followed the rest of the Gentoo guide--which is basically the same as installing Gentoo normally, sans the kernel setup.

I tried using the raspberrypi-userland package from portage, but it was...weird. All the libraries seemed to be empty, and it did not include an Xorg driver for the VideoCore GPU in the Pi. I decided to see how Pidora did it, since I'd heard that it had full hardware acceleration. This also turned out to be mostly false. I finally found out that newer XOrg releases actually support the VideoCore well enough using fbdev, and so I emerged xorg-server with fbdev for my VIDEO_CARDS variable. While I was in Pidora, I stole the userland libraries for EGL, GLES2, and OpenVG (as well as some others that I don't know about, like vcos).

With all this in hand, Gentoo installed, updated, and runs without issue. I am currently writing this blog post using the Raspberry Pi, I have Kashyyyk running, and I am compiling SpiderMonkey all quite comfortably, using X11 and Fluxbox.

But surely you are curious, Gentoo compiles ALL packages on the local machine... isn't that horrifically slow on the Pi?

Yes it is. I have left it on for well over 100 hours total to compile all the necessary packages. The intial system update and Xorg were the worst, at almost 24 hours each. I just left the Pi on overnight and while I was at work, and it all worked out eventually.

I considered using distcc, but by the time that I was sure that my Gentoo install with stolen kernel and libraries was going to work it seemed silly to set up a cross-compiler at that point.

I conclude that, if you are willing to let the Pi sit and compile on its own for hours on end, or if you already have distcc set up, Gentoo works very well on Raspberry Pi. I definitely recommend it over Raspbian.