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

Add Musl import, error if unrecognised platform #325

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

adam-fowler
Copy link
Contributor

Add support for Musl
Also error if platform is not recognised.

@adam-fowler adam-fowler requested a review from FranzBusch August 5, 2024 17:20
@adam-fowler
Copy link
Contributor Author

@finagolfin you may be interested in this.

@finagolfin
Copy link
Contributor

Thanks for the head's up, but I don't actually use Musl. I've just been tinkering with it because I want to release a similar SDK bundle for Android.

I will need to submit a similar pull soon to this repo for Bionic though, as I have a local patch for that currently.

@adam-fowler
Copy link
Contributor Author

It was more about the package not compiling for Android anymore when it did before.

@finagolfin
Copy link
Contributor

It was more about the package not compiling for Android anymore when it did before.

OK, this package should cross-compile fine for Android with the current 5.10 release, but the upcoming 6.0 release uses a new Android overlay, that this package has not been ported to yet.

I have the trivial patch needed for that available locally on my Android phone, just need to clean it up and submit it.

@adam-fowler
Copy link
Contributor Author

OK, this package should cross-compile fine for Android with the current 5.10 release

Ah that was the problem I found with Musl. It compiled fine, but the actual code caused crashes given the lock primitive defaulted to Int if the platform was unrecognised.

@FranzBusch
Copy link
Member

@swift-ci please test

@FranzBusch FranzBusch merged commit e83857c into apple:main Aug 6, 2024
2 checks passed
typealias Primitive = pthread_mutex_t
#elseif canImport(WinSDK)
typealias Primitive = SRWLOCK
#else
typealias Primitive = Int
#error("Unsupported platform")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From gitblame it seem like this was added for web assembly:
https://github.com/apple/swift-async-algorithms/pull/273/files
Which seems that this can be checked for with arch(wasm32) or os(WASI)
There is also an underscore check for multithreading: #if _runtime(_multithreaded)
This was added in swiftlang/swift#72649

swift-testing uses a combination of os(WASI) and _runtime(_multithreaded) combined with compiler(>=6.1)
https://github.com/swiftlang/swift-testing/pull/322/files

FWIW Mutex has just landed in Swift 6.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @0xpablo

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

Successfully merging this pull request may close these issues.

4 participants