Skip to content

Commit 84f31d5

Browse files
[One .NET] don't pass satellite assemblies to the AOT compiler (#6687)
Fixes: dotnet/runtime#64269 An F# test was failing in AOT builds with: Microsoft.Android.Sdk.Aot.targets(74,5): Precompiling failed for C:\src\xamarin-android\bin\TestDebug\temp\BuildBasicApplicationFSharpTrue\obj\Release\android-arm\aot-in\FSharp.Core.resources.dll. AOT of image obj\Release\android-arm\aot-in\FSharp.Core.resources.dll failed. Mono Ahead of Time compiler - compiling assembly C:\src\xamarin-android\bin\TestDebug\temp\BuildBasicApplicationFSharpTrue\obj\Release\android-arm\aot-in\FSharp.Core.resources.dll AOTID 302CA46D-4000-DCAD-1A9F-642D849470DE Using profile data file 'C:\Program Files\dotnet\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-ci.dotnet-release-aot-by-default.36\targets\dotnet.aotprofile' Added 0 methods from profile. Compiled: 0/0 Executing the native assembler: "C:\Program Files\dotnet\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-ci.dotnet-release-aot-by-default.36\tools\binutils\arm-linux-androideabi-as" -mfpu=vfp3 -o obj\Release\android-arm\aot\armeabi-v7a\FSharp.Core.resources\temp.s.o obj\Release\android-arm\aot\armeabi-v7a\FSharp.Core.resources\temp.s Executing the native linker: "C:\Program Files\dotnet\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-ci.dotnet-release-aot-by-default.36\tools\binutils\arm-linux-androideabi-ld" -Bsymbolic -shared -o obj\Release\android-arm\aot\FSharp.Core.resources.dll.so.tmp obj\Release\android-arm\aot\armeabi-v7a\FSharp.Core.resources\temp.s.o Stripping the binary: "C:\Program Files\dotnet\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.200-ci.dotnet-release-aot-by-default.36\tools\binutils\arm-linux-androideabi-strip" --strip-symbol=\$a --strip-symbol=\$d obj\Release\android-arm\aot\FSharp.Core.resources.dll.so.tmp [C:\src\xamarin-android\bin\TestDebug\temp\BuildBasicApplicationFSharpTrue\UnnamedProject.fsproj] It turns out we shouldn't be passing satellite assemblies to the AOT compiler, they appear to be included in `@(ResolvedFileToPublish)`: <ItemGroup> <_AndroidAotInputs Include="@(ResolvedFileToPublish)" Condition=" '%(Extension)' == '.dll' " /> </ItemGroup> Viewing these assemblies, I see the metadata `%(ResolvedFileToPublish.AssetType)` is equal to `resources`. I think we can simply check for this and ignore these files. The F# test I parameterized to include an AOT build. I also removed a `TODO` on F# tests, since this is fixed now: dotnet/linker#1448
1 parent 67718cf commit 84f31d5

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Aot.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ They run in a context of an inner build with a single $(RuntimeIdentifier).
3434

3535
<Target Name="_AndroidAotInputs">
3636
<ItemGroup>
37-
<_AndroidAotInputs Include="@(ResolvedFileToPublish)" Condition=" '%(Extension)' == '.dll' " />
37+
<_AndroidAotInputs Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.dll' and '%(ResolvedFileToPublish.AssetType)' != 'resources' " />
3838
</ItemGroup>
3939
</Target>
4040

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,6 @@ public void CheckResourceDesignerIsCreated (bool isRelease, ProjectLanguage lang
523523
Language = language,
524524
IsRelease = isRelease,
525525
};
526-
if (Builder.UseDotNet && isFSharp && isRelease) {
527-
//TODO: temporary until this is fixed: https://github.com/mono/linker/issues/1448
528-
proj.AndroidLinkModeRelease = AndroidLinkMode.None;
529-
}
530526
proj.SetProperty ("AndroidUseIntermediateDesignerFile", "True");
531527
using (var b = CreateApkBuilder ()) {
532528
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
@@ -553,10 +549,6 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL
553549
Language = language,
554550
IsRelease = isRelease,
555551
};
556-
if (Builder.UseDotNet && isFSharp && isRelease) {
557-
//TODO: temporary until this is fixed: https://github.com/mono/linker/issues/1448
558-
proj.AndroidLinkModeRelease = AndroidLinkMode.None;
559-
}
560552
using (var b = CreateApkBuilder ()) {
561553
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
562554
var designerPath = GetResourceDesignerPath (b, proj);

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,22 +270,34 @@ static void Test ()
270270
}
271271
}
272272

273+
static object [] BuildBasicApplicationFSharpSource = new object [] {
274+
new object[] {
275+
/*isRelease*/ false,
276+
/*aot*/ false,
277+
},
278+
new object[] {
279+
/*isRelease*/ true,
280+
/*aot*/ false,
281+
},
282+
new object[] {
283+
/*isRelease*/ true,
284+
/*aot*/ true,
285+
},
286+
};
287+
273288
[Test]
289+
[TestCaseSource (nameof (BuildBasicApplicationFSharpSource))]
274290
[Category ("Minor"), Category ("FSharp")]
275291
[NonParallelizable] // parallel NuGet restore causes failures
276-
public void BuildBasicApplicationFSharp ([Values (true, false)] bool isRelease)
292+
public void BuildBasicApplicationFSharp (bool isRelease, bool aot)
277293
{
278294
var proj = new XamarinAndroidApplicationProject {
279295
Language = XamarinAndroidProjectLanguage.FSharp,
280296
IsRelease = isRelease,
297+
AotAssemblies = aot,
281298
};
282-
if (Builder.UseDotNet && isRelease) {
283-
//TODO: temporary until this is fixed: https://github.com/mono/linker/issues/1448
284-
proj.AndroidLinkModeRelease = AndroidLinkMode.None;
285-
}
286-
using (var b = CreateApkBuilder ()) {
287-
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
288-
}
299+
using var b = CreateApkBuilder ();
300+
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
289301
}
290302

291303
[Test]

0 commit comments

Comments
 (0)