apple / swift-service-context

Minimal type-safe context propagation container
https://github.com/apple/swift-distributed-tracing
Apache License 2.0
66 stars 22 forks source link

Compilation fails on Swift 5.5 [known issue until Xcode ships with macOS 12 SDK] #16

Closed pokryfka closed 3 years ago

pokryfka commented 3 years ago

Environment:

swift --version
swift-driver version: 1.26.9 Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)
Target: x86_64-apple-macosx11.0

Steps:

swift build

Result:

/xxx/swift-distributed-tracing-baggage/Sources/InstrumentationBaggage/Baggage.swift:232:5: error: unknown attribute 'TaskLocal'
    @TaskLocal public static var current: Baggage?
    ^
[2/2] Compiling InstrumentationBaggage BaggageKey.swift

Expected result:

Additional steps/requirements like extra compilation flags described in README.md and, if possible, included in the manifest file Package.swift.

ktoso commented 3 years ago

I'm assuming you got that Swift from the Xcode 12 RC -- it is known to not be working as it includes the "old" macOS 11 SDK which does not have concurrency in it.

Long story short: This is an issue with Xcode and the SDK it ships. It couldn't ship macOS 12 SDK since macOS 12 isn't "released" yet. There will be a new Xcode with the macOS 12 SDK at some point, ad that point it things will actually work as they should.

The workaround is: use Beta Xcode 12 builds. One could hack around with nightly snapshots but we don't recommend that.

More information here: https://github.com/swift-server/swift-service-lifecycle/issues/110#issuecomment-921356359

pokryfka commented 3 years ago

Its Swift 5.5 shipped with Xcode 13 installed via App Store.

Thank you for the link and explanation, much appreciated and helpful.

I dont want to install another Xcode which is super heavy but will try installing another Swift version and test compilation on Linux via Docker.

Looking forward to the Xcode with the macOS 12 SDK!

ktoso commented 3 years ago

Right that's (sadly) expected expected with that Xcode then. Too bad with the timing this year but that's how it ended up as.

Thanks for checking in! We're also looking forward to the Xcode with the newest SDK :)

pokryfka commented 3 years ago

I think this one can be closed, the package builds without problems using Xcode 13.1

ktoso commented 3 years ago

Thanks for the ping! Yep that's right.

Now we have the same adventures kind of with 5.6 needing projects 😆 😭 but thankfully not this one.