Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
path = external/debugger-libs
url = https://github.com/mono/debugger-libs
branch = master
[submodule "external/dlfcn-win32"]
path = external/dlfcn-win32
url = https://github.com/dlfcn-win32/dlfcn-win32.git
branch = v1.1.1
[submodule "external/Java.Interop"]
path = external/Java.Interop
url = https://github.com/xamarin/java.interop.git
Expand Down
3 changes: 3 additions & 0 deletions build-tools/installers/create-installers.targets
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
<_MSBuildFiles Include="$(MSBuildSrcDir)\javadoc-to-mdoc.pdb" Condition=" '$(PackageId)' != 'Microsoft.Android.Sdk' " />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Java.Interop.dll" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Java.Interop.pdb" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Java.Interop.Localization.dll" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Java.Interop.Localization.pdb" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Java.Interop.dll.config" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Java.Interop.Export.dll" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Java.Interop.Export.pdb" />
Expand Down Expand Up @@ -228,6 +230,7 @@
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Bindings.JarToXml.targets" Condition=" '$(PackageId)' != 'Microsoft.Android.Sdk' " />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Build.Tasks.dll" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Build.Tasks.pdb" />
<_MSBuildFiles Include="@(_LocalizationLanguages->'$(MSBuildSrcDir)\%(Identity)\Java.Interop.Localization.resources.dll')" />
<_MSBuildFiles Include="@(_LocalizationLanguages->'$(MSBuildSrcDir)\%(Identity)\Xamarin.Android.Build.Tasks.resources.dll')" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.BuildInfo.txt" />
<_MSBuildFiles Include="$(MSBuildSrcDir)\Xamarin.Android.Cecil.dll" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace Xamarin.Android.Prepare
class Step_BuildMingwDependencies : Step
{
static readonly SortedDictionary <string, (string description, string libraryName)> dependencies = new SortedDictionary <string, (string description, string libraryName)> (StringComparer.Ordinal) {
{ "dlfcn-win32", (description: "libdl for Windows", libraryName: "libdl.a") },
{ "mman-win32", (description: "mmap for Windows", libraryName: "libmman.a") },
};

Expand Down
21 changes: 0 additions & 21 deletions build-tools/xaprepare/xaprepare/ThirdPartyNotices/dlfcn.cs

This file was deleted.

1 change: 0 additions & 1 deletion build-tools/xaprepare/xaprepare/xaprepare.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
<Compile Include="Steps\Step_ThirdPartyNotices.cs" />
<Compile Include="ThirdPartyNotices\aapt2.cs" />
<Compile Include="ThirdPartyNotices\bundletool.cs" />
<Compile Include="ThirdPartyNotices\dlfcn.cs" />
<Compile Include="ThirdPartyNotices\Java.Interop.cs" />
<Compile Include="ThirdPartyNotices\K4os.Compression.LZ4.cs" />
<Compile Include="ThirdPartyNotices\lz4.cs" />
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop
1 change: 0 additions & 1 deletion external/dlfcn-win32
Submodule dlfcn-win32 deleted from ef7e41
9 changes: 6 additions & 3 deletions src/monodroid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ else()
if(WIN32 OR MINGW)
message(STATUS "Win32 or MinGW")
set(EXTRA_COMPILER_FLAGS "${EXTRA_COMPILER_FLAGS} -DWINDOWS -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA -fomit-frame-pointer")
set(EXTRA_LINKER_FLAGS "${EXTRA_LINKER_FLAGS} -ldl -lmman -static -pthread -dynamic -lmincore -lmswsock -lwsock32 -lshlwapi -lpsapi -lwinmm")
set(EXTRA_LINKER_FLAGS "${EXTRA_LINKER_FLAGS} -lmman -static -pthread -dynamic -lmincore -lmswsock -lwsock32 -lshlwapi -lpsapi -lwinmm")

if (MINGW_TARGET_32)
set(ANDROID_ABI "host-mxe-Win32")
Expand Down Expand Up @@ -298,6 +298,7 @@ set(MONODROID_SOURCES
${JAVA_INTEROP_SRC_PATH}/java-interop.cc
${JAVA_INTEROP_SRC_PATH}/java-interop-mono.cc
${JAVA_INTEROP_SRC_PATH}/java-interop-util.cc
${JAVA_INTEROP_SRC_PATH}/java-interop-dlfcn.cc
)

set(XA_INTERNAL_API_SOURCES
Expand Down Expand Up @@ -392,11 +393,13 @@ else()
set(LINK_LIBS "-lmonosgen-2.0 -lz ${EXTRA_LINKER_FLAGS}")
endif()

set(DEBUG_HELPER_LINK_LIBS "-ldl")
if(NOT MINGW AND NOT WIN32)
set(DEBUG_HELPER_LINK_LIBS "-ldl")
endif()
if(ENABLE_NDK)
set(LINK_LIBS "${LINK_LIBS} -llog")
set(DEBUG_HELPER_LINK_LIBS "${DEBUG_HELPER_LINK_LIBS} -llog")
elseif(NOT ANDROID)
elseif(NOT ANDROID AND NOT MINGW AND NOT WIN32)
set(LINK_LIBS "-pthread ${LINK_LIBS} -ldl")
endif()

Expand Down
20 changes: 12 additions & 8 deletions src/monodroid/jni/android-system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <errno.h>
#include <assert.h>
#include <ctype.h>
#include <dlfcn.h>
#include <fcntl.h>

#ifdef ANDROID
Expand All @@ -27,6 +26,8 @@
#include "jni-wrappers.hh"
#include "xamarin-app.hh"
#include "cpp-util.hh"
#include "java-interop-dlfcn.h"
#include "java-interop.h"

#if defined (DEBUG) || !defined (ANDROID)
namespace xamarin::android::internal {
Expand All @@ -39,6 +40,7 @@ namespace xamarin::android::internal {
}
#endif // DEBUG || !ANDROID

using namespace microsoft::java_interop;
using namespace xamarin::android;
using namespace xamarin::android::internal;

Expand Down Expand Up @@ -347,7 +349,7 @@ AndroidSystem::get_full_dso_path (const char *base_dir, const char *dso_path, bo
}

void*
AndroidSystem::load_dso (const char *path, int dl_flags, bool skip_exists_check)
AndroidSystem::load_dso (const char *path, unsigned int dl_flags, bool skip_exists_check)
{
if (path == nullptr || *path == '\0')
return nullptr;
Expand All @@ -358,14 +360,16 @@ AndroidSystem::load_dso (const char *path, int dl_flags, bool skip_exists_check)
return nullptr;
}

void *handle = dlopen (path, dl_flags);
char *error = nullptr;
void *handle = java_interop_lib_load (path, dl_flags, &error);
if (handle == nullptr && utils.should_log (LOG_ASSEMBLY))
log_info_nocheck (LOG_ASSEMBLY, "Failed to load shared library '%s'. %s", path, dlerror ());
log_info_nocheck (LOG_ASSEMBLY, "Failed to load shared library '%s'. %s", path, error);
java_interop_free (error);
return handle;
}

void*
AndroidSystem::load_dso_from_specified_dirs (const char **directories, size_t num_entries, const char *dso_name, int dl_flags)
AndroidSystem::load_dso_from_specified_dirs (const char **directories, size_t num_entries, const char *dso_name, unsigned int dl_flags)
{
assert (directories != nullptr);
if (dso_name == nullptr)
Expand All @@ -386,13 +390,13 @@ AndroidSystem::load_dso_from_specified_dirs (const char **directories, size_t nu
}

void*
AndroidSystem::load_dso_from_app_lib_dirs (const char *name, int dl_flags)
AndroidSystem::load_dso_from_app_lib_dirs (const char *name, unsigned int dl_flags)
{
return load_dso_from_specified_dirs (static_cast<const char**> (app_lib_directories), app_lib_directories_size, name, dl_flags);
}

void*
AndroidSystem::load_dso_from_override_dirs ([[maybe_unused]] const char *name, [[maybe_unused]] int dl_flags)
AndroidSystem::load_dso_from_override_dirs ([[maybe_unused]] const char *name, [[maybe_unused]] unsigned int dl_flags)
{
#ifdef RELEASE
return nullptr;
Expand All @@ -402,7 +406,7 @@ AndroidSystem::load_dso_from_override_dirs ([[maybe_unused]] const char *name, [
}

void*
AndroidSystem::load_dso_from_any_directories (const char *name, int dl_flags)
AndroidSystem::load_dso_from_any_directories (const char *name, unsigned int dl_flags)
{
void *handle = load_dso_from_override_dirs (name, dl_flags);
if (handle == nullptr)
Expand Down
10 changes: 5 additions & 5 deletions src/monodroid/jni/android-system.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ namespace xamarin::android::internal
char* get_bundled_app (JNIEnv *env, jstring dir);
int count_override_assemblies ();
long get_gref_gc_threshold ();
void* load_dso (const char *path, int dl_flags, bool skip_exists_check);
void* load_dso_from_any_directories (const char *name, int dl_flags);
void* load_dso (const char *path, unsigned int dl_flags, bool skip_exists_check);
void* load_dso_from_any_directories (const char *name, unsigned int dl_flags);
char* get_full_dso_path_on_disk (const char *dso_name, bool &needs_free);
monodroid_dirent_t* readdir (monodroid_dir_t *dir);

Expand Down Expand Up @@ -118,9 +118,9 @@ namespace xamarin::android::internal
size_t _monodroid_get_system_property_from_file (const char *path, char **value);
#endif
char* get_full_dso_path (const char *base_dir, const char *dso_path, bool &needs_free);
void* load_dso_from_specified_dirs (const char **directories, size_t num_entries, const char *dso_name, int dl_flags);
void* load_dso_from_app_lib_dirs (const char *name, int dl_flags);
void* load_dso_from_override_dirs (const char *name, int dl_flags);
void* load_dso_from_specified_dirs (const char **directories, size_t num_entries, const char *dso_name, unsigned int dl_flags);
void* load_dso_from_app_lib_dirs (const char *name, unsigned int dl_flags);
void* load_dso_from_override_dirs (const char *name, unsigned int dl_flags);
char* get_existing_dso_path_on_disk (const char *base_dir, const char *dso_name, bool &needs_free);

#if defined (WINDOWS)
Expand Down
14 changes: 10 additions & 4 deletions src/monodroid/jni/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
#include <ctype.h>
#include <assert.h>
#include <limits.h>
#include <dlfcn.h>
#include <mono/metadata/mono-debug.h>

#ifdef ANDROID
#include <android/log.h>
#endif

#if defined (APPLE_OS_X)
#include <dlfcn.h>
#endif // def APPLE_OX_X

#include "java-interop-util.h"

#include "monodroid.h"
Expand All @@ -42,6 +45,9 @@
#include "globals.hh"
#include "cpp-util.hh"

#include "java-interop-dlfcn.h"

using namespace microsoft::java_interop;
using namespace xamarin::android;

//
Expand Down Expand Up @@ -79,7 +85,7 @@ Debug::monodroid_profiler_load (const char *libmono_path, const char *desc, cons
}
simple_pointer_guard<char[]> mname (mname_ptr);

int dlopen_flags = RTLD_LAZY;
unsigned int dlopen_flags = JAVA_INTEROP_LIB_LOAD_LOCALLY;
simple_pointer_guard<char[]> libname (utils.string_concat ("libmono-profiler-", mname.get (), ".so"));
bool found = false;
void *handle = androidSystem.load_dso_from_any_directories (libname, dlopen_flags);
Expand Down Expand Up @@ -108,7 +114,7 @@ typedef void (*ProfilerInitializer) (const char*);
bool
Debug::load_profiler (void *handle, const char *desc, const char *symbol)
{
ProfilerInitializer func = reinterpret_cast<ProfilerInitializer> (dlsym (handle, symbol));
ProfilerInitializer func = reinterpret_cast<ProfilerInitializer> (java_interop_lib_symbol (handle, symbol, nullptr));
log_warn (LOG_DEFAULT, "Looking for profiler init symbol '%s'? %p", symbol, func);

if (func != nullptr) {
Expand All @@ -129,7 +135,7 @@ Debug::load_profiler_from_handle (void *dso_handle, const char *desc, const char

if (result)
return true;
dlclose (dso_handle);
java_interop_lib_close (dso_handle, nullptr);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/monodroid/jni/monodroid-glue-internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace xamarin::android::internal
char* get_java_class_name_for_TypeManager (jclass klass);

private:
int convert_dl_flags (int flags);
unsigned int convert_dl_flags (int flags);
#if defined (WINDOWS) || defined (APPLE_OS_X)
static const char* get_my_location ();
#endif // defined(WINDOWS) || defined(APPLE_OS_X)
Expand Down
Loading