[swift-dev] Cross-compile for Android armv7 from OSX

Geordie Jay geojay at gmail.com
Mon Jan 18 13:03:35 CST 2016


I have just pushed a branch to the SwiftAndroid repo that is at the stage of correctly compiling the swift toolchain and stdlib objects for android-armv7 and macosx-x86_64 (as verified using nm from the different toolchains): https://github.com/SwiftAndroid/swift/tree/osx-crosscompile <https://github.com/SwiftAndroid/swift/tree/osx-crosscompile>. The problem is it fails at the linker stage.

Basically the OSX linker doesn't understand the “—sysroot” option (See AddSwift.cmake:59). Up until that point though (throughout the compiling stage), we need that option because otherwise the Android components attempt to use OSX /usr/include, which throws all sorts of errors because of wrong architecture etc. Why it fails to compile when I remove the “—sysroot” option, but also fails _with_ it in the link stage will probably be key to fixing this. Again, it seems that what we really need to do is use the Android linker, not the Xcode one.

I'm going to try figure out how to do that tomorrow but not confident I’ll get far given my limited experience with this.. This work may also be of interest to the Raspberry Pi / BeagleBoard folks, would also love to hear some opinions about how to solve the CMAKE_SYSTEM_NAME problem, that will also affect cross-compilation for those uses. In any case, any hints or collaborators would be most welcome.

Geordie

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160118/edec48d6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160118/edec48d6/attachment.sig>


More information about the swift-dev mailing list