Build-packages: Package conflicts when cross-compiling (amd64 to arm64)

I have a problem with conflicting packages when I try to build a snap package on an amd64 host machine for an arm64 target. The amd64 host is a docker container, running Ubuntu Bionic. This docker container contains everything that is required to build amd64 as well as arm64 binaries. Everything works fine as long as I don’t use the “build-packages” option in snapcraft.yaml.

Let’s have a look at a specific example. Let’s say I want to build nftables for an arm64 target. The following snapcraft.yaml (which is a simplified and slightly modified version of the snapcraft.yaml from the nftables-pk snap (https://bitbucket.org/kravietz/snap-nftables/src/master/snap/snapcraft.yaml) is the one that I am using:

name: nftables
version: 0.0.1
summary: nftables
description: |
        Provides the latest version of nft command-line utility
grade: devel
confinement: strict
base: core18

parts:
  libnftnl:
    plugin: autotools
    source: libnftnl
    build-packages:
      - bison
      - flex
      - pkg-config
      - on amd64 to arm64:
        - "libmnl-dev:arm64"
        - "libgmp-dev:arm64"
        - "libreadline-dev:arm64"
      - else:
        - "libmnl-dev"
        - "libgmp-dev"
        - "libreadline-dev"
  nftables:
    plugin: autotools
    source: nftables
    configflags:
        - --disable-man-doc
        - CFLAGS=-I$SNAPCRAFT_STAGE/include
        - LDFLAGS=-L$SNAPCRAFT_STAGE/lib
    after: [libnftnl]

As you can see, I used build-packages to define which packages to use for which architecture. Running “snapcraft --target-arch=amd64” works as expected. Running “snapcraft --target-arch=arm64” on the other hand fails because snapcraft tries to install both architecture packages at once (e.g. libmnl-dev and libmnl-dev:arm64) and those package conflict with each other:

Setting target machine to 'arm64'
Using 'snap/snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Installing build dependencies: libmnl-dev libmnl-dev:arm64 libmnl0:arm64 libreadline-dev:arm64 libreadline7:arm64 libtinfo-dev:arm64 libtinfo5:arm64
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libmnl-dev is already the newest version (1.0.4-2).
libmnl-dev set to manually installed.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libmnl-dev : Conflicts: libmnl-dev:arm64 but 1.0.4-2 is to be installed
 libmnl-dev:arm64 : Conflicts: libmnl-dev but 1.0.4-2 is to be installed
E: Unable to correct problems, you have held broken packages.
Could not install all requested build packages: libmnl-dev libmnl-dev:arm64 libmnl0:arm64 libreadline-dev:arm64 libreadline7:arm64 libtinfo-dev:arm64 libtinfo5:arm64

What would be the “correct” or preferred method? I can think of several potential workarounds (e.g. like adding e.g. libnml, libgmp, libreadline as a part to the snapcraft.yaml), but they (might) have other drawbacks (let alone the problems that might arise because these packages themselves may have dependencies I would have to handle, etc.).

Any help appreciated. Thank you!

Michael