not reliable way to detect target architecture

Bug #1813634 reported by Ondrej Kubik
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

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
architectures:
  - 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
   SNAPCRAFT_ARCH_TRIPLET has host arch

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

Output:
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/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1043, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/_runner.py", line 93, in run
    ctx.forward(lifecyclecli.commands["snap"])
  File "/usr/lib/python3/dist-packages/click/core.py", line 553, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 136, in snap
    project = _execute(steps.PRIME, parts=[], **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 34, in _execute
    project_config = project_loader.load_config(project)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/__init__.py", line 36, in load_config
    return Config(project)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_config.py", line 233, in __init__
    build_tools=self.build_tools,
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py", line 55, in __init__
    self._process_parts()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py", line 86, in _process_parts
    self.load_part(part_name, plugin_name, properties)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/project_loader/_parts_config.py", line 206, in load_part
    definitions_schema=self._validator.definitions_schema,
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/_plugin_loader.py", line 79, in load_plugin
    plugin.enable_cross_compilation()
  File "/usr/lib/python3/dist-packages/snapcraft/_baseplugin.py", line 188, in enable_cross_compilation
    "to a different target architecture".format(self.name)
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

apps:
  Blink:
    co...

Read more...

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.