swift-collections icon indicating copy to clipboard operation
swift-collections copied to clipboard

Version 1.1.0 fails to compile

Open jbelkins opened this issue 1 year ago • 8 comments

When building swift-collections on macOS 12 / Xcode 14.0.1 / destination 'platform=OS X', the package fails to compile. The same macOS version and Xcode version compile successfully for the iOS & tvOS platforms, as well as for every other combination of host OS / Xcode version / target OS I have tried.

Relevant logs from the compile failure:

❌  /Users/runner/Library/Developer/Xcode/DerivedData/smithy-swift-eqehdcxsyalqqmgtkhjdigcyxfcr/SourcePackages/checkouts/swift-collections/Sources/RopeModule/Rope/Basics/Rope+Builder.swift:18:29: cannot specialize protocol type 'Sequence'

  public init(_ items: some Sequence<Element>) {
                            ^



❌  /Users/runner/Library/Developer/Xcode/DerivedData/smithy-swift-eqehdcxsyalqqmgtkhjdigcyxfcr/SourcePackages/checkouts/swift-collections/Sources/RopeModule/Rope/Basics/Rope+Builder.swift:230:64: cannot specialize protocol type 'Sequence'

    public mutating func insertBeforeTip(_ items: __owned some Sequence<Element>) {
                                                               ^



❌  /Users/runner/Library/Developer/Xcode/DerivedData/smithy-swift-eqehdcxsyalqqmgtkhjdigcyxfcr/SourcePackages/checkouts/swift-collections/Sources/RopeModule/Rope/Basics/Rope+Builder.swift:24:17: for-in loop requires 'some Sequence<Element>' to conform to 'Sequence'

    for item in items {
                ^~~~~



❌  /Users/runner/Library/Developer/Xcode/DerivedData/smithy-swift-eqehdcxsyalqqmgtkhjdigcyxfcr/SourcePackages/checkouts/swift-collections/Sources/RopeModule/Rope/Basics/Rope+Builder.swift:234:21: for-in loop requires 'some Sequence<Element>' to conform to 'Sequence'

        for item in items {
                    ^~~~~



❌  /Users/runner/Library/Developer/Xcode/DerivedData/smithy-swift-eqehdcxsyalqqmgtkhjdigcyxfcr/SourcePackages/checkouts/swift-collections/Sources/RopeModule/Rope/Operations/Rope+RemoveSubrange.swift:[32](https://github.com/smithy-lang/smithy-swift/actions/runs/7832430857/job/21371108130?pr=660#step:11:33):[36](https://github.com/smithy-lang/smithy-swift/actions/runs/7832430857/job/21371108130?pr=660#step:11:37): cannot specialize protocol type 'Sequence'

    with newElements: __owned some Sequence<Element>
                                   ^

A link to an example failed compile on Github CI: https://github.com/smithy-lang/smithy-swift/actions/runs/7832430857/job/21371108130?pr=660

Information

  • Package version: swift-collections 1.1.0
  • Platform version: macOS 12.7.3 (specifically, this happened on Github CI runner macos-12, version 2.312.0)
  • Swift version: Error occurred while building with xcodebuild for -destination 'platform=OS X'.
Xcode 14.0.1
Build version 14A400

Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
Target: x86_64-apple-macosx12.0

Checklist

  • [x] If possible, I've reproduced the issue using the main branch of this package.
  • [x] I've searched for existing GitHub issues.

Steps to Reproduce

Compile swift-collections on the macOS, Xcode, and destination described above.

Expected behavior

Compile should succeed.

Actual behavior

Compile fails with the error messages above.

jbelkins avatar Feb 08 '24 16:02 jbelkins

Xcode 14.0.1
Build version 14A400

Apple Swift version 5.7 (swiftlang-5.7.0.127.4 clang-1400.0.29.50)
Target: x86_64-apple-macosx12.0

https://github.com/apple/swift-collections?tab=readme-ov-file#project-status

It looks like the swift-collections 1.1.x package requires Swift 5.7.2 and Xcode 14.2.

vanvoorden avatar Feb 08 '24 18:02 vanvoorden

It looks like the swift-collections 1.1.x package requires Swift 5.7.2 and Xcode 14.2.

Surprising that a breaking change like dropping toolchain version(s) would be made in a minor version bump. In any case, if this was intentional and my use of an unsupported Swift version was the cause of the failure, the maintainers may close this issue.

jbelkins avatar Feb 08 '24 19:02 jbelkins

Testing every minor release ever shipped for a major Swift release (such as 5.7) would be prohibitively expensive, so we only ran prerelease tests on the latest point releases (in this case, 5.7.2 on Apple platforms and 5.7.3 on Linux). Point releases contain critical bug fixes, so my general expectation is that upgrading to them would be much easier (i.e., a much easier sell) than upgrading to a new major Swift release.

However, I did not expect that primary associated types only became usable in 5.7.1+ -- that is an unpleasant surprise. This is quite a pickle, especially as the SwiftPM manifest header does not allow packages to require specific point releases.

I'm tempted to ask you to upgrade to 5.7.2 if possible. If this problem turns out to affect many clients, then plan B would be to immediately bump the requirement to 5.8 in a new tag and to roll back the 1.1.0 tag.

(We could technically also roll back the introduction of the some Sequence<Foo> syntax, but it's not a trivial change, and given the option, I overwhelmingly prefer to move forward, not back.)

lorentey avatar Feb 08 '24 22:02 lorentey

the SwiftPM manifest header does not allow packages to require specific point releases

https://developer.apple.com/documentation/PackageDescription/Package#overview

@lorentey Hmm… this documentation has an example of requiring a point release (swift-tools-version:3.0.2)… is that not going to help us here?

vanvoorden avatar Feb 08 '24 23:02 vanvoorden

Unfortunately, that doesn't seem to work. 😞

lorentey avatar Feb 08 '24 23:02 lorentey

https://github.com/apple/swift-package-manager/blob/main/Sources/Commands/PackageTools/ToolsVersionCommand.swift#L72-L80

https://github.com/apple/swift-package-manager/blob/main/Sources/PackageModel/ToolsVersion.swift#L78-L81

https://github.com/apple/swift-package-manager/blob/main/Sources/Workspace/InitPackage.swift#L422-L425

https://github.com/apple/swift-package-manager/blob/main/Tests/WorkspaceTests/ToolsVersionSpecificationRewriterTests.swift#L167-L171

@lorentey Hmm… are we running into one of these code paths that is zeroing the patch version?

vanvoorden avatar Feb 09 '24 18:02 vanvoorden

Perhaps! The quick smoke test I ran was this:

$ head -1 Package.swift
// swift-tools-version:5.9.2
$ xcrun swift --version
swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0
$ xcrun swift build
error: 'swift-collections': package 'swift-collections' is using Swift tools version 5.9.2 but the installed version is 5.9.0
error: ExitCode(rawValue: 1)
[0/1] Planning build
error: 'swift-collections': package 'swift-collections' is using Swift tools version 5.9.2 but the installed version is 5.9.0

Looking closer, this may be because what SwiftPM believes to be its version number does not match the toolchain's version:

$ xcrun swift package --version
Swift Package Manager - Swift 5.9.0

In Swift 5.7.2, SwiftPM reports itself as "5.7.1" (🤨), so perhaps setting the package manifest to that would have been a workable option. (The 1.1.0 tag is out, so if we want this adjusted, then that would need to be done in a new tag, with 1.1.0 removed altogether. At this moment, I don't know if doing that would be worth the disruption of a disappearing tag.)

lorentey avatar Feb 09 '24 21:02 lorentey

I'm facing this same issue on monterey, have you figured out any solution yet?

repoluhun avatar Feb 17 '24 09:02 repoluhun

The solution is to upgrade to Xcode 14.2 with Swift 5.7.2. Do you have a reason for not doing that?

lorentey avatar Feb 19 '24 01:02 lorentey

My MacBook doesn’t support any higher Xcode versions On 2024. Feb 19., Mon at 2:00, Karoy Lorentey @.***> wrote:

The solution is to upgrade to Xcode 14.2 with Swift 5.7.2. Do you have a reason for not doing that?

— Reply to this email directly, view it on GitHub https://github.com/apple/swift-collections/issues/359#issuecomment-1951523877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMP2BFXAEKNYWD6IRA3WSY3YUKP25AVCNFSM6AAAAABDACUY2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJRGUZDGOBXG4 . You are receiving this because you commented.Message ID: @.***>

repoluhun avatar Feb 19 '24 05:02 repoluhun

Xcode 14.2 requires macOS 12.5, just like Xcode 14.0.

lorentey avatar Feb 20 '24 22:02 lorentey