Although it's not quite live yet at the time of posting (merged to dev but not yet promoted to master), I'm happy to announce the upcoming availability of Swift 6.0.1 for Gentoo via GURU. As with Swift 5.10.1 for Gentoo on GURU, this is an unofficial package not supported by either the Swift project or Gentoo developers.
tl;dr:
If you haven't previously installed Swift via GURU, you can install Swift 6.0.1 by:
emerge --ask app-eselect/eselect-repositoryto enable adding additional ebuild repositories usingeselecteselect repository enable guruto enable the GURU package repoemerge --sync guru- Add
dev/lang-swift ~amd64to/etc/portage/package.accept_keywords- Because GURU packages are considered unstable, you need to explicitly accept packages via the "accept keywords" system. An alternative to doing this manually is running the following command with
--autounmask --autounmask-writeto accept the necessary keyword changes, then runetc-updateto write the changes to the right file (but doing it manually makes it easier to permanently whitelist all Swift versions)
- Because GURU packages are considered unstable, you need to explicitly accept packages via the "accept keywords" system. An alternative to doing this manually is running the following command with
emerge --ask dev-lang/swift
If you currently have the swift-5.10.1 package installed, you'll need to:
emerge -uUD dev-lang/swiftto do a deep update to the latest versioneselect swift updateafterwards to ensure/usr/bin/swift& co are pointing to the latest Swift version (just this once; it's otherwise automatic)
I'll update this thread when these updates should be generally available; if you get the opportunity to update and run into issues, please don't hesitate to let me know! The easiest way to capture as much info as possible during the installation would be to
emerge --ask dev-lang/swift 2>&1 | tee emerge-swift.log
or
emerge -uUD dev-lang/swift 2>&1 | tee emerge-swift.log
so we can capture standard error.
Details
Background: RFC: Requiring Swift to build the Swift toolchain
The Swift 6 compiler and toolchain require an existing Swift compiler in order to build; for a source-based distribution like Gentoo, this means that you need to bootstrap using an earlier compiler that can build without Swift. The Swift 5.10.x line is intended to be the last Swift release capable of being built this way, with 5.10.1 being the latest compiler release in this line at the time of writing.
This means that it must be possible to have multiple Swift compilers installed simultaneously, which required some changes to how I wrote the existing Swift 5.10.1 package:
- I had to change package slotting in order to allow simultaneous compilers to be installed. The existing package defaulted to slot
0, and if the new Swift 6.0.1 package also used slot0, it would be impossible for them to coexist. Slot numbers don't have an inherent meaning, and I could have picked slot1for Swift 6.x.y, slot2for Swift 7.x.y, etc. Instead, I opted to use sub-slots to allow for multiple compilers in the same line to also be installed: Swift 5.10.1 now uses slot5/10, Swift 6.0.1 uses slot6/0, and so on. This scheme will allow you to have one compiler version installed permajor.minorrelease, if you desire- The benefit of going through the pain of changing the slot number for 5.10.1 right now is that it's trivial to keep the mapping in the future, and it enables requesting specific Swift versions via slots. (
emergedoesn't otherwise support depending on specific version ranges, but by requesting, e.g., slot5/10, you'll get a compiler in the 5.10.x range)
- The benefit of going through the pain of changing the slot number for 5.10.1 right now is that it's trivial to keep the mapping in the future, and it enables requesting specific Swift versions via slots. (
- Because you'll now likely have at least two compilers installed at a time, I also wrote
app-eselect/eselect-swiftto help manage the "currently active" Swift compiler at/usr/bin/swiftwitheselect swift set. (eselect swift listwill list available Swift versions,eselect swift showwill show the currently-set compiler,eselect swift updatewill switch to the newest-installed version, etc.)- This works because the updated packages write versioned symlinks for
swift,swiftc, andsourcekit-lspto/usr/bin(e.g.,/usr/bin/swift-5.10.1,/usr/bin/swift-6.0.1) which theeselectmodule can then link to as/usr/bin/swift,/usr/bin/swiftc, etc.) The mechanism is written flexibly so if future Swift packages wanted to symlink more versioned tools into/usr/bin, they'll get picked up automatically and things should Just Work™
- This works because the updated packages write versioned symlinks for
Unfortunately, these two changes required a significant update to the swift-5.10.1 package, so I've also released swift-5.10.1-r1 which will require a rebuild:
- It's not possible to update a package's slot without reinstalling
- The original Swift package wasn't written with the
eselectsymlinking scheme in mind, so unconditionally symlinked to/usr/bin/swift, and did not write versioned symlinks- This also means that
eselectwould technically be messing with files installed by a package, which is iffy
- This also means that
- There were a few unrelated fixes I wanted to make to the package that wouldn't have been picked up if you already had it installed, such as compiling without assertions (
)
Because these first two changes are pretty significant, I've made swift-5.10.1-r1 and swift-6.0.1 intentionally incompatible with swift-5.10.1:0 (the original package in slot 0) — I effectively want to phase out the slot 0 version of the original package, and offer folks the benefits of the new slotting scheme (without having to worry about compatibility with a slot 0 in the future).
If you just try to emerge --ask dev-lang/swift, emerge will complain that the new packages are incompatible with what you've got installed, and you'll need to emerge --depclean dev-lang/swift before you can install the newer versions; if you instead do a deep update with emerge -uUD, emerge will automatically uninstall the existing package.
- Annoying nit: from my experience,
emergewill uninstall the existing package after installing the newer packages. I wrote these new packages to automaticallyeselect swift updateafter installation so you're typically pointing at the latest Swift version after you update. Since the slot0package technically owns/usr/bin/swift,/usr/bin/swiftc, and/usr/bin/sourcekit-lsp, uninstalling the package will likely remove those symlinks. Just runeselect swift updateagain if this happens and you should have the latest links. This shouldn't be necessary again in the future!
Sorry for the hassle of having to reinstall, but hopefully, future updates will be a heck of a lot smoother.