Skip to content
Draft
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
6 changes: 4 additions & 2 deletions build-tools/scripts/Ndk.projitems.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<AndroidNdkApiLevel_X86 Condition=" '$(AndroidNdkApiLevel_X86)' == '' ">@NDK_X86_API_NET@</AndroidNdkApiLevel_X86>
<AndroidNdkApiLevel_X86_64 Condition=" '$(AndroidNdkApiLevel_X86_64)' == '' ">@NDK_X86_64_API@</AndroidNdkApiLevel_X86_64>
<AndroidNdkApiLevel_X64 Condition=" '$(AndroidNdkApiLevel_X64)' == '' ">@NDK_X86_64_API_NET@</AndroidNdkApiLevel_X64>
<AndroidNdkApiLevelNonMono_Arm Condition=" '$(AndroidNdkApiLevelNonMono_Arm)' == '' ">@NDK_ARMEABI_V7_API_NON_MONO@</AndroidNdkApiLevelNonMono_Arm>
<AndroidNdkApiLevelNonMono_Arm64 Condition=" '$(AndroidNdkApiLevelNonMono_Arm64)' == '' ">@NDK_ARM64_V8A_API_NON_MONO@</AndroidNdkApiLevelNonMono_Arm64>
<AndroidNdkApiLevelNonMono_X64 Condition=" '$(AndroidNdkApiLevelNonMono_X64)' == '' ">@NDK_X86_64_API_NON_MONO@</AndroidNdkApiLevelNonMono_X64>
</PropertyGroup>
Expand All @@ -21,10 +22,11 @@
Condition=" $(AndroidSupportedTargetJitAbisForConditionalChecks.Contains (':armeabi-v7a:')) ">
<ApiLevel>$(AndroidNdkApiLevel_ArmV7a)</ApiLevel>
<ApiLevelNET>$(AndroidNdkApiLevel_Arm)</ApiLevelNET>
<ApiLevelNonMono>$(AndroidNdkApiLevelNonMono_Arm)</ApiLevelNonMono>
<AndroidRID>android-arm</AndroidRID>
<SupportMonoVM>True</SupportMonoVM>
<SupportCoreCLR>False</SupportCoreCLR>
<SupportNativeAOT>False</SupportNativeAOT>
<SupportCoreCLR>True</SupportCoreCLR>
<SupportNativeAOT>True</SupportNativeAOT>
</AndroidSupportedTargetJitAbi>

<AndroidSupportedTargetJitAbi
Expand Down
3 changes: 2 additions & 1 deletion build-tools/scripts/XABuildConfig.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ namespace Xamarin.Android.Tools
};

public static readonly Dictionary <AndroidTargetArch, int> ArchToApiLevelNonMono = new () {
{ AndroidTargetArch.Arm64, @NDK_ARM64_V8A_NONMONO_API@ },
{ AndroidTargetArch.Arm, @NDK_ARMEABI_V7_NONMONO_API@ },
{ AndroidTargetArch.Arm64, @NDK_ARM64_V8A_NONMONO_API@ },
{ AndroidTargetArch.X86_64, @NDK_X86_64_NONMONO_API@ },
};
}
Expand Down
1 change: 1 addition & 0 deletions build-tools/scripts/xa_build_configuration.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ set(NETCORE_APP_RUNTIME_DIR_ARM64 "@NETCORE_APP_RUNTIME_ANDROID_ARM64@")
set(NETCORE_APP_RUNTIME_DIR_X86 "@NETCORE_APP_RUNTIME_ANDROID_X86@")
set(NETCORE_APP_RUNTIME_DIR_X86_64 "@NETCORE_APP_RUNTIME_ANDROID_X86_64@")

