diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs index 40f55f7cdde..75aa79d7247 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs @@ -277,7 +277,7 @@ bool DoExecute () { throw new Exception ("Unsupported Android target architecture ABI: " + abi); } - if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, requireLibm:EnableLLVM)) { + if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, enableLLVM:EnableLLVM)) { return false; } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/MakeBundleNativeCodeExternal.cs b/src/Xamarin.Android.Build.Tasks/Tasks/MakeBundleNativeCodeExternal.cs index 40bb2646754..4f0b2f95ab2 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/MakeBundleNativeCodeExternal.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/MakeBundleNativeCodeExternal.cs @@ -98,7 +98,7 @@ bool DoExecute () break; } - if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, requireLibm:true)) { + if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, enableLLVM: false)) { return false; } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/NdkUtils.cs b/src/Xamarin.Android.Build.Tasks/Tasks/NdkUtils.cs index 31958ecb42e..57000bee4a3 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/NdkUtils.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/NdkUtils.cs @@ -16,7 +16,7 @@ namespace Xamarin.Android.Tasks { public static class NdkUtil { - public static bool ValidateNdkPlatform (TaskLoggingHelper log, string ndkPath, AndroidTargetArch arch, bool requireLibm) + public static bool ValidateNdkPlatform (TaskLoggingHelper log, string ndkPath, AndroidTargetArch arch, bool enableLLVM) { // Check that we have a compatible NDK version for the targeted ABIs. NdkUtil.NdkVersion ndkVersion; @@ -30,12 +30,18 @@ public static bool ValidateNdkPlatform (TaskLoggingHelper log, string ndkPath, A // NDK r10d is buggy and cannot link x86_64 ABI shared libraries because they are 32-bits. // See https://code.google.com/p/android/issues/detail?id=161421 - if (requireLibm && ndkVersion.Version == 10 && ndkVersion.Revision == "d" && arch == AndroidTargetArch.X86_64) { + if (enableLLVM && ndkVersion.Version == 10 && ndkVersion.Revision == "d" && arch == AndroidTargetArch.X86_64) { log.LogCodedError ("XA3004", "Android NDK r10d is buggy and provides an incompatible x86_64 libm.so. " + "See https://code.google.com/p/android/issues/detail?id=161422."); return false; } + if (enableLLVM && (ndkVersion.Version < 10 || (ndkVersion.Version == 10 && ndkVersion.Revision[0] < 'd'))) { + log.LogMessage (MessageImportance.High, + "The detected Android NDK version is incompatible with the targeted LLVM configuration, " + + "please upgrade to NDK r10d or newer."); + } + return true; }