Valgrind snap build for arm64 fails

I am trying to build a snap for valgrind. The snap builds fine from amd but fails for arm64 with the following output:

EXPERIMENTAL* --target-arch for core20 enabled.
Snapcraft is running in directory 'snap'.  If this is the snap assets directory, please run snapcraft from /home/builder/projects/snaps/hello.
Cleaning later steps and re-pulling utils ('stage-packages' property changed)
+ snapcraftctl pull
Building utils 
+ snapcraftctl build
Staging utils 
+ snapcraftctl stage
Priming utils 
+ snapcraftctl prime
Failed to generate snap metadata: The specified command 'usr/bin/valgrind' defined in the app 'valgrind' does not exist.
Ensure that 'usr/bin/valgrind' is installed with the correct path.

I verified the location of where the valgrind binary is installed by installing valgrind on an arm64 via apt-get and it is in the location as specified in the snapcraft.yaml file, i.e., usr/bin/valgrind

My snapcraft.yaml file contents are as follows:

name: hello
base: core20
version: '2.10'
summary: valgrind
description: valgrind

grade: devel
confinement: devmode

    bind: $SNAP/usr/local/bin
    bind: $SNAP/usr/lib/valgrind
    bind: $SNAP/usr/include/valgrind
    bind: $SNAP/usr/lib/x86_64-linux-gnu/valgrind
    bind: $SNAP/usr/libexec/valgrind
    bind: $SNAP/usr/lib/debug

    command: usr/bin/valgrind

    plugin: nil
    source: .
      - to arm64:
        - valgrind

Any idea why it fails to build? Thanks!

I really need some help in this. Any input would be greatly appreciated.

It seems that you’re hard-coding the arch triplet for x86_64 in the layout mapping, you can use $SNAPCRAFT_ARCH_TRIPLET instead.

Thanks for the response.

Sorry, that was a typo from myside while posting my question. I had tried the script with aarch64-linux-gnu (not x86_64-linux-gnu) for the arm64 build.

I also tried using $SNAPCRAFT_ARCH_TRIPLET, but I still get the same error during snapcraft build.

One idea is to run with --debug to shell into the build instance when the problem occurs (or run snapcraft prime --use-lxd --shell-after since we know that it happens post-prime) to inspect the prime directory contents to investigate the missing files (are they there, with a slightly different name? are they on a different location? or not generated at all?). Also make sure the arch triplet for the machine you’re building on matches the triplet used in the layouts stanza.