From 99eee1521aad086f0d7fe58eaae645e3efc676f4 Mon Sep 17 00:00:00 2001 From: Konstantin Baladurin Date: Fri, 5 Jul 2019 18:35:15 +0300 Subject: [PATCH] Preload NI dlls in hydra --- NativeLauncher/CMakeLists.txt | 3 +++ NativeLauncher/dotnet.preload.list | 31 +++++++++++++++++++++++ NativeLauncher/inc/coreclr_host.h | 3 +++ NativeLauncher/inc/launcher_env.h | 1 + NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 22 ++++++++++++++++ NativeLauncher/launcher/dotnet/dotnet_launcher.h | 1 + packaging/dotnet-launcher.spec | 1 + 7 files changed, 62 insertions(+) create mode 100644 NativeLauncher/dotnet.preload.list diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index 97d8eff..1819d86 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -54,6 +54,8 @@ IF(DEFINED DEFAULT_BASE_ADDR_START) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDEFAULT_BASE_ADDR_START=${DEFAULT_BASE_ADDR_START}") ENDIF(DEFINED DEFAULT_BASE_ADDR_START) +ADD_DEFINITIONS(-DLOADERDIR="${LOADERDIR}") + OPTION(NOT_USE_FUNCTION "Remove build warning" OFF) IF(NOT_USE_FUNCTION) ADD_DEFINITIONS("-DNOT_USE_FUNCTION") @@ -187,3 +189,4 @@ INSTALL(FILES inc/ni_common.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES inc/tac_common.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES ../dotnet-launcher.pc DESTINATION ${LIBDIR}/pkgconfig) INSTALL(FILES dotnet-launcher.info DESTINATION /usr/share/parser-plugins) +INSTALL(FILES dotnet.preload.list DESTINATION ${LOADERDIR}) diff --git a/NativeLauncher/dotnet.preload.list b/NativeLauncher/dotnet.preload.list new file mode 100644 index 0000000..775f8ba --- /dev/null +++ b/NativeLauncher/dotnet.preload.list @@ -0,0 +1,31 @@ +/usr/share/dotnet.tizen/netcoreapp/System.Private.CoreLib.dll +/usr/share/dotnet.tizen/netcoreapp/System.Private.Xml.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Private.Uri.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Collections.ni.dll +/usr/share/dotnet.tizen/netcoreapp/SOS.NETCore.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Security.Cryptography.Primitives.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Reflection.Extensions.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Diagnostics.Debug.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Security.Cryptography.Algorithms.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Runtime.Extensions.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Threading.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Console.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Text.RegularExpressions.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Collections.Concurrent.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Reflection.Metadata.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Threading.Tasks.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Threading.Thread.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Runtime.InteropServices.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Private.DataContractSerialization.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Linq.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Threading.Timer.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Linq.Expressions.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.Runtime.ni.dll +/usr/share/dotnet.tizen/netcoreapp/System.IO.FileSystem.ni.dll +/usr/share/dotnet.tizen/framework/Tizen.Applications.Common.ni.dll +/usr/share/dotnet.tizen/framework/ElmSharp.ni.dll +/usr/share/dotnet.tizen/framework/Tizen.System.Information.ni.dll +/usr/share/dotnet.tizen/framework/Tizen.ni.dll +/usr/share/dotnet.tizen/framework/Tizen.Applications.UI.ni.dll +/usr/share/dotnet.tizen/framework/Tizen.Applications.Service.ni.dll \ No newline at end of file diff --git a/NativeLauncher/inc/coreclr_host.h b/NativeLauncher/inc/coreclr_host.h index 6a795ee..56f780b 100644 --- a/NativeLauncher/inc/coreclr_host.h +++ b/NativeLauncher/inc/coreclr_host.h @@ -58,6 +58,9 @@ extern "C" int cbMultiByte, char16_t * lpWideCharStr, int cchWideChar); + + typedef int (*coreclr_preload_assembly_ptr)( + const char* assemblyPath); } #endif /* __CORECLR_HOST_H__ */ diff --git a/NativeLauncher/inc/launcher_env.h b/NativeLauncher/inc/launcher_env.h index c295f2c..8c404d0 100644 --- a/NativeLauncher/inc/launcher_env.h +++ b/NativeLauncher/inc/launcher_env.h @@ -31,5 +31,6 @@ #define TIZEN_DOTNET_SDK_NUGET "Tizen.NET.Sdk" #define NET_STANDARD_LIBRARY_NUGET "NETStandard.Library" #define PLATFORM_TPA_CACHE "/usr/share/dotnet.tizen/lib/platform_tpa_cache" +#define AOT_PRELOAD_PATH LOADERDIR "/dotnet.preload.list" #endif //__LAUNCHER_ENV_H_ \ No newline at end of file diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index acd97cd..8cfe0a7 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -252,6 +252,7 @@ CoreRuntime::CoreRuntime(const char* mode) : shutdown(nullptr), createDelegate(nullptr), setEnvironmentVariable(nullptr), + preloadAssembly(nullptr), __coreclrLib(nullptr), __hostHandle(nullptr), __domainId(-1), @@ -375,11 +376,32 @@ int CoreRuntime::preinitialize(bool standalone) CORELIB_RETURN_IF_NOSYM(coreclr_execute_assembly_ptr, executeAssembly, "coreclr_execute_assembly"); CORELIB_RETURN_IF_NOSYM(coreclr_shutdown_ptr, shutdown, "coreclr_shutdown"); CORELIB_RETURN_IF_NOSYM(coreclr_create_delegate_ptr, createDelegate, "coreclr_create_delegate"); + CORELIB_RETURN_IF_NOSYM(coreclr_preload_assembly_ptr, preloadAssembly, "coreclr_preload_assembly"); #undef CORELIB_RETURN_IF_NOSYM _INFO("libcoreclr dlopen and dlsym success"); +#define PRELOAD_IMAGE(path) \ + do { \ + int st = preloadAssembly(path); \ + if (st != 0) { \ + _ERR("preload of %s failed! (0x%08x)", path, st); \ + } else { \ + _DBG("preload of %s succeded", path); \ + } \ + } while (0) + + std::ifstream preloadList(AOT_PRELOAD_PATH); + if (preloadList) { + std::string path; + while (getline(preloadList, path)) { + PRELOAD_IMAGE(path.c_str()); + } + } + +#undef PRELOAD_IMAGE + return 0; } diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.h b/NativeLauncher/launcher/dotnet/dotnet_launcher.h index 88fb931..926f92c 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.h +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.h @@ -44,6 +44,7 @@ class CoreRuntime coreclr_shutdown_ptr shutdown; coreclr_create_delegate_ptr createDelegate; set_environment_variable_ptr setEnvironmentVariable; + coreclr_preload_assembly_ptr preloadAssembly; std::string __nativeLibDirectory; void* __coreclrLib; void* __hostHandle; diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index b888686..65e2480 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -145,6 +145,7 @@ chsmack -t -a User::App::Shared /opt/etc/skel/.dotnet %{_loaderdir}/dotnet.loader %{_loaderdir}/dotnet.launcher %{_loaderdir}/dotnet.debugger +%{_loaderdir}/dotnet.preload.list %{_native_lib_dir}/libsqlite3.so %{_bindir}/nitool %{_bindir}/tpatool -- 2.7.4