I want to speed up builds for my WPE WebKit Mir Kiosk snap. A native build on a RasPi 4 with 4 GB RAM + 4 GB swap takes ~4+ hours (I know, it’s a whole browser). Launchpad remote builds are equally slow, not even accounting for wait time – but hey, free service so no complaints I have to debug a segmentation fault that only occurs in the armhf version of my snap, so any speedup would be a huge productivity boost.
The WPE WebKit folks advise to cross-build, but only do so with buildroot/yocto setups. I researched the current state of this in snapcraft and would like feedback if I’m missing something, or if I’m going in the completely wrong direction. Also, I can’t seem to have meson pick up the architecture-specific pkg-config, but that’s a different thing.
I gathered from various topics1 that I need to:
- specify
architectures
in snapcraft.yaml:
architectures:
- build-on: amd64
run-on: armhf
- Install cross-compiler packages for my C/C++ parts:
build-packages:
- on amd64 to armhf:
- "gcc-8-arm-linux-gnueabihf:amd64"
- "g++-8-arm-linux-gnueabihf:amd64"
# make sure to quote this: https://forum.snapcraft.io/t/stage-packages-with-target-arch/6617/2?u=tobias)
- Specify these compilers in the meson/cmake parts (resp. cross-build definition for meson):
plugin: meson
meson-parameters:
- --cross-file=${SNAPCRAFT_PROJECT_DIR}/meson.cross # contains host/target architecture definitions, paths to compilers pkg-config etc. for the cross-building packages.
# […]
plugin: cmake
configflags:
- -DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc-8
- -DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++-8
- Ensure build/stage packages are pulled from the ARM archives:
stage-packages: # make sure to quote this: https://forum.snapcraft.io/t/stage-packages-with-target-arch/6617/2?u=tobias)
- "some-package:armhf"
- Run
snapcraft
without--target-arch
as that’s unsupported for the meson/cmake plug-ins.
1: Cross compile snap on amd64 to arm - #9 by ijohnson / Stage-Packages with --target-arch - #2 by ijohnson / Specifying architecture on cross-compilations [quite old] / Snapcraft 3.x target-arch not working