meta: architectures
Metadata
Current evaluation
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.
Suggested action: —
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 |
|---|---|---|---|---|
| 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged. Implements build-on and build-for architecture support for core22 snaps, introducing the SNAPCRAFT_BUILD_FOR environment variable and shorthand syntax. Temporarily moved to draft to fix a duplicate build regression prior to final merge. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #4313 environment: add build-on and build-for envvars for core20 | snapcraft | merged | Merged into main. Added SNAPCRAFT_ARCH_BUILD_ON and SNAPCRAFT_ARCH_BUILD_FOR environment variables to expose build architecture details for core20. Approved, passed CI, and increased coverage. | |
| #4150 meta: use build-for in snap.yaml architecture | snapcraft | merged | Merged fix correcting snap.yaml architecture generation. When build-for is set to all, the file now correctly outputs architectures: all instead of the previous incorrect build-on value. Resolves CRAFT-1535. | |
| #532 environment: add build-on and build-for architectures | craft-parts | merged | Merged following approval and CI checks. Introduces CRAFT_ARCH_BUILD_ON and CRAFT_ARCH_BUILD_FOR environment variables to standardize architecture naming, deprecating CRAFT_TARGET_ARCH and CRAFT_ARCH_TRIPLET. Resolves #514. | |
| #4332 environment: error when build-for arch variable cannot be evaluated | snapcraft | merged | Merged. Resolves #4314 by raising an error instead of silently evaluating to None when SNAPCRAFT_ARCH_BUILD_FOR or SNAPCRAFT_ARCH_TRIPLET_BUILD_FOR cannot be determined for core20 snaps. Approved by three reviewers and passed CI. | |
| #3812 architectures: add schema support | snapcraft | merged | Merged after approval and passing CI. Added schema support for defining architectures in snapcraft.yaml as part one for core22. Coverage increased by 0.09%, and the build_to parameter was renamed to build_for during review. | |
| #5606 schema: add build-for in architectures for core22 | snapcraft | merged | Merged update adding the build-for field to the core22 architectures schema. The change aligns the schema with official documentation and passed all review and CI checks. | |
| #1862256 snapcraft should complain loudly when building base: core20 snap on i386 | snapcraft (launchpad) | closed | Closed as superseded. Improved architecture parsing in snapcraft now correctly rejects unsupported base-architecture combinations, addressing the original request without requiring explicit i386 core20 checks. | |
| #4854 Accept `build-for: [all]` and `--build-for=all` for architecture-independent snaps | snapcraft | closed | Closed without resolution. The request to add tests and fix regressions for architecture-independent snaps on core22 and core24 was abandoned with no implementation recorded. | |
| #1377 fix: make snap build on all architectures. | charmcraft | merged | Merged to resolve issue #1369 by enabling snap builds across armhf, arm64, ppc64el, and s390x. Approved by two reviewers, the two-file change (+25/-40 lines) updates build configurations for full multi-platform compatibility. | |
| #331 feat(snap): build on arm64 | fetch-service | merged | Merged after two approvals with zero unresolved comments. Adds arm64 build support for the snap package via a single-file change (+4/-0 lines). A successful build log confirms cross-architecture snap compilation is now enabled. |