From 07341b50bc6c6455c4ed82ae782aece4de0b3912 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 16 Sep 2019 15:42:57 -0400 Subject: [PATCH] [wasm] Initial netcore support. (mono/mono#16718) * [runtime] Fix configure support for netcore+out of tree builds. Add wasm support for generating netcore/config.make. * [runtime] Add bundle support for the netcore assembly loader. * [netcore] Add missing linker exclusion. * [wasm] Add netcore builds, enabled by defining ENABLE_WASM_NETCORE in Make.config. The targets are 'package-wasm-runtime-netcore' and 'package-wasm-bcl-netcore'. The binaries are copied to out/wasm-runtime-netcore- and out/wasm-bcl/netcore. * [wasm] Add netcore support to the build system and packager. * Fix the build. * Fix the dynamic build. Commit migrated from https://github.com/mono/mono/commit/422d559ea45f2e7e998825da26c3fd79a03d5e99 --- src/mono/configure.ac | 15 ++++++++++++++- src/mono/mono/metadata/assembly.c | 17 +++++++++++++++++ .../src/LinkerDescriptor/System.Private.CoreLib.xml | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 27b740c..2ee1b2e 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -137,6 +137,7 @@ platform_tizen=no platform_ios=no host_darwin=no host_linux=no +build_darwin=no case "$host" in wasm32*) @@ -144,6 +145,11 @@ case "$host" in CPPFLAGS="$CPPFLAGS -D_REENTRANT -DUSE_MMAP -s WASM=1" libgc_threads=pthreads platform_wasm=yes + # FIXME: + RID="osx-x64" + COREARCH="x64" + CORETARGETS="-p:TargetsUnix=true -p:TargetsOSX=true" + build_darwin=yes ;; *-mingw*|*-*-cygwin*) AC_DEFINE(DISABLE_PORTABILITY,1,[Disable the io-portability layer]) @@ -6969,13 +6975,20 @@ if test x$buildsgen = xyes; then fi if test "x$with_core" = "xonly"; then + if test ! -d netcore; then + # Out of tree builds + mkdir -p netcore + echo "all:" > netcore/Makefile + fi echo "VERSION = $VERSION" > netcore/config.make echo "RID = $RID" >> netcore/config.make echo "COREARCH = $COREARCH" >> netcore/config.make echo "CORETARGETS = $CORETARGETS" >> netcore/config.make echo "MONO_CORLIB_VERSION = $MONO_CORLIB_VERSION" >> netcore/config.make - if test x$host_darwin = xyes; then + if test x$build_darwin = xyes; then + echo "HOST_PLATFORM ?= macos" >> netcore/config.make + elif test x$host_darwin = xyes; then echo "HOST_PLATFORM ?= macos" >> netcore/config.make elif test x$host_win32 = xyes; then echo "HOST_PLATFORM ?= win32" >> netcore/config.make diff --git a/src/mono/mono/metadata/assembly.c b/src/mono/mono/metadata/assembly.c index 8f6d029..fc76569 100644 --- a/src/mono/mono/metadata/assembly.c +++ b/src/mono/mono/metadata/assembly.c @@ -4459,6 +4459,11 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus * corlib = load_in_path (corlib_name, (const char**)assemblies_path, &req, status); } } + if (!corlib) { + /* Maybe its in a bundle */ + char *corlib_name = g_strdup_printf ("%s.dll", MONO_ASSEMBLY_CORLIB_NAME); + corlib = mono_assembly_request_open (corlib_name, &req, status); + } g_assert (corlib); #else // A nonstandard preload hook may provide a special mscorlib assembly @@ -4741,6 +4746,18 @@ mono_assembly_request_byname (MonoAssemblyName *aname, const MonoAssemblyByNameR } #else result = netcore_load_reference (aname, req->request.alc, req->requesting_assembly, !req->no_postload_search); + + if (!result && bundles != NULL) { + MonoImageOpenStatus status; + MonoImage *image; + image = mono_assembly_open_from_bundle (req->request.alc, aname->name, &status, FALSE); + if (!image) { + char *name = g_strdup_printf ("%s.dll", aname->name); + image = mono_assembly_open_from_bundle (req->request.alc, name, &status, FALSE); + } + if (image) + result = mono_assembly_request_load_from (image, aname->name, &req->request, &status); + } #endif return result; } diff --git a/src/mono/netcore/System.Private.CoreLib/src/LinkerDescriptor/System.Private.CoreLib.xml b/src/mono/netcore/System.Private.CoreLib/src/LinkerDescriptor/System.Private.CoreLib.xml index 548692c..3b1c78a 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/LinkerDescriptor/System.Private.CoreLib.xml +++ b/src/mono/netcore/System.Private.CoreLib/src/LinkerDescriptor/System.Private.CoreLib.xml @@ -28,6 +28,8 @@ + +