not reliable way to detect target architecture

Bug #1813634 reported by Ondrej Kubik
This bug affects 3 people
Affects Status Importance Assigned to Milestone

Bug Description

There is no reliable way to determine target snap architecture or at least project.target_arch does not provide consistent value

tested with snapcraft version 3.0.1

Tested use cases:
native build:
    project.target_arch - has expected value
    SNAPCRAFT_ARCH_TRIPLET has host arch

cross build with --target-arch:
    project.target_arch has expected target arch value
    SNAPCRAFT_ARCH_TRIPLET has target arch

build on amd64 with following statement in snapcraft.yaml
  - build-on: [amd64, arm64]
    run-on: arm64

expected values:
    project.target_arch has target arch
    SNAPCRAFT_ARCH_TRIPLET has target arch
actual values:
   project.target_arch is empty

Revision history for this message
Ian Johnson (anonymouse67) wrote :

I can reproduce this with snapcraft version 3.4+git7.gba7c6e1

Also, I can't even get the $SNAPCRAFT_ARCH_TRIPLET to have the target arch when using --target-arch, it is always the host arch for me now when building a snap with a base specified (and hence using multipass).

Revision history for this message
Ian Johnson (anonymouse67) wrote :
Revision history for this message
Ondrej Kubik (ondrak) wrote :

yep, SNAPCRAFT_ARCH_TRIPLET works OK in destructive mode. When running using by multipass snapcraft becomes different beast, a bit tricky to predict. In general snapcraft is not giving much help to handle cross compiling.
I understand that it would be naive to expect from snapcracft to solve cross compiling for all the various build systems, but giving enough information about host and target is minimum info it can provide.... And I believe this should not be hard to pass, especially since we have already have env variable there.
A bit worrying this is not getting any attention... not even comment from snapcraft team

Revision history for this message
Saeed (saeedmasoumi) wrote :
Download full text (3.5 KiB)

We are facing the same issue and it's critical to have it fixed please. I don't wanna introduce fragile hacks into build and deployment pipeline to fix such issues.

Command: snapcraft --target-arch armhf

Setting target machine to 'armhf'
Sorry, an error occurred in Snapcraft:
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 11, in <module>
    load_entry_point('snapcraft==2.43.1+18.4', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/click/", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/", line 93, in run
  File "/usr/lib/python3/dist-packages/click/", line 553, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/", line 136, in snap
    project = _execute(steps.PRIME, parts=[], **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/", line 34, in _execute
    project_config = project_loader.load_config(project)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/", line 36, in load_config
    return Config(project)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/", line 233, in __init__
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/", line 55, in __init__
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/", line 86, in _process_parts
    self.load_part(part_name, plugin_name, properties)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/", line 206, in load_part
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/", line 79, in load_plugin
  File "/usr/lib/python3/dist-packages/snapcraft/", line 188, in enable_cross_compilation
    "to a different target architecture".format(
NotImplementedError: The plugin used by 'setup' does not support cross-compiling to a different target architecture

and the yaml looks like:

grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots



To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.