From 8ef7a6e3f94a033a8f79d1cae3989fff7adeee06 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Thu, 21 Sep 2023 21:25:53 +0000 Subject: [PATCH] Bump NDK to r26 (#8213) Changes: https://github.com/android/ndk/wiki/Changelog-r26#announcements NDK r26 has the following changes which are interesting to us: * libc++ has been updated. The NDK's libc++ now comes directly from our LLVM toolchain, so every future LLVM update is also a libc++ update. * Updated LLVM to clang-r487747c, based on LLVM 17 development The `libc++` update brings internal implementation changes, and as a result we no longer need to partially instantiate a couple of classes previously underlying the `vector` and `basic_string` implementations. --- .../ConfigAndData/BuildAndroidPlatforms.cs | 6 +++--- .../Tasks/NdkUtilTests.cs | 2 +- src/monodroid/CMakeLists.txt | 1 - src/monodroid/jni/cxx-abi/string.cc | 1 - src/monodroid/jni/cxx-abi/vector.cc | 12 ------------ tests/Mono.Android-Tests/jni/reuse-threads.c | 15 +++++++++------ 6 files changed, 13 insertions(+), 24 deletions(-) delete mode 100644 src/monodroid/jni/cxx-abi/vector.cc diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs index b721305778b..442a897ef6a 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs @@ -5,10 +5,10 @@ namespace Xamarin.Android.Prepare { class BuildAndroidPlatforms { - public const string AndroidNdkVersion = "25c"; - public const string AndroidNdkPkgRevision = "25.2.9519653"; + public const string AndroidNdkVersion = "26"; + public const string AndroidNdkPkgRevision = "26.0.10792818"; public const int NdkMinimumAPI = 21; - public const int NdkMinimumAPILegacy32 = 19; + public const int NdkMinimumAPILegacy32 = 21; public static readonly List AllPlatforms = new List { new AndroidPlatform (apiName: "", apiLevel: 1, platformID: "1"), diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs index b5a8df827ac..25d67d0e4c5 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/NdkUtilTests.cs @@ -41,7 +41,7 @@ public void TestNdkUtil () Assert.IsTrue (ndk.ValidateNdkPlatform (arch, enableLLVM: false)); Assert.AreEqual (0, errors.Count, "NdkTools.ValidateNdkPlatform should not have returned false."); int level = ndk.GetMinimumApiLevelFor (arch); - int expected = 19; + int expected = 21; Assert.AreEqual (expected, level, $"Min Api Level for {arch} should be {expected}."); var compilerNoQuotes = ndk.GetToolPath (NdkToolKind.CompilerC, arch, level); Assert.AreEqual (0, errors.Count, "NdkTools.GetToolPath should not have errored."); diff --git a/src/monodroid/CMakeLists.txt b/src/monodroid/CMakeLists.txt index 61c2f414ed9..9c4d711f774 100644 --- a/src/monodroid/CMakeLists.txt +++ b/src/monodroid/CMakeLists.txt @@ -505,7 +505,6 @@ if(ANDROID) ${BIONIC_SOURCES_DIR}/cxa_guard.cc ${SOURCES_DIR}/cxx-abi/string.cc ${SOURCES_DIR}/cxx-abi/terminate.cc - ${SOURCES_DIR}/cxx-abi/vector.cc ) endif() else() diff --git a/src/monodroid/jni/cxx-abi/string.cc b/src/monodroid/jni/cxx-abi/string.cc index 53b5731defc..30d528e14ac 100644 --- a/src/monodroid/jni/cxx-abi/string.cc +++ b/src/monodroid/jni/cxx-abi/string.cc @@ -7,7 +7,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template class __attribute__ ((__visibility__("hidden"))) __basic_string_common; template class __attribute__ ((__visibility__("hidden"))) basic_string; _LIBCPP_END_NAMESPACE_STD diff --git a/src/monodroid/jni/cxx-abi/vector.cc b/src/monodroid/jni/cxx-abi/vector.cc deleted file mode 100644 index 277224ae0a5..00000000000 --- a/src/monodroid/jni/cxx-abi/vector.cc +++ /dev/null @@ -1,12 +0,0 @@ -// -// Defining the macro will make the the explicit instantations below truely hidden -// -#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS - -#include - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class __attribute__ ((__visibility__("hidden"))) __vector_base_common; - -_LIBCPP_END_NAMESPACE_STD diff --git a/tests/Mono.Android-Tests/jni/reuse-threads.c b/tests/Mono.Android-Tests/jni/reuse-threads.c index 07223a60f37..a88574d94c0 100644 --- a/tests/Mono.Android-Tests/jni/reuse-threads.c +++ b/tests/Mono.Android-Tests/jni/reuse-threads.c @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #include @@ -206,15 +207,17 @@ rt_invoke_callback_on_new_thread (CB cb) return 0; } +static int _register_retval = 0; + /* We return -2 for errors, because -1 is reserved for the pthreads PTHREAD_CANCELED special value, indicating that the * thread was canceled. */ -static int +static void* _register_type_from_new_thread (void *data) { RegisterFromThreadContext *context = (RegisterFromThreadContext*)data; if (context == NULL) { - return -100; + return (void*)(intptr_t)-100; } JNIEnv *env = _get_env ("_register_type_from_new_thread"); @@ -227,7 +230,7 @@ _register_type_from_new_thread (void *data) (*env)->ExceptionClear (env); } - return -101; + return (void*)(intptr_t)-101; } int ret = 0; @@ -286,7 +289,7 @@ _register_type_from_new_thread (void *data) cleanup: (*env)->PopLocalFrame (env, NULL); - return ret; + return (void*)(intptr_t)ret; } JNIEXPORT int JNICALL @@ -312,10 +315,10 @@ rt_register_type_on_new_thread (const char *java_type_name, jobject class_loader return -201; } - if ((int)tr == -1 /* PTHREAD_CANCELED - not defined in bionic */) { + if ((int)(intptr_t)tr == -1 /* PTHREAD_CANCELED - not defined in bionic */) { __android_log_print (ANDROID_LOG_INFO, "XA/RuntimeTest", "RegisterOnNewThread: worker thread was canceled"); return -202; } - return (int)tr; + return (int)(intptr_t)tr; }