-
Notifications
You must be signed in to change notification settings - Fork 516
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
[registrar] Fix registration of stub Objective-C classes. Fixes #21546. #21593
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build] Build failed 🔥Build failed for the job 'Build macOS tests' Pipeline on Agent |
7dba6e3
to
3ebd719
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3ebd719
to
597c77d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
10febf8
to
ec3143f
Compare
/azp run xamarin-macios-pr |
Azure Pipelines successfully started running 1 pipeline(s). |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
/azp run xamarin-macios-pr,xamarin-macios-pr-apidiff |
Azure Pipelines successfully started running 2 pipeline(s). |
✅ [CI Build] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ [CI Build] Build passed (Build packages) ✅Pipeline on Agent |
✅ [CI Build] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
✅ API diff for current PR / commit.NET (No breaking changes)✅ API diff vs stable.NET (No breaking changes)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
💻 [CI Build] Windows Integration Tests passed 💻✅ All Windows Integration Tests passed. Pipeline on Agent |
🔥 [CI Build] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 1 tests failed, 106 tests passed. Failures❌ generator tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Test failure is unrelated (#21864). |
Objective-C has a fairly new feature called stub (unrealized) classes, which don't exist until runtime. They were introduced to support Swift classes exposed to Objective-C, when the exact layout of the class isn't known at compile time, and the creation of the class itself is deferred until runtime.
An Objective-C class is marked as a stub class by adding the
objc_class_stub
attribute to the class definition:__attribute__((objc_class_stub) @interface ObjCStubClass : NSObject @end
Sidenote: the class will also have the
objc_subclassing_restricted
attribute, because Clang requires the latter when the former is present.When this attribute is present, Clang will generate code to load the class at runtime, instead of just fetching it, when doing
[ObjCStubClass class]
.Our immediate symptom of stub classes when using the static registrar is that the above would crash:
objc_class_stub
attribute to the generated Objective-C header (because we don't know that the class is a stub class).[ObjCStubClass class]
, because of the missing attribute.The first step in the fix is to add a new
IsStubClass
property to theRegister
attribute, so that we can let the registrars know about them.Then update the static registrar to add the
objc_class_stub
attribute to the generated Objective-C header.We also need a fix for the dynamic registrar, because we call the
objc_getClass ("ObjCStubClass")
there to get the Objective-C class, and that doesn't work unless the stub class has already been realized/used (objc_getClass
returns NULL). It turns out that computing the total number of Objective-C classes in the process will also realize all stub Objective-C classes, so that's what we do when we find a stub Objective-C class.References:
Fixes #21546.