Skip to content
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

ComActivator causes linker to include code which is not needed in most cases #43604

Closed
4 tasks
vitek-karas opened this issue Oct 19, 2020 · 5 comments
Closed
4 tasks
Assignees
Labels
area-Interop-coreclr size-reduction Issues impacting final app size primary for size sensitive workloads
Milestone

Comments

@vitek-karas
Copy link
Member

CoreCLR ComClassFactory::CreateInstanceFromClassFactory calls into managed Internal.Runtime.InteropServices.LicenseInteropProxy.Create (and some other methods as well). This dependency is hardcoded in the System.Private.CoreLib descriptor and so linker can't ever remove the LicenseInteropProxy.

This type brings in a lot of dependencies (ultimately even BinaryFormatter) which also have some trim analysis warnings.

This functionality should not be needed when COM support is turned off - see COM Feature switch.

Also - this functionality is probably only needed when managed COM activation is used by the project - that is, it can only ever be called if ComActivator was used.

Vast majority of .NET Core projects don't use ComActivator and thus including this code is unnecessary.

What to do about this:

  • Verify that the code in ComClassFactory::CreateInstanceFromClassFactory which calls into LicenseInteropProxy can only be used when ComActivator is also used. If this is not true, then more work is needed to determine what to do.
  • Instead of rooting the LicenseInteropProxy always, make it a dynamic dependency (via DynamicDependencyAttribute) of the ComActivator (the right method on it) and remove it from the CoreLib's ILLink descriptor.
  • Add a trimming test which validates that the LicenseInteropProxy is not present in a normal console hello world (even without any feature switches)
  • Make sure that the code is also hidden behind the COM feature switch (this might be a NOP since ComActivator should be hidden behind the feature switch, but maybe some small pieces will be left-over).
@vitek-karas vitek-karas added area-Interop-coreclr linkable-framework Issues associated with delivering a linker friendly framework labels Oct 19, 2020
@vitek-karas vitek-karas added this to the 6.0.0 milestone Oct 19, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Oct 19, 2020
@vitek-karas
Copy link
Member Author

Depending on the outcome of #36659 this might not be needed fully - we may just decide to simply remove the unconditional rooting of LicenseInteropProxy if COM Server scenarios will not be supported with trimming turned on.

@AaronRobinsonMSFT AaronRobinsonMSFT removed the untriaged New issue has not been triaged by the area owner label Oct 19, 2020
@marek-safar marek-safar added size-reduction Issues impacting final app size primary for size sensitive workloads and removed linkable-framework Issues associated with delivering a linker friendly framework labels Dec 9, 2020
@eerhardt
Copy link
Member

@LakshanF - is this something you've solved with your trimming work?

@elinor-fung
Copy link
Member

@LakshanF - is there still more to do here?

@LakshanF LakshanF self-assigned this Jul 9, 2021
@LakshanF
Copy link
Contributor

LakshanF commented Jul 9, 2021

I'll double check

@LakshanF
Copy link
Contributor

Closing this now with the following validation,

  • With PR Root ComActivator for hosting #54524, BuiltInComInteropSupport is used to control the 3 host APIs. Specifically, when this property is false (default behavior);
    • The helper class, LicenseInteropProxy, is not present
    • The 3 methods in ComActivator as needed by COM Server host is there in a skeleton mode (as in will throw if called from native side to indicate built-in COM support is disabled)
  • Ran the COM Server Demo sample under Net6.0 to confirm that it fails when trimmed in the default mode and passes in trimmed mode when BuiltInComInteropSupport is set to true

@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Interop-coreclr size-reduction Issues impacting final app size primary for size sensitive workloads
Projects
None yet
Development

No branches or pull requests

7 participants