Skip to content

Commit 05bc90a

Browse files
authored
Bump to NDK r27 (#9020)
Changes: https://github.com/android/ndk/wiki/Changelog-r27 NDK r27 has been released. The most important change affecting us is that we should start building all our native libraries with [16k page alignment](https://github.com/android/ndk/wiki/Changelog-r27#announcements), support for which is already in `main` and will be refined once #9075 is merged. Notable changes: * NDK switched to LLVM 18.0.1 as its toolchain * A RISC-V sysroot (AKA riscv64, or rv64) has been added. It is not supported. It is present to aid bringup for OS vendors, but it's not yet a supported Android ABI. It will not be built by default. * Added APP_SUPPORT_FLEXIBLE_PAGE_SIZES for ndk-build and ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES for CMake. * The unsupported libclang, libclang-cpp, libLLVM, and libLTO libraries were removed to save space.
1 parent 9ba9efa commit 05bc90a

File tree

15 files changed

+99
-19
lines changed

15 files changed

+99
-19
lines changed

build-tools/xaprepare/xaprepare/ConfigAndData/BuildAndroidPlatforms.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace Xamarin.Android.Prepare
55
{
66
class BuildAndroidPlatforms
77
{
8-
public const string AndroidNdkVersion = "26d";
9-
public const string AndroidNdkPkgRevision = "26.3.11579264";
8+
public const string AndroidNdkVersion = "27";
9+
public const string AndroidNdkPkgRevision = "27.0.12077973";
1010
public const int NdkMinimumAPI = 21;
1111
public const int NdkMinimumAPILegacy32 = 21;
1212

src-ThirdParty/llvm/verbose_abort.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include <__config>
10+
#include <__verbose_abort>
11+
#include <cstdarg>
12+
#include <cstdio>
13+
#include <cstdlib>
14+
15+
#ifdef __BIONIC__
16+
# include <android/api-level.h>
17+
# if __ANDROID_API__ >= 21
18+
# include <syslog.h>
19+
extern "C" void android_set_abort_message(const char* msg);
20+
# else
21+
# include <assert.h>
22+
# endif // __ANDROID_API__ >= 21
23+
#endif // __BIONIC__
24+
25+
#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
26+
# include <CrashReporterClient.h>
27+
#endif
28+
29+
_LIBCPP_BEGIN_NAMESPACE_STD
30+
31+
_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) {
32+
// Write message to stderr. We do this before formatting into a
33+
// buffer so that we still get some information out if that fails.
34+
{
35+
va_list list;
36+
va_start(list, format);
37+
std::vfprintf(stderr, format, list);
38+
va_end(list);
39+
}
40+
41+
// Format the arguments into an allocated buffer for CrashReport & friends.
42+
// We leak the buffer on purpose, since we're about to abort() anyway.
43+
char* buffer;
44+
(void)buffer;
45+
va_list list;
46+
va_start(list, format);
47+
48+
#if defined(__APPLE__) && __has_include(<CrashReporterClient.h>)
49+
// Note that we should technically synchronize accesses here (by e.g. taking a lock),
50+
// however concretely we're only setting a pointer, so the likelihood of a race here
51+
// is low.
52+
vasprintf(&buffer, format, list);
53+
CRSetCrashLogMessage(buffer);
54+
#elif defined(__BIONIC__)
55+
vasprintf(&buffer, format, list);
56+
57+
# if __ANDROID_API__ >= 21
58+
// Show error in tombstone.
59+
android_set_abort_message(buffer);
60+
61+
// Show error in logcat.
62+
openlog("libc++", 0, 0);
63+
syslog(LOG_CRIT, "%s", buffer);
64+
closelog();
65+
# else
66+
// The good error reporting wasn't available in Android until L. Since we're
67+
// about to abort anyway, just call __assert2, which will log _somewhere_
68+
// (tombstone and/or logcat) in older releases.
69+
__assert2(__FILE__, __LINE__, __func__, buffer);
70+
# endif // __ANDROID_API__ >= 21
71+
#endif
72+
va_end(list);
73+
74+
std::abort();
75+
}
76+
77+
_LIBCPP_END_NAMESPACE_STD

src/native/CMakePresets.json.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"cacheVariables": {
1919
"ANDROID_NDK": "@AndroidNdkDirectory@",
2020
"ANDROID_TOOLCHAIN": "clang",
21+
"ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES": "ON",
2122
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
2223
"CMAKE_MAKE_PROGRAM": "@NinjaPath@",
2324
"OUTPUT_PATH": "@OutputPath@",

src/native/monodroid/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ target_compile_options(
133133
${XAMARIN_MONO_ANDROID_LIB}
134134
PRIVATE
135135
${XA_DEFAULT_SYMBOL_VISIBILITY}
136+
${XA_COMMON_CXX_ARGS}
136137
)
137138

138139
target_include_directories(

src/native/monodroid/embedded-assemblies.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ namespace xamarin::android::internal {
389389
bool need_to_scan_more_apks = true;
390390

391391
AssemblyStoreIndexEntry *assembly_store_hashes;
392-
std::mutex assembly_decompress_mutex;
392+
xamarin::android::mutex assembly_decompress_mutex;
393393
};
394394
}
395395

src/native/monodroid/monodroid-glue-internal.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,15 @@ namespace xamarin::android::internal
346346
jnienv_register_jni_natives_fn jnienv_register_jni_natives = nullptr;
347347
MonoAssemblyLoadContextGCHandle default_alc = nullptr;
348348

349-
static std::mutex pinvoke_map_write_lock;
349+
static xamarin::android::mutex pinvoke_map_write_lock;
350350
static pinvoke_library_map other_pinvoke_map;
351351
static MonoCoreRuntimeProperties monovm_core_properties;
352352
MonovmRuntimeConfigArguments runtime_config_args;
353353

354354
static void *system_native_library_handle;
355355
static void *system_security_cryptography_native_android_library_handle;
356356
static void *system_io_compression_native_library_handle;
357-
static std::mutex dso_handle_write_lock;
357+
static xamarin::android::mutex dso_handle_write_lock;
358358
};
359359
}
360360
#endif

src/native/monodroid/monodroid-glue.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ using namespace microsoft::java_interop;
7777
using namespace xamarin::android;
7878
using namespace xamarin::android::internal;
7979

80-
std::mutex MonodroidRuntime::pinvoke_map_write_lock;
80+
xamarin::android::mutex MonodroidRuntime::pinvoke_map_write_lock;
8181

8282
MonoCoreRuntimeProperties MonodroidRuntime::monovm_core_properties = {
8383
.trusted_platform_assemblies = nullptr,
@@ -86,7 +86,7 @@ MonoCoreRuntimeProperties MonodroidRuntime::monovm_core_properties = {
8686
.pinvoke_override = &MonodroidRuntime::monodroid_pinvoke_override
8787
};
8888

89-
std::mutex MonodroidRuntime::dso_handle_write_lock;
89+
xamarin::android::mutex MonodroidRuntime::dso_handle_write_lock;
9090
bool MonodroidRuntime::startup_in_progress = true;
9191

9292
void

src/native/monodroid/monodroid-tracing.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace {
1515
decltype(xa_get_java_backtrace)* _xa_get_java_backtrace;
1616
decltype(xa_get_interesting_signal_handlers)* _xa_get_interesting_signal_handlers;
1717
bool tracing_init_done;
18-
std::mutex tracing_init_lock {};
18+
xamarin::android::mutex tracing_init_lock {};
1919
}
2020

2121
void

src/native/monodroid/startup-aware-lock.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace xamarin::android::internal
88
class StartupAwareLock final
99
{
1010
public:
11-
explicit StartupAwareLock (std::mutex &m)
11+
explicit StartupAwareLock (xamarin::android::mutex &m)
1212
: lock (m)
1313
{
1414
if (MonodroidRuntime::is_startup_in_progress ()) {
@@ -34,7 +34,7 @@ namespace xamarin::android::internal
3434
StartupAwareLock& operator= (StartupAwareLock const&) = delete;
3535

3636
private:
37-
std::mutex& lock;
37+
xamarin::android::mutex& lock;
3838
};
3939
}
4040
#endif

src/native/monodroid/timing-internal.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ namespace xamarin::android::internal
440440

441441
private:
442442
std::atomic_size_t next_event_index = 0;
443-
std::mutex event_vector_realloc_mutex;
443+
xamarin::android::mutex event_vector_realloc_mutex;
444444
std::vector<TimingEvent> events;
445445

446446
static TimingEvent init_time;

0 commit comments

Comments
 (0)