Cross Compilers for Swift 5.1.1
Release Notes:
This release contains installer packages for MacOS cross compilers of the Swift 5.1.1 release. There is a separate installer package for the following architectures:
- arm64 - for Raspberry Pi 3, 3+, 4 running 64-bit OSes.
- armv7 - for Pi 2, 3, 3+, 4 running 32-bit OSes such as Raspbian
- armv7-raspbian - for Pi 2, 3, 3+, 4 running directly under Raspbian
- armv6 - Pi 0 and 1 running 32-bit OSes such as Raspbian.
- amd64 - for Intel architecture devices running Linux.
Each distribution includes: a toolchain, an SDK, a destination file and a collection of libs used at runtime. X-compiled applications are best run under Docker, but judicious setting of the LD_LIBRARY_PATH variable to point at the correct runtime can also work.
See the main page for more details.
Example usage:
cd helloworld
swift build --destination /Library/Developer/Destinations/arm64-5.1.0-RELEASE.json
swift build --destination /Library/Developer/Destinations/amd64-5.1.0-RELEASE.json
swift build --destination /Library/Developer/Destinations/armv7-5.1.0-RELEASE.json
/Library/Developer/Toolchains/armhf-5.1.1-RELEASE_armv6.xctoolchain/usr/bin/swift build --destination /Library/Developer/Destinations/armv6-5.1.1-RELEASE.json
Associated Ubuntu 18.04 runtimes for each architecture can be found in /Library/Developer/Runtimes after installation. The runtimes are the easiest way to construct distro-less docker containers for deploying to your Pi or cloud installation.
Note that this release includes the mosquitto MQTT developer packages. This is not strictly necessary for compiling but has been added for convenience because many R/Pi IoT projects (in particular the maintainer's :) ) require an MQTT client.
NB, this release includes a Mac OS/X toolchain: swift-5.1.1-osx-armv6.pkg. This has one patch to the swift package manager to include an armv6 target for generation of binaries using the armv6 instruction set. You do not need to download this package as it is incorporated in the armv6 cross-compiler: Swift-arm6-5.1.pkg during x-compiler build. It is here solely to allow others to build the x-compiler without having to apply the patch and rebuild a macosx toolchain themselves.
You do need to make sure you use that particular version of the swift toolchain when compiling your Pi Zero/1 code. i.e. do NOT just say swift build --destination /Library/Developer/Destinations/armv6-5.1.1-RELEASE.json as that will pick up the standard xcode version of swift which does not include support for emitting armv6 objects. You should instead use the swift command from the x-compiler toolchain as shown above.