-
Notifications
You must be signed in to change notification settings - Fork 534
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
[Xamarin.Android.Build.Tasks] implement $(AndroidStripILAfterAOT) #8172
Changes from 10 commits
815e374
2d8bfff
d0db340
f747395
19b2ab9
6152320
0feee89
747aabc
0902fea
6ac4b46
647c8b9
b5dc596
e4db7b8
40475e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1075,5 +1075,24 @@ public void SupportDesugaringStaticInterfaceMethods () | |
); | ||
} | ||
|
||
[Test] | ||
public void EnableAndroidStripILAfterAOT () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly silly question, but is there any way to test that Perhaps we should crack open the linked "app.dll" assembly and verify that e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we should do something like this test: And then we could assert a method has 0 instructions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would be great, if we could create a test like that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jonathanpeppers: |
||
{ | ||
var proj = new XamarinAndroidApplicationProject { | ||
IsRelease = true, | ||
EnableDefaultItems = true, | ||
}; | ||
proj.SetProperty("AndroidStripILAfterAOT", "true"); | ||
|
||
var builder = CreateApkBuilder (); | ||
Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed"); | ||
RunProjectAndAssert (proj, builder); | ||
|
||
WaitForPermissionActivity (Path.Combine (Root, builder.ProjectDirectory, "permission-logcat.log")); | ||
bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity", | ||
Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30); | ||
Assert.IsTrue(didLaunch, "Activity should have started."); | ||
} | ||
|
||
} | ||
} |
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
<Move/>
feels absurd to me:@(_ILStripTrimmedAssemblies)
is an output parameter, so I would normally intuit/assume that%(_ILStripTrimmedAssemblies.Identity)
is the file that was created. However, this<Move/>
implies that%(_ILStripTrimmedAssemblies.Identity)
has not in fact been created, and instead what was created is%(_ILStripTrimmedAssemblies.TrimmedAssemblyFileName)
, which must be moved to%(_ILStripTrimmedAssemblies.Identity)
.Does this make sense to anyone? Why was
<ILStrip/>
defined this way?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.
The goal of
ILStrip
is to trim IL code away from the assemblies which were AOT'ed. However, not all AOT'ed assemblies might be trimmable. That's why we have_ILStripTrimmedAssemblies
.ILStrip
also doesn't overwrite existing assemblies with the trimmed ones. It is designed this way, in case%(_ILStripTrimmedAssemblies.Identity)
are not the ones that you want to replace with the trimmed ones. They could be the ones which live in other directories. AndILStrip
could possibly has no knowledge of that.Here for
System.Private.CoreLib.dll
,%(_ILStripTrimmedAssemblies.Identity)
is<a_path>/System.Private.CoreLib.dll
%(_ILStripTrimmedAssemblies.TrimmedAssemblyFileName)
is<a_path>/System.Private.CoreLib_trimmed.dll
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.
@fanyang-mono: how does
<ILStrip/>
know which method bodies it can remove? I see that the<MonoAOTCompiler/>
invocation was updated to add aMonoAOTCompiler.TrimmingEligibleMethodsOutputDirectory
property, but how does<ILStrip/>
konw about the$(IntermediateOutputPath)tokens
directory?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.
The output
_MonoAOTCompiledAssemblies
fromMonoAOTCompiler
has a metadataMethodTokenFile
. It stores the trimmable method token for the corresponding assembly.