So, this actually is both for snapd and snapcraft, but I can only pick one… So, snapd it is…
Last week, @niemeyer and I had a conversation about architecture handling in both snapcraft and snapd, which involved discussing examples of where relying on base arch names (i386
, amd64
, arm64
, armhf
, armel
, etc.) can bite us.
This is very obviously depicted with ARM, as the armel
set expands to a very large set of somewhat incompatible software-floating-point little endian 32-bit ARM architectures. The armhf
set expands to a slightly smaller set of hardware-floating-point architectures that have incompatibilities as well.
It’s even more problematic when distributions redefine what those names mean. For example, Raspbian defines armhf
as armv6hl
, while Debian defines it as armv7hl
. This can lead to dpkg-compatible but not CPU/binary compatible installations. In Fedora, we have derivative distributions that do rebuild the distribution for different so-called armhfp
architectures for various reasons (IoT, SBCs, etc.). Unfortunately, the way snapd and snapcraft handle (or intend to handle in some cases) architectures is too coarse for this.
This is the reason that RPM doesn’t actually build packages to a base arch name. Instead, we build to target the exact architecture (which is why Mageia and openSUSE 32-bit x86 packages are mostly i586
packages with some i686
packages, while Fedora and CentOS ones are all i686
packages). This means we don’t have armhfp
packages or arm
packages, we have armv7hl
and armv5tl
packages (this can be observed in Mageia, which does offer these). Pignus (a Fedora derivative focusing on Raspberry Pi devices) ships armv6hl
packages for broader compatibility with the Raspberry Pi ecosystem.
So, after talking with @niemeyer about it to better fomulate the idea, I propose that we move to more granular names for architectures and internally alias them as necessary.
This means that for snapcraft and snapd, you’d be telling it armv7hl
rather than armhf
. On the snapcraft side, package manager backends can handle translating as appropriate. Going from “real arch” to “base arch” is way easier than the other way around, depending on the distribution and target device.
For example, today, as of Debian 9, this is the following base arch map:
DPKG Base Architecture | Real Architecture |
---|---|
amd64 | x86_64 |
i386 | i686 |
arm64 | aarch64 |
armhf | armv7hl |
armel | armv4t |
ppc64 | ppc64 (powerpc64)* |
ppc64el | ppc64le (powerpc64le)* |
s390x | s390x |
Note: For ppc64 variants, I’ve seen both names used throughout aspects of compilers and other things (at least on my computer), hence the other name in parenthesis.
My proposal is that snapd use the real architecture names to disambiguate and to make it easier for properly determining what’s runnable on the target machine. As a transition measure, we can alias the current names and mark them as deprecated to get people onto the path of using more granular names. As neither snapd nor snapcraft do a lot with architecture names yet, we’re in a position to fix this before it can bite us.
This also makes it much easier to support new architectures, as we don’t have to bend over backwards to contort a base arch name it try to differentiate them. And flavors that offer some enhancements, like armv7hnl
, armv8hnl
, etc. are trivial to support, as they have well-defined schemes.