swiftlang/swift-syntax

`600.0.0-prerelease-2024-07-24` fails to build on macOS 12 with Swift 5.10

SimplyDanny opened this issue · 12 comments

Description

The latest release of SwiftLint (0.56.1) incorporates SwiftSyntax 600.0.0-prerelease-2024-07-24 as a dependency. Supported are versions back to macOS 12. While everything builds fine for Homebrew on macOS 14 and 13 with Swift 5.10, the build fails on macOS 12 on the changes introduced by #2742.

Swift 5.10 is installed via Homebrew on macOS 13 and 12 since there is no Xcode version available on these platforms that ships with Swift 5.10 included.

I don't know how this is all related. Would be glad if you could shine some light on the issue and guide me to a fix.

Steps to Reproduce

My assumption is that any library depending on this SwiftSyntax version and built on macOS 12 would fail to build. I actually try to do that in SwiftLint on plain (non-Homebrew) machines with the same result (macOS 13 succeeds; macOS 12 fails).

Synced to Apple’s issue tracker as rdar://133401576

Are you trying to build swift-syntax with a Swift 5.7 compiler on macOS 12? swift-syntax requires a Swift 5.8 compiler to build since #2742, the swift-tools-version just didn’t get updated.

Couldn’t you build with a newer Swift version and backdeploy to macOS 12?

Are you trying to build swift-syntax with a Swift 5.7 compiler on macOS 12? swift-syntax requires a Swift 5.8 compiler to build since #2742, the swift-tools-version just didn’t get updated.

SwiftLint specifies // swift-tools-version:5.9. So if a Swift 5.7 compiler was actually used, it'd have refused to start building right from the beginning, wouldn't it?

Couldn’t you build with a newer Swift version and backdeploy to macOS 12?

I think this is not how Homebrew works. Everyone should be able to build things from source given a formula that defines the build steps. Downloading pre-built binaries is just a shortcut as a convenience for the impatient user (99% of users). SwiftLint provides binaries that should be runnable on older macOS versions, but not for Homebrew.

Seems like while a Swift 5.10 compiler is used, the SDK is still read from the Xcode installation. The outdated standard library would explain the compile errors. I'll report back ...

Seems like while a Swift 5.10 compiler is used, the SDK is still read from the Xcode installation. The outdated standard library would explain the compile errors. I'll report back ...

As the SDK is shipped with Xcode only and OS-dependent I won't get this to work at all if the new code now calls API the SDK doesn't provide. Right?

What confuses me is that the reference for UnsafeMutableBufferPointer.deinitialize claims "macOS 10.10+". How does that relate?

The relevant variable here should be the SDK installed in the Xcode being used, not the host OS. Which Xcode are you using on macOS 12? Or, alternatively, which Xcode are you using to get a Swift 5.9+ compiler?

The relevant variable here should be the SDK installed in the Xcode being used, not the host OS. Which Xcode are you using on macOS 12? Or, alternatively, which Xcode are you using to get a Swift 5.9+ compiler?

It's Xcode 14.2 installed on the host. The Swift 5.10 toolchain is installed via Homebrew as well. It was built with Xcode 13.3 as far as I can see.

The Swift 5.10 toolchain is installed via Homebrew as well.

Just to be clear: By Swift 5.10 toolchain, you refer to a Swift open source toolchain from swift.org?

It was built with Xcode 13.3 as far as I can see.

And by this you mean that the 5.10 toolchain from swift.org was built using Xcode 13.3 to your best knowledge?

I should have made this clearer before. Sorry for that. Homebrew provides an own Swift package. So you can basically install it via brew install swift. It's not an official toolchain from swift.org but a manual build. In their formula, Xcode 13.3 is specified as a build dependency.

Seems like I got it now. The only requirement is to build the Swift 6 branch with a Swift 5.8+ compiler and a matching standard library.

The toolchain provided by Homebrew apparently misses some components compared to the regular toolchains. However, this needs to be sorted with the Homebrew folks, not here in this thread.

What's somehow missing is an overview about the API provided by the standard library with respect to the Swift versions that support it. Can that be found somewhere? The only documentation for the standard library is provided by Apple. swift.org even links there, but Apple's website only allows to show differences between the latest Xcode releases/betas. No mention of Swift versions at all. This would be a welcome feature.

I put up #2801 to increase the tool version.

Thank you very much for getting me on the right track with this issue. 🙏

Homebrew download of swift line 0.56..1 for Mac is available.
Thank to both parties that investigated and fixed this.