Skip to content

Instantly share code, notes, and snippets.

@rarecoil
Last active May 1, 2019 20:22
Show Gist options
  • Save rarecoil/8197ea8ef9710ea336e5be9212c6bb26 to your computer and use it in GitHub Desktop.
Save rarecoil/8197ea8ef9710ea336e5be9212c6bb26 to your computer and use it in GitHub Desktop.
Windows 10 LTSC as an Arch Linux ARM Build Slave for RPi 3

Windows 10 LTSC as an Arch Linux ARM RPi 3 Build Slave

Your SBC (in my case a Raspberry Pi 3) is likely not the fastest machine in your collection. Thankfully, if you have a laptop or desktop you normally use, you can recruit it to assist your Raspberry Pi in compiling Arch Linux packages for itself. It is fairly easy to do with another Arch Linux machine, but a little tougher if you don't have one running that.

I have two laptops, a ThinkPad X250 running Windows 10 Enterprise LTSC and an Apple MacBook. The X250's i7-5600U has a substantial amount more power than my MacBook, but runs Windows. This is not a big deal with the Windows Subsystem for Linux and distcc, a distributed C compiler infrastructure.

For this to work, both computers must be on the same network and they must be able to talk to each other.

Preparing Windows Subsystem for Linux as a distcc slave

Following these steps will make your Windows laptop the slave for the Raspberry Pi, which will do a lot of the compilation for you.

You'll first need to enable Windows Subsystem for Linux and install the Arch userspace yuk7/ArchWSL before proceeding. Once this is done, run pacman -Syu to synchronize and update your userspace, and pacman -Syy git base-devel distcc for some basic dependencies.

The Arch Linux ARM team distributes their own build tools in the Arch AUR. You can use their toolchain for our builds for the sake of consistency. Install their toolchain for distccd-alarm next:

git clone https://aur.archlinux.org/distccd-alarm.git
cd distccd-alarm
makepkg -si

This will install the package. However, the Windows Subsystem for Linux doesn't have systemd services you can run. You can open a WSL bash window and then run distccd manually. Change $RASPI_IP_ADDRESS to the IP address of your Raspberry Pi.

export PATH=/opt/x-tools8/aarch64-unknown-linux-gnu/bin:$PATH
export DISTCC_ARGS="--allow $RASPI_IP_ADDRESS --port 3636 --log-file /tmp/distccd-armv8.log"
/usr/bin/distccd --daemon --no-detach $DISTCC_ARGS

At this point, your laptop is now ready to accept connections from the Raspberry Pi and will build on its behalf.

Note that if you have multiple computers you can use as slaves, you can run distcc on all of them with this configuration.

Preparing the Raspberry Pi

Edit /etc/makepkg.conf on your ARM Raspberry Pi. This is the master. You will need to know:

  1. The IP address of your laptop and your Raspberry Pi
  2. How many threads you want to run. I am using 6 which appears to be a good balance on my 4 logical CPU cores.
  3. What architecture you're building for (in our case, armv8).

Once you know this:

  1. Change BUILDENV to be (distcc color !ccache check !sign).
  2. Change DISTCC_HOSTS to be something in the format "$IP_ADDRESS:$DISTCC_PORT/$NUM_THREADS". So, if your laptop is at 192.168.1.100, you are using port 3636 to compile for ARMv8, and you have 6 threads to give, set DISTCC_HOSTS to "192.168.1.100:3636/6".
  3. Change MAKEFLAGS to the format -j$NUM_THREADS. In my case, that is -j8, for the 2 locally and 6 to the ThinkPad.

If you have multiple hosts, add each of them to DISTCC_HOSTS with the same format as above, each separated by a space. Put your fastest machine first in the list. Then, change MAKEFLAGS to the total number of threads across all machines.

Tips for compilation

If you try to compile large packages from git with a Raspberry Pi, you are likely to run out of memory. For example, the test Raspberry Pi 3's git would run out of memory on Resolving deltas when cloning the kernel. Set up a couple of gigabytes of swap space to give the Pi a little breathing room.

More information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment