Cross-compiling a flatpak

Corentin Noël corentin.noel at collabora.com
Thu Mar 22 16:17:48 UTC 2018


Hi everyone,

I'm playing a little bit with flatpak and wanted to experiment cross-
compilation with it.
I haven't seen anything regarding cross-compilation right now, but I'm
wanting to further investigate this issue.

I wanted to know if you had some thoughts about it, or if there was
some plans documented somewhere (or in someone's mind)

Here are my thoughts when I look at this issue:

Let's imagine that I'm using a x86_64 system and want to build a
`bar.foo.HelloWorld` application targetting the aarch64 architecture.
 * my application will target the `org.freedesktop.Platform//1.6`
runtime and require the `org.freedesktop.Sdk//1.6` sdk
 * I start a build with `flatpak build` using a new --target=aarch64
flag showing my intention to cross-build
   * `org.freedesktop.Sdk/x86_64/1.6` and
`org.freedesktop.Platform/x86_64/1.6` are mounted as usual to start the
compilation.
   * the target flag makes flatpak mount a
`org.freedesktop.Sdk.Extension.Cross-aarch64/x86_64/1.6` SDK extension
(mounted under /usr/lib/sdk/Cross-aarch64), this extension contains all
the toolchain for building to the aarch64 architecture. (and it might
also contain some useful things for cross-compilation like a meson
crossfile definition)
   * the target flag makes flatpak mount
`org.freedesktop.Platform/aarch64/1.6` and
`org.freedesktop.Sdk/aarch64/1.6` (and their dependencies) under
/sysroots/aarch64/ as it is doing for the native architecture in /
   * the build happens targetting the sysroot in /sysroots/aarch64/
   * the resulting flatpak is define to be aarch64

So with the current flatpak implementation I'm mostly missing two
parts:
 * Be able to mount at build time a Sdk & Runtime of a foreign
architecture in a well-defined location
 * Define the resulting flatpak as being of another architecture

Do you think that it's the right way to do it and that it's something
that might be implemented in flatpak?


More information about the Flatpak mailing list