-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Enable dynamic replacement with library evolution #30965
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
Enable dynamic replacement with library evolution #30965
Conversation
@@ -629,6 +629,8 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const { | |||
return SILLinkage::Private; | |||
|
|||
case Kind::DynamicallyReplaceableFunctionKey: | |||
return getSILFunction()->getLinkage(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aschwaighofer This was the only actual change I had to make. Are you aware of anything that I might have missed?
@swift-ci Please test |
The way we choose which accessors get marked dynamically replaceable is not right. JohnM and Jrose explained to me that we should use the opaque accessors instead of whatever I choose to replace. |
@aschwaighofer Do you have an example that we miscompile today? @rjmccall Do you remember what the issue was? |
I don't have an example. But the accessors that are printed in the swiftinterface file need to be the ones that are marked dynamic, I think. |
Build failed |
Here is the comment from the commit 1980c4a that disabled dynamic in library evolution mode:
|
I am not sure that we actually print all opaque accessors in the swift interface file. |
@aschwaighofer I don't understand why, though. There's no resilience boundary between the instrumented library and the dynamic replacement stub. |
It looks like the only thing that fails is the linkage computation for the dynamic replacement key of class methods. Even though methods have hidden linkage to prevent them from being directly referenced from outside a resilient module, we need to ensure the dynamic replacement key is visible. Fixes <rdar://problem/58457716>.
c0ad045
to
23cac67
Compare
@swift-ci Please smoke test |
I'm going to merge this PR since it fixes the class method linkage issue. I'll keep poking at the accessor thing to try to come up with an example where the current scheme fails. |
This might be the case how it is being used today. But dynamic is a language feature like any other. So a resilient dynamic foo should be resilient? It should be possible to resiliently replace it. If we ship the compiler with 'invalid' interface files we can't rely on them without some sort of versioning in the future (or so was the argument brought up in the radar). I am not 100% sure anymore but the example above I think also is a distillation of a problem I ran into at some point. The mismatch was causing a problem somehow: I can see this causing problems when the compilation of the replacement would use the .swiftinterface file. It would try to replace the wrong entry points. |
It might be worth running the resilience tests with -enable-implicit-dynamic enabled and to see that does not cause issues. I ran the all tests like this at one point (hack the compiler to have enable-implicit-dynamic enabled is probably the easiest way to do this). |
This might no longer reproduce today because this could have only reproduced when we were (erroneously) preferring .swiftinterface over .swiftmodule files? |
@slavapestov - this seems to have caused a regression: https://ci-external.swift.org/job/swift-PR-windows/1596/consoleText |
swiftlang#30965 broke the Windows test suite, this speculatively fixes it.
test: speculative fix after #30965
Fixes rdar://problem/58457716.