Cross-compilation SDKs for Android

An Android multi-architecture cross-compilation SDK for Swift 5.8 is now available. The Swift compiler currently does not support multi-architecture library setups other than on Mac and Windows, so I had to add a line to the Android destination config to tell it where I placed the Swift libraries.

Native builds of the Swift 5.8 toolchain that run on Android in the Termux app are also online. Since I build that native compiler and control where the libraries are installed, I put the Swift libraries in <sysroot>/usr/lib/ for the first time (based on a comment by @etcwilde), spun off Swift runtime library and SDK packages that can be used from any Android device, and patched the Swift compiler to look in the right places.

That means cross-compiling Swift in Termux is now as simple as

> pkg install swift swift-sdk-arm
> swiftc -target armv7-linux-android hello.swift

I had to turn bootstrapping the compiler off on 64-bit too, ie disabling the portions of the compiler written in Swift, because of an issue with C++ interoperability between libc++ and the LLVM headers, so bare regex literals currently don't work with this native Swift compiler.

7 Likes