Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Linux) Build failure against 2024-09-25 nightly toolchain -- error: cannot inherit from class 'Thread' (compiled with Swift 6.1) because it has overridable members that could not be loaded in Swift 5.10 #615

Open
clackary opened this issue Oct 14, 2024 · 2 comments

Comments

@clackary
Copy link
Contributor

This one is another instance of a swiftlang compiler bug I've been running into for a while: swiftlang/swift-corelibs-foundation#5108

root@7481e59c0960:/project/opentelemetry-swift# /home/dev-toolchain/swift-DEVELOPMENT-SNAPSHOT-2024-09-25-a-ubuntu22.04-aarch64/usr/bin/swift build
...
/project/opentelemetry-swift/Sources/OpenTelemetrySdk/Logs/Processors/BatchLogRecordProcessor.swift:41:15: error: cannot inherit from class 'Thread' (compiled with Swift 6.1) because it has overridable members that could not be loaded in Swift 5.10
 39 | }
 40 | 
 41 | private class BatchWorker : Thread {
    |               `- error: cannot inherit from class 'Thread' (compiled with Swift 6.1) because it has overridable members that could not be loaded in Swift 5.10
 42 |   let logRecordExporter : LogRecordExporter
 43 |   let scheduleDelay : TimeInterval

From what I've seen in the other cases, it looks like would be feasible to workaround the issue by making a Thread property within BatchWorker, and then wrapping the start and cancel calls with matching BatchWorker funcs.

But the problem here is the override on Thread.main(). I don't think there's a way to do this without inheriting from Thread.

Configuration:
OS: Linux Ubuntu 22.04
Toolchain: swift-DEVELOPMENT-SNAPSHOT-2024-09-25-a-ubuntu22.04-aarch64

@ArielDemarco
Copy link
Contributor

Hey @clackary! You're right that it was introduced in that nightly build; and looking at the issue you created in swift-corelibs-foundation, it seems it's not expected (and thankfully, because it'd be quite problematic 😂). From what I see, they've opened a PR that theoretically solves the problem with both NSLock and Thread.
Maybe once that PR gets merged, it would be good to test and see if the problem disappears in the BatchWorker class

@dayaffe
Copy link

dayaffe commented Feb 20, 2025

+1 to fixing this issue as we are looking to use otel-swift on linux in aws-sdk-swift. Found this issue after running into the same error mentioned

nachoBonafonte pushed a commit that referenced this issue Feb 27, 2025
* Work around #615, and add support for building with the Static Linux SDK
* Factor out threading abstraction for BatchWorkers and use normal Thread subclass on Apple platforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants