diff --git a/src/mono/msbuild/android/build/AndroidBuild.targets b/src/mono/msbuild/android/build/AndroidBuild.targets index 917aed8850669..7a6c5ebd687c3 100644 --- a/src/mono/msbuild/android/build/AndroidBuild.targets +++ b/src/mono/msbuild/android/build/AndroidBuild.targets @@ -112,12 +112,21 @@ <_AotOutputType>ObjectFile - - - - - + + <_Triple Condition="'$(TargetArchitecture)' == 'arm'">armv7-linux-gnueabi + <_Triple Condition="'$(TargetArchitecture)' == 'arm64'">aarch64-linux-android + <_Triple Condition="'$(TargetArchitecture)' == 'x86'">i686-linux-android + <_Triple Condition="'$(TargetArchitecture)' == 'x64'">x86_64-linux-android + + + + <_AsOptions>-target $(_Triple) -c -x assembler + <_LdName>clang + <_LdOptions>-fuse-ld=lld + <_AsName>clang + + @@ -141,19 +150,6 @@ 21 - - - - - - - - - <_AsPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_AsPrefixPath)')) <_ToolPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_ToolPrefixPath)')) @@ -221,20 +217,23 @@ diff --git a/src/mono/sample/Android/AndroidSampleApp.csproj b/src/mono/sample/Android/AndroidSampleApp.csproj index 7fb665824e5be..573b44ee71053 100644 --- a/src/mono/sample/Android/AndroidSampleApp.csproj +++ b/src/mono/sample/Android/AndroidSampleApp.csproj @@ -69,36 +69,40 @@ 21 - - - - - - - - - <_AsPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_AsPrefixPath)')) <_ToolPrefixPath>$([MSBuild]::EnsureTrailingSlash('$(_ToolPrefixPath)')) + + <_Triple Condition="'$(TargetArchitecture)' == 'arm'">armv7-linux-gnueabi + <_Triple Condition="'$(TargetArchitecture)' == 'arm64'">aarch64-linux-android + <_Triple Condition="'$(TargetArchitecture)' == 'x86'">i686-linux-android + <_Triple Condition="'$(TargetArchitecture)' == 'x64'">x86_64-linux-android + + + + <_AsOptions>-target $(_Triple) -c -x assembler + <_LdName>clang + <_LdOptions>-fuse-ld=lld + <_AsName>clang + + diff --git a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs index 89241ebdd85f4..7961b84a1595c 100644 --- a/src/tasks/AotCompilerTask/MonoAOTCompiler.cs +++ b/src/tasks/AotCompilerTask/MonoAOTCompiler.cs @@ -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 /// public string? ToolPrefix { get; set; } + /// + /// Name of the assembler tool ran by the AOT compiler. + /// + public string? AsName { get; set; } + + /// + /// Passes as-options to the AOT compiler + /// + public string? AsOptions { get; set; } + /// /// Prepends a prefix to the name of the assembler (as) tool ran by the AOT compiler. /// @@ -277,6 +287,11 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task /// public string? LdFlags { get; set; } + /// + /// Passes ld-options to the AOT compiler + /// + public string? LdOptions { get; set; } + /// /// Specify WorkingDirectory for the AOT compiler /// @@ -741,6 +756,16 @@ private PrecompileArguments GetPrecompileArgumentsFor(ITaskItem assemblyItem, st 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 @@ private PrecompileArguments GetPrecompileArgumentsFor(ITaskItem assemblyItem, st 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. diff --git a/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs b/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs index 6370c49df8540..0741e92dfe811 100644 --- a/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs +++ b/src/tasks/MobileBuildTasks/Android/Ndk/NdkTools.cs @@ -101,9 +101,9 @@ public string ClangPath 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