Python snap for ARM

Hello,

I am trying to port a python (core18/20 base) snap to ARM platform (Beagle bone black running debian 10) and facing a couple of issues.

  1. Building the snap on ubuntu 18 machine with run-on: armhf for architectures field does generate the snap for armhf but the snap fails to run with Exec format error. Looks like the runtime binaries and libraries are all packed for x86_64 instead of arm-linux-gnueabihf.
  2. Building directly on the target does generate a snap with correct libraries and runtime packed, but running results in segfault
writev(2, [{iov_base="      2119:\t", iov_len=12}, {iov_base="__vdso_gettimeofday", iov_len=19}], 2      2119:	__vdso_gettimeofday) = 31
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1f} ---
+++ killed by SIGSEGV +++
error: signal: segmentation fault

Any idea on what could be wrong and how to properly build a python snap for ARM is appreciated.

$ snap --version
snap    2.49
snapd   2.49
series  16
debian  10
kernel  4.19.94-ti-r42
]
$ snapcraft --version
locale: Cannot set LC_CTYPE to default locale: No such file or directory
Locale not set! Snapcraft will temporarily use C.UTF-8
snapcraft, version 4.5.4

$ snap list
Name       Version   Rev    Tracking       Publisher   Notes
core       16-2.49   10861  latest/stable  canonicalâś“  core
core18     20210128  1989   latest/stable  canonicalâś“  base
core20     20201210  906    latest/stable  canonicalâś“  base
snapcraft  4.5.4     6125   latest/stable  canonicalâś“  classic

well, as you found in 1) you are building an x86 snap but tell snapcraft it will run on armhf …

you will need to build on an arm system to actually produce arm binaries, what i tend to do is:

(note that the same setup will indeed also work on classic (non UbuntuCore) installations … using the correct lxd containers to match your snapcraft.yaml is key here: base: core -> 16.04, base: core18 -> 18.04, base: core20 -> 20.04)

Thanks @ogra, I have actually installed snapcraft and snapd on BBB running debian buster and building the snap, that is actually throwing a segfault. I will go through your blog and see if I can get some hints

you will need an ubuntu environment to build … thus the lxd containers …

I tried to install lxd via snapcraft on BBB and followed the steps in your blog , for some reason I am not able to get the network up on the lxd container. Still trying to figure out the reason.

try running lxd.check-kernel …

1 Like

it was dnsmasq on the host playing foul, stopping the service on the host and restarting lxd snap fixed the network issue and was able to build the snap as well.

1 Like