I have been working previously on Buildroot support for Swift on Armv5 since Swift 5.4, and I'm excited to share that work has culminated into a set of scripts and distributable binaries to cross compile the Swift runtime (and SwiftPM packages) for Debian 11 Armhf. This binary distribution can be used with existing toolchains from Swift.org and @futurejones swiftlang.xyz.
I have also provided Docker images to quickly cross compile for Debian 11 Armhf
-
latest: this is the bare minimum environment needed to cross compile the Swift runtime for Armv7. Includes Swift 5.6.1 compiler, Cmake 3.22 and LLVM headers. The
build.sh
script can be used to cross compile the runtime. Takes about 5 minutes to compile Swift, Dispatch, Foundation and XCTest. -
5.6.1-prebuilt: This image builds on
latest
as a base, but also includes the Debian 11 sysroot needed to cross compile Swift packages and the Swift runtime already compiled for Armv7. Thegenerate-swiftpm-toolchain.sh
andbuild-swift-package.sh
scripts can be used to cross compile packages.
Example of Docker image usage:
In this example, the colemancda/swift-armv7:5.6.1-prebuilt
Docker image is used to cross compile the package in a x86 CI environment. The -prebuilt
suffix means the image contains the Debian 11 Armhf sysroot with the Swift runtime librares. The next GitHub Action takes the compiled .xctest
executable and runs it in a self hosted Armv7 environment (Orange Pi Zero 2 development board).
v0.3.0 binaries
-
Swift 5.6.1 runtime with Dispatch, Foundation and XCTest cross compiled for Debian 11 Armhf