Categories
Brainwaves

Building AArch64 Arch Linux packages on a x86_64 host

I was looking for a convenient way of easily building AArch64 (ARM64 / ARMv8-A) packages for Arch Linux ARM, namely for the PinePhone. One option is to cross-compile the packages, but maintaining a cross-compilation toolchain is a pain. I wanted the experience of compiling natively without the need to heat up the weak ARM CPU these devices have.

QEMU to the rescue! It is possible to run an emulated Arch Linux ARM on a non-ARM device. This way you can compile natively. And with armutils this whole process of building packages can be automated. All you need is to install a few AUR packages, create an AArch64 chroot and start building!

Dependencies

You’ll need qemu-user-static-bin, binfmt-qemu-static-all-arch and finally armutils-git, installed from AUR (e.g. via yay).

Creating a chroot


mkarmroot -u http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz <YOUR-PATH>/aarch64/root base-devel

Building a package

Assuming <YOUR-PATH>/pkg contains the package PKGBUILD file:

cd <YOUR-PATH>/pkg
sudo makearmpkg -r ../aarch64 -- --noconfirm

Done!

Leave a Reply

Your email address will not be published. Required fields are marked *