[CMake] Add broader support for cross-compiling the portions of the compiler that are written in Swift to non-Darwin Unix

Add cross-compilation flags for the newly added Swift source in `lib/ASTGen/`,
similar to how `SwiftCompilerSources/` is already cross-compiled for other
platforms. Make sure the Swift source in the compiler builds and links against
`SWIFTLIB_DIR` in this cross-compilation build directory, not the one that comes
with the native host compiler.

This requires changing the dependency chain in `CROSSCOMPILE` mode, as normally
the Swift compiler is built first when building natively for the host, then it's
used to build the stdlib. However, when cross-compiling the toolchain, the stdlib
must be cross-compiled first by the host compiler, then the portions of the
Swift compiler written in Swift must be cross-compiled with that new stdlib. All
these dependency changes simply change that compilation order when cross-compiling,
including removing the dependency that the Swift compiler is built before the
stdlib when cross-compiling the Swift compiler.

All changes in this pull are gated on the `CROSSCOMPILE` mode, so they will
not affect any of the existing CI or build presets.
This commit is contained in:
Finagolfin
2024-02-11 19:00:45 +05:30
parent 77cd7b5e87
commit fcf7614638
6 changed files with 41 additions and 16 deletions

View File

@@ -836,8 +836,9 @@ function(_compile_swift_files
endif()
set(swift_compiler_tool_dep)
if(SWIFT_INCLUDE_TOOLS)
# Depend on the binary itself, in addition to the symlink.
if(SWIFT_INCLUDE_TOOLS AND NOT BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
# Depend on the binary itself, in addition to the symlink, unless
# cross-compiling the compiler.
set(swift_compiler_tool_dep "swift-frontend${target_suffix}")
endif()