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

Initial ILLink support #4707

Closed
radekdoulik opened this issue May 21, 2020 · 2 comments
Closed

Initial ILLink support #4707

radekdoulik opened this issue May 21, 2020 · 2 comments
Assignees

Comments

@radekdoulik
Copy link
Member

Make the assembly for custom steps. Enable the ILLink for Release builds.

@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

@radekdoulik can we close this, it seems like we got this in #4669.

@radekdoulik
Copy link
Member Author

@jonathanpeppers we can, indeed :-)

@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

3 participants