Skip to content

Commit 14260f4

Browse files
tritaoatsushieno
authored andcommitted
[Xamarin.Android.Build.Tasks] Improved NDK version validation in AOT LLVM configuration. (#113)
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=31985.
1 parent 5e6b839 commit 14260f4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/Aot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ bool DoExecute () {
277277
throw new Exception ("Unsupported Android target architecture ABI: " + abi);
278278
}
279279

280-
if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, requireLibm:EnableLLVM)) {
280+
if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, enableLLVM:EnableLLVM)) {
281281
return false;
282282
}
283283

src/Xamarin.Android.Build.Tasks/Tasks/MakeBundleNativeCodeExternal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool DoExecute ()
9898
break;
9999
}
100100

101-
if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, requireLibm:true)) {
101+
if (!NdkUtil.ValidateNdkPlatform (Log, AndroidNdkDirectory, arch, enableLLVM: false)) {
102102
return false;
103103
}
104104

src/Xamarin.Android.Build.Tasks/Tasks/NdkUtils.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Xamarin.Android.Tasks
1616
{
1717
public static class NdkUtil {
1818

19-
public static bool ValidateNdkPlatform (TaskLoggingHelper log, string ndkPath, AndroidTargetArch arch, bool requireLibm)
19+
public static bool ValidateNdkPlatform (TaskLoggingHelper log, string ndkPath, AndroidTargetArch arch, bool enableLLVM)
2020
{
2121
// Check that we have a compatible NDK version for the targeted ABIs.
2222
NdkUtil.NdkVersion ndkVersion;
@@ -30,12 +30,18 @@ public static bool ValidateNdkPlatform (TaskLoggingHelper log, string ndkPath, A
3030

3131
// NDK r10d is buggy and cannot link x86_64 ABI shared libraries because they are 32-bits.
3232
// See https://code.google.com/p/android/issues/detail?id=161421
33-
if (requireLibm && ndkVersion.Version == 10 && ndkVersion.Revision == "d" && arch == AndroidTargetArch.X86_64) {
33+
if (enableLLVM && ndkVersion.Version == 10 && ndkVersion.Revision == "d" && arch == AndroidTargetArch.X86_64) {
3434
log.LogCodedError ("XA3004", "Android NDK r10d is buggy and provides an incompatible x86_64 libm.so. " +
3535
"See https://code.google.com/p/android/issues/detail?id=161422.");
3636
return false;
3737
}
3838

39+
if (enableLLVM && (ndkVersion.Version < 10 || (ndkVersion.Version == 10 && ndkVersion.Revision[0] < 'd'))) {
40+
log.LogMessage (MessageImportance.High,
41+
"The detected Android NDK version is incompatible with the targeted LLVM configuration, " +
42+
"please upgrade to NDK r10d or newer.");
43+
}
44+
3945
return true;
4046
}
4147

0 commit comments

Comments
 (0)