Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ stages:
extraBuildArgs: -p:UseMonoRuntime=true -p:_DisableCheckForUnsupportedMonoMobileRuntime=true
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
artifactFolder: $(DotNetTargetFramework)-Mono
# https://github.com/dotnet/runtime/issues/131760
condition: false
Comment thread
jonathanpeppers marked this conversation as resolved.

- template: /build-tools/automation/yaml-templates/apk-instrumentation.yaml
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,25 @@
</ItemGroup>
</Target>

<!-- Override _RemoveRegisterAttribute to strip [Register] attributes from shrunk assemblies -->
<!--
Override _RemoveRegisterAttribute to strip [Register] attributes from shrunk assemblies.

The shrunk copies must be taken from the *final* linked assemblies. `_GenerateJavaStubs`
runs `RewriteMarshalMethods`, which rewrites @(_ResolvedAssemblies) in place (removing the
`cb_*` JNI callback fields), and `_PostTrimmingPipeline` rewrites them again after ILLink.
Depending on `_GenerateJavaStubs` keeps this copy ordered after those rewrites.

`$(_AndroidLinkFlag)` tracks ILLink, while @(_ResolvedAssemblies) tracks the later in-place
rewrites that the link flag cannot observe. The assembly hash also invalidates the target when
the resolved assembly set changes. Without the final assemblies as inputs, the shrunk copies
could go stale while @(_ResolvedAssemblies) moved on, so mono-aot-cross compiled the rewritten
assemblies while packaging shipped the pre-rewrite copies. Their metadata field tables then
disagreed, and AOT `SFLDA` patches resolved to the wrong MonoClassField at runtime. This mirrors
`_RemoveRegisterAttributeCoreClr` in Microsoft.Android.Sdk.TypeMap.Trimmable.targets.
-->
<Target Name="_RemoveRegisterAttribute"
DependsOnTargets="_PrepareAssemblies"
Inputs="$(_AndroidLinkFlag)"
DependsOnTargets="_PrepareAssemblies;_GenerateJavaStubs"
Inputs="$(_AndroidLinkFlag);@(_ResolvedAssemblies);$(_ResolvedUserAssembliesHashFile);$(_AndroidBuildPropertiesCache);@(_AndroidMSBuildAllProjects)"
Outputs="$(_RemoveRegisterFlag)"
Condition="'$(AndroidLinkMode)' != 'None' AND '$(AndroidIncludeDebugSymbols)' != 'true'">
<CopyIfChanged
Expand All @@ -394,6 +409,9 @@
ShrunkFrameworkAssemblies="@(_ShrunkAssemblies)" />
<MakeDir Directories="$(MonoAndroidIntermediateAssemblyDir)shrunk" />
<Touch Files="$(_RemoveRegisterFlag)" AlwaysCreate="true" />
<ItemGroup>
<FileWrites Include="$(_RemoveRegisterFlag)" />
</ItemGroup>
</Target>

<!-- Collect native typemap files for archive (FastDev) -->
Expand Down
Loading