Skip to content

Commit cc27251

Browse files
authored
Merge pull request #24 from swift-embedded-linux/main
Update for Swift 6.2.3
2 parents 2cf1d1b + d209dea commit cc27251

14 files changed

Lines changed: 235 additions & 197 deletions

.github/actions/build-with-sysroot/action.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ runs:
7070
xtremekforever/swift-builder:${{ inputs.builder-tag }} \
7171
swift build -c release \
7272
--package-path swift-hello \
73-
--destination /opt/${{ env.SDK_NAME }}/${{ inputs.distribution }}.json \
74-
-Xswiftc -cxx-interoperability-mode=default \
75-
-Xswiftc -enable-testing
73+
--destination /opt/${{ env.SDK_NAME }}/${{ inputs.distribution }}.json
7674
cp ${{ github.workspace }}/swift-hello/.build/release/swift-hello ${{ github.workspace }}/artifacts/swift-hello
7775
- name: Test Static SDK for Linux
7876
shell: bash
@@ -84,7 +82,6 @@ runs:
8482
swift build -c release \
8583
--package-path swift-hello \
8684
--destination /opt/${{ env.SDK_NAME }}/${{ inputs.distribution }}-static.json \
87-
-Xswiftc -cxx-interoperability-mode=default \
8885
--static-swift-stdlib
8986
cp ${{ github.workspace }}/swift-hello/.build/release/swift-hello ${{ github.workspace }}/artifacts/swift-hello-static
9087
- uses: actions/upload-artifact@v4

.github/workflows/build-swift-latest.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ name: Build Swift Latest
22

33
on:
44
push:
5-
branches: [ "main", "feature/**" ]
5+
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8+
workflow_dispatch:
89

910
jobs:
1011
build-latest:
1112
strategy:
1213
fail-fast: false
1314
matrix:
1415
swift-target-arch: ["armv7"]
15-
distribution: ["debian-bookworm"]
16+
distribution: ["debian-trixie"]
1617
include:
1718
- swift-target-arch: "armv6"
18-
distribution: "raspios-bookworm"
19+
distribution: "raspios-trixie"
1920
env:
20-
SWIFT_VERSION: "6.1.2"
21-
SWIFT_TAG: swift-6.1.2-RELEASE
21+
SWIFT_VERSION: "6.2.3"
22+
SWIFT_TAG: swift-6.2.3-RELEASE
2223
name: Build Swift
2324
runs-on: ubuntu-latest
2425
steps:

.github/workflows/build-swift-nightly.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- swift-6.0-branch
1414
- swift-6.1-branch
1515
- swift-6.2-branch
16+
- swift-6.3-branch
1617
- development
1718
distribution:
1819
description: 'Distribution'
@@ -25,6 +26,10 @@ on:
2526
- ubuntu-noble
2627
- debian-bullseye
2728
- debian-bookworm
29+
- debian-trixie
30+
- raspios-bullseye
31+
- raspios-bookworm
32+
- raspios-trixie
2833

2934
jobs:
3035
nightly:

.github/workflows/build-swift-release.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: Build Swift Release
22

33
on:
44
push:
5-
branches: [ "release/6.1.2" ]
5+
branches: [ "release/6.2.3" ]
66

77
env:
8-
SWIFT_VERSION: "6.1.2"
9-
SWIFT_TAG: swift-6.1.2-RELEASE
8+
SWIFT_VERSION: "6.2.3"
9+
SWIFT_TAG: swift-6.2.3-RELEASE
1010
SWIFT_WORKSPACE_CACHE: swift-workspace
1111

