1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-09 17:44:48 +09:00

[release/9.0-staging] Change assembler to clang in android MonoAOT (#110812)

* Change assembler to clang in android MonoAOT

* Disabled NdkToolFinder task

* Port changes to sample app

* Allowed overwriting AsOptions

---------

Co-authored-by: Jeremi Kurdek <jkurdek@gmail.com>
This commit is contained in:
github-actions[bot] 2025-01-13 15:11:38 +01:00 committed by GitHub
parent 9ee881abb0
commit 555da9fbe2
Signed by: github
GPG key ID: B5690EEEBB952194
4 changed files with 71 additions and 38 deletions

View file

@ -112,12 +112,21 @@
<_AotOutputType>ObjectFile</_AotOutputType>
</PropertyGroup>
<ItemGroup>
<MonoAOTCompilerDefaultAotArguments Condition="'$(TargetArchitecture)' == 'arm'" Include="mtriple=armv7-linux-gnueabi" />
<MonoAOTCompilerDefaultAotArguments Condition="'$(TargetArchitecture)' == 'arm64'" Include="mtriple=aarch64-linux-android" />
<MonoAOTCompilerDefaultAotArguments Condition="'$(TargetArchitecture)' == 'x86'" Include="mtriple=i686-linux-android" />
<MonoAOTCompilerDefaultAotArguments Condition="'$(TargetArchitecture)' == 'x64'" Include="mtriple=x86_64-linux-android" />
<PropertyGroup>
<_Triple Condition="'$(TargetArchitecture)' == 'arm'">armv7-linux-gnueabi</_Triple>
<_Triple Condition="'$(TargetArchitecture)' == 'arm64'">aarch64-linux-android</_Triple>
<_Triple Condition="'$(TargetArchitecture)' == 'x86'">i686-linux-android</_Triple>
<_Triple Condition="'$(TargetArchitecture)' == 'x64'">x86_64-linux-android</_Triple>
</PropertyGroup>
<PropertyGroup>
<_AsOptions>-target $(_Triple) -c -x assembler</_AsOptions>
<_LdName>clang</_LdName>
<_LdOptions>-fuse-ld=lld</_LdOptions>
<_AsName>clang</_AsName>
</PropertyGroup>
<ItemGroup>
<MonoAOTCompilerDefaultAotArguments Include="static" />
<MonoAOTCompilerDefaultAotArguments Include="dwarfdebug" />
<MonoAOTCompilerDefaultAotArguments Condition="'$(_IsLibraryMode)' == 'true'" Include="direct-icalls" />
@ -141,19 +150,6 @@
<AndroidLibraryMinApiLevel Condition="'$(AndroidLibraryMinApiLevel)' == ''">21</AndroidLibraryMinApiLevel>
</PropertyGroup>
<NdkToolFinderTask
Condition="'$(AOTWithLibraryFiles)' == 'true' or '$(_IsLibraryMode)' == 'true'"
Architecture="$(TargetArchitecture)"
HostOS="$(_HostOS)"
MinApiLevel="$(AndroidLibraryMinApiLevel)">
<Output TaskParameter="AsPrefixPath" PropertyName="_AsPrefixPath" />
<Output TaskParameter="ToolPrefixPath" PropertyName="_ToolPrefixPath" />
<Output TaskParameter="Triple" PropertyName="_Triple" />
<Output TaskParameter="LdName" PropertyName="_LdName" />
<Output TaskParameter="LdPath" PropertyName="_LdPath" />
<Output TaskParameter="ClangPath" PropertyName="_ClangPath" />
</NdkToolFinderTask>
<PropertyGroup Condition="'$(AOTWithLibraryFiles)' == 'true' or '$(_IsLibraryMode)' == 'true'">
<_AsPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_AsPrefixPath)'))</_AsPrefixPath>
<_ToolPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_ToolPrefixPath)'))</_ToolPrefixPath>
@ -221,20 +217,23 @@
<MonoAOTCompiler
AotModulesTablePath="$(_AotModuleTablePath)"
AsPrefix="$(_AsPrefixPath)"
AsName="$(_AsName)"
AsOptions="$(_AsOptions)"
Assemblies="@(_AotInputAssemblies)"
CompilerBinaryPath="$(_CompilerBinaryPath)"
DirectPInvokes="@(DirectPInvokes)"
DirectPInvokeLists="@(DirectPInvokeLists)"
EnableUnmanagedCallersOnlyMethodsExport="$(_EnableUnmanagedCallersOnlyMethodsExport)"
IntermediateOutputPath="$(_MobileIntermediateOutputPath)"
LdName="$(_LdName)"
LdOptions="$(_LdOptions)"
LibraryFormat="$(_AotLibraryFormat)"
LLVMPath="$(_MonoLLVMPath)"
MibcProfilePath="@(ProfiledAOTProfilePaths)"
Mode="$(_AOTMode)"
OutputDir="$(_MobileIntermediateOutputPath)"
OutputType="$(_AotOutputType)"
ToolPrefix="$(_ToolPrefixPath)"
Triple="$(_Triple)"
UseAotDataFile="$(_UseAotDataFile)"
UseLLVM="$(MonoEnableLLVM)">
<Output TaskParameter="CompiledAssemblies" ItemName="_AssembliesToBundleInternal" />

View file

