Repository navigation
Fix the build without the ExperimentalIO trait - #103
Merged
FranzBusch merged 1 commit intoNov 12, 2026
Merged
Conversation
`PThreadTaskExecutor.current()` reads `PThread.currentExecutor`, which exists only with the `ExperimentalIO` trait, so the package failed to build with its default traits. Every caller of `current()` is in the `ExperimentalIO`-only operation extensions, so gate it the same way as `PThread.currentExecutor`.
FranzBusch
approved these changes
Nov 12, 2026
FranzBusch
pushed a commit
that referenced
this pull request
Nov 12, 2026
On musl, such as with the Static Linux SDK, and on Android, the package fails to build with its default traits: ``` Sources/PlatformExecutors/PThread/Internal/IO/PlatformIOBackend.swift:15:8: error: Unsupported platform ``` 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 for `Musl` as well, the same way most of the package already handles both C libraries, and gives `SystemCoreCount`'s Musl import the `@unsafe` its 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: - imports the `Android` module wherever `Glibc` and `Musl` are imported outside the `ExperimentalIO` code, and selects the epoll backend and the pthread `PlatformExecutorFactory` for Android; - marks creating a `pthread_attr_t` `unsafe` on Android, since Bionic's holds a pointer; - coerces the thread function to whichever `pthread_create` start-routine signature the NDK declares (NDK 28 made it nullable), the way swift-nio's `ThreadPosix.swift` does; - adds the headers the C shim's Android `pthread_getname_np` emulation 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 `main` does not currently build without `ExperimentalIO`: - Static Linux SDK (aarch64-swift-linux-musl): the package builds with its default traits, and a static executable with `typealias DefaultExecutorFactory = PlatformExecutorFactory` gets `PThreadTaskExecutor` as its global executor, sized to the cgroup's CPU limit. - Android SDK (aarch64-unknown-linux-android28, x86_64-unknown-linux-android28, NDK 30): the package builds with its default traits. I have not run it on a device. - glibc (Linux, aarch64): unchanged; builds and runs as before. I don't have the toolchain the `ExperimentalIO` trait needs, so the `ExperimentalIO` paths in the changed files are not covered on musl or Android.
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.
Since #91, the package no longer builds with its default traits on Linux.
PThreadTaskExecutor.current()readsPThread.currentExecutor, whichPThread.swiftdeclares only under#if ExperimentalIO && !os(WASI), whilecurrent()itself is not gated:Every caller of
current()is in theExperimentalIO-onlyPThreadTaskExecutor+*Operations.swiftfiles, so this gates it the same way asPThread.currentExecutor.CI didn't catch this because both Linux jobs build with
--traits ExperimentalIOor--traits ExperimentalIOUring. A job that builds with the default traits would keep this configuration from regressing.Tested on Linux (Swift 6.4, aarch64):
swift buildwith no traits succeeds, and an executable withtypealias DefaultExecutorFactory = PlatformExecutorFactorygetsPThreadTaskExecutoras its global executor, sized to the cgroup's CPU limit.