set(CORECLR_APP_RUNTIME_DIR_ARM "@CORECLR_APP_RUNTIME_ANDROID_ARM@")
set(CORECLR_APP_RUNTIME_DIR_ARM64 "@CORECLR_APP_RUNTIME_ANDROID_ARM64@")
set(CORECLR_APP_RUNTIME_DIR_X86_64 "@CORECLR_APP_RUNTIME_ANDROID_X86_64@")
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static partial class Defaults
/// <c>build-tools/scripts/Ndk.projitems.in</c>.
/// </summary>
public static readonly HashSet<string> NativeAotSupportedAbis = new (StringComparer.Ordinal) {
"armeabi-v7a",
"arm64-v8a",
"x86_64",
};
Expand Down
8 changes: 6 additions & 2 deletions build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ GeneratedFile Get_Cmake_XA_Build_Configuration (Context context)
{ "@NETCORE_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86) },
{ "@NETCORE_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86_64) },

{ "@CORECLR_APP_RUNTIME_ANDROID_ARM@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidARM) },
{ "@CORECLR_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidARM64) },
{ "@CORECLR_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.CoreClrAppRuntimeAndroidX86_64) },
};
Expand All @@ -124,8 +125,9 @@ GeneratedFile GetCmakePresetsCommon (Context context, string sourcesDir)
{ "@NDK_ARM64_V8A_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI },
{ "@NDK_X86_API_NET@", BuildAndroidPlatforms.NdkMinimumAPILegacy32 },
{ "@NDK_X86_64_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI },
{ "@NDK_ARM64_V8A_NONMONO_API_NET@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_X86_64_NONMONO_API_NET@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_ARMEABI_V7_NONMONO_API_NET@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_ARM64_V8A_NONMONO_API_NET@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_X86_64_NONMONO_API_NET@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@XA_BUILD_CONFIGURATION@", context.Configuration },
{ "@XA_TEST_OUTPUT_DIR@", Utilities.EscapePathSeparators (props.GetRequiredValue (KnownProperties.TestOutputDirectory)) },
};
Expand Down Expand Up @@ -197,6 +199,7 @@ GeneratedFile Get_XABuildConfig_cs (Context context)
{ "@NDK_ARM64_V8A_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
{ "@NDK_X86_API@", BuildAndroidPlatforms.NdkMinimumAPILegacy32.ToString ().ToString () },
{ "@NDK_X86_64_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString ().ToString () },
{ "@NDK_ARMEABI_V7_NONMONO_API@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_ARM64_V8A_NONMONO_API@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_X86_64_NONMONO_API@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@XA_SUPPORTED_ABIS@", context.Properties.GetRequiredValue (KnownProperties.AndroidSupportedTargetJitAbis).Replace (':', ';') },
Expand Down Expand Up @@ -257,6 +260,7 @@ GeneratedFile Get_Ndk_projitems (Context context)
{ "@NDK_X86_64_API@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
{ "@NDK_X86_64_API_NET@", BuildAndroidPlatforms.NdkMinimumAPI.ToString () },
{ "@NDK_ARM64_V8A_API_NON_MONO@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_ARMEABI_V7_API_NON_MONO@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
{ "@NDK_X86_64_API_NON_MONO@", BuildAndroidPlatforms.NdkMinimumNonMonoAPI },
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
<AllowPublishAotWithoutRuntimeIdentifier Condition=" '$(AllowPublishAotWithoutRuntimeIdentifier)' == '' ">true</AllowPublishAotWithoutRuntimeIdentifier>
<!-- NativeAOT's targets currently gives an error about cross-compilation -->
<DisableUnsupportedError Condition=" $([MSBuild]::IsOSPlatform('windows')) and '$(DisableUnsupportedError)' == '' ">true</DisableUnsupportedError>
<!-- HACK: make dotnet restore include Microsoft.NETCore.App.Runtime.NativeAOT.linux-bionic-arm64 -->
<!-- HACK: make dotnet restore include Microsoft.NETCore.App.Runtime.NativeAOT.linux-bionic-* packs -->
<_IsPublishing Condition=" '$(_IsPublishing)' == '' ">true</_IsPublishing>
<!-- ResolvedFileToPublish is not populated until _AndroidComputeIlcCompileInputs, so
proguard generation must run after that target instead of after ILLink. -->
Expand Down Expand Up @@ -86,9 +86,16 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
<PropertyGroup>
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64</_NdkAbi>
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64</_NdkAbi>
<_NdkAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">arm</_NdkAbi>
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">$(AndroidNdkApiLevel_Arm64)</_NDKApiLevel>
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">$(AndroidNdkAPiLevel_X64)</_NDKApiLevel>
<_NdkSysrootAbi>$(_NdkAbi)-linux-android</_NdkSysrootAbi>
<_NDKApiLevel Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">$(AndroidNdkApiLevel_Arm)</_NDKApiLevel>
<_NdkClangPrefix Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64-linux-android</_NdkClangPrefix>
<_NdkClangPrefix Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64-linux-android</_NdkClangPrefix>
<_NdkClangPrefix Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">armv7a-linux-androideabi</_NdkClangPrefix>
<_NdkSysrootAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' ">aarch64-linux-android</_NdkSysrootAbi>
<_NdkSysrootAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' ">x86_64-linux-android</_NdkSysrootAbi>
<_NdkSysrootAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm' ">arm-linux-androideabi</_NdkSysrootAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('windows')) ">windows-x86_64</_NdkPrebuiltAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('osx')) ">darwin-x86_64</_NdkPrebuiltAbi>
<_NdkPrebuiltAbi Condition=" $([MSBuild]::IsOSPlatform('linux')) ">linux-x86_64</_NdkPrebuiltAbi>
Expand Down Expand Up @@ -124,8 +131,8 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
application. If, for some reason, `clang++` has to be used, `<LinkerArgs>` need to be
added to pass `-nostdlib` to it.
-->
<CppCompilerAndLinker>$(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppCompilerAndLinker>
<CppLinker>$(_NdkAbi)-linux-android$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppLinker>
<CppCompilerAndLinker>$(_NdkClangPrefix)$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppCompilerAndLinker>
<CppLinker>$(_NdkClangPrefix)$(_NDKApiLevel)-clang$(_NdkWrapperScriptExt)</CppLinker>
<ObjCopyName>llvm-objcopy</ObjCopyName>

<!-- We must ensure this is `false`, as it would interfere with statically linking libc++ -->
Expand Down Expand Up @@ -210,6 +217,7 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.

<Target Name="_PrepareNativeAotAndroidAppInputs">
<ItemGroup>
<_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm' " Include="armeabi-v7a" />
<_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-arm64' " Include="arm64-v8a" />
<_PrivateBuildTargetAbi Condition=" '$(RuntimeIdentifier)' == 'android-x64' " Include="x86_64" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"Microsoft.Android.Runtime.Mono.37.android-arm64",
"Microsoft.Android.Runtime.Mono.37.android-x86",
"Microsoft.Android.Runtime.Mono.37.android-x64",
"Microsoft.Android.Runtime.CoreCLR.37.android-arm",
"Microsoft.Android.Runtime.CoreCLR.37.android-arm64",
"Microsoft.Android.Runtime.CoreCLR.37.android-x64",
"Microsoft.Android.Runtime.NativeAOT.37.android-arm",
"Microsoft.Android.Runtime.NativeAOT.37.android-arm64",
"Microsoft.Android.Runtime.NativeAOT.37.android-x64",
"Microsoft.Android.Templates"
Expand Down Expand Up @@ -78,6 +80,10 @@
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.CoreCLR.37.android-arm": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.CoreCLR.37.android-arm64": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
Expand All @@ -86,6 +92,10 @@
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.NativeAOT.37.android-arm": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.NativeAOT.37.android-arm64": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
Expand Down
2 changes: 2 additions & 0 deletions src/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@ if(IS_CLR_RUNTIME)
set(LOCAL_CORECLR_CONFIG Release)
endif()

set(RUNTIME_DIR_ARM "${LOCAL_CORECLR_PATH}/${CLR_PACKAGE_NAME_STEM}-arm/${LOCAL_CORECLR_CONFIG}/runtimes/android-arm")
set(RUNTIME_DIR_ARM64 "${LOCAL_CORECLR_PATH}/${CLR_PACKAGE_NAME_STEM}-arm64/${LOCAL_CORECLR_CONFIG}/runtimes/android-arm64")
set(RUNTIME_DIR_X86_64 "${LOCAL_CORECLR_PATH}/${CLR_PACKAGE_NAME_STEM}-x64/${LOCAL_CORECLR_CONFIG}/runtimes/android-x64")
else()
set(RUNTIME_DIR_ARM "${CORECLR_APP_RUNTIME_DIR_ARM}")
set(RUNTIME_DIR_ARM64 "${CORECLR_APP_RUNTIME_DIR_ARM64}")
set(RUNTIME_DIR_X86_64 "${CORECLR_APP_RUNTIME_DIR_X86_64}")
endif()
Expand Down
31 changes: 31 additions & 0 deletions src/native/CMakePresets.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@
}
},

{
"name": "nonmono-common-armeabi-v7a",
"hidden": true,
"cacheVariables": {
"ANDROID_ABI": "armeabi-v7a",
"ANDROID_NATIVE_API_LEVEL": "@NDK_ARMEABI_V7_NONMONO_API_NET@",
"ANDROID_PLATFORM": "android-@NDK_ARMEABI_V7_NONMONO_API_NET@",
"ANDROID_RID": "android-arm"
}
},

{
"name": "common-arm64-v8a",
"hidden": true,
Expand Down Expand Up @@ -173,11 +184,31 @@
"inherits": ["default-common", "common-debug", "common-armeabi-v7a"]
},

{
"name": "nativeaot-default-debug-armeabi-v7a",
"inherits": ["nativeaot-default-common", "common-debug", "nonmono-common-armeabi-v7a"]
},

{
"name": "coreclr-default-debug-armeabi-v7a",
"inherits": ["default-common", "common-debug", "nonmono-common-armeabi-v7a"]
},

{
"name": "default-release-armeabi-v7a",
"inherits": ["default-common", "common-release", "common-armeabi-v7a"]
},

{
"name": "nativeaot-default-release-armeabi-v7a",
"inherits": ["nativeaot-default-common", "common-release", "nonmono-common-armeabi-v7a"]
},

{
"name": "coreclr-default-release-armeabi-v7a",
"inherits": ["default-common", "common-release", "nonmono-common-armeabi-v7a"]
},

{
"name": "analyzers-debug-armeabi-v7a",
"hidden": true,
Expand Down
2 changes: 1 addition & 1 deletion src/native/clr/host/typemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ auto TypeMapper::managed_to_java_debug (const char *typeName, const uint8_t *mvi
dynamic_local_path_string full_type_name;
full_type_name.append (typeName);

hash_t mvid_hash = xxhash::hash (mvid, 16z); // we must hope managed land called us with valid data
hash_t mvid_hash = xxhash::hash (reinterpret_cast<const char*>(mvid), 16z); // we must hope managed land called us with valid data

auto equal = [](TypeMapAssembly const& entry, hash_t key) -> bool { return entry.mvid_hash == key; };
auto less_than = [](TypeMapAssembly const& entry, hash_t key) -> bool { return entry.mvid_hash < key; };
Expand Down
3 changes: 1 addition & 2 deletions src/native/native-clr.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<OutputType>Exe</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<!-- HACK HACK: until CoreCLR exists for all the targets, work only with arm64 -->
<AndroidSupportedTargetAotAbis>arm64:x86_64</AndroidSupportedTargetAotAbis>
<AndroidSupportedTargetJitAbis>arm64-v8a:x86_64</AndroidSupportedTargetJitAbis>
<AndroidSupportedTargetJitAbis>armeabi-v7a:arm64-v8a:x86_64</AndroidSupportedTargetJitAbis>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />
Expand Down
2 changes: 1 addition & 1 deletion src/native/native-nativeaot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

<AndroidSupportedTargetAotAbis>arm64:x86_64</AndroidSupportedTargetAotAbis>
<AndroidSupportedTargetJitAbis>arm64-v8a:x86_64</AndroidSupportedTargetJitAbis>
<AndroidSupportedTargetJitAbis>armeabi-v7a:arm64-v8a:x86_64</AndroidSupportedTargetJitAbis>
</PropertyGroup>

<Import Project="..\..\Configuration.props" />
Expand Down