Description
As discussed in:
- Remove remaining ILLinkTrim.xml from libraries #35199 (comment)
- Run illink task with at the end of build #31712 (comment)
We are currently "rooting" types in the libraries specifically for COM:
runtime/src/libraries/Microsoft.CSharp/src/ILLinkTrim.xml
Lines 7 to 8 in 0955d7f
A lot of scenarios in .NET don't have COM support, as such we should be able to trim out any COM specific code when we are linking for a scenario that won't ever need COM (Blazor, Xamarin, Linux, etc).
One way of doing this would be to add a new feature switch to the product that would enable/disable COM. We can then add the switch in code to remove any COM specific code. In order to remove the COM types from being rooted by the ILLinkTrim.xml
"descriptor XML files" above, we would need the ILLinker to allow "feature switches" to be present in the descriptor XML files, and to include/exclude that root based on the feature switch.
Note that Blazor today is already using something similar when it uses monolinker.exe
- --exclude-feature com
. See the Blazor build code. However, --exclude-feature
is not supported by the ILLinker, only by monolinker.exe
.