Bug 11165 - Linker does not remove unused type forwarders
Summary: Linker does not remove unused type forwarders
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 6.3.x
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Sebastien Pouliot
Depends on:
Reported: 2013-03-14 14:07 UTC by Marek Safar
Modified: 2017-01-31 21:23 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Marek Safar 2013-03-14 14:07:43 UTC

Comment 1 Sebastien Pouliot 2013-03-14 14:28:30 UTC
Did bugzilla eat your description ? it happened to me (and at least someone else) a few times :-(

Got a test case that shows this ?
Comment 2 Marek Safar 2013-03-14 14:34:35 UTC
1. Build hello world app
2. Check System.Core type forwarders

There are 3 in my case and they are clearly never used (all code is compiled from sources).
Comment 3 Sebastien Pouliot 2013-03-15 13:41:01 UTC
That's weird - I added code to remove them last week (or the one before) and I do not see them when I run mtouch with the debugger (but they are present when building normally).
Comment 4 Sebastien Pouliot 2013-03-15 14:08:49 UTC
nm, that was an old binary (with more than 3).

The three left overs (ExtensionAttribute, Action and Func) exists because the types are marked. 

Removing them is not impossible but needs additional data (can't use the marking). We'll need to create test cases that needs some of the forwarder to make sure we don't break them.
Comment 5 Marek Safar 2013-03-15 14:11:22 UTC
What is marked are real type ExtensionAttribute, Action and Func not their forwarders.

E.g. corlib::System.Action is used not System.Core::System.Action
Comment 6 Sebastien Pouliot 2013-03-15 14:40:42 UTC
Yup, but the linker does not have the data to know if the forwarders were used. 

If some (linked or not) code has references to System.Core::* then the forwarder will be needed (at AOT time) to build the application. So we need to get the data first then apply it (and can't safely remove them before).

Removing those 3 type forwarders saves very few bytes (not enough to make System.Core change file size). PCL support will likely make this more useful (and also provide the test cases).
Comment 7 Marek Safar 2013-03-15 14:45:27 UTC
Creating test case is trivial, if you need one I can cook it
Comment 8 Sebastien Pouliot 2013-03-15 14:48:43 UTC
many things are trivial - if you think it's the best use of your time please go ahead!
Comment 10 PJ 2013-11-19 16:44:56 UTC
This bug was targeted for a past milestone, moving to the next non-hotfix active milestone.
Comment 11 GouriKumari 2016-01-11 16:37:33 UTC
This is an enhancement and changing the milestone to  far future.
Comment 12 Sebastien Pouliot 2017-01-31 21:23:09 UTC
forwarders are now gone - everything gets resolved and they are not needed for fullAOT

cycle9 https://github.com/xamarin/xamarin-macios/pull/1589
master https://github.com/xamarin/xamarin-macios/pull/1600