You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also contains all the same modules for static linking with `--static-swift-stdlib`.
73
+
74
+
See the [README](https://github.com/swift-embedded-linux/armhf-debian?tab=readme-ov-file#continuous-integration--artifacts) for more information on build artifacts.
61
75
62
76
build-for-raspios:
63
77
strategy:
64
78
fail-fast: false
65
79
matrix:
66
80
distribution-version: [
67
81
"bullseye",
68
-
"bookworm"
82
+
"bookworm",
83
+
"trixie"
69
84
]
70
85
swift-target-arch: ["armv6", "armv7"]
71
86
name: Build for RaspiOS
72
87
runs-on: ubuntu-latest
88
+
permissions:
89
+
contents: write
73
90
needs: [fetch-sources]
74
91
steps:
75
92
- uses: actions/checkout@v4
@@ -95,4 +112,15 @@ jobs:
95
112
commit: ${{ github.sha }}
96
113
artifactErrorsFailBuild: false
97
114
artifacts: "*.tar.gz"
98
-
body: "See the [README](https://github.com/xtremekforever/swift-armv7#continuous-integration) for more information on build artifacts."
115
+
body: |
116
+
Contains Swift 6.2.x built for various distributions 🎉 The following modules are included for **armv6** / **armv7**:
Also contains all the same modules for static linking with `--static-swift-stdlib`.
125
+
126
+
See the [README](https://github.com/swift-embedded-linux/armhf-debian?tab=readme-ov-file#continuous-integration--artifacts) for more information on build artifacts.
Since Linux armv7 is not officially supported by the Swift project ([swiftlang](https://github.com/swiftlang)), this is an effort
4
-
to maintain builds of the runtime that can be used for cross-compilation to armv7.
3
+
Since support for Linux armhf (armv6 and armv7) is not officially supported by the Swift project ([swiftlang/swift](https://github.com/swiftlang)), this is an effort
4
+
to maintain community-supported builds of the runtime that can be used for cross-compilation to these architectures.
5
5
6
6
Some main goals:
7
7
8
-
- Build major versions of Swift (since 5.10) and provide build artifacts for various distributions that support armv7 (Ubuntu, Debian).
9
-
- Provide SDKs that can be downloaded and used to cross-compile user applications and libraries to armv7.
8
+
- Build major versions of Swift since 5.10 and provide build artifacts for various distributions that support armv6 and armv7.
9
+
- Provide SDKs that can be downloaded and used to cross-compile user applications and libraries to armv6 and armv7.
10
10
- Maintain a CI that can build snapshots/nightly versions of Swift to find and fix issues.
11
11
12
-
NOTE: Building for armv6 is also now supported, although it is limited to working with the `raspios`
13
-
distribution since that is the only version of Debian that supports the ARMv6 architecture. However,
14
-
this makes this project also compatible with older Raspberry Pi models such as the RPI 1, Zero, and so on.
12
+
Also check the [armhf-action](https://github.com/swift-embedded-linux/armhf-action) repo which contains a ready-made GitHub action for downloading, installing, and using the SDKs generated by this repo to cross-compile Swift packages for armv6 and armv7 from GitHub workflows.
15
13
16
-
## Compilation
14
+
## Support
17
15
18
-
There are various options for compiling Swift for armv7 with these scripts.
16
+
The following Linux distributions are currently supported:
19
17
20
-
### Build Swift runtime cross compiled from Linux
18
+
- Raspberry Pi OS (armv6 & armv7)
19
+
- 11: Bullseye
20
+
- 12: Bookworm
21
+
- 13: Trixie
22
+
- Debian (armv7 only)
23
+
- 11: Bullseye
24
+
- 12: Bookworm
25
+
- 13: Trixie
26
+
- Ubuntu (armv7 only)
27
+
- 20.04: Focal
28
+
- 22.04: Jammy
29
+
- 24.04: Noble
21
30
22
-
To build for the default (Debian Bookworm) for armv7, use the `build.sh` script:
31
+
Notes:
32
+
- armv6 is only supported on Raspberry Pi OS distributions since it is the only distribution that supports the armv6 "hard-float" variant that is targeted by the repo. This means we can maintain compatibility with the full line of [Raspberry Pi SBCs](https://www.raspberrypi.com/news/raspberry-pi-product-series-explained/) in this repo.
33
+
- Interim support for Ubuntu versions (20.10, 21.04, 23.10, etc) is possible by picking the closest LTS release and compiling for that, since glibc and and core library versions will likely be compatible.
34
+
35
+
> [!TIP]
36
+
> If more distribution support is needed and/or desired, feel free to open an Issue to have it added. Or, consider adding support in the scripts and CI workflows and contributing it back!
37
+
38
+
## Continuous Integration & Artifacts
39
+
40
+
This repo contains CI scripts that use GitHub actions to compile different versions of Swift
41
+
for armv6/armv7 for different distributions. Artifacts are generated and published to CI runs that can
42
+
be downloaded and used locally:
43
+
44
+
-`sysroot-$DISTRIBUTION`: Contains sysroot for the given distribution, used to compile Swift and included in SDKs.
45
+
-`$SWIFT_TAG-$DISTRIBUTION-[armv6|armv7]-install`: Swift armv7 runtime built for the given distribution, can be installed to the target.
46
+
-`$SWIFT_TAG-$DISTRIBUTION-[armv6|armv7]-sdk`: The cross-compilation SDK for the given distribution, must be installed to /opt to use.
47
+
48
+
To use the SDK that is generated by the CI or published to the [Releases](https://github.com/xtremekforever/swift-armv7/releases) page, first
49
+
extract it to /opt:
23
50
24
51
```bash
25
-
export SWIFT_NATIVE_PATH=/path/to/swift/toolchain
26
-
./build.sh
52
+
sudo tar -xf swift-6.2.3-RELEASE-debian-bookworm-armv7-sdk.tar.gz -C /opt
53
+
```
54
+
55
+
Then, from a Swift package, use the `--destination` paramter to cross-compile it for the target:
56
+
57
+
```bash
58
+
swift build --destination /opt/swift-6.2.3-RELEASE-debian-bookworm-armv7/debian-bookworm.json
27
59
```
28
60
29
-
NOTE: The toolchain pointed to by SWIFT_NATIVE_PATH should match the version of Swift being built.
30
-
If not, failures will occur in the compilation.
61
+
## Compiling Locally & Contributing
62
+
63
+
There are various options for compiling Swift for armhf with these scripts.
64
+
65
+
> [!NOTE]
66
+
> These scripts require that Docker at least be installed with [multi-platform support](https://docs.docker.com/build/building/multi-platform/) enabled. The multi-platform support is used to build sysroots for various distributions, based on container images from Docker Hub.
67
+
68
+
### Build Swift Runtime in Container (Easy Way)
31
69
32
-
### Build Swift runtime using custom sysroot
70
+
The easiest way to compile the runtime is inside of the provided Docker container. This ensures that you have the same version of Swift for the host as what you are compiling for the target.
33
71
34
-
To build a custom sysroot and use it to build, run the `build-sysroot.sh` script. This requires a
35
-
working installation of Docker with [multi-platform support](https://docs.docker.com/build/building/multi-platform/) enabled.
72
+
Start by creating the default sysroot (debian bookworm), then run the `build-in-container.sh` script:
36
73
37
74
```bash
38
-
./build-sysroot.sh ubuntu:noble
75
+
./build-sysroot.sh debian bookworm
76
+
./build-in-container.sh
39
77
```
40
78
41
-
Then, provide the`STAGING_DIR` env variable to the build script:
79
+
Things such as`STAGING_DIR`, `SWIFT_VERSION`, and `SWIFT_TARGET_ARCH` can also be passed through environment variables:
To build the Swift runtime on the host, you must have a matching version of Swift installed. It is recommended to use [swiftly](https://github.com/swiftlang/swiftly) to make this simpler.
89
+
90
+
To build for the default (Debian Bookworm) for armv7, use the `build.sh` script:
91
+
92
+
```bash
93
+
export SWIFT_NATIVE_PATH=/path/to/swift/toolchain
45
94
./build.sh
46
95
```
47
96
48
-
Extra dependencies can also be installed into the sysroot if desired or needed, which in turn will
49
-
be installed into the cross-compilation SDK (see [Building a Cross Compilation SDK for Linux](#building-a-cross-compilation-sdk-for-linux)). To do this, use:
97
+
NOTE: The toolchain pointed to by SWIFT_NATIVE_PATH must match the version of Swift being built. If not, failures will occur in the compilation.
98
+
99
+
It is possible to build for armv6 as well by building and providing a sysroot for raspios, and changing the target to armv6 while invoking the build script:
Extra dependencies can also be installed into the sysroot if desired or needed, which in turn will be installed into the cross-compilation SDK (see [Building a Cross Compilation SDK for Linux](#building-a-cross-compilation-sdk-for-linux)). To do this, add the `EXTRA_DEPENDENCIES` environment variable:
By default, the SDK will be generated to be installed at a path of /opt/$SWIFT_TAG-$DISTRIBUTION-armv7, but this can be customized by providing a different install prefix to the script:
0 commit comments