-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ILLink should keep parameter names for methods which are used to create a delagate #85831
Conversation
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas Issue DetailsThis is a fix for dotnet/linker#3061. If the app creates a delegate over a method and later on access the NativeAOT already handles this correctly, but ILLink doesn't and will trim the parameter names away. The correct behavior is to treat such method as reflection accessible (we really don't want to mark the The ideal way to implement this is to perform full data flow on method addresses, which would allow us to detect which method is the delegate created for. (this is what NativeAOT ends up doing through JIT) But that is rather complex, an easier solution is to treat any method which address is accessed as reflection enabled. This covers all delegates. It might mark more methods as reflection enabled, but it's very uncommon. So this change does that, it will mark all methods accessed via This requires lot more test changes to enable sane testing:
|
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
Outdated
Show resolved
Hide resolved
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
Show resolved
Hide resolved
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
Outdated
Show resolved
Hide resolved
|
||
#if false |
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.
What's the reason for disabling the custom attribute check? Might be worth a comment here.
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.
VerifyCustomAttributes
has not been ported to NativeAOT yet, so it doesn't work. There's lot of code in this file which is not even ifdefed out, but never called, so you can see some possible callsites for this method, but none are actually active.
There's LOT of things to do to get even close to the ILLink functionality in this area. And lot of things are either not possible, or unreasonably hard because NativeAOT doesn't store the information, or the way it's stored is very different and complex.
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.
LGTM, thanks!
This is a fix for dotnet/linker#3061.
If the app creates a delegate over a method and later on access the
Delegate.Method
property it can get aMethodInfo
which it can use to inspect some aspects of the method, specifically parameter names.NativeAOT already handles this correctly, but ILLink doesn't and will trim the parameter names away. The correct behavior is to treat such method as reflection accessible (we really don't want to mark the
Delegate.Method
property as trim incompatible).The ideal way to implement this is to perform full data flow on method addresses, which would allow us to detect which method is the delegate created for. (this is what NativeAOT ends up doing through JIT)
But that is rather complex, an easier solution is to treat any method which address is accessed as reflection enabled. This covers all delegates. It might mark more methods as reflection enabled, but it's very uncommon.
So this change does that, it will mark all methods accessed via
ldftn
(or similar) as reflection enabled.Additionally this cleans up marking of reflection enabled members in the MarkStep. Specifically there was a distinction between reflection accessed and indirect accessed methods, but the latter only kicked in for the obsolete preserve attributes. It's better to reflection mark those as well. This might cause a small size regression, but it's very unlikely to be even observable.
This requires lot more test changes to enable sane testing:
Kept
attribute validationKept
attribute (as that's not always possible)