-
Notifications
You must be signed in to change notification settings - Fork 537
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 NET5/ILLink support #4669
Conversation
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.props
Outdated
Show resolved
Hide resolved
...marin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Linker.targets
Outdated
Show resolved
Hide resolved
src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/FixAbstractMethodsStep.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like some of the tests on CI are hitting:
Unrecognized command-line option: '--custom-data'
Do you know what .NET 5 version we need for this to work?
We can bump this number: https://github.com/xamarin/xamarin-android/blob/3f438e46d7b166a3a3ef54c9ffafb5f426760468/build-tools/automation/azure-pipelines.yaml#L53
We could maybe try 5.0.100-preview.5.20264.3
, which is latest master here: https://github.com/dotnet/installer#build-status
Locally I am using 5.0.100-preview.5.20229.12. I will try to bump it to lastest. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might have to wait until this lands: #4692
This fixes the change from netcoreapp5.0
-> net5.0
.
Indeed. dotnet tests are now failing with related error:
|
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
|
Based on the new `Microsoft.NET.ILLink` NuGet package, this is a start to what it would look like to use it for Xamarin.Android.
And use it in place of Mono.Tuner one, where needed for net5
Do not run `LinkAssemblies` task on NET5 Temporarily disable `_RemoveRegisterAttribute` target. It is crashing, presumably because the assemblies are in different location.
The step so far only installs `FixAbstractMethodsStep`. Parts of the code come from xamarin-macios repo. We might share these and move them to linker. Or enable more linker API to avoid getting the pipeline steps with reflection.
And re-enable `_RemoveRegisterAttribute` target, as the assemblies now end up in the right place
To avoid few #if's and make the code better readable
To avoid using Xamarin.Android.Linker namespace and introducing another `#if`'s
We don't need them anymore as we have the new extension method in that namespace
We still need `using Mono.Tuner;` for non NET5 version.
So that it is built
This can be enabled again when #4708 is resolved.
Which fell out in previous merge
To make the test build with linker
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.ILLink" Version="5.0.0-preview.3.20227.3" /> | ||
<ProjectReference Include="..\..\external\Java.Interop\src\Java.Interop.Export\Java.Interop.Export.csproj" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why we would have a @(ProjectReference)
to Java.Interop.Export.dll
. I don't see any mentions of types located within that assembly within this PR, e.g. neither JniSignature
nor MarshalMemberBuilder
make an appearance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to have MarshalMemberBuilder.GetMarshalMethodName
for TryGetMarshalMethod
method.
Xamarin.Android.Build.Tasks.sln
Outdated
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Android.Tools.AndroidSdk", "external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj", "{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157}" | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Tools.AndroidSdk", "external\xamarin-android-tools\src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj", "{E34BCFA0-CAA4-412C-AA1C-75DB8D67D157}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xamarin.Android.Linker", "src\Xamarin.Android.Linker\Xamarin.Android.Linker.csproj", "{2A237E71-1FA3-409B-B13E-F6294932A5A9}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I half wonder if this should be Microsoft.Android.Linker
. :-/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even better Microsoft.Android.Sdk.ILLink
;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many assemblies do we want running around? That's a rather fine-grained name…
@@ -165,7 +166,7 @@ bool CheckInvokerType (TypeDefinition type, string name) | |||
|
|||
void PreserveInterfaceMethods (TypeDefinition type, TypeDefinition invoker) | |||
{ | |||
foreach (var m in type.GetMethods ()) { | |||
foreach (var m in type.Methods.Where (m => !m.IsConstructor)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for this change? The PR description is anemic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one comes from Mono.Tuner.MethodBodyRocks
class, which is not part of illink public API and was simple enough to inline.
Implements #4707
With .NET5 we are switching from XA linker implemented as msbuild task to ILLink tool with custom steps provided in an assembly.
The new assembly with our custom steps is named
Microsoft.Android.Sdk.ILLink
and the source code is located insrc/Microsoft.Android.Sdk.ILLink
. It is used during build byILLink
tool.The initial support is already able to link and run simple XA and XA/XF samples.
Future work
Notes
src/Microsoft.Android.Sdk.ILLink/Profile.cs
with missing pieces.TypeDefinition.GetMethods
extension method fromMono.Tuner.MethodBodyRocks
is not public. It is very simple so we are inlining it.Release
configuration defaults.Initial results:
apkdiff output summary for HelloAndroid sample, comparing
Debug
andRelease
apk'sContext:
_RunILLink
target https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ILLink.targets