Skip to content

Commit e47a210

Browse files
committed
Works locally, let's see how it fares on CI
1 parent 6299dab commit e47a210

File tree

10 files changed

+33
-13
lines changed

10 files changed

+33
-13
lines changed

src/native/clr/host/host.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <runtime-base/dso-loader.hh>
2424
#include <runtime-base/jni-wrappers.hh>
2525
#include <runtime-base/logger.hh>
26+
#include <runtime-base/monodroid-dl.hh>
2627
#include <runtime-base/search.hh>
2728
#include <runtime-base/timing-internal.hh>
2829
#include <shared/log_types.hh>
@@ -432,6 +433,13 @@ void Host::Java_mono_android_Runtime_initInternal (
432433
gettid ()
433434
);
434435

436+
for (size_t i = 0; i < dso_jni_preloads_idx_count; i++) {
437+
DSOCacheEntry &entry = dso_cache[dso_jni_preloads_idx[i]];
438+
const std::string_view dso_name = MonodroidDl::get_dso_name (&entry);
439+
log_debug (LOG_ASSEMBLY, "Preloading JNI shared library: {}", dso_name);
440+
MonodroidDl::monodroid_dlopen (&entry, dso_name, RTLD_NOW);
441+
}
442+
435443
struct JnienvInitializeArgs init = {};
436444
init.javaVm = jvm;
437445
init.env = env;

src/native/clr/include/runtime-base/monodroid-dl.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace xamarin::android
7373
return find_dso_cache_entry_common<CacheKind::DSO> (hash);
7474
}
7575

76+
public:
7677
[[gnu::always_inline]]
7778
static auto get_dso_name (const DSOCacheEntry *const dso) -> std::string_view
7879
{
@@ -83,7 +84,6 @@ namespace xamarin::android
8384
return &dso_names_data[dso->name_index];
8485
}
8586

86-
public:
8787
[[gnu::flatten]]
8888
static auto monodroid_dlopen (DSOCacheEntry *dso, std::string_view const& name, int flags) noexcept -> void*
8989
{

src/native/clr/include/xamarin-app.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ extern "C" {
348348
[[gnu::visibility("default")]] extern AssemblyStoreRuntimeData assembly_store;
349349

350350
[[gnu::visibility("default")]] extern DSOCacheEntry dso_cache[];
351+
[[gnu::visibility("default")]] extern const uint dso_jni_preloads_idx_count;
352+
[[gnu::visibility("default")]] extern const uint dso_jni_preloads_idx[];
351353
[[gnu::visibility("default")]] extern DSOCacheEntry aot_dso_cache[];
352354
[[gnu::visibility("default")]] extern const char dso_names_data[];
353355
[[gnu::visibility("default")]] extern DSOApkEntry dso_apk_entries[];

src/native/clr/xamarin-app-stub/application_dso_stub.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ DSOCacheEntry dso_cache[] = {
127127
},
128128
};
129129

130+
const uint dso_jni_preloads_idx_count = 1;
131+
const uint dso_jni_preloads_idx[1] = {
132+
0
133+
};
134+
130135
DSOCacheEntry aot_dso_cache[] = {
131136
{
132137
.hash = xamarin::android::xxhash::hash (fake_dso_name, sizeof(fake_dso_name) - 1),

src/native/common/include/runtime-base/dso-loader.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ namespace xamarin::android {
7171
}
7272

7373
private:
74-
static auto load_jni_on_main_thread (std::string_view const& full_name, std::string const& undecorated_name) noexcept -> void*;
75-
7674
[[gnu::always_inline]]
7775
static auto log_and_return (void *handle, std::string_view const& full_name) -> void*
7876
{

src/native/common/runtime-base/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ set(LIB_NAME runtime-base-common)
22
set(LIB_ALIAS xa::runtime-base-common)
33

44
set(XA_RUNTIME_BASE_SOURCES
5-
dso-loader.cc
65
timing-internal.cc
76
)
87
add_clang_check_sources("${XA_RUNTIME_BASE_SOURCES}")

src/native/common/runtime-base/dso-loader.cc

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/native/mono/monodroid/monodroid-glue.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,15 @@ MonodroidRuntime::create_and_initialize_domain (JNIEnv* env, jclass runtimeClass
12241224
bool force_preload_assemblies, bool have_split_apks) noexcept
12251225
{
12261226
MonoDomain* domain = create_domain (env, runtimeApks, is_root_domain, have_split_apks);
1227+
1228+
for (size_t i = 0; i < dso_jni_preloads_idx_count; i++) {
1229+
DSOCacheEntry &entry = dso_cache[dso_jni_preloads_idx[i]];
1230+
1231+
log_debug (LOG_ASSEMBLY, "Preloading JNI shared library: {}", optional_string (entry.name));
1232+
char *err = nullptr;
1233+
MonodroidDl::monodroid_dlopen (&entry, entry.hash, entry.name, RTLD_NOW, &err);
1234+
}
1235+
12271236
// Asserting this on desktop apparently breaks a Designer test
12281237
abort_unless (domain != nullptr, "Failed to create AppDomain");
12291238

@@ -1439,6 +1448,7 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
14391448
log_debug (LOG_DEFAULT, "Using runtime path: {}", optional_string (AndroidSystem::get_runtime_libdir ()));
14401449
}
14411450

1451+
14421452
AndroidSystem::setup_process_args (runtimeApks);
14431453
mono_dl_fallback_register (MonodroidDl::monodroid_dlopen, MonodroidDl::monodroid_dlsym, nullptr, nullptr);
14441454

src/native/mono/xamarin-app-stub/application_dso_stub.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ DSOCacheEntry dso_cache[] = {
145145
},
146146
};
147147

148+
const uint dso_jni_preloads_idx_count = 1;
149+
const uint dso_jni_preloads_idx[1] = {
150+
0
151+
};
152+
148153
DSOCacheEntry aot_dso_cache[] = {
149154
{
150155
.hash = xamarin::android::xxhash::hash (fake_dso_name, sizeof(fake_dso_name) - 1),

src/native/mono/xamarin-app-stub/xamarin-app.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ MONO_API MONO_API_EXPORT AssemblyStoreSingleAssemblyRuntimeData assembly_store_b
341341
MONO_API MONO_API_EXPORT AssemblyStoreRuntimeData assembly_store;
342342

343343
MONO_API MONO_API_EXPORT DSOCacheEntry dso_cache[];
344+
MONO_API MONO_API_EXPORT const uint dso_jni_preloads_idx_count;
345+
MONO_API MONO_API_EXPORT const uint dso_jni_preloads_idx[];
344346
MONO_API MONO_API_EXPORT DSOCacheEntry aot_dso_cache[];
345347
MONO_API MONO_API_EXPORT DSOApkEntry dso_apk_entries[];
346348

0 commit comments

Comments
 (0)