Kernel cross compile problem (missing snapcraft target-arch options)

Hi everyone,

i’m experiencing a problem cross compiling kernel with the latest snapcraft version (2.31) on a Ubuntu-Xenial.
Using the previous xenial snapcraft package (2.29) i was able to cross compile a kernel from source for armhf architecture.
Upgrading the version i obtain the following error:

scripts/kconfig/conf  --defconfig=arch/x86/configs/my_dev_board_defconfig Kconfig
***
*** Can't find default configuration "arch/x86/configs/my_dev_board_defconfig"!
***

It seems that the cross compile options is ignored, and search the default x86 tree instead of the requested arm

Furtermore the “target-arch” option is missing from the help message (snapcraft --help)

Have you experienced similar problems with this new version? Is the cross compilation support beeing removed?
Thanks

Francesco

It works here:

$ snapcraft --target-arch=armhf

Snapped pc-kernel_4.4.0-81.104_armhf.snap

just cross-compiled the xenial kernel on my amd64 box.

ii snapcraft 2.31
all easily craft snaps

The option is indeed there, but with the CLI overhaul the implementation changed. So I think it’s a bug with the options being absent from --help - the same seems to hold true for --no-parallel-builds and --enable-geoip, which are all implemented in the same way.

1 Like

Thanks @kalikiana and @ppisati for the quick reply

I noticed from the code that the options are still there. Command line parsing is changed from 2.29 to 2.31 so my previous invocation was wrong

$ snapcraft -d --target-arch armhf snap

I’ve used the syntax suggested by @ppisati and everything works only if the snapcraft is invoked without snap target, that is the default. If i explicitly set the snap options, the target machine is not set to armhf:

without subcommand (default to snap)

$ snapcraft -d --target-arch=armhf
Starting snapcraft 2.31 from /usr/lib/python3/dist-packages/snapcraft/cli.
Setting target machine to 'armhf'
Setting up part 'kernel' with plugin 'kernel' and properties...

with snap subcommand

$ snapcraft -d --target-arch=armhf snap
Starting snapcraft 2.31 from /usr/lib/python3/dist-packages/snapcraft/cli.
Setting up part 'kernel' with plugin 'kernel' and properties...
...

Could be a bug or i’m missing the correct options?
Thanks

Francesco

1 Like

Thank you for investigating this to narrow it down further. It’s definitely a bug, snap should behave the same as no explicit command (although even before the CLI revamp that wasn’t entirely true, there used to be a bug that was the reverse of this one). I’m having a look at the code, and will try to come up with a fix, as well as a test case - it seems like this slipped coverage.

Turns out the order is being the problem. snapcraft --target-arch=armhf snap doesn’t work, but snapcraft snap --target-arch=armhf does.

I’ve added integration tests for both cases in my PR. I’m still trying to figure out exactly where this difference is coming from.

1 Like