moving to self-hosted build (which will involve building Swift 5.9 first, then Swift 6.x with utils/build-script)
I am working slowly on both of these but could definitely use some help. Xaver, do you want to reach out offline, either DM me or email me at padl.com (username same as on here).
I'm still learning about both Yocto and the Swift build system so, forgive any inaccuracies in the text below.
Here's my understanding of where we're at.
The current meta-swift layers (both the original and my 6.0.2 PR) download the host toolchain from download.swift.org, which is capable of cross-compiling, and then explicitly build the standard library and Foundation for the target
Irrespective of how the cross-compiler is built, it's important that the target libraries are built in the specific Yocto target environment to ensure that the glibc version matches, any sub-arch optimisations are made, etc.
Because this doesn't use build-script it's not particularly resilient to new Swift releases (it is easy, for example, to miss new CMake defines for experimental features that should be enabled by default)
We also do have some issues with cross-compiling which may or may not be related to not using build-script, in particular to do with the heuristic used by the Swift clang driver to find the location of libstdc++ which is required for the C++ interop modules to build
To be consistent with the way other languages are built on Yocto, we would ideally prefer to build the Swift cross-compiler from scratch
Because Swift 5.10 and above require Swift to build the compiler, this also means we will need to build Swift 5.9
Ideally we should support both static and dynamic linking of the Swift standard libraries for the target, either way they do have to be built. Likely we also want to support musl as well as glibc. But these (to me) are stretch goals.
Care needs to be taken integrating SwiftPM vendored dependencies with Yocto. We need to decide whether we are OK with SwiftPM managing the dependency versions or these should be lifted into the Bitbake recipe.
Orthogonal to this (but also important) is that the dependencies are only fetched near the do_fetch build task as Yocto by default does not provide network access during the do_compile task. My current PR does this by adding a do_swift_package_resolve task between do_unpack and do_compile, which runs swift package resolve as well as git submodule update --init --recursive --depth 1.
Anyway, that's my brain dump of where I think we're at. More to follow.