fix(wasi): use mock TLS for all non-threaded WASI targets - #378
Draft
aryansk wants to merge 2 commits into
Draft
Conversation
The gate os(WASI) && (swift(<6.1) || !_runtime) incorrectly falls through to pthread APIs on Swift 6.1+ non-threaded WASI, where pthread_* is not in scope. Guard solely on !_runtime. Fixes apple#370
Contributor
|
@aryansk Could you retarget this PR to the release/1.8.x branch? This is clearly a bug fix. |
Author
|
Done — I retargeted this PR to release/1.8.x; it remains Draft while the branch-specific checks run. |
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.
Summary
Gates mock TLS on WASI solely on
!_runtime(_multithreaded)rather thanswift(<6.1) || !_runtime. On Swift 6.1+ standard WASI toolchains the old gate falls into the#elsebranch, which assumes POSIXpthread_key_t/pthread_*. Standard WASI libc does not expose those symbols for the non-threaded target, producing scope-resolution failures:With the fix, non-threaded WASI always uses the mock
_PlatformTLSKey/dictionary store and pthread paths are reserved for threaded WASI, regardless of Swift version.Issue
Fixes #370 —
[WASI] Compilation failure on Swift 6.1+ due to missing pthread symbols.Validation
git diff --checkpassesExports.swift(typealias andmakeTLSKey)