Cross Compile to PinePhone Part Four
Now we’ve got ourselve a handy script for cross compiling, I think it’s time to introduce other means of cross compiliing and why I not using existing methods.
pmbootstrap is the central tool to develop and install postmarketOS. It works using Alpine chroots to avoid installing software on the host’s machine.
Pmbootstrap is a script to build packages for postmarketOS. It supports cross compiling and various other options, it also handles dependencies for you. And you can use apline ports build files directly without hacking it as we did on part two for ArchLinux. Most important, it’s available as pip package. Meaning you can use it to build packages for postmarketOS even if you’re not on Apline Linux! PinePhone is well supported by PostmarketOS and Plasma Mobile developers also work closely with PostmarketOS developers. If you have postmarketOS installed on your pinephone or any Android phones postmarketOS supports (there are over 1000 devices postmarketOS supports), do try pmbootstrap.
Distcc + crosstool-ng
Distcc with crosstool-ng is the standard cross compile work flow for ArchLinux arm. Distcc is a distributed compiler frontend. You can have a compiling farm with powerful machines while still building on laptop, distcc distributes the work across to compiling farm. Crosstool-ng is a toolchain generator, it can generator toolchains to suit specific needs. Combine the power of distcc and crosstool-ng you have the ability to cross compile while executing normal makepkg commands. Yeah, this workflow is well supported by makepkg, no hack required.
The disadvantage of this workflow is obvious. Imagine you have to setup Distcc, crosstool-ng and build your own rootfs just to compile a small app to pinephone. It’s not worth the effort. It only make sense on CI where thousands of tasks are being executed every day.
Container is also an option when cross compiling. Under the hood, docker uses binfmt as we did. With docker, you don’t risk polluting host system. And updating docker is easy. In fact, KDE build Android packages with docker. The problem with docker is as I said before, Plasma Mobile is a rolling platform. The rootfs is changing everyday unlike Android. This means if we want to use docker, the docker image itself will need to be build everyday on CI. And you will have to update it everyday. It’s no more convenient than building your own rootfs.