Building B2G OS on Arch Linux


(Alastair Pharo) #1

Some people on Telegram expressed interest in how I am able to build B2G OS from Arch Linux without resorting to a VM, or anything like that. Arch Linux is tricky because software is constantly being updated. As such, any problems that can arise trying to build with the latest build tools will probably trip up Arch Linux users.

Unfortunately I didn’t document my steps when I first worked through this, so I may not be completely exhaustive concerning the packages that need to be installed. If I’ve missed something or the situation changes again, hopefully someone can correct/update below :slight_smile:

Existing instructions

The existing instructions for building on Arch Linux are here. I followed these as a starting point. So I install the following:

sudo pacman -S --needed \
  alsa-lib autoconf2.13 bison ccache curl firefox flex \
  gcc-multilib git gperf libnotify libxt libx11 mesa \
  multilib-devel wget wireless_tools yasm zip \
  lib32-mesa lib32-mesa-libgl lib32-ncurses \
  lib32-readline lib32-zlib lzop

The only difference to MDN with the above is that the libxml2-utils package doesn’t exist anymore.

I also installed and set up a python virtual env, as described in MDN, so that executing python --version gives “Python 2.7.12”.

AUR packages

GNU make

What isn’t mentioned on MDN is that Archlinux only packages GNU Make version 4, but you need either 3.81 or 3.82 to use the Android build system (maybe just for KitKat and earlier?). The solution for this that I have found is to install the make3 package from AUR.

This package replaces GNU make 4, which might be a problem if you need version 4 for another project. @lissyx (below) recommends against replacing your system make, so you may want to look for an alternative to installing this on your system. One possibility is that you can build make3 using makepkg, as described below, but then skip over the pacman -U step and instead prepend <place where you cloned to>/make3/pkg/usr/bin to your PATH in your .userconfig, as @lissyx describes below.

I had to edit the package to comment out the make check line. For whatever reason, one test failed for me. So the process by which I installed make3 looks like this:

git clone https://aur.archlinux.org/make3.git
cd make3
makepkg # if this fails, comment out "make check" in PKGBUILD and retry
sudo pacman -U make3-3.82-1-x86_64.pkg.tar.xz

Ncurses 5 Compat

The Android NDK (see below) needs ncurses 5, but Arch has ncurses 6. Fortunately this can be fixed in a non-invasive way by compiling and installing the ncurses5-compat-libs package from AUR. I also installed the lib32-ncurses5-compat-libs package, so I’m fairly sure this is needed too if your host machine is 64-bit. These two packages install straightforwardly so I haven’t listed the makepkg steps.

Android NDK

Additionally, building B2G now needs a copy of the Android NDK. You don’t have to install this from AUR, but it helps to keep track of the dependencies (i.e. ncurses compat). As issues have been reported with version 12 of the NDK, we need to get version 11. This means going back in the recipe’s git history using git checkout, as described below.

git clone https://aur.archlinux.org/android-ndk.git
cd android-ndk
git checkout 49f09c2eaebff46af27b04d0e8c29289e5cbcd93
makepkg
sudo pacman -U <whatever the package file is>

Build system config

Aside from the standard instructions, I made the following changes.

  1. Use github copy of gaia kanikani branch; so in .repo/manifests/base.xml, I have <project name="gaia" path="gaia" remote="b2g" revision="kanikani" /> for Gaia (the “remote” part is different). Also either do a repo sync after this or git reset --hard b2g/kanikani. This is not Arch-specific, but still needs to be done.

  2. Put the following into my .userconfig so that the build system knows where to find the NDK.

    export B2G_ANDROID_NDK_PATH=/opt/android-ndk
    

I believe that that’s the extent of the Arch Linux specific stuff.


(Alastair Pharo) #2

As a footnote, I should mention that I’m building for the nexus-4-kk set-up. At least for me, the version of GCC that actually gets used to compile the device is downloaded by the B2G build script to prebuilts/gcc/linux-x86/arm/. I’m not sure if this is specific to this device or not. Anyway, it seems that the system GCC is not used, so it doesn’t matter that it’s GCC 6.


(Lissyx) #3

This is not device specific. Host tools are being built with the host compiler though, so it might still be problematic with too new GCC.

I would not recommend changing your system’s make version. Rather compile a static make 3.81 and override the PATH in your .userconfig to force it use at build time. This is what I am doing on <= KK devices builds:

export PATH="$HOME/bin/make3.81/bin/:$PATH"

Besides, thanks for sharing those infos. I think it would be valuable to anyone that you check on MDN and update what is relevant :slight_smile:


(Alastair Pharo) #4

Thanks for that feedback. I’ve updated the post above to include your advice about the path.


(Baikalink) #5

Hey asppsa, thanks for share!
You didn’t have some trouble due to the python version?

Edit: ah, ok, I get it… :slight_smile:


(Lapineige) #6

Thanks for this @asppsa.
Could you add it on the wiki ? :slight_smile: