meta: architectures
Metadata
Current evaluation
Merged core22 architecture support, including build-on/build-for handling, host and build-instance selection, and SNAPCRAFT_BUILD_FOR filtering, via commit 4876b53.
Resolution: closed resolved
Reason: PR #3821 was approved and merged into main as commit 4876b5368 (merge commit 37fe38a5), completing the core22 architecture support series.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [X] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [X] Have you successfully run `make lint`?
- [X] Have you successfully run `pytest tests/unit`?
-----
## Overview
Add support for architectures.
- Snapcraft's lifecycle will execute for each `build_on`->`build_for` defined in `snapcraft.yaml`.
- Only snaps where `build_on` equals the host architecture will be built.
- When using `lxd` or `multipass`, a separate instance will be used for each `build_on`->`build_for` pair.
7th and final part of supporting architectures for `core22`.
## Details
- Add support for `build-on` and `build-for` for `core22` snaps.
- Add environmental variable `SNAPCRAFT_BUILD_FOR` to limit which snaps are built
Note: For `core22` snaps, `run-on` has been replaced with `build-for`.
### Examples
These example `snapcraft.yaml` snippets show how to use architectures.
#### Single architecture
Building on `amd64` will produce 1 snap for `amd64`.
```
architectures:
- build-on: amd64
build-for: amd64
```
#### Single architecture, shorthand
This is the same as the previous example, but in a shorthand format.
```
architectures:
- amd64
```
#### Multiple architectures
- Building on `amd64` will produce 1 snap for `amd64`.
- Building on `arm64` will produce 1 snap for `arm64`.
```
architectures:
- build-on: amd64
build-for: amd64
- build-on: arm64
build-for: arm64
```
#### Multiple architectures, shorthand
This is the same as the previous example, but in a shorthand format.
```
architectures:
- amd64
- arm64
```
#### Multiple architecture, cross-compiling
- Building on `amd64` will produce 2 snaps, 1 snap for `amd64` and 1 snap for `arm64`.
- Building on `arm64` will produce 1 snap for `arm64`.
```
architectures:
- build-on: amd64
build-for: amd64
- build-on: [amd64, arm64]
build-for: arm64
```
#### Architecture independent
For snaps that can run on any architecture (e.g. python or shell scripts), use `build-for: all`.
```
architectures:
- build-on: amd64
build-for: all
```
#### Limiting builds with environmental variable
The environmental variable `SNAPCRAFT_BUILD_FOR` can be used so that only 1 snap package is produced.
- Running `snapcraft` on `amd64` will produce 2 snaps, 1 snap for `amd64` and 1 snap for `arm64`.
- Running `SNAPCRAFT_BUILD_FOR=arm64 snapcraft` will produce 1 snap for `arm64`.
```
architectures:
- build-on: amd64
build-for: amd64
- build-on: amd64
build-for: arm64
```
(CRAFT-1173)
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged core22 architecture support, including build-on/build-for handling, host and build-instance selection, and SNAPCRAFT_BUILD_FOR filtering, via commit 4876b53. | |
| stealth/space-bunny-alpha | — | closed resolved | PR #3821 by mr-cal merged to main as commit 4876b53, adding core22 architectures support: build-on/build-for, host filtering, per-pair lxd/multipass instances and SNAPCRAFT_BUILD_FOR (CRAFT-1173). | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in PR #3821 via commit 4876b53, adding core22 build-on/build-for support, host filtering, separate build instances, and SNAPCRAFT_BUILD_FOR. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged adding build-on and build-for architecture support for core22 snaps. Introduced the SNAPCRAFT_BUILD_FOR environment variable to limit builds. Temporarily drafted to fix a duplicate build regression before final merge. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Adds build-on and build-for architecture support for core22 snaps, replacing run-on. Introduces SNAPCRAFT_BUILD_FOR to limit builds. Temporarily drafted to fix a duplicate build regression before final merge. |
Update history
No update history recorded yet.
Related work
-
Related To:
snapcore/snapcraft#3812
(confidence 95%)
Earlier architecture schema support merged as commit 629e4ce51; #3821 was the final implementation part.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #5606 schema: add build-for in architectures for core22 | snapcraft | merged | Merged as c9822a38c via snapcraft#5606, adding build-for to the core22 architectures schema in snapcraft.json. | |
| #2009520 core18/20: inconsistent architecture parsing | snapcraft (launchpad) | closed | Superseded by snapcore/snapcraft#4340 and #4341. Core22+ overlapping build-on handling merged in #3821 (4876b53); core20 support was declined. | |
| #4630 feat: add platforms and drop architectures for core24 | snapcraft | merged | Merged as canonical/snapcraft#4630 (f771a4ab8), adding optional core24 platform selection and removing legacy architectures, with host build defaults. | |
| #1997752 base core20: wrong arch triplet | snapcraft (launchpad) | closed | Wrong SNAPCRAFT_ARCH_TRIPLET for core20 build-on/run-on builds fixed by adding SNAPCRAFT_ARCH_BUILD_ON/BUILD_FOR and *_TRIPLET_BUILD_FOR envvars (PR #4313, commit 93a9d8170); follow-up #4332 (48bd0632f) errors on unevaluable multi-arch cases. | |
| #1999580 core22: wrong arch in snap.yaml when building for all archs | snapcraft (launchpad) | closed | Fixed in merged canonical/snapcraft#4150 (commit 77d3454d): core22 snap.yaml now records build-for (all) instead of the build-on architecture. | |
| #4313 environment: add build-on and build-for envvars for core20 | snapcraft | merged | Merged PR #4313 as 93a9d8170, adding core20 SNAPCRAFT build-on/build-for architecture and triplet environment variables plus tests. | |
| #1533713 Add metadata describing the architectures that a snap can be built for | snapcraft (launchpad) | closed | Core20 added build-on/build-for platform metadata in 2018, enabling CI to derive builds and build-for: [all] for architecture-independent snaps. | |
| #3812 architectures: add schema support | snapcraft | merged | Merged as commit 629e4ce51: adds core22 architectures schema support to snapcraft.yaml (build_to renamed to build_for), part 1 of CRAFT-1163; full feature followed in #3821 (4876b53). | |
| #3414 project loader: export SNAPCRAFT_TARGET_ARCH in build environment | snapcraft | merged | Merged PR #3414 (commit ff2cd96bb) added SNAPCRAFT_TARGET_ARCH to the global build environment in set_global_environment() for core22, alongside SNAPCRAFT_ARCH_TRIPLET. | |
| #4543 fix(remote): parse comma-separated architectures | snapcraft | merged | Merged in snapcore/snapcraft#4543 as b8eed87c0, fixing comma-separated remote-build architectures and enforcing --build-for/--build-on exclusivity. |