@ -69,36 +69,40 @@
<AndroidLibraryMinApiLevel Condition="'$(AndroidLibraryMinApiLevel)' == ''">21</AndroidLibraryMinApiLevel>
</PropertyGroup>
<NdkToolFinderTask
Condition="'$(AOTWithLibraryFiles)' == 'true'"
Architecture="$(TargetArchitecture)"
HostOS="$(_HostOS)"
MinApiLevel="$(AndroidLibraryMinApiLevel)">
<Output TaskParameter="AsPrefixPath" PropertyName="_AsPrefixPath" />
<Output TaskParameter="ToolPrefixPath" PropertyName="_ToolPrefixPath" />
<Output TaskParameter="Triple" PropertyName="_Triple" />
<Output TaskParameter="LdName" PropertyName="_LdName" />
<Output TaskParameter="LdPath" PropertyName="_LdPath" />
<Output TaskParameter="ClangPath" PropertyName="_ClangPath" />
</NdkToolFinderTask>
<PropertyGroup Condition="'$(AOTWithLibraryFiles)' == 'true'">
<_AsPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_AsPrefixPath)'))</_AsPrefixPath>
<_ToolPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_ToolPrefixPath)'))</_ToolPrefixPath>
</PropertyGroup>
<PropertyGroup>
<_Triple Condition="'$(TargetArchitecture)' == 'arm'">armv7-linux-gnueabi</_Triple>
<_Triple Condition="'$(TargetArchitecture)' == 'arm64'">aarch64-linux-android</_Triple>
<_Triple Condition="'$(TargetArchitecture)' == 'x86'">i686-linux-android</_Triple>
<_Triple Condition="'$(TargetArchitecture)' == 'x64'">x86_64-linux-android</_Triple>
</PropertyGroup>
<PropertyGroup>
<_AsOptions>-target $(_Triple) -c -x assembler</_AsOptions>
<_LdName>clang</_LdName>
<_LdOptions>-fuse-ld=lld</_LdOptions>
<_AsName>clang</_AsName>
</PropertyGroup>
<MonoAOTCompiler Condition="'$(ForceAOT)' == 'true'"
AotModulesTablePath="$(_AotModulesTablePath)"
AsPrefix="$(_AsPrefixPath)"
AsName="$(_AsName)"
AsOptions="$(_AsOptions)"
Assemblies="@(AotInputAssemblies)"
CompilerBinaryPath="@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','$(TargetOS)-$(TargetArchitecture.ToLowerInvariant())'))"
IntermediateOutputPath="$(IntermediateOutputPath)"
LdName="$(_LdName)"
LdOptions="$(_LdOptions)"
LibraryFormat="$(_AotLibraryFormat)"
LLVMPath="$(MonoAotCrossDir)"
Mode="$(_AotMode)"
OutputDir="$(_MobileIntermediateOutputPath)"
OutputType="$(_AotOutputType)"
ToolPrefix="$(_ToolPrefixPath)"
Triple="$(_Triple)"
UseAotDataFile="false"
UseLLVM="$(UseLLVM)">
<Output TaskParameter="CompiledAssemblies" ItemName="BundleAssemblies" />

View file

@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
@ -230,6 +230,16 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task
/// </summary>
public string? ToolPrefix { get; set; }
/// <summary>
/// Name of the assembler tool ran by the AOT compiler.
/// </summary>
public string? AsName { get; set; }
/// <summary>
/// Passes as-options to the AOT compiler
/// </summary>
public string? AsOptions { get; set; }
/// <summary>
/// Prepends a prefix to the name of the assembler (as) tool ran by the AOT compiler.
/// </summary>
@ -277,6 +287,11 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task
/// </summary>
public string? LdFlags { get; set; }
/// <summary>
/// Passes ld-options to the AOT compiler
/// </summary>
public string? LdOptions { get; set; }
/// <summary>
/// Specify WorkingDirectory for the AOT compiler
/// </summary>
@ -741,6 +756,16 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task
aotArgs.Add($"tool-prefix={ToolPrefix}");
}
if (!string.IsNullOrEmpty(AsName))
{
aotArgs.Add($"as-name={AsName}");
}
if (!string.IsNullOrEmpty(AsOptions))
{
aotArgs.Add($"as-options={AsOptions}");
}
if (!string.IsNullOrEmpty(AsPrefix))
{
aotArgs.Add($"as-prefix={AsPrefix}");
@ -956,6 +981,11 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task
aotArgs.Add($"ld-flags={LdFlags}");
}
if (!string.IsNullOrEmpty(LdOptions))
{
aotArgs.Add($"ld-options={LdOptions}");
}
// we need to quote the entire --aot arguments here to make sure it is parsed
// on Windows as one argument. Otherwise it will be split up into multiple
// values, which wont work.

View file

@ -101,9 +101,9 @@ namespace Microsoft.Android.Build.Ndk
private void ValidateRequiredProps(string hostOS)
{
if (Ndk.NdkVersion.Main.Major != 23)
if (Ndk.NdkVersion.Main.Major != 27)
{
throw new Exception($"NDK 23 is required. An unsupported NDK version was found ({Ndk.NdkVersion.Main.Major}).");
throw new Exception($"NDK 27 is required. An unsupported NDK version was found ({Ndk.NdkVersion.Main.Major}).");
}
try