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

Replace reflection usage when preparing linker pipeline #4709

Closed
radekdoulik opened this issue May 21, 2020 · 1 comment
Closed

Replace reflection usage when preparing linker pipeline #4709

radekdoulik opened this issue May 21, 2020 · 1 comment
Assignees
Milestone

Comments

@radekdoulik
Copy link
Member

Context: #4669

We are temporarily using reflection to modify pipeline in SetupStep. This should be replaced by using cmd line arguments (--custom-step) and relevant msbuild parts or by using Pipeline API.

It is not clear yet whether the Pipeline API would be public. I would like to wait before redoing the temporary solution until later when it will be more clear whether we might need pipeline steps removal/replacement or not.

@radekdoulik radekdoulik added this to the .net-5 milestone May 21, 2020
@radekdoulik radekdoulik self-assigned this May 21, 2020
radekdoulik added a commit that referenced this issue Jun 4, 2020
Implements #4707

With .NET5 we are switching from XA linker implemented as msbuild task to ILLink tool with [custom steps](https://github.com/mono/linker/blob/master/docs/custom-steps.md) provided in an assembly.

The new assembly with our custom steps is named `Microsoft.Android.Sdk.ILLink` and the source code is located in `src/Microsoft.Android.Sdk.ILLink`. It is used during build by `ILLink` tool.

The initial support is already able to link and run simple XA and XA/XF samples.

Future work
* replace reflection usage in SetupStep #4709
* audit reflection usage in our code #4708
* add more customs steps - we are still missing MonoDroidMarkStep

Notes
* the Profile API is not available in the linker [public API](https://github.com/mono/linker/tree/master/src/linker/ref). we work around it by adding `src/Microsoft.Android.Sdk.ILLink/Profile.cs` with missing pieces.
* `TypeDefinition.GetMethods` extension method from `Mono.Tuner.MethodBodyRocks` is not public. It is very simple so we are inlining it.
* the ILLink is now enabled in `Release` configuration defaults.
* tests were updated to reference more packages, to not miss second level dependencies.

Initial results:

apkdiff output summary for HelloAndroid sample, comparing `Debug` and `Release` apk's
```
  -       7,300 Davik executables -2.34% (of 311,436)
  -  14,733,944 Assemblies -31.85% (of 46,265,064)
  -   2,492,452 Shared libraries -11.43% (of 21,803,164)
  -  15,528,456 Package size difference -28.70% (of 54,114,462)
```

Context:
* `_RunILLink` target https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ILLink.targets
* linker documentation https://github.com/mono/linker/tree/master/docs

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: Jonathan Pryor <jonpryor@vt.edu>
@jonathanpeppers
Copy link
Member

I think this was fixed in: #5748

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants