Preload NI dlls in hydra
authorKonstantin Baladurin <k.baladurin@samsung.com>
Fri, 5 Jul 2019 15:35:15 +0000 (18:35 +0300)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Mon, 14 Oct 2019 21:58:17 +0000 (06:58 +0900)
NativeLauncher/CMakeLists.txt
NativeLauncher/dotnet.preload.list [new file with mode: 0644]
NativeLauncher/inc/coreclr_host.h
NativeLauncher/inc/launcher_env.h
NativeLauncher/launcher/dotnet/dotnet_launcher.cc
NativeLauncher/launcher/dotnet/dotnet_launcher.h
packaging/dotnet-launcher.spec

index 97d8eff..1819d86 100644 (file)
@@ -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 (file)
index 0000000..775f8ba
--- /dev/null
@@ -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
index 6a795ee..56f780b 100644 (file)
@@ -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__ */
index c295f2c..8c404d0 100644 (file)
@@ -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
index acd97cd..8cfe0a7 100644 (file)
@@ -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;
 }
 
index 88fb931..926f92c 100644 (file)
@@ -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;
index b888686..65e2480 100644 (file)
@@ -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