Repository navigation
Support musl and Android in the pthread executors - #104
Merged
FranzBusch merged 3 commits intoNov 12, 2026
Merged
Conversation
The epoll I/O backend and its eventfd and timerfd wrappers were selected only for Glibc, so on musl, such as the Static Linux SDK, the build failed with "Unsupported platform". Select them for Musl as well, and mark SystemCoreCount's Musl import @unsafe like its Glibc import, which strict memory safety otherwise rejects.
The pthread executors are compiled for Android, but no C library is imported there, so the build fails with "unable to identify your C library". Import the Android module wherever Glibc and Musl are imported outside the ExperimentalIO code, and select the epoll backend and the pthread executor factory for it. Bionic's declarations also need adjusting: its pthread_attr_t holds a pointer, so creating one is unsafe, and NDK 28 made pthread_create's start routine nullable, so coerce the thread function to whichever signature the NDK declares, as swift-nio does. The C shim's pthread_getname_np emulation for Android was missing the headers it uses.
FranzBusch
requested changes
Nov 12, 2026
FranzBusch
left a comment
Member
There was a problem hiding this comment.
We should also enable the CI to validate this
FranzBusch
approved these changes
Nov 12, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On musl, such as with the Static Linux SDK, and on Android, the package fails to build with its default traits:
On Android the C shim and the C library imports fail before that.
musl. The epoll I/O backend, and the eventfd and timerfd wrappers it uses, are selected with
canImport(Glibc)alone, so on musl no backend is available. The first commit selects them forMuslas well, the same way most of the package already handles both C libraries, and givesSystemCoreCount's Musl import the@unsafeits Glibc import already has, which strict memory safety otherwise rejects.Android. The pthread executors are compiled for Android, but no C library is imported there. The second commit:
Androidmodule whereverGlibcandMuslare imported outside theExperimentalIOcode, and selects the epoll backend and the pthreadPlatformExecutorFactoryfor Android;pthread_attr_tunsafeon Android, since Bionic's holds a pointer;pthread_createstart-routine signature the NDK declares (NDK 28 made it nullable), the way swift-nio'sThreadPosix.swiftdoes;pthread_getname_npemulation uses.The io_uring backend stays Glibc-only, and the
ExperimentalIO-only files are unchanged.Tested with the Swift 6.4.2 SDKs, together with #103, since
maindoes not currently build withoutExperimentalIO:typealias DefaultExecutorFactory = PlatformExecutorFactorygetsPThreadTaskExecutoras its global executor, sized to the cgroup's CPU limit.I don't have the toolchain the
ExperimentalIOtrait needs, so theExperimentalIOpaths in the changed files are not covered on musl or Android.