1212
jobs:
@@ -28,12 +28,15 @@ jobs:
2828
distribution: [
2929
"debian-bullseye",
3030
"debian-bookworm",
31+
"debian-trixie",
3132
"ubuntu-focal",
3233
"ubuntu-jammy",
3334
"ubuntu-noble"
3435
]
3536
name: Build for armv7
3637
runs-on: ubuntu-latest
38+
permissions:
39+
contents: write
3740
needs: [fetch-sources]
3841
steps:
3942
- uses: actions/checkout@v4
@@ -57,19 +60,33 @@ jobs:
5760
commit: ${{ github.sha }}
5861
artifactErrorsFailBuild: true
5962
artifacts: "*.tar.gz"
60-
body: "See the [README](https://github.com/xtremekforever/swift-armv7#continuous-integration) for more information on build artifacts."
63+
body: |
64+
Contains Swift 6.2.x built for various distributions 🎉 The following modules are included for **armv6** / **armv7**:
65+
66+
- Essential Modules: `Swift`, `Glibc`, `Dispatch`, `Concurrency`, `Synchronization`
67+
- Foundation: `Foundation`, `Essentials`, `Internalization`, `Networking`, `XML`, `Collections`
68+
- C++ Interop: `Cxx`, `CxxStdlib`
69+
- Testing: `XCTest`, `Testing`
70+
- Optional Modules: `BlocksRuntime`, `Distributed`, `Differentiation`, `Observation`, `StringProcessing`, `RegexBuilder`, `RegexParser`, `RemoteMirror`, `SwiftOnoneSupport`
71+
72+
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.
6175
6276
build-for-raspios:
6377
strategy:
6478
fail-fast: false
6579
matrix:
6680
distribution-version: [
6781
"bullseye",
68-
"bookworm"
82+
"bookworm",
83+
"trixie"
6984
]
7085
swift-target-arch: ["armv6", "armv7"]
7186
name: Build for RaspiOS
7287
runs-on: ubuntu-latest
88+
permissions:
89+
contents: write
7390
needs: [fetch-sources]
7491
steps:
7592
- uses: actions/checkout@v4
@@ -95,4 +112,15 @@ jobs:
95112
commit: ${{ github.sha }}
96113
artifactErrorsFailBuild: false
97114
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**:
117+
118+
- Essential Modules: `Swift`, `Glibc`, `Dispatch`, `Concurrency`, `Synchronization`
119+
- Foundation: `Foundation`, `Essentials`, `Internalization`, `Networking`, `XML`, `Collections`
120+
- C++ Interop: `Cxx`, `CxxStdlib`
121+
- Testing: `XCTest`, `Testing`
122+
- Optional Modules: `BlocksRuntime`, `Distributed`, `Differentiation`, `Observation`, `StringProcessing`, `RegexBuilder`, `RegexParser`, `RemoteMirror`, `SwiftOnoneSupport`
123+
124+
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.

README.md

Lines changed: 89 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,116 @@
1-
# Swift Runtime for Linux Armv7
1+
# Swift Runtime for Debian armhf Distributions
22

3-
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.
55

66
Some main goals:
77

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.
1010
- Maintain a CI that can build snapshots/nightly versions of Swift to find and fix issues.
1111

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.
1513

16-
## Compilation
14+
## Support
1715

18-
There are various options for compiling Swift for armv7 with these scripts.
16+
The following Linux distributions are currently supported:
1917

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
2130

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:
2350

2451
```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
2759
```
2860

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)
3169

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.
3371

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:
3673

3774
```bash
38-
./build-sysroot.sh ubuntu:noble
75+
./build-sysroot.sh debian bookworm
76+
./build-in-container.sh
3977
```
4078

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:
4280

4381
```bash
44-
export STAGING_DIR=$(pwd)/sysroot-ubuntu-noble
82+
./build-sysroot raspios bookworm
83+
STAGING_DIR=sysroot-raspios-bookworm SWIFT_VERSION=6.0 SWIFT_TARGET_ARCH=armv6 ./build-in-container.sh
84+
```
85+
86+
### Build Swift Runtime on Host
87+
88+
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
4594
./build.sh
4695
```
4796

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:
50100

51101
```bash
52-
EXTRA_DEPENDENCIES="libsqlite3-dev" ./build-sysroot debian:bookworm.sh
102+
export SWIFT_NATIVE_PATH=/path/to/swift/toolchain
103+
./build-sysroot raspios bookworm
104+
STAGING_DIR=sysroot-raspios-bookworm SWIFT_TARGET_ARCH=armv6 ./build.sh
105+
```
106+
107+
### Build Swift Runtime with Customized Sysroot
108+
109+
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:
110+
111+
```bash
112+
EXTRA_DEPENDENCIES="libsqlite3-dev" ./build-sysroot ubuntu noble
113+
STAGING_DIR=sysroot-ubuntu-noble ./build.sh
53114
```
54115

55116
### Cross compile Swift package from Linux
@@ -73,39 +134,16 @@ export SWIFT_NATIVE_PATH=/tmp/cross-toolchain/debian-bookworm.sdk
73134

74135
### Building a Cross Compilation SDK for Linux
75136

76-
After building the armv7 runtime using the `build.sh` script, you can generate a redistributable SDK
137+
After building the armv6/armv7 runtime using the `build.sh` script, you can generate a redistributable SDK
77138
using the `build-linux-cross-sdk.sh` script. You must provide the swift tag and distribution name:
78139

79140
```bash
80-
./build-linux-cross-sdk.sh swift-6.1.2-RELEASE ubuntu-noble
141+
SWIFT_TARGET_ARCH=armv7 ./build-linux-cross-sdk.sh swift-6.2.3-RELEASE ubuntu-noble
81142
```
82143

83144
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:
84145

85146
```bash
86147
export SDK_INSTALL_PREFIX=/home/myuser/swift-sdks
87-
./build-linux-cross-sdk.sh swift-6.1.2-RELEASE ubuntu-noble
88-
```
89-
90-
## Continuous Integration & Releases
91-
92-
This repo also contains CI scripts that use GitHub actions to compile different versions of Swift
93-
for armv7 for different distributions. Artifacts are generated and published to CI runs that can
94-
be downloaded and used locally:
95-
96-
- `sysroot-$DISTRIBUTION`: Contains sysroot for the given distribution, used to compile Swift and included in SDKs.
97-
- `$SWIFT_TAG-$DISTRIBUTION-armv7-install`: Swift armv7 runtime built for the given distribution, can be installed to the target.
98-
- `$SWIFT_TAG-$DISTRIBUTION-armv7-sdk`: The cross-compilation SDK for the given distribution, must be installed to /opt to use.
99-
100-
To use the SDK that is generated by the CI or published to the [Releases](https://github.com/xtremekforever/swift-armv7/releases) page, first
101-
extract it to /opt:
102-
103-
```bash
104-
sudo tar -xf swift-6.1.2-RELEASE-debian-bookworm-armv7-sdk.tar.gz -C /opt
105-
```
106-
107-
Then, from a Swift package, use the `--destination` paramter to cross-compile it for the target:
108-
109-
```bash
110-
swift build --destination /opt/swift-6.1.2-RELEASE-debian-bookworm-armv7/debian-bookworm.json
148+
./build-linux-cross-sdk.sh swift-6.2.3-RELEASE ubuntu-noble
111149
```

build-swift-package.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if [ $STATIC_SWIFT_STDLIB ]; then
88
STATIC="Static"
99
else
1010
# Only build tests when not building statically
11-
PARAMS="--build-tests -Xswiftc -enable-testing"
11+
PARAMS="--build-tests"
1212
fi
1313

1414
echo "Cross compile Swift package $PARAMS"
@@ -19,5 +19,4 @@ $SWIFT_NATIVE_PATH/swift build \
1919
--configuration ${SWIFTPM_CONFIGURATION} \
2020
--scratch-path ${SWIFT_PACKAGE_BUILDDIR}${STATIC_SUFFIX} \
2121
--destination ${SWIFTPM_DESTINATION_FILE} \
22-
-Xswiftc -cxx-interoperability-mode=default \
2322
$PARAMS

build-swift-stdlib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ cmake -S $SWIFT_SRCDIR -B $SWIFT_BUILDDIR -G Ninja \
5555
-DSWIFT_ENABLE_EXPERIMENTAL_NONESCAPABLE_TYPES=ON \
5656
-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION=ON \
5757
-DSWIFT_ENABLE_SYNCHRONIZATION=ON \
58+
-DSWIFT_ENABLE_VOLATILE=ON \
5859
-DSWIFT_SHOULD_BUILD_EMBEDDED_STDLIB=OFF \
5960
-DSWIFT_INCLUDE_TESTS=OFF \
6061
-DSWIFT_INCLUDE_TEST_BINARIES=OFF \

0 commit comments

Comments
 (0)