Remove --skip-unresolved from illink#91007
Conversation
|
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas Issue DetailsAfter the discussion around #90261 and #90469, I wanted to see if we could get rid of When cecil needs to resolve an assembly as part of member resolution, it defers to our AssemblyResolver by calling With these changes, a few testcases that were intentionally written to test the behavior of missing references started failing, so I've changed the expected behavior for those.
|
|
Historically, I've been in favor of error on unresolved. While syncing up with upstream recently and having to revisit a lot of our resolving code I'm less certain of that view. I'll brain dump some thoughts. Unity - Mono vs IL2CPP player buildsAny behavior difference between Mono and IL2CPP is prone to being labeled an "IL2CPP issue" or a "Code stripping issue". Sometimes they are. Other times it's actually a horrible set of assemblies UnityLinker & IL2CPP have been given and types and methods are missing. A user doesn't realize there is an issue with the assemblies because the code paths with missing types or methods are never called and so there is never an error during mono player builds. In many cases, using skip-unresolved=true allows a trimmed assembly to have the same build & runtime experience as a non-trimmed assembly. That is appealing. Unity - Unresolved strubbingHistorically, in UnityLinker we hooked into the This scheme was unsustainable. It many cases you can't correctly recreate missing things. We won't be doing this going forward with CoreCLR bcl. However, IL2CPP cannot handle missing types and method today. Using We've never used --skip-unresolved=falseUsing UnityLinker & CoreCLR bclWhen I landed our |
|
I think my feeling is that if Microsoft wants to make illink fail on unresolved members, that would make life easier for us and our users in the long run. I am nervous that the transition to get the Unity ecosystem aligned with erroring on unresolved members could be painful. Given the unknowns, it may be wise to switch over to That's my 2 cents. |
|
Thanks for your thoughtful comments @mrvoorhe. @vitek-karas and I discussed it, and we shared your concern about the risk of this change, since we don't know which code might be depending on the The potential benefit of being stricter is that it could turn some runtime exceptions into build-time warnings/errors if you're trimming. But our philosophy behind trimming is that it should aim to warn about differences in behavior introduced by trimming, so producing these warnings isn't necessarily desirable for us.
Could you clarify what the default was prior to your net7 sync? I wasn't sure because these two statements seemed contradictory - maybe there's a nuance I am missing. |
Yes, let me try again. It's hard to follow. The situation today (Unity 2023.2) and all previous versions of Unity was:
Essentially, Unity to-date has not treated resolution failures as build errors. Now, a quick pause for context. With the sync up with illink, we removed our unresolved stubbing logic. There were a number of reasons.
The situation going forward with CoreCLR is (currently):
We are treading into new territory with the behavior during IL2CPP Player Builds. I don't know how it will go. I'm also not sure if having CoreCLR Player build behave differently is going to do be the best. We may end up adjusting the behavior before release. @sbomer Does that make more sense? |
|
Thanks a lot, that clarifies it. Those defaults make sense to me. I'll be curious to see how the I'm going to close this PR since I don't think we have a good reason to change the behavior at the moment. |
|
@sbomer I'll keep you posted on how it goes. I was thinking of special casing the two missing assemblies that the mscorlib shim references. I forget how, but I was ultimately able to get our linker tests green without having to resort to that. Those two assemblies may not be enough. I may have to do what you suggest and treat missing references in forwarders specially. We'll see what happens. |
After the discussion around #90261 and #90469, I wanted to see if we could get rid of
--skip-unresolvedentirely by making theResolvebehavior always strict (error on resolution failure), and replacing just the callsites where we need to be resilient to failures (mainly when encountering type forwarders to assemblies that aren't present). I'm not sure yet if this is a good idea, so I'm curious what you think of the approach @vitek-karas @mrvoorhe.When cecil needs to resolve an assembly as part of member resolution, it defers to our AssemblyResolver by calling
Resolvedirectly. This change adds extension methods for exported types (unfortunately requiring some code to be duplicated from cecil) that allows resolving them with a call to a differentResolveoverload that doesn't error on resolution failures.With these changes, a few testcases that were intentionally written to test the behavior of missing references started failing, so I've changed the expected behavior for those.