Architectures¶
snapcraft.yaml¶
The architectures how-to guide provides examples of
how to use the platforms and architectures key.
core24¶
platforms:
<platform 1>:
build-on: [<arch 1>, <arch 2>]
build-for: [<arch 1>]
<platform 2>:
build-on: [<arch 3>]
build-for: [<arch 4>]
...
platform¶
The platform name describes a build-on/build-for pairing. If the
platform name is a valid debian architecture, then build-on and
build-for can be omitted (see below for details).
For a list of supported architectures, see Supported CPU architectures.
The recommended platform name is the build-for arch.
build-on¶
The build-on field is an optional list of architectures where the snap can
be built. It can contain multiple architectures.
If the platform name is a valid architecture and build-for is not defined,
then build-on can be omitted. build-on will assume the platform name.
build-for¶
The build-for field is an optional single-element list containing the
architecture where the snap should run.
If the platform name is a valid architecture, then build-for will
assume the platform name.
build-for: [all] is a special key to denote an architecture-independent
snap. If the all key is used, no other build-on/build-for pairs can
be defined. See this page to learn how to
use the all key.
all cannot be used for build-on.
core22¶
The root key architectures defines a list of build-on->build-for
pairs with the following syntax:
architectures:
- build-on: [<arch 1>, <arch 2>]
build-for: [<arch 1>]
- build-on: [<arch 3>]
build-for: [<arch 4>]
For a list of supported architectures, see Supported CPU architectures.
Data types¶
If the value is a single item, it can be written as a single element list or a scalar. For example:
architectures:
- build-on: amd64
build-for: arm64
is equivalent to:
architectures:
- build-on: [amd64]
build-for: [arm64]
Note
Using a list is the recommended syntax. Scalars are not recommended.
build-on¶
The build-on field is required and can contain multiple architectures.
build-for¶
The build-for field is optional and should be a single element list. If it
is not defined, the build-for will be set the build-on for each build
in the build plan.
build-for: [all] is a special key to denote an architecture-independent
snap. If the all key is used, no other build-on/build-for pairs can
be defined. See this page to learn how to
use the all key.
all cannot be used for build-on.
The same architecture cannot be defined in multiple build-for entries.
core20¶
The above syntax and rules for core22 apply for core20 except that
run-on is used in place of build-for. Additionally, core20 supports
multiple architectures in the run-on field, which will create
multi-architecture snaps.
Shorthand format¶
Legacy behavior
Shorthand architectures are resolved differently depending on the snap’s base. In core20 snaps, declaring multiple shorthand architectures yields a single multi-architecture artifact.
As an alternative to the explicit format described above, core20 snaps
support a shorthand format can be used for simple multi-architecture build-on
definitions.
architectures: [amd64, arm64]
is equivalent to:
architectures:
- build-on: [amd64, arm64]
The explicit and shorthand format cannot be mixed.
Project variables¶
core24¶
Project variable |
Description |
|---|---|
|
The architecture of the platform the snap is built for. |
|
The architecture of the platform the snap is built on. |
|
The architecture triplet of the platform the snap is built for. |
|
The architecture triplet of the platform the snap is built on. |
core22¶
Project variable |
Description |
|---|---|
|
The architecture of the platform the snap is built for. |
|
The architecture of the platform the snap is built on. |
|
The architecture triplet of the platform the snap is built for. |
|
The architecture triplet of the platform the snap is built on. |
|
deprecated: use
|
|
deprecated: use |
core20¶
core20 snaps use the terminology run-on in the architectures field
in the project file. The project variables and documentation use the
preferred term build-for.
Project variable |
Description |
|---|---|
|
The architecture of the platform the snap is built for. |
|
The architecture of the platform the snap is built on. |
|
The architecture triplet of the platform the snap is built for. |
|
The architecture triplet of the platform the snap is built on. |
|
The architecture triplet specified by
|
|
The architecture specified by
|
SNAPCRAFT_ARCH_BUILD_FOR and SNAPCRAFT_ARCH_TRIPLET_BUILD_FOR are not
available in any of the following scenarios:
when the build-for architecture is not in the list of supported architectures
when building a multi-architecture snap
Supported CPU architectures¶
core22 and higher¶
Local builds¶
Snapcraft supports building for these architectures locally:
amd64
arm64
armhf
ppc64el
riscv64
s390x
Launchpad builds¶
Launchpad supports remote building for these architectures:
amd64
arm64
armhf
ppc64el
riscv64
s390x
core20¶
Local builds¶
Snapcraft supports building for these architectures locally:
amd64
arm64
armhf
i386
powerpc
ppc64el
riscv64
s390x
Launchpad builds¶
Launchpad supports remote building for these architectures:
amd64
arm64
armhf
i386
ppc64el
riscv64
s390x
Environment variables and command line arguments¶
core22¶
The command line argument --build-for=<arch> or environment variable
SNAPCRAFT_BUILD_FOR=<arch> is used to build a single snap package for an
architecture. It selects a single build-on->build-for pair from the build
plan. It does not allow building a snap not defined by the build plan.
The command line argument takes priority over the environment variable.
See Build plans for more information on how build plans are created.
core20¶
--target-arch=<arch> is used for cross-compiling in core20. It adds
repositories for the target arch, which are used for stage-packages. The
target arch does not need to be listed in the architectures key.
The --target-arch argument can only be used in destructive mode and with
--enable-experimental-target-arch or the environment variable
SNAPCRAFT_ENABLE_EXPERIMENTAL_TARGET_ARCH.
The full usage is
snapcraft --destructive-mode --enable-experimental-target-arch --target-arch=<arch>.