Open finagolfin opened 9 months ago
I asked directly on the forum what the plan is and was told that a switch to using CMake's built-in Swift support is planned, so I will hold off on my changes building on the existing cross-compilation support and see what ends up rolling out with that new effort first.
Motivation
The Swift source in
SwiftCompilerSources/
has long supported cross-compilation, added by @eeckstein in #40068 for Darwin a couple years ago and then in #40277 for non-Darwin Unix by me. However, the recently added Swift source inlib/{ASTGen,Macros}/
andtools/swift-plugin-server/
does not support cross-compilation, and the new swift-syntax parser never has. Before we start requiring the swift-syntax parser to build the Swift compiler, we better get it cross-compiling, as cross-compilation will be the only way to get the Swift compiler running on new platforms after that.Proposed solution
I cross-compile the Swift compiler for Android AArch64 from a linux x86_64 host, and these are the three changes I had to make to get all this Swift source in the compiler itself cross-compiled:
_add_host_swift_compile_options()
, which is used to buildlib/{ASTGen,Macros}/
andtools/swift-plugin-server/
. This should be easy to generalize likeSwiftCompilerSources/
does.add_swift_syntax_library()
: this may take more work to generalize because of the cross-repo CMake config.swift-plugin-server
withadd_pure_swift_host_tool()
and 1. doesn't work, so I hacked it to use the oldadd_swift_host_tool()
instead. I forget the precise error but it had to do with itsswiftLLVMJSON
dependency in turn linking a C++ library,swiftBasic
, so the tool wasn't actually pure Swift. That works fine when natively compiling, but not when cross-compiling.I can probably implement 1. easily for non-Darwin Unix, but I'm looking for input from @rintaro and @bnbarham on how we should properly fix the other two, plus I don't use Darwin or Windows so others will have to get cross-compilation working again there.