RFC: Requiring Swift to build the Swift toolchain

This topic has been on my mind lately given my recent[1] experiences[2] getting Swift going on Gentoo, primarily because the idiomatic Gentoo approach to packages presents effectively a worst-case scenario for bootstrapping Swift:

  1. It is strongly preferred that packages build from source (ideally on the machine they're going to run on), and cross-compilation wouldn't be a preferred solution;
  2. It is atypical (though possible!) for multiple versions of a package to be installable simultaneously, so
  3. It's quite uncommon of for a version of a package to depend on an earlier version of the same unless absolutely necessary

(Of course, Gentoo is... niche... and I wouldn't expect (nor suggest) that the Swift project at large consider it a meaningful use-case, but it is interesting to design with the potential of this in mind.)

I was initially concerned, but with a bit of thought, this seems pretty reasonably surmountable:

So long as there's a guarantee that Swift 5.10 can be relied upon to bootstrap future compilers, one possible path forward on the platform:

  1. Split the current swift-5.10.1 package (which builds Swift 5.10.1, installs it into a versioned dir, and symlinks some binaries into /usr/bin) into swift-toolchain-5.10.1 (which just builds and installs) and swift-5.10.1 (which depends on swift-toolchain-5.10.1, and just symlinks)
    • Since swift-toolchain-<vers> is standalone, I can slot it to allow multiple major.minor versions to be installed simultaneously
    • Since swift-<vers> is not, it will continue to only allow one version at a time
  2. Future versions of swift-<vers> can then depend on swift-toolchain-5.10.1 and swift-toolchain-<vers>

Of course, these details are pretty Gentoo-specific so no need to pay too close attention, but this is at least a vote of confidence that any platform which the Swift 5.10 line can be updated to support can bootstrap itself without needing cross-compilation. (Which, again, is a sort of worst-case scenario for support.)

So, +1 from me. (Especially if we're comfortable marking Swift 5.10.x as a sort of LTS release, given the special nature of this change.)


  1. Swift 5.10.1 for Gentoo on GURU ↩︎

  2. Building the Swift Project on Linux with lld instead of gold ↩︎