-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix NSLock
/Thread
subclassing issues
#5122
base: main
Are you sure you want to change the base?
Conversation
@swift-ci test |
Using a toolchain built with this change, it seems that this resolves the issue for
|
Gently bumping this, as it's still affecting the latest nightly toolchains. |
Hey, unfortunately I've yet to find a great solution to this so far. I've tried various approaches to convince the compiler that |
Currently,
NSLock
/Thread
cannot be subclassed due to the following (or related) issues:This is because
NSLock
/Thread
have members whose types come frompthread.h
.CoreFoundation
currently importspthread.h
in its public headers, and this led the compiler to believe thatpthread.h
came from theCoreFoundation
module and not theSwiftGlibc
clang module. This results in a failure because due to the@_implementationOnly
import,CoreFoundation
is not loaded by clients.To resolve this, we need to ensure the compiler realizes that
pthread.h
and the types within come from theSwiftGlibc
clang module rather thanCoreFoundation
. To do this, we import theSwiftGlibc.h
header file (from theSwiftGlibc
clang module) before importingpthread.h
. However,SwiftGlibc.h
is not in the default header search paths so we need CMake to lookup the path forSwiftGlibc.h
(by asking the compiler) and add the search path when building CoreFoundation. We don't need to do this for the SwiftPM build since it seems that the modules are resolved differently and we do not have this issue (which is also why we can't add a unit test for this).Resolves #5108, rdar://137716518