I’ve spent the last few months banging though the bits and pieces of the work that Stacey Son implemented for QEMU to allow us to more or less chroot into a foreign architecture as though it were a normal chroot. This has opened up a lot of opportunities to bootstrap the non-x86 architectures on FreeBSD.
Before I get started, I’d like to thank Stacey Son, Ed Maste, Juergen Lock, Peter Wemm, Justin Hibbits, Alexander Kabaev, Baptiste Daroussin and Bryan Drewery for the group effort in getting us the point of working ARMv6, MIPS32 and MIPS64 builds. This has been a group effort for sure.
This will require a 10stable or 11current machine, as this uses Stacey’s binary activator patch to redirect execution of binaries through QEMU depending on the ELF header of the file. See binmiscctl(8) for more details.
Mechanically, this is a pretty easy setup. You’ll need to install ports-mgmt/poudriere-devel with the qemu-user option selected. This will pull in the qemu-user code to emulate the environment we need to get things going.
I’ll pretend that you want an ARMv6 environment here. This is suitable to build packages for the Rasberry PI and Beagle Bone Black. Run this as root:
binmiscctl add armv6 –interpreter “/usr/local/bin/qemu-arm” –magic
“x7fx45x4cx46x01x01x01x00x00x00x00x00x00x00x00x00x02
x00x28x00″ –mask “xffxffxffxffxffxffxffx00xffxffxffxff
xffxffxffxffxfexffxffxff” –size 20 –set-enabled
This magic will load the imgact_binmisc.ko kernel module. The rest of the command line instructs the kernel to redirect execution though /usr/local/bin/qemu-arm if the ELF header of the file matches an ARMv6 signature.
Build your poudriere jail (remember to install poudriere-devel for now as it has not been moved to stable at the time of this writing) with the following command:
poudriere jail -c -j 11armv632 -m svn -a armv6 -v head
Once this is done, you will be able to start a package build via poudriere bulk as you normally would:
poudriere bulk -j 11armv632 -a
or
poudriere bulk -j 11armv632 -f <my_file_of_ports_to_build>
Currently, we are running the first builds in the FreeBSD project to determine what needs the most attention first. Hopefully, soon we’ll have something that looks like a coherent package set for non-x86 architectures.
For more information, work in progress things and possible bugs in qemu-user code, see Stacey’s list of things at: