-
Notifications
You must be signed in to change notification settings - Fork 127
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
Unable to resolve some types from System.Runtime.dll in custom linker step #2267
Comments
Looks like there's a file in my repro that still points into paths on my local system; this version hopefully works better: |
IL Linker will strip away unused forwarders. Did marking step see the bindings-test.dll, or was that added after sweep was done? If it's the latter, it's kind of expected. Adding assemblies (either in custom steps or at runtime with APIs like Assembly.LoadFrom) will not work great. |
The marking step saw bindings-test.dll. No assemblies were added after the linker started executing, either in a custom step or with Assembly.LoadFrom. This is a snippet from interdependent-binding-projects.dll (the executable assembly):
The log shows this at some point:
I'm not sure what's being skipped here. The final action seems to be Save:
The default action is copy, this is what we pass to the linker (the bindings-test.dll assembly does not have any assembly-level linker attributes saying it's linkable):
|
@sbomer assigning to you... since it needs a mac. |
This has to do with how Cecil represents references to built-in types. When the linker is marking the field type of Usually for But this check doesn't cover typereferences which don't exist in metadata (like those constructed for built-in types), so the forwarder in I can see a few ways to fix it:
Based on recent conversation with @vitek-karas I think type references encoded as custom attribute arguments will have a similar problem (I think the target needs to be marked). |
@rolfbjarne Any idea why this just started failing now? Trying to gauge the need to have this in 6.0 |
@agocke It was tracked in the issues for quite a while as failed builds so it was likely always happening after the .NET 6 shift. It took time to track down the root cause though. |
Is this a common scenario? |
Now, I cannot answer that so hopefully @rolfbjarne will chime in. On the Xamarin tracking issue it's listed as P1, or "something we can't go to stable with". The original issue was tracked as xamarin/xamarin-macios#12275, which split off from on-device tests. |
It's been failing for a while, I just hadn't had time to track it down to a linker issue (my first guess before starting to investigate was that it was a problem with the test in question, so the priority wasn't as high as it should have been).
It only happens in one out of quite a few tests we have. It's a small test project, which makes sense from the investigation here - from the description it's probably more likely to run into this with a small project than a big project (because a big project is more likely to use all the intrinsic types and preserve the corresponding type forwarders). I'm unsure how common it would be in the real world; after all most projects start out small, and it wouldn't be good if a lot of people ran into this after writing a little bit of code. |
That's good enough -- unless it's a known corner case I'm comfortable taking it through, assuming we can get a fix ready relatively soon |
Fixed in #2276 |
Repro:
removedtypeforwarder-7b80c56.zip
Download & extract && run
./test.sh
(I'm using .NET 6.0.100-rc.2.21420.30, if you have a different version, you'll probably have to update a few paths at the top of the script to find illink.dll).Full output: https://gist.github.com/rolfbjarne/53ced784587bc75b25bba67ece307891
This is what happens:
We have a custom linker step that runs at the end of the linker process (after the linked output has been saved), and looks at certain types. When it fails, it's looking at the
Bindings.Test.Sf
struct in the bindings-test.dll. This is a struct with a single float:The error occurs because the field's type can't be resolved here:
https://github.com/xamarin/xamarin-macios/blob/8dc41314ed3c5f90376d87c760a697bf942d0589/tools/common/StaticRegistrar.cs#L2318-L2320
I've added the following debug spew locally: https://gist.github.com/rolfbjarne/034debd1d54c5273e22ac47f44405cfa, and this is printed earlier (you can also see this output in the full log output from above):
The interesting part is that fields of other types are resolved just fine:
The difference seems to be that the linked version of System.Runtime doesn't have a type forwarder for System.Single:
while it does for System.Int32:
It seems the version of bindings-test.dll that's in memory has references to type forwarders in System.Runtime.dll that have been removed.
The text was updated successfully, but these errors were encountered: