From 7bf6e37fc44595f9015bb08a6bac18abb987cbbd Mon Sep 17 00:00:00 2001 From: "Aryan Singh K." <70511529+aryansk@users.noreply.github.com> Date: Tue, 11 Aug 2026 15:03:44 +0530 Subject: [PATCH] fix(wasi): use mock TLS for all non-threaded WASI targets 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 #370 --- Sources/System/Internals/Exports.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/System/Internals/Exports.swift b/Sources/System/Internals/Exports.swift index 088a3251..6ce7d4dc 100644 --- a/Sources/System/Internals/Exports.swift +++ b/Sources/System/Internals/Exports.swift @@ -184,7 +184,7 @@ extension String { // TLS #if os(Windows) internal typealias _PlatformTLSKey = DWORD -#elseif os(WASI) && (swift(<6.1) || !_runtime(_multithreaded)) +#elseif os(WASI) && !_runtime(_multithreaded) // Mock TLS storage for single-threaded WASI. // Carries no state of its own, and only used to index `sharedTLSStorage`. internal final class _PlatformTLSKey: @unchecked Sendable { @@ -214,7 +214,7 @@ internal func makeTLSKey() -> _PlatformTLSKey { fatalError("Unable to create key") } return raw - #elseif os(WASI) && (swift(<6.1) || !_runtime(_multithreaded)) + #elseif os(WASI) && !_runtime(_multithreaded) return _PlatformTLSKey() #else var raw = pthread_key_t()