Subject: sbuilds, crossbuilds, and Mir [2/3]: sbuild optimizations

From: Robert Carr <[email-masked]>
Date: Fri, 19 Sep 2014 11:13:21 -0700

Hi! If you've followed along with the last email you have an sbuild that
can build mir! However it probably takes quite some time (> 30 minutes).
What can we do to reduce it? I have it down to 3 minutes on my system :D

Vaguely ordered in terms of efficacy

1. apt-cacher-ng. Follow the steps on SimpleSbuild...this helps a bunch.
2. Prepopulating with mir build-deps: Based on the instructions on
SimpleSbuild
schroot -c source:utopic-amd64-armhf -u root # Enter source chroot
apt-get update && apt-get -aarmhf build-dep mir

Unfortunately apt-get -aarmhf will not work due to the g++-4.9 issue so you
have to manually install the dependencies. Here is a list with the
appropriate multiarch tags:
http://paste.ubuntu.com/8381507/

3. eatmydata. follow the steps here https://wiki.debian.org/sbuild

4. Use shm overlays for schroot. Follow instructions on SimpleSbuild
creating chroot, and when building with sbuild also pass -c
utopic-amd64-armhf-shm to explicitly select the shm chroot. Do not modify
the source: for the shm chroot.

5. I noticed debugsym generation was taking a long time. You can skip this
by using NO_PKG_MANGLE, this will also skip things such as png optimization
(a little costly on the docs).

Add to ~/.sbuildrc above the "# dont remove this" line

$build_environment = { 'NO_PKG_MANGLE' => '1' };

If you wish to retain debug symbols you can disable stripping when building
DEB_BUILD_OPTIONS="nostrip" sbuild...blabla

6. --no-apt-update --no-apt-distupgrade may be passed to sbuild if you are
using prepopulated dependencies.

7. ccache would be great but it always misses with mir.

8. Disable build of tests for example if you just need to produce a server
library for manually testing...this can be done as in the "bs" script in
the previous email.

With all these applied my sbuild time from a clean start is down to just
over 3 minutes!