Hi. I am trying to build armhf snap inside the container on arm64 machine.
I am using armhf lxc ubuntu image. Getting this error. Changes to architectures field does not seem to have any effect. Any pointers on how to deal with this?
root@octo-pi3:/var/octo-avenger# snapcraft snap --destructive-mode --verbosity=debug
2024-03-24 14:09:11.570 Starting Snapcraft 7.5.5
Traceback (most recent call last):
File "/snap/snapcraft/11046/bin/snapcraft", line 8, in <module>
sys.exit(run())
File "/snap/snapcraft/11046/lib/python3.8/site-packages/snapcraft/cli.py", line 256, in run
_run_dispatcher(dispatcher, global_args)
File "/snap/snapcraft/11046/lib/python3.8/site-packages/snapcraft/cli.py", line 229, in _run_dispatcher
dispatcher.run()
File "/snap/snapcraft/11046/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
return self._loaded_command.run(self._parsed_command_args)
File "/snap/snapcraft/11046/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 138, in run
parts_lifecycle.run(self.name, parsed_args)
File "/snap/snapcraft/11046/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 209, in run
_expand_environment(
File "/snap/snapcraft/11046/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 728, in _expand_environment
info = craft_parts.ProjectInfo(
File "/snap/snapcraft/11046/lib/python3.8/site-packages/craft_parts/infos.py", line 94, in __init__
self._set_machine(arch)
File "/snap/snapcraft/11046/lib/python3.8/site-packages/craft_parts/infos.py", line 281, in _set_machine
raise errors.InvalidArchitecture(self._host_arch)
craft_parts.errors.InvalidArchitecture: Architecture 'armv8l' is not supported.
Make sure the architecture name is correct.
Snapcraft and craft-parts expectarmv7l and not armv8l. It would be trivial to add armv8l to craft-parts but I’m not sure if it’s intentionally omitted.
If we make added support for armv8l, then a snap marked with the debian architecture armhf built on armv8l will not work on armv7l machines. (based on my limited understanding of arm architectures)
Well … armv8l output in uname actually means that you are running on an arm64 (aarch64) host that is operating in 32bit compatibility mode, as long as the snap does not actually call directly into the kernel you should be fine since your userspace is most likely armhf anayway …
With armhf on the decline (thanks to 2038 approaching fast and not all distros doing the time_t transition to hold timestamp values in 64bit allocations (a 32bit integer as used by armhf today is to small to hold a unix timestamp beyond 2038)) we will likely see more often that armhf snaps will be built in 64bit hosts that run a 32bit container/userspace, so it might make sense to allow armv8l as a pattern match in snapcraft.
Yup, exactly my use case, I created lxc container with armhf userspace. With 0 aarch64 dependencies.
I have a graviton aarch64 machine that I wanted to also use for pi3 armhf builds.
I guess I can find a code that checks the supported architectures and patch it inside my container for now. Snap will still mark the architecture though, is there a way to override that part easily?