From c996d5ef25e5336d21d33ecdc5da7d90de32be00 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 15 Apr 2020 11:14:10 -0300 Subject: [PATCH 01/49] Implementation the linking of shim globalization into mono runtime. --- .../Common/src/Interop/Interop.Libraries.cs | 4 ++ src/mono/configure.ac | 38 +++++++++++++++++++ src/mono/mono/metadata/Makefile.am | 28 ++++++++++++-- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Interop.Libraries.cs index 4fee38ad35bd22..9a64a909e35ca8 100644 --- a/src/libraries/Common/src/Interop/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Interop.Libraries.cs @@ -6,6 +6,10 @@ internal static partial class Interop { internal static partial class Libraries { +#if MONO + internal const string GlobalizationNative = "__Internal"; +#else internal const string GlobalizationNative = "libSystem.Globalization.Native"; +#endif } } diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 22c584cf76fd4c..26d2899c2e737d 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6783,6 +6783,44 @@ AC_COMPILE_IFELSE( AC_MSG_RESULT(no) ]) +# for icu shim +if test x$target_osx = xyes; then + ORIG_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" + AC_CHECK_LIB(icucore, ucol_open, [], + [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) + + AC_DEFINE(ICU_LIBS, -licucore, [adding -licucore]) + + AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) + if test x$have_sys_icu = xyes; then + ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" + AC_MSG_NOTICE($ICU_CFLAGS) + AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + fi + CPPFLAGS=$ORIG_CPPFLAGS +elif test x$host_win32 = xyes; then + echo "TODO" +elif test x$host_linux = xyes; then + ORIG_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" + + AC_CHECK_LIB(icuuc, main, [], + [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) + AC_CHECK_LIB(icui18n, main, [], + [AC_MSG_ERROR([Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform).])]) + + AC_DEFINE(ICU_LIBS, [-licuuc, -licui18n], [adding -licuuc and -licui18n]) + + AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) + if test x$have_sys_icu = xyes; then + ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" + AC_MSG_NOTICE($ICU_CFLAGS) + AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + fi + CPPFLAGS=$ORIG_CPPFLAGS +fi + AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) diff --git a/src/mono/mono/metadata/Makefile.am b/src/mono/mono/metadata/Makefile.am index 0415d87bee410c..2618809c531fa6 100644 --- a/src/mono/mono/metadata/Makefile.am +++ b/src/mono/mono/metadata/Makefile.am @@ -103,7 +103,11 @@ Z_LIBS=$(BUNDLE_ZLIB_PATH) endif endif -noinst_LTLIBRARIES = libmonoruntime-config.la $(support_libraries) $(boehm_libraries) $(sgen_libraries) +if HAVE_SYS_ICU +ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native +endif + +noinst_LTLIBRARIES = libmonoruntime-config.la $(support_libraries) $(boehm_libraries) $(sgen_libraries) $(shim_libraries) lib_LTLIBRARIES = $(icall_table_libraries) $(ilgen_libraries) @@ -136,6 +140,24 @@ libmonoruntime_support_la_SOURCES = support.c libmonoruntime_support_la_LDFLAGS = $(Z_LIBS) libmonoruntime_support_la_CFLAGS = $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @ZLIB_CFLAGS@ +shim_libraries = libmonoruntime-shimglobalization.la + +libmonoruntime_shimglobalization_la_SOURCES = \ + $(ICU_SHIM_PATH)/pal_calendarData.c \ + $(ICU_SHIM_PATH)/pal_casing.c \ + $(ICU_SHIM_PATH)/pal_collation.c \ + $(ICU_SHIM_PATH)/pal_idna.c \ + $(ICU_SHIM_PATH)/pal_locale.c \ + $(ICU_SHIM_PATH)/pal_localeNumberData.c \ + $(ICU_SHIM_PATH)/pal_localeStringData.c \ + $(ICU_SHIM_PATH)/pal_normalization.c \ + $(ICU_SHIM_PATH)/pal_timeZoneInfo.c \ + $(ICU_SHIM_PATH)/pal_icushim.c + +libmonoruntime_shimglobalization_la_LDFLAGS = $(ICU_LIBS) +libmonoruntime_shimglobalization_la_CPPFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/Common/ + + # # This library contains the icall tables if the runtime was configured with --disable-icall-tables # @@ -424,12 +446,12 @@ if !ENABLE_MSVC_ONLY libmonoruntime_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources) # Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342. libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES) @CXX_ADD_CFLAGS@ -libmonoruntime_la_LIBADD = libmonoruntime-config.la $(support_libraries) +libmonoruntime_la_LIBADD = libmonoruntime-config.la $(support_libraries) $(shim_libraries) libmonoruntimesgen_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(sgen_sources) # Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342. libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES) @CXX_ADD_CFLAGS@ -libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la $(support_libraries) +libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la $(support_libraries) $(shim_libraries) endif # !ENABLE_MSVC_ONLY From fc6ec08ba3188fd5db0858b9254a7997c7252de0 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 15 Apr 2020 11:15:16 -0300 Subject: [PATCH 02/49] Adding ICU_CFLAGS to configure.ac --- src/mono/configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 26d2899c2e737d..3432b3bc01dc68 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6826,6 +6826,7 @@ AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(CCLDFLAGS) AC_SUBST(ZLIB_CFLAGS) +AC_SUBST(ICU_CFLAGS) # Update all submodules recursively to ensure everything is checked out if test "x$with_core" != "xonly"; then From da6f76688a120a02d10973c7aa8000ee8ae24686 Mon Sep 17 00:00:00 2001 From: thaystg Date: Fri, 17 Apr 2020 17:25:02 -0300 Subject: [PATCH 03/49] Implementing globalization shim linked on mono runtime on windows. --- src/mono/msvc/libmono-dynamic.vcxproj | 14 +-- src/mono/msvc/libmonoruntime.targets | 1 + src/mono/msvc/libmonoruntime.targets.filters | 1 + src/mono/msvc/libmonoruntime.vcxproj | 16 ++-- src/mono/msvc/mono.props | 2 + src/mono/msvc/shimglobalization.targets | 53 +++++++++++ .../msvc/shimglobalization.targets.filters | 91 +++++++++++++++++++ .../GlobalizationMode.Windows.Mono.cs | 29 +++++- 8 files changed, 189 insertions(+), 18 deletions(-) create mode 100644 src/mono/msvc/shimglobalization.targets create mode 100644 src/mono/msvc/shimglobalization.targets.filters diff --git a/src/mono/msvc/libmono-dynamic.vcxproj b/src/mono/msvc/libmono-dynamic.vcxproj index 3b1fab1c678a23..e00fd9ccacd863 100644 --- a/src/mono/msvc/libmono-dynamic.vcxproj +++ b/src/mono/msvc/libmono-dynamic.vcxproj @@ -96,8 +96,8 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -123,8 +123,8 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_COMMON);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -147,8 +147,8 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C true Level3 true @@ -177,7 +177,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C true Level3 true diff --git a/src/mono/msvc/libmonoruntime.targets b/src/mono/msvc/libmonoruntime.targets index ba371e200fef98..bc85f8c87451e6 100644 --- a/src/mono/msvc/libmonoruntime.targets +++ b/src/mono/msvc/libmonoruntime.targets @@ -1,6 +1,7 @@ + diff --git a/src/mono/msvc/libmonoruntime.targets.filters b/src/mono/msvc/libmonoruntime.targets.filters index 870a2b19f6e217..3ac39f156fdaee 100644 --- a/src/mono/msvc/libmonoruntime.targets.filters +++ b/src/mono/msvc/libmonoruntime.targets.filters @@ -1,6 +1,7 @@  + diff --git a/src/mono/msvc/libmonoruntime.vcxproj b/src/mono/msvc/libmonoruntime.vcxproj index 4c009edd823914..ee9c76b39570d8 100644 --- a/src/mono/msvc/libmonoruntime.vcxproj +++ b/src/mono/msvc/libmonoruntime.vcxproj @@ -97,8 +97,8 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -111,8 +111,8 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION_COMMON));%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -125,8 +125,8 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true @@ -141,8 +141,8 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions;TARGET_WINDOWS;PALEXPORT=EXTERN_C + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true diff --git a/src/mono/msvc/mono.props b/src/mono/msvc/mono.props index e71f2cc330d6db..a870529a5689b8 100644 --- a/src/mono/msvc/mono.props +++ b/src/mono/msvc/mono.props @@ -45,6 +45,8 @@ $(MONO_LIBGC_INCLUDE_DIR) $(MONO_EGLIB_SOURCE_DIR) 610 + $(top_srcdir)/../libraries/Native/Unix/System.Globalization.Native + $(top_srcdir)/../libraries/Native/Unix/Common $(MONO_DIR)/external/llvm-project/llvm/include diff --git a/src/mono/msvc/shimglobalization.targets b/src/mono/msvc/shimglobalization.targets new file mode 100644 index 00000000000000..18cdd4aafc832a --- /dev/null +++ b/src/mono/msvc/shimglobalization.targets @@ -0,0 +1,53 @@ + + + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + CompileAsCpp + + + + + + + + + + + + + + + + + + diff --git a/src/mono/msvc/shimglobalization.targets.filters b/src/mono/msvc/shimglobalization.targets.filters new file mode 100644 index 00000000000000..7b3baefee83353 --- /dev/null +++ b/src/mono/msvc/shimglobalization.targets.filters @@ -0,0 +1,91 @@ + + + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Source Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + Header Files$(MonoRuntimeFilterSubFolder)\shimglobalization + + + + + + + + + + + diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs index 5aaa1431703762..90d85339704df0 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs @@ -1,16 +1,39 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Runtime.CompilerServices; + namespace System.Globalization { internal partial class GlobalizationMode { - internal static bool UseNls => true; - + internal static bool UseNls { + get { + return !Invariant && Interop.Globalization.LoadICU() == 0; + } + } private static bool GetGlobalizationInvariantMode() { - return GetInvariantSwitchValue(); + bool invariantEnabled = GetInvariantSwitchValue(); + if (invariantEnabled) + return true; + + LoadICU(); + return false; + } + + // Keep this in a separate method to avoid loading the native lib in invariant mode + [MethodImpl(MethodImplOptions.NoInlining)] + private static void LoadICU() + { + int res = Interop.Globalization.LoadICU(); + if (res == 0) + { + string message = "Couldn't find a valid ICU package installed on the system. " + + "Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support."; + Environment.FailFast(message); + } } } } From 6f0bb5cb534625151afe17d7bbaafbba07a2def6 Mon Sep 17 00:00:00 2001 From: thaystg Date: Sat, 25 Apr 2020 10:55:39 -0300 Subject: [PATCH 04/49] Implementing ICU shim on mono on windows. --- .../Common/src/Interop/Interop.Calendar.cs | 25 +- .../Common/src/Interop/Interop.Casing.cs | 14 +- .../Common/src/Interop/Interop.Collation.cs | 63 ++++- .../Common/src/Interop/Interop.ICU.cs | 11 +- .../Common/src/Interop/Interop.Idna.cs | 9 + .../Common/src/Interop/Interop.Locale.cs | 38 ++- .../src/Interop/Interop.Normalization.cs | 9 + .../src/Interop/Interop.TimeZoneInfo.cs | 6 +- .../System.Globalization.Native/pal_icushim.c | 1 + src/mono/mono/metadata/icall-table.h | 11 + src/mono/mono/metadata/icall.c | 250 ++++++++++++++++++ src/mono/mono/metadata/object-internals.h | 3 + src/mono/mono/metadata/object.c | 6 + src/mono/msvc/libmono-dynamic.vcxproj | 6 +- src/mono/msvc/libmonoruntime.vcxproj | 8 +- 15 files changed, 432 insertions(+), 28 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Calendar.cs b/src/libraries/Common/src/Interop/Interop.Calendar.cs index 0b9e2c283f0f89..c1256c92468a35 100644 --- a/src/libraries/Common/src/Interop/Interop.Calendar.cs +++ b/src/libraries/Common/src/Interop/Interop.Calendar.cs @@ -5,6 +5,7 @@ using System; using System.Globalization; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { @@ -13,20 +14,36 @@ internal static partial class Globalization internal delegate void EnumCalendarInfoCallback( [MarshalAs(UnmanagedType.LPWStr)] string calendarString, IntPtr context); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetCalendars")] +#endif internal static extern int GetCalendars(string localeName, CalendarId[] calendars, int calendarsCapacity); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetCalendarInfo")] +#endif internal static extern unsafe ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char* result, int resultCapacity); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EnumCalendarInfo")] +#endif internal static extern bool EnumCalendarInfo(EnumCalendarInfoCallback callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")] +#endif internal static extern int GetLatestJapaneseEra(); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetJapaneseEraStartDate")] +#endif internal static extern bool GetJapaneseEraStartDate(int era, out int startYear, out int startMonth, out int startDay); } } diff --git a/src/libraries/Common/src/Interop/Interop.Casing.cs b/src/libraries/Common/src/Interop/Interop.Casing.cs index 499f9445d89ceb..880c7b0df0e635 100644 --- a/src/libraries/Common/src/Interop/Interop.Casing.cs +++ b/src/libraries/Common/src/Interop/Interop.Casing.cs @@ -3,18 +3,30 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCase")] +#endif internal static extern unsafe void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCaseInvariant")] +#endif internal static extern unsafe void ChangeCaseInvariant(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCaseTurkish")] +#endif internal static extern unsafe void ChangeCaseTurkish(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); } } diff --git a/src/libraries/Common/src/Interop/Interop.Collation.cs b/src/libraries/Common/src/Interop/Interop.Collation.cs index a59292e0fca1df..b73652ddcb3a7b 100644 --- a/src/libraries/Common/src/Interop/Interop.Collation.cs +++ b/src/libraries/Common/src/Interop/Interop.Collation.cs @@ -5,54 +5,97 @@ using System; using System.Globalization; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Ansi, EntryPoint = "GlobalizationNative_GetSortHandle")] +#endif internal static extern unsafe ResultCode GetSortHandle(string localeName, out IntPtr sortHandle); [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CloseSortHandle")] internal static extern unsafe void CloseSortHandle(IntPtr handle); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareString")] +#endif internal static extern unsafe int CompareString(IntPtr sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOf")] +#endif internal static extern unsafe int IndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")] +#endif internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")] +#endif internal static extern unsafe int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")] +#endif internal static extern unsafe int IndexOfOrdinalIgnoreCase(char* target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool StartsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool EndsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool StartsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool EndsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetSortKey")] +#endif internal static extern unsafe int GetSortKey(IntPtr sortHandle, char* str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareStringOrdinalIgnoreCase")] +#endif internal static extern unsafe int CompareStringOrdinalIgnoreCase(char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortVersion")] +#endif internal static extern int GetSortVersion(IntPtr sortHandle); } } diff --git a/src/libraries/Common/src/Interop/Interop.ICU.cs b/src/libraries/Common/src/Interop/Interop.ICU.cs index 0dce072958a7fa..ac99d8b8d41b6a 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.cs @@ -3,15 +3,24 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { - [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICU")] +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else + [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")] +#endif internal static extern int LoadICU(); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")] +#endif internal static extern int GetICUVersion(); } } diff --git a/src/libraries/Common/src/Interop/Interop.Idna.cs b/src/libraries/Common/src/Interop/Interop.Idna.cs index e9014da1e5d9e6..f46057531f1908 100644 --- a/src/libraries/Common/src/Interop/Interop.Idna.cs +++ b/src/libraries/Common/src/Interop/Interop.Idna.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { @@ -11,10 +12,18 @@ internal static partial class Globalization internal const int AllowUnassigned = 0x1; internal const int UseStd3AsciiRules = 0x2; +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ToAscii")] +#endif internal static extern unsafe int ToAscii(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ToUnicode")] +#endif internal static extern unsafe int ToUnicode(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity); } } diff --git a/src/libraries/Common/src/Interop/Interop.Locale.cs b/src/libraries/Common/src/Interop/Interop.Locale.cs index a6517185ce0632..b62eb775d86be6 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.cs @@ -3,40 +3,70 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleName")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool GetLocaleName(string localeName, char* value, int valueLength); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoString")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool GetLocaleInfoString(string localeName, uint localeStringData, char* value, int valueLength); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetDefaultLocaleName")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool GetDefaultLocaleName(char* value, int valueLength); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IsPredefinedLocale")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool IsPredefinedLocale(string localeName); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleTimeFormat")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern unsafe bool GetLocaleTimeFormat(string localeName, bool shortFormat, char* value, int valueLength); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoInt")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern bool GetLocaleInfoInt(string localeName, uint localeNumberData, ref int value); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoGroupingSizes")] [return: MarshalAs(UnmanagedType.Bool)] +#endif internal static extern bool GetLocaleInfoGroupingSizes(string localeName, uint localeGroupingData, ref int primaryGroupSize, ref int secondaryGroupSize); - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocales")] - internal static extern int GetLocales([Out] char[]? value, int valueLength); +#endif + internal static extern int GetLocales(char[]? value, int valueLength); } } diff --git a/src/libraries/Common/src/Interop/Interop.Normalization.cs b/src/libraries/Common/src/Interop/Interop.Normalization.cs index f981eac6405db3..4829d647483851 100644 --- a/src/libraries/Common/src/Interop/Interop.Normalization.cs +++ b/src/libraries/Common/src/Interop/Interop.Normalization.cs @@ -3,16 +3,25 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; using System.Text; internal static partial class Interop { internal static partial class Globalization { +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IsNormalized")] +#endif internal static extern unsafe int IsNormalized(NormalizationForm normalizationForm, char* src, int srcLen); +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_NormalizeString")] +#endif internal static extern unsafe int NormalizeString(NormalizationForm normalizationForm, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity); } } diff --git a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs index f60b81f0da8cf6..5c0ec21c0ce98f 100644 --- a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs +++ b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { @@ -15,8 +16,11 @@ internal enum TimeZoneDisplayNameType Standard = 1, DaylightSavings = 2, } - +#if MONO + [MethodImplAttribute(MethodImplOptions.InternalCall)] +#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetTimeZoneDisplayName")] +#endif internal static extern unsafe ResultCode GetTimeZoneDisplayName( string localeName, string timeZoneId, diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c index fbea9cf6ca87f4..68afaabc2e254c 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c @@ -6,6 +6,7 @@ #if defined(TARGET_UNIX) #include #elif defined(TARGET_WINDOWS) +#include #include #include #include diff --git a/src/mono/mono/metadata/icall-table.h b/src/mono/mono/metadata/icall-table.h index 48587adfd3838b..8469c169b142b7 100644 --- a/src/mono/mono/metadata/icall-table.h +++ b/src/mono/mono/metadata/icall-table.h @@ -76,6 +76,9 @@ typedef gint32 *gint32_ref; typedef gint64 *gint64_ref; typedef gpointer *gpointer_ref; typedef gsize *gsize_ref; +typedef guint16 *guint16_ref; +typedef guint8 *guint8_ref; +typedef const guint16_ref *const_guint16_ref; typedef guint32 *guint32_ref; typedef guint64 *guint64_ref; typedef int *int_ref; @@ -85,6 +88,8 @@ typedef MonoClassField *MonoClassField_ref; typedef MonoEvent *MonoEvent_ref; typedef MonoEventInfo *MonoEventInfo_ref; typedef MonoGenericParamInfo *MonoGenericParamInfo_ptr; +typedef MonoIntPtr *MonoIntPtr_ref; +typedef MonoIntPtr **MonoIntPtr_ptr; typedef MonoMethod *MonoMethod_ref; typedef MonoMethodInfo *MonoMethodInfo_ref; typedef MonoResolveTokenError *MonoResolveTokenError_ref; @@ -136,6 +141,8 @@ typedef MonoStringHandle MonoStringOutHandle; #define MONO_HANDLE_TYPE_WRAP_guchar_ptr ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_guint ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_const_guchar_ptr ICALL_HANDLES_WRAP_NONE +#define MONO_HANDLE_TYPE_WRAP_const_guint16_ref ICALL_HANDLES_WRAP_NONE +#define MONO_HANDLE_TYPE_WRAP_guint16 ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_guint32 ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_guint64 ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_int ICALL_HANDLES_WRAP_NONE @@ -164,6 +171,7 @@ typedef MonoStringHandle MonoStringOutHandle; #define MONO_HANDLE_TYPE_WRAP_MonoMethodInfo_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoPropertyInfo_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoType_ref ICALL_HANDLES_WRAP_VALUETYPE_REF +#define MONO_HANDLE_TYPE_WRAP_MonoIntPtr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoTypedRef_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_gint32_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_gint64_ref ICALL_HANDLES_WRAP_VALUETYPE_REF @@ -171,12 +179,15 @@ typedef MonoStringHandle MonoStringOutHandle; #define MONO_HANDLE_TYPE_WRAP_gsize_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_guint32_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_guint64_ref ICALL_HANDLES_WRAP_VALUETYPE_REF +#define MONO_HANDLE_TYPE_WRAP_guint16_ref ICALL_HANDLES_WRAP_VALUETYPE_REF +#define MONO_HANDLE_TYPE_WRAP_guint8_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_int_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_gint32_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_int_ptr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_char_ptr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_guint8_ptr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoResolveTokenError_ref ICALL_HANDLES_WRAP_VALUETYPE_REF +#define MONO_HANDLE_TYPE_WRAP_MonoIntPtr_ptr ICALL_HANDLES_WRAP_VALUETYPE_REF // HANDLE is not used just to avoid duplicate typedef warnings with some compilers. // gpointer == void* == HANDLE == FILE_HANDLE == PROCESS_HANDLE. diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index a39cf2c832d26a..5b4de18db44636 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -120,6 +120,24 @@ #include "mono/metadata/icall-signatures.h" #include "mono/utils/mono-signal-handler.h" +#ifdef ENABLE_NETCORE +#include +typedef uint16_t UChar; + +#include "pal_locale.h" +#include "pal_calendarData.h" +#include "pal_casing.h" +#include "pal_collation.h" +#include "pal_locale.h" +#include "pal_localeNumberData.h" +#include "pal_localeStringData.h" +#include "pal_icushim.h" +#include "pal_idna.h" +#include "pal_normalization.h" +#include "pal_timeZoneInfo.h" + +#endif + #if _MSC_VER #pragma warning(disable:4047) // FIXME differs in levels of indirection #endif @@ -3541,7 +3559,239 @@ ves_icall_System_RuntimeType_IsWindowsRuntimeObjectType (MonoError *error) mono_error_set_not_implemented (error, "%s", "System.RuntimeType.IsWindowsRuntimeObjectType"); return FALSE; } + #endif /* ENABLE_NETCORE */ +#ifdef ENABLE_NETCORE +void +ves_icall_System_GlobalizationNative_ChangeCase (guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoBoolean bToUpper, MonoError *error) +{ + GlobalizationNative_ChangeCase (src, srcLen, dstBuffer, dstBufferCapacity, bToUpper); +} + +void +ves_icall_System_GlobalizationNative_ChangeCaseInvariant (guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoBoolean bToUpper, MonoError* error) +{ + GlobalizationNative_ChangeCaseInvariant (src, srcLen, dstBuffer, dstBufferCapacity, bToUpper); +} + +void +ves_icall_System_GlobalizationNative_ChangeCaseTurkish (guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoBoolean bToUpper, MonoError* error) +{ + GlobalizationNative_ChangeCaseTurkish (src, srcLen, dstBuffer, dstBufferCapacity, bToUpper); +} + +void +ves_icall_System_GlobalizationNative_CloseSortHandle (gpointer sortHandle, MonoError* error) +{ + GlobalizationNative_CloseSortHandle (sortHandle); +} + +gint32 +ves_icall_System_GlobalizationNative_CompareString (gpointer sortHandle, guint16_ref lpStr1, gint32 cwStr1Len, guint16_ref lpStr2, gint32 cwStr2Len, gint32 options, MonoError* error) +{ + guint32 ret = GlobalizationNative_CompareString (sortHandle, lpStr1, cwStr1Len, lpStr2, cwStr2Len, options); + return ret; +} + +gint32 +ves_icall_System_GlobalizationNative_CompareStringOrdinalIgnoreCase (guint16_ref lpStr1, gint32 cwStr1Len, guint16_ref lpStr2, gint32 cwStr2Len, MonoError* error) +{ + guint32 ret = GlobalizationNative_CompareStringOrdinalIgnoreCase (lpStr1, cwStr1Len, lpStr2, cwStr2Len); + return ret; +} + +gint32 +ves_icall_System_GlobalizationNative_EndsWith (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, MonoError* error) +{ + return GlobalizationNative_EndsWith (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options); +} + +gint32 +ves_icall_System_GlobalizationNative_EnumCalendarInfo (MonoDelegateHandle callback, MonoStringHandle localeName, guint16 calendarId, gint32 dataType, gpointer context, MonoError* error) +{ + gpointer ptr = mono_delegate_to_ftnptr_impl (callback, error); + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + return GlobalizationNative_EnumCalendarInfo (ptr, localeNameStr, calendarId, dataType, context); +} + +gint32 +ves_icall_System_GlobalizationNative_GetCalendarInfo (MonoStringHandle localeName, guint16 calendarId, gint32 dataType, guint16_ref result, gint32 resultCapacity, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + return GlobalizationNative_GetCalendarInfo (localeNameStr, calendarId, dataType, result, resultCapacity); +} + +gint32 +ves_icall_System_GlobalizationNative_GetCalendars (MonoStringHandle localeName, MonoArrayHandle calendars_handle, gint32 calendarsCapacity, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + gpointer calendars = mono_array_addr_with_size_internal (MONO_HANDLE_RAW(calendars_handle), 1, 0); + return GlobalizationNative_GetCalendars (localeNameStr, calendars, calendarsCapacity); +} + +gint32 +ves_icall_System_GlobalizationNative_GetDefaultLocaleName (guint16_ref value, guint32 valueLength, MonoError* error) +{ + return GlobalizationNative_GetDefaultLocaleName (value, valueLength); +} + +gint32 +ves_icall_System_GlobalizationNative_GetICUVersion (MonoError* error) +{ + return GlobalizationNative_GetICUVersion (); +} + +gint32 +ves_icall_System_GlobalizationNative_GetJapaneseEraStartDate (gint32 era, gint32_ref startYear, gint32_ref startMonth, gint32_ref startDay, MonoError* error) +{ + return GlobalizationNative_GetJapaneseEraStartDate (era, startYear, startMonth, startDay); +} + +gint32 +ves_icall_System_GlobalizationNative_GetLatestJapaneseEra (MonoError* error) +{ + return GlobalizationNative_GetLatestJapaneseEra (); +} + +MonoBoolean +ves_icall_System_GlobalizationNative_GetLocaleInfoGroupingSizes (MonoStringHandle localeName, gint32 localeGroupingDat, gint32_ref primaryGroupSize, gint32_ref secondaryGroupSize, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16(localeName); + return GlobalizationNative_GetLocaleInfoGroupingSizes (localeNameStr, localeGroupingDat, primaryGroupSize, secondaryGroupSize); +} + +MonoBoolean +ves_icall_System_GlobalizationNative_GetLocaleInfoInt (MonoStringHandle localeName, guint32 localeNumberData, guint32_ref value, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16(localeName); + return GlobalizationNative_GetLocaleInfoInt (localeNameStr, localeNumberData, value); +} + +MonoBoolean +ves_icall_System_GlobalizationNative_GetLocaleInfoString (MonoStringHandle localeName, guint32 localeStringData, guint16_ref value, guint32 valueLength, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + return GlobalizationNative_GetLocaleInfoString (localeNameStr, localeStringData, value, valueLength); +} + +MonoBoolean +ves_icall_System_GlobalizationNative_GetLocaleName (MonoStringHandle localeName, guint16_ref value, guint32 valueLength, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + return GlobalizationNative_GetLocaleName (localeNameStr, value, valueLength); +} + +gint32 +ves_icall_System_GlobalizationNative_GetLocales (MonoArrayHandle value, gint32 valueLength, MonoError* error) +{ + gint32 ret = 0; + MonoArray* value_ptr = MONO_HANDLE_RAW(value); + if (value_ptr == NULL) + ret = GlobalizationNative_GetLocales((UChar*)value_ptr, valueLength); + else { + mono_unichar2 *vpch = (mono_unichar2*) mono_array_addr_with_size_internal (value_ptr, 1, 0); + ret = GlobalizationNative_GetLocales (vpch, valueLength); + } + return ret; +} + +MonoBoolean +ves_icall_System_GlobalizationNative_GetLocaleTimeFormat (MonoStringHandle localeName, guint32 shortFormat, guint16_ref value, guint32 valueLength, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + return GlobalizationNative_GetLocaleTimeFormat (localeNameStr, shortFormat, value, valueLength); + +} + +gint32 +ves_icall_System_GlobalizationNative_GetSortHandle (MonoStringHandle sortName, gpointer_ptr ppSortHandle, MonoError* error) +{ + char* sortNameStr = mono_string_handle_to_utf8 (sortName, error); + return GlobalizationNative_GetSortHandle (sortNameStr, (SortHandle **)ppSortHandle); +} + +gint32 +ves_icall_System_GlobalizationNative_GetSortKey (gpointer sortHandle, guint16_ref str, guint32 strLength, guint8_ref sortKey, guint32 sortKeyLength, guint32 options, MonoError* error) +{ + return GlobalizationNative_GetSortKey (sortHandle, str, strLength, sortKey, sortKeyLength, options); +} + +gint32 +ves_icall_System_GlobalizationNative_GetSortVersion (gpointer sortHandle, MonoError* error) +{ + return GlobalizationNative_GetSortVersion (sortHandle); +} + +gint32 +ves_icall_System_GlobalizationNative_GetTimeZoneDisplayName (MonoStringHandle localeName, MonoStringHandle timeZoneId, gint32 type, guint16_ref result, gint32 resultLength, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + mono_unichar2* timeZoneIdStr = mono_string_handle_to_utf16 (timeZoneId); + return GlobalizationNative_GetTimeZoneDisplayName (localeNameStr, timeZoneIdStr, type, result, resultLength); +} + +gint32 +ves_icall_System_GlobalizationNative_IndexOf (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, gint32_ref pMatchedLength, MonoError* error) +{ + return GlobalizationNative_IndexOf (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options, pMatchedLength); +} + +gint32 +ves_icall_System_GlobalizationNative_IndexOfOrdinalIgnoreCase (guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 findLast, MonoError* error) +{ + return GlobalizationNative_IndexOfOrdinalIgnoreCase (lpTarget, cwTargetLength, lpSource, cwSourceLength, findLast); +} + +gint32 +ves_icall_System_GlobalizationNative_IsNormalized (gint32 normalizationForm, guint16_ref src, gint32 srcLen, MonoError* error) +{ + return GlobalizationNative_IsNormalized (normalizationForm, src, srcLen); +} + +gint32 +ves_icall_System_GlobalizationNative_IsPredefinedLocale (MonoStringHandle localeName, MonoError* error) +{ + mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); + return GlobalizationNative_IsPredefinedLocale (localeNameStr); +} + +gint32 +ves_icall_System_GlobalizationNative_LastIndexOf (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, MonoError* error) +{ + return GlobalizationNative_LastIndexOf (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options); +} + +gint32 +ves_icall_System_GlobalizationNative_LoadICU (MonoError* error) +{ + return GlobalizationNative_LoadICU (); +} + +gint32 +ves_icall_System_GlobalizationNative_NormalizeString (gint32 normalizationForm, guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoError* error) +{ + return GlobalizationNative_NormalizeString (normalizationForm, src, srcLen, dstBuffer, dstBufferCapacity); +} + +gint32 +ves_icall_System_GlobalizationNative_StartsWith (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, MonoError* error) +{ + return GlobalizationNative_StartsWith (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options); +} + +gint32 +ves_icall_System_GlobalizationNative_ToAscii (guint32 flags, guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoError* error) +{ + return GlobalizationNative_ToAscii (flags, src, srcLen, dstBuffer, dstBufferCapacity); +} + +gint32 +ves_icall_System_GlobalizationNative_ToUnicode (guint32 flags, guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoError* error) +{ + return GlobalizationNative_ToUnicode (flags, src, srcLen, dstBuffer, dstBufferCapacity); +} + +#endif void ves_icall_RuntimeMethodInfo_GetPInvoke (MonoReflectionMethodHandle ref_method, int* flags, MonoStringHandleOut entry_point, MonoStringHandleOut dll_name, MonoError *error) diff --git a/src/mono/mono/metadata/object-internals.h b/src/mono/mono/metadata/object-internals.h index 0b369effebb52c..6551eec4ee201f 100644 --- a/src/mono/mono/metadata/object-internals.h +++ b/src/mono/mono/metadata/object-internals.h @@ -1737,6 +1737,9 @@ mono_string_handle_length (MonoStringHandle s); char * mono_string_handle_to_utf8 (MonoStringHandle s, MonoError *error); +mono_unichar2 * +mono_string_handle_to_utf16(MonoStringHandle s); + char * mono_string_to_utf8_image (MonoImage *image, MonoStringHandle s, MonoError *error); diff --git a/src/mono/mono/metadata/object.c b/src/mono/mono/metadata/object.c index 952b2be7c1cc0e..712d0c0fe4cc97 100644 --- a/src/mono/mono/metadata/object.c +++ b/src/mono/mono/metadata/object.c @@ -7848,6 +7848,12 @@ mono_string_handle_to_utf8 (MonoStringHandle s, MonoError *error) return mono_string_to_utf8_checked_internal (MONO_HANDLE_RAW (s), error); } +mono_unichar2* +mono_string_handle_to_utf16(MonoStringHandle s) +{ + return mono_string_to_utf16(MONO_HANDLE_RAW(s)); +} + /** * mono_string_to_utf8_ignore: * \param s a MonoString diff --git a/src/mono/msvc/libmono-dynamic.vcxproj b/src/mono/msvc/libmono-dynamic.vcxproj index e00fd9ccacd863..f87d68935a6c25 100644 --- a/src/mono/msvc/libmono-dynamic.vcxproj +++ b/src/mono/msvc/libmono-dynamic.vcxproj @@ -96,7 +96,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -123,7 +123,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_COMMON);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -147,7 +147,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C true Level3 diff --git a/src/mono/msvc/libmonoruntime.vcxproj b/src/mono/msvc/libmonoruntime.vcxproj index ee9c76b39570d8..c3c7de64953564 100644 --- a/src/mono/msvc/libmonoruntime.vcxproj +++ b/src/mono/msvc/libmonoruntime.vcxproj @@ -98,7 +98,7 @@ Level3 Disabled WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -112,7 +112,7 @@ Level3 Disabled WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION_COMMON));%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON));%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -126,7 +126,7 @@ Level3 true WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true @@ -142,7 +142,7 @@ Level3 true WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions;TARGET_WINDOWS;PALEXPORT=EXTERN_C - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true From 806ab54fba26b3492f5f656953e7acafae774228 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Sat, 25 Apr 2020 15:33:11 -0300 Subject: [PATCH 05/49] Adding files that I forgot. --- .../System.Globalization.Native/pal_icushim.c | 0 src/mono/mono/metadata/icall-decl.h | 0 src/mono/mono/metadata/icall-def-netcore.h | 37 +++++++++++++++++++ src/mono/mono/metadata/icall-table.h | 0 4 files changed, 37 insertions(+) mode change 100644 => 100755 src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c mode change 100644 => 100755 src/mono/mono/metadata/icall-decl.h mode change 100644 => 100755 src/mono/mono/metadata/icall-table.h diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c old mode 100644 new mode 100755 diff --git a/src/mono/mono/metadata/icall-decl.h b/src/mono/mono/metadata/icall-decl.h old mode 100644 new mode 100755 diff --git a/src/mono/mono/metadata/icall-def-netcore.h b/src/mono/mono/metadata/icall-def-netcore.h index 9206bebfc8347c..249611742ac798 100644 --- a/src/mono/mono/metadata/icall-def-netcore.h +++ b/src/mono/mono/metadata/icall-def-netcore.h @@ -1,3 +1,40 @@ +ICALL_TYPE(SYSGLOB, "Interop/Globalization", SYSGLOB_1) +HANDLES(SYSGLOB_1, "ChangeCase", ves_icall_System_GlobalizationNative_ChangeCase, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) +HANDLES(SYSGLOB_2, "ChangeCaseInvariant", ves_icall_System_GlobalizationNative_ChangeCaseInvariant, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) +HANDLES(SYSGLOB_3, "ChangeCaseTurkish", ves_icall_System_GlobalizationNative_ChangeCaseTurkish, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) +HANDLES(SYSGLOB_4, "CloseSortHandle", ves_icall_System_GlobalizationNative_CloseSortHandle, void, 1, (gpointer)) +HANDLES(SYSGLOB_5, "CompareString",ves_icall_System_GlobalizationNative_CompareString, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) +HANDLES(SYSGLOB_6, "CompareStringOrdinalIgnoreCase", ves_icall_System_GlobalizationNative_CompareStringOrdinalIgnoreCase, gint32, 4, (guint16_ref, gint32, guint16_ref, gint32)) +HANDLES(SYSGLOB_7, "EndsWith", ves_icall_System_GlobalizationNative_EndsWith, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) +HANDLES(SYSGLOB_8, "EnumCalendarInfo", ves_icall_System_GlobalizationNative_EnumCalendarInfo, gint32, 5, (MonoDelegate, MonoString, guint16, gint32, gpointer)) +HANDLES(SYSGLOB_9, "GetCalendarInfo", ves_icall_System_GlobalizationNative_GetCalendarInfo, gint32, 5, (MonoString, guint16, gint32, guint16_ref, gint32)) +HANDLES(SYSGLOB_10, "GetCalendars", ves_icall_System_GlobalizationNative_GetCalendars, gint32, 3, (MonoString, MonoArray, gint32)) +HANDLES(SYSGLOB_11, "GetDefaultLocaleName", ves_icall_System_GlobalizationNative_GetDefaultLocaleName, gint32, 2, (guint16_ref, guint32)) +HANDLES(SYSGLOB_12, "GetICUVersion", ves_icall_System_GlobalizationNative_GetICUVersion, gint32, 0, ()) +HANDLES(SYSGLOB_13, "GetJapaneseEraStartDate", ves_icall_System_GlobalizationNative_GetJapaneseEraStartDate, gint32, 4, (gint32, gint32_ref, gint32_ref, gint32_ref)) +HANDLES(SYSGLOB_14, "GetLatestJapaneseEra", ves_icall_System_GlobalizationNative_GetLatestJapaneseEra, gint32, 0, ()) +HANDLES(SYSGLOB_15, "GetLocaleInfoGroupingSizes", ves_icall_System_GlobalizationNative_GetLocaleInfoGroupingSizes, MonoBoolean, 4, (MonoString, gint32, gint32_ref, gint32_ref)) +HANDLES(SYSGLOB_16, "GetLocaleInfoInt", ves_icall_System_GlobalizationNative_GetLocaleInfoInt, MonoBoolean, 3, (MonoString, guint32, guint32_ref)) +HANDLES(SYSGLOB_17, "GetLocaleInfoString", ves_icall_System_GlobalizationNative_GetLocaleInfoString, MonoBoolean, 4, (MonoString, guint32, guint16_ref, guint32)) +HANDLES(SYSGLOB_18, "GetLocaleName", ves_icall_System_GlobalizationNative_GetLocaleName, MonoBoolean, 3, (MonoString, guint16_ref, guint32)) +HANDLES(SYSGLOB_19, "GetLocaleTimeFormat", ves_icall_System_GlobalizationNative_GetLocaleTimeFormat, MonoBoolean, 4, (MonoString, guint32, guint16_ref, guint32)) +HANDLES(SYSGLOB_20, "GetLocales", ves_icall_System_GlobalizationNative_GetLocales, gint32, 2, (MonoArray, gint32)) +HANDLES(SYSGLOB_21, "GetSortHandle", ves_icall_System_GlobalizationNative_GetSortHandle, gint32, 2, (MonoString, gpointer_ptr)) +HANDLES(SYSGLOB_22, "GetSortKey", ves_icall_System_GlobalizationNative_GetSortKey, gint32, 6, (gpointer, guint16_ref, guint32, guint8_ref, guint32, guint32)) +HANDLES(SYSGLOB_23, "GetSortVersion", ves_icall_System_GlobalizationNative_GetSortVersion, gint32, 1, (gpointer)) +HANDLES(SYSGLOB_24, "GetTimeZoneDisplayName", ves_icall_System_GlobalizationNative_GetTimeZoneDisplayName, gint32, 5, (MonoString, MonoString, gint32, guint16_ref, gint32)) +HANDLES(SYSGLOB_25, "IndexOf", ves_icall_System_GlobalizationNative_IndexOf, gint32, 7, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32, gint32_ref)) +HANDLES(SYSGLOB_26, "IndexOfOrdinalIgnoreCase", ves_icall_System_GlobalizationNative_IndexOfOrdinalIgnoreCase, gint32, 5, (guint16_ref, gint32, guint16_ref, gint32, gint32)) +HANDLES(SYSGLOB_27, "IsNormalized", ves_icall_System_GlobalizationNative_IsNormalized, gint32, 3, (gint32, guint16_ref, gint32)) +HANDLES(SYSGLOB_28, "IsPredefinedLocale", ves_icall_System_GlobalizationNative_IsPredefinedLocale, gint32, 1, (MonoString)) +HANDLES(SYSGLOB_29, "LastIndexOf", ves_icall_System_GlobalizationNative_LastIndexOf, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) +HANDLES(SYSGLOB_30, "LoadICU", ves_icall_System_GlobalizationNative_LoadICU, gint32, 0, ()) +HANDLES(SYSGLOB_31, "NormalizeString", ves_icall_System_GlobalizationNative_NormalizeString, gint32, 5, (gint32, guint16_ref, gint32, guint16_ref, gint32)) +HANDLES(SYSGLOB_32, "StartsWith", ves_icall_System_GlobalizationNative_StartsWith, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) +HANDLES(SYSGLOB_33, "ToAscii", ves_icall_System_GlobalizationNative_ToAscii, gint32, 5, (guint32, guint16_ref, gint32, guint16_ref, gint32)) +HANDLES(SYSGLOB_34, "ToUnicode", ves_icall_System_GlobalizationNative_ToUnicode, gint32, 5, (guint32, guint16_ref, gint32, guint16_ref, gint32)) + + ICALL_TYPE(SAFEWAITHANDLE, "Microsoft.Win32.SafeHandles.SafeWaitHandle", SAFEWAITHANDLE_1) // && UNIX NOHANDLES(ICALL(SAFEWAITHANDLE_1, "CloseEventInternal", ves_icall_System_Threading_Events_CloseEvent_internal)) diff --git a/src/mono/mono/metadata/icall-table.h b/src/mono/mono/metadata/icall-table.h old mode 100644 new mode 100755 From 63b31b366fbeebb56c16fb520efb1000d306630f Mon Sep 17 00:00:00 2001 From: thaystg Date: Mon, 27 Apr 2020 13:42:38 -0300 Subject: [PATCH 06/49] using dllimport as suggested by Aleksey --- .../Common/src/Interop/Interop.Calendar.cs | 25 ++------ .../Common/src/Interop/Interop.Casing.cs | 14 +--- .../Common/src/Interop/Interop.Collation.cs | 64 +++---------------- .../Common/src/Interop/Interop.ICU.cs | 13 +--- .../Common/src/Interop/Interop.Idna.cs | 9 --- .../Common/src/Interop/Interop.Libraries.cs | 4 -- .../Common/src/Interop/Interop.Locale.cs | 38 ++--------- .../src/Interop/Interop.Normalization.cs | 9 --- .../src/Interop/Interop.TimeZoneInfo.cs | 6 +- .../Native/Unix/Common/pal_compiler.h | 2 + src/mono/mono/metadata/icall-def-netcore.h | 6 +- src/mono/mono/metadata/icall.c | 8 +-- src/mono/msvc/libmono-dynamic.vcxproj | 8 +-- src/mono/msvc/libmonoruntime.vcxproj | 8 +-- 14 files changed, 39 insertions(+), 175 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Calendar.cs b/src/libraries/Common/src/Interop/Interop.Calendar.cs index c1256c92468a35..0b9e2c283f0f89 100644 --- a/src/libraries/Common/src/Interop/Interop.Calendar.cs +++ b/src/libraries/Common/src/Interop/Interop.Calendar.cs @@ -5,7 +5,6 @@ using System; using System.Globalization; using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; internal static partial class Interop { @@ -14,36 +13,20 @@ internal static partial class Globalization internal delegate void EnumCalendarInfoCallback( [MarshalAs(UnmanagedType.LPWStr)] string calendarString, IntPtr context); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetCalendars")] -#endif internal static extern int GetCalendars(string localeName, CalendarId[] calendars, int calendarsCapacity); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetCalendarInfo")] -#endif internal static extern unsafe ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char* result, int resultCapacity); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EnumCalendarInfo")] -#endif internal static extern bool EnumCalendarInfo(EnumCalendarInfoCallback callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")] -#endif internal static extern int GetLatestJapaneseEra(); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetJapaneseEraStartDate")] -#endif internal static extern bool GetJapaneseEraStartDate(int era, out int startYear, out int startMonth, out int startDay); } } diff --git a/src/libraries/Common/src/Interop/Interop.Casing.cs b/src/libraries/Common/src/Interop/Interop.Casing.cs index 880c7b0df0e635..499f9445d89ceb 100644 --- a/src/libraries/Common/src/Interop/Interop.Casing.cs +++ b/src/libraries/Common/src/Interop/Interop.Casing.cs @@ -3,30 +3,18 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCase")] -#endif internal static extern unsafe void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCaseInvariant")] -#endif internal static extern unsafe void ChangeCaseInvariant(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCaseTurkish")] -#endif internal static extern unsafe void ChangeCaseTurkish(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper); } } diff --git a/src/libraries/Common/src/Interop/Interop.Collation.cs b/src/libraries/Common/src/Interop/Interop.Collation.cs index 62028b832829d6..a59292e0fca1df 100644 --- a/src/libraries/Common/src/Interop/Interop.Collation.cs +++ b/src/libraries/Common/src/Interop/Interop.Collation.cs @@ -5,98 +5,54 @@ using System; using System.Globalization; using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Ansi, EntryPoint = "GlobalizationNative_GetSortHandle")] -#endif internal static extern unsafe ResultCode GetSortHandle(string localeName, out IntPtr sortHandle); [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CloseSortHandle")] internal static extern unsafe void CloseSortHandle(IntPtr handle); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareString")] -#endif internal static extern unsafe int CompareString(IntPtr sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOf")] -#endif internal static extern unsafe int IndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")] -#endif - internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); + internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")] -#endif internal static extern unsafe int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")] -#endif internal static extern unsafe int IndexOfOrdinalIgnoreCase(char* target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool StartsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool EndsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool StartsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool EndsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetSortKey")] -#endif internal static extern unsafe int GetSortKey(IntPtr sortHandle, char* str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareStringOrdinalIgnoreCase")] -#endif internal static extern unsafe int CompareStringOrdinalIgnoreCase(char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortVersion")] -#endif internal static extern int GetSortVersion(IntPtr sortHandle); } } diff --git a/src/libraries/Common/src/Interop/Interop.ICU.cs b/src/libraries/Common/src/Interop/Interop.ICU.cs index ac99d8b8d41b6a..fcde6488138c2f 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.cs @@ -3,24 +3,15 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else - [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")] -#endif + [DllImport("__Internal", EntryPoint = "GlobalizationNative_LoadICU")] internal static extern int LoadICU(); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else - [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")] -#endif + [DllImport("__Internal", EntryPoint = "GlobalizationNative_GetICUVersion")] internal static extern int GetICUVersion(); } } diff --git a/src/libraries/Common/src/Interop/Interop.Idna.cs b/src/libraries/Common/src/Interop/Interop.Idna.cs index f46057531f1908..e9014da1e5d9e6 100644 --- a/src/libraries/Common/src/Interop/Interop.Idna.cs +++ b/src/libraries/Common/src/Interop/Interop.Idna.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; internal static partial class Interop { @@ -12,18 +11,10 @@ internal static partial class Globalization internal const int AllowUnassigned = 0x1; internal const int UseStd3AsciiRules = 0x2; -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ToAscii")] -#endif internal static extern unsafe int ToAscii(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ToUnicode")] -#endif internal static extern unsafe int ToUnicode(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity); } } diff --git a/src/libraries/Common/src/Interop/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Interop.Libraries.cs index 9a64a909e35ca8..4fee38ad35bd22 100644 --- a/src/libraries/Common/src/Interop/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Interop.Libraries.cs @@ -6,10 +6,6 @@ internal static partial class Interop { internal static partial class Libraries { -#if MONO - internal const string GlobalizationNative = "__Internal"; -#else internal const string GlobalizationNative = "libSystem.Globalization.Native"; -#endif } } diff --git a/src/libraries/Common/src/Interop/Interop.Locale.cs b/src/libraries/Common/src/Interop/Interop.Locale.cs index b62eb775d86be6..a6517185ce0632 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.cs @@ -3,70 +3,40 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; internal static partial class Interop { internal static partial class Globalization { -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleName")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool GetLocaleName(string localeName, char* value, int valueLength); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoString")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool GetLocaleInfoString(string localeName, uint localeStringData, char* value, int valueLength); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetDefaultLocaleName")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool GetDefaultLocaleName(char* value, int valueLength); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IsPredefinedLocale")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool IsPredefinedLocale(string localeName); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleTimeFormat")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern unsafe bool GetLocaleTimeFormat(string localeName, bool shortFormat, char* value, int valueLength); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoInt")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern bool GetLocaleInfoInt(string localeName, uint localeNumberData, ref int value); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoGroupingSizes")] [return: MarshalAs(UnmanagedType.Bool)] -#endif internal static extern bool GetLocaleInfoGroupingSizes(string localeName, uint localeGroupingData, ref int primaryGroupSize, ref int secondaryGroupSize); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocales")] -#endif - internal static extern int GetLocales(char[]? value, int valueLength); + internal static extern int GetLocales([Out] char[]? value, int valueLength); } } diff --git a/src/libraries/Common/src/Interop/Interop.Normalization.cs b/src/libraries/Common/src/Interop/Interop.Normalization.cs index 4829d647483851..f981eac6405db3 100644 --- a/src/libraries/Common/src/Interop/Interop.Normalization.cs +++ b/src/libraries/Common/src/Interop/Interop.Normalization.cs @@ -3,25 +3,16 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; using System.Text; internal static partial class Interop { internal static partial class Globalization { -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IsNormalized")] -#endif internal static extern unsafe int IsNormalized(NormalizationForm normalizationForm, char* src, int srcLen); -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_NormalizeString")] -#endif internal static extern unsafe int NormalizeString(NormalizationForm normalizationForm, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity); } } diff --git a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs index 5c0ec21c0ce98f..f60b81f0da8cf6 100644 --- a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs +++ b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; internal static partial class Interop { @@ -16,11 +15,8 @@ internal enum TimeZoneDisplayNameType Standard = 1, DaylightSavings = 2, } -#if MONO - [MethodImplAttribute(MethodImplOptions.InternalCall)] -#else + [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetTimeZoneDisplayName")] -#endif internal static extern unsafe ResultCode GetTimeZoneDisplayName( string localeName, string timeZoneId, diff --git a/src/libraries/Native/Unix/Common/pal_compiler.h b/src/libraries/Native/Unix/Common/pal_compiler.h index 8661443fc9f45a..998ebc613f4d7a 100644 --- a/src/libraries/Native/Unix/Common/pal_compiler.h +++ b/src/libraries/Native/Unix/Common/pal_compiler.h @@ -34,3 +34,5 @@ #define EXTERN_C extern #endif // __cplusplus #endif // EXTERN_C + +#include diff --git a/src/mono/mono/metadata/icall-def-netcore.h b/src/mono/mono/metadata/icall-def-netcore.h index 249611742ac798..2216b3ef1b7532 100644 --- a/src/mono/mono/metadata/icall-def-netcore.h +++ b/src/mono/mono/metadata/icall-def-netcore.h @@ -1,4 +1,4 @@ -ICALL_TYPE(SYSGLOB, "Interop/Globalization", SYSGLOB_1) +/*ICALL_TYPE(SYSGLOB, "Interop/Globalization", SYSGLOB_1) HANDLES(SYSGLOB_1, "ChangeCase", ves_icall_System_GlobalizationNative_ChangeCase, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) HANDLES(SYSGLOB_2, "ChangeCaseInvariant", ves_icall_System_GlobalizationNative_ChangeCaseInvariant, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) HANDLES(SYSGLOB_3, "ChangeCaseTurkish", ves_icall_System_GlobalizationNative_ChangeCaseTurkish, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) @@ -27,12 +27,12 @@ HANDLES(SYSGLOB_25, "IndexOf", ves_icall_System_GlobalizationNative_IndexOf, gin HANDLES(SYSGLOB_26, "IndexOfOrdinalIgnoreCase", ves_icall_System_GlobalizationNative_IndexOfOrdinalIgnoreCase, gint32, 5, (guint16_ref, gint32, guint16_ref, gint32, gint32)) HANDLES(SYSGLOB_27, "IsNormalized", ves_icall_System_GlobalizationNative_IsNormalized, gint32, 3, (gint32, guint16_ref, gint32)) HANDLES(SYSGLOB_28, "IsPredefinedLocale", ves_icall_System_GlobalizationNative_IsPredefinedLocale, gint32, 1, (MonoString)) -HANDLES(SYSGLOB_29, "LastIndexOf", ves_icall_System_GlobalizationNative_LastIndexOf, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) +HANDLES(SYSGLOB_29, "LastIndexOf", ves_icall_System_GlobalizationNative_LastIndexOf, gint32, 7, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32, gint32_ref)) HANDLES(SYSGLOB_30, "LoadICU", ves_icall_System_GlobalizationNative_LoadICU, gint32, 0, ()) HANDLES(SYSGLOB_31, "NormalizeString", ves_icall_System_GlobalizationNative_NormalizeString, gint32, 5, (gint32, guint16_ref, gint32, guint16_ref, gint32)) HANDLES(SYSGLOB_32, "StartsWith", ves_icall_System_GlobalizationNative_StartsWith, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) HANDLES(SYSGLOB_33, "ToAscii", ves_icall_System_GlobalizationNative_ToAscii, gint32, 5, (guint32, guint16_ref, gint32, guint16_ref, gint32)) -HANDLES(SYSGLOB_34, "ToUnicode", ves_icall_System_GlobalizationNative_ToUnicode, gint32, 5, (guint32, guint16_ref, gint32, guint16_ref, gint32)) +HANDLES(SYSGLOB_34, "ToUnicode", ves_icall_System_GlobalizationNative_ToUnicode, gint32, 5, (guint32, guint16_ref, gint32, guint16_ref, gint32))*/ ICALL_TYPE(SAFEWAITHANDLE, "Microsoft.Win32.SafeHandles.SafeWaitHandle", SAFEWAITHANDLE_1) // && UNIX diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index e48eba50835b13..384ddefd4c4a9d 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -3562,6 +3562,7 @@ ves_icall_System_RuntimeType_IsWindowsRuntimeObjectType (MonoError *error) #endif /* ENABLE_NETCORE */ #ifdef ENABLE_NETCORE +/* void ves_icall_System_GlobalizationNative_ChangeCase (guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoBoolean bToUpper, MonoError *error) { @@ -3756,9 +3757,9 @@ ves_icall_System_GlobalizationNative_IsPredefinedLocale (MonoStringHandle locale } gint32 -ves_icall_System_GlobalizationNative_LastIndexOf (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, MonoError* error) +ves_icall_System_GlobalizationNative_LastIndexOf (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, gint32_ref pMatchedLength, MonoError* error) { - return GlobalizationNative_LastIndexOf (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options); + return GlobalizationNative_LastIndexOf (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options, pMatchedLength); } gint32 @@ -3789,8 +3790,7 @@ gint32 ves_icall_System_GlobalizationNative_ToUnicode (guint32 flags, guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoError* error) { return GlobalizationNative_ToUnicode (flags, src, srcLen, dstBuffer, dstBufferCapacity); -} - +}*/ #endif void diff --git a/src/mono/msvc/libmono-dynamic.vcxproj b/src/mono/msvc/libmono-dynamic.vcxproj index f87d68935a6c25..755c0e30f50b8a 100644 --- a/src/mono/msvc/libmono-dynamic.vcxproj +++ b/src/mono/msvc/libmono-dynamic.vcxproj @@ -97,7 +97,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -124,7 +124,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -148,7 +148,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API true Level3 true @@ -177,7 +177,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API true Level3 true diff --git a/src/mono/msvc/libmonoruntime.vcxproj b/src/mono/msvc/libmonoruntime.vcxproj index c3c7de64953564..fc6c6293fec750 100644 --- a/src/mono/msvc/libmonoruntime.vcxproj +++ b/src/mono/msvc/libmonoruntime.vcxproj @@ -97,7 +97,7 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -111,7 +111,7 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON));%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -125,7 +125,7 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true @@ -141,7 +141,7 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions;TARGET_WINDOWS;PALEXPORT=EXTERN_C + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions;TARGET_WINDOWS;PALEXPORT=MONO_API $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true From 9dbce14a33dcc93adc3a486627e3539066dcbddd Mon Sep 17 00:00:00 2001 From: thaystg Date: Mon, 27 Apr 2020 13:45:10 -0300 Subject: [PATCH 07/49] Fixing lastindexof --- src/libraries/Common/src/Interop/Interop.Collation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/src/Interop/Interop.Collation.cs b/src/libraries/Common/src/Interop/Interop.Collation.cs index a59292e0fca1df..ece19be581c8bc 100644 --- a/src/libraries/Common/src/Interop/Interop.Collation.cs +++ b/src/libraries/Common/src/Interop/Interop.Collation.cs @@ -23,7 +23,7 @@ internal static partial class Globalization internal static extern unsafe int IndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")] - internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options); + internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")] internal static extern unsafe int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast); From e582815bc08c901722f7b2eb7413114b48085d16 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 27 Apr 2020 15:10:54 -0300 Subject: [PATCH 08/49] Using dllimport --- .../Common/src/Interop/Interop.ICU.cs | 4 +- .../Common/src/Interop/Interop.Libraries.cs | 4 + src/mono/mono/metadata/icall-def-netcore.h | 37 --- src/mono/mono/metadata/icall-table.h | 11 - src/mono/mono/metadata/icall.c | 252 +----------------- src/mono/mono/metadata/object-internals.h | 27 -- src/mono/mono/metadata/object.c | 6 - 7 files changed, 7 insertions(+), 334 deletions(-) mode change 100755 => 100644 src/mono/mono/metadata/icall-table.h diff --git a/src/libraries/Common/src/Interop/Interop.ICU.cs b/src/libraries/Common/src/Interop/Interop.ICU.cs index fcde6488138c2f..0dce072958a7fa 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.cs @@ -8,10 +8,10 @@ internal static partial class Interop { internal static partial class Globalization { - [DllImport("__Internal", EntryPoint = "GlobalizationNative_LoadICU")] + [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICU")] internal static extern int LoadICU(); - [DllImport("__Internal", EntryPoint = "GlobalizationNative_GetICUVersion")] + [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")] internal static extern int GetICUVersion(); } } diff --git a/src/libraries/Common/src/Interop/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Interop.Libraries.cs index 4fee38ad35bd22..9a64a909e35ca8 100644 --- a/src/libraries/Common/src/Interop/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Interop.Libraries.cs @@ -6,6 +6,10 @@ internal static partial class Interop { internal static partial class Libraries { +#if MONO + internal const string GlobalizationNative = "__Internal"; +#else internal const string GlobalizationNative = "libSystem.Globalization.Native"; +#endif } } diff --git a/src/mono/mono/metadata/icall-def-netcore.h b/src/mono/mono/metadata/icall-def-netcore.h index 2216b3ef1b7532..9206bebfc8347c 100644 --- a/src/mono/mono/metadata/icall-def-netcore.h +++ b/src/mono/mono/metadata/icall-def-netcore.h @@ -1,40 +1,3 @@ -/*ICALL_TYPE(SYSGLOB, "Interop/Globalization", SYSGLOB_1) -HANDLES(SYSGLOB_1, "ChangeCase", ves_icall_System_GlobalizationNative_ChangeCase, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) -HANDLES(SYSGLOB_2, "ChangeCaseInvariant", ves_icall_System_GlobalizationNative_ChangeCaseInvariant, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) -HANDLES(SYSGLOB_3, "ChangeCaseTurkish", ves_icall_System_GlobalizationNative_ChangeCaseTurkish, void, 5, (guint16_ref, gint32, guint16_ref, gint32, MonoBoolean)) -HANDLES(SYSGLOB_4, "CloseSortHandle", ves_icall_System_GlobalizationNative_CloseSortHandle, void, 1, (gpointer)) -HANDLES(SYSGLOB_5, "CompareString",ves_icall_System_GlobalizationNative_CompareString, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) -HANDLES(SYSGLOB_6, "CompareStringOrdinalIgnoreCase", ves_icall_System_GlobalizationNative_CompareStringOrdinalIgnoreCase, gint32, 4, (guint16_ref, gint32, guint16_ref, gint32)) -HANDLES(SYSGLOB_7, "EndsWith", ves_icall_System_GlobalizationNative_EndsWith, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) -HANDLES(SYSGLOB_8, "EnumCalendarInfo", ves_icall_System_GlobalizationNative_EnumCalendarInfo, gint32, 5, (MonoDelegate, MonoString, guint16, gint32, gpointer)) -HANDLES(SYSGLOB_9, "GetCalendarInfo", ves_icall_System_GlobalizationNative_GetCalendarInfo, gint32, 5, (MonoString, guint16, gint32, guint16_ref, gint32)) -HANDLES(SYSGLOB_10, "GetCalendars", ves_icall_System_GlobalizationNative_GetCalendars, gint32, 3, (MonoString, MonoArray, gint32)) -HANDLES(SYSGLOB_11, "GetDefaultLocaleName", ves_icall_System_GlobalizationNative_GetDefaultLocaleName, gint32, 2, (guint16_ref, guint32)) -HANDLES(SYSGLOB_12, "GetICUVersion", ves_icall_System_GlobalizationNative_GetICUVersion, gint32, 0, ()) -HANDLES(SYSGLOB_13, "GetJapaneseEraStartDate", ves_icall_System_GlobalizationNative_GetJapaneseEraStartDate, gint32, 4, (gint32, gint32_ref, gint32_ref, gint32_ref)) -HANDLES(SYSGLOB_14, "GetLatestJapaneseEra", ves_icall_System_GlobalizationNative_GetLatestJapaneseEra, gint32, 0, ()) -HANDLES(SYSGLOB_15, "GetLocaleInfoGroupingSizes", ves_icall_System_GlobalizationNative_GetLocaleInfoGroupingSizes, MonoBoolean, 4, (MonoString, gint32, gint32_ref, gint32_ref)) -HANDLES(SYSGLOB_16, "GetLocaleInfoInt", ves_icall_System_GlobalizationNative_GetLocaleInfoInt, MonoBoolean, 3, (MonoString, guint32, guint32_ref)) -HANDLES(SYSGLOB_17, "GetLocaleInfoString", ves_icall_System_GlobalizationNative_GetLocaleInfoString, MonoBoolean, 4, (MonoString, guint32, guint16_ref, guint32)) -HANDLES(SYSGLOB_18, "GetLocaleName", ves_icall_System_GlobalizationNative_GetLocaleName, MonoBoolean, 3, (MonoString, guint16_ref, guint32)) -HANDLES(SYSGLOB_19, "GetLocaleTimeFormat", ves_icall_System_GlobalizationNative_GetLocaleTimeFormat, MonoBoolean, 4, (MonoString, guint32, guint16_ref, guint32)) -HANDLES(SYSGLOB_20, "GetLocales", ves_icall_System_GlobalizationNative_GetLocales, gint32, 2, (MonoArray, gint32)) -HANDLES(SYSGLOB_21, "GetSortHandle", ves_icall_System_GlobalizationNative_GetSortHandle, gint32, 2, (MonoString, gpointer_ptr)) -HANDLES(SYSGLOB_22, "GetSortKey", ves_icall_System_GlobalizationNative_GetSortKey, gint32, 6, (gpointer, guint16_ref, guint32, guint8_ref, guint32, guint32)) -HANDLES(SYSGLOB_23, "GetSortVersion", ves_icall_System_GlobalizationNative_GetSortVersion, gint32, 1, (gpointer)) -HANDLES(SYSGLOB_24, "GetTimeZoneDisplayName", ves_icall_System_GlobalizationNative_GetTimeZoneDisplayName, gint32, 5, (MonoString, MonoString, gint32, guint16_ref, gint32)) -HANDLES(SYSGLOB_25, "IndexOf", ves_icall_System_GlobalizationNative_IndexOf, gint32, 7, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32, gint32_ref)) -HANDLES(SYSGLOB_26, "IndexOfOrdinalIgnoreCase", ves_icall_System_GlobalizationNative_IndexOfOrdinalIgnoreCase, gint32, 5, (guint16_ref, gint32, guint16_ref, gint32, gint32)) -HANDLES(SYSGLOB_27, "IsNormalized", ves_icall_System_GlobalizationNative_IsNormalized, gint32, 3, (gint32, guint16_ref, gint32)) -HANDLES(SYSGLOB_28, "IsPredefinedLocale", ves_icall_System_GlobalizationNative_IsPredefinedLocale, gint32, 1, (MonoString)) -HANDLES(SYSGLOB_29, "LastIndexOf", ves_icall_System_GlobalizationNative_LastIndexOf, gint32, 7, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32, gint32_ref)) -HANDLES(SYSGLOB_30, "LoadICU", ves_icall_System_GlobalizationNative_LoadICU, gint32, 0, ()) -HANDLES(SYSGLOB_31, "NormalizeString", ves_icall_System_GlobalizationNative_NormalizeString, gint32, 5, (gint32, guint16_ref, gint32, guint16_ref, gint32)) -HANDLES(SYSGLOB_32, "StartsWith", ves_icall_System_GlobalizationNative_StartsWith, gint32, 6, (gpointer, guint16_ref, gint32, guint16_ref, gint32, gint32)) -HANDLES(SYSGLOB_33, "ToAscii", ves_icall_System_GlobalizationNative_ToAscii, gint32, 5, (guint32, guint16_ref, gint32, guint16_ref, gint32)) -HANDLES(SYSGLOB_34, "ToUnicode", ves_icall_System_GlobalizationNative_ToUnicode, gint32, 5, (guint32, guint16_ref, gint32, guint16_ref, gint32))*/ - - ICALL_TYPE(SAFEWAITHANDLE, "Microsoft.Win32.SafeHandles.SafeWaitHandle", SAFEWAITHANDLE_1) // && UNIX NOHANDLES(ICALL(SAFEWAITHANDLE_1, "CloseEventInternal", ves_icall_System_Threading_Events_CloseEvent_internal)) diff --git a/src/mono/mono/metadata/icall-table.h b/src/mono/mono/metadata/icall-table.h old mode 100755 new mode 100644 index 8469c169b142b7..48587adfd3838b --- a/src/mono/mono/metadata/icall-table.h +++ b/src/mono/mono/metadata/icall-table.h @@ -76,9 +76,6 @@ typedef gint32 *gint32_ref; typedef gint64 *gint64_ref; typedef gpointer *gpointer_ref; typedef gsize *gsize_ref; -typedef guint16 *guint16_ref; -typedef guint8 *guint8_ref; -typedef const guint16_ref *const_guint16_ref; typedef guint32 *guint32_ref; typedef guint64 *guint64_ref; typedef int *int_ref; @@ -88,8 +85,6 @@ typedef MonoClassField *MonoClassField_ref; typedef MonoEvent *MonoEvent_ref; typedef MonoEventInfo *MonoEventInfo_ref; typedef MonoGenericParamInfo *MonoGenericParamInfo_ptr; -typedef MonoIntPtr *MonoIntPtr_ref; -typedef MonoIntPtr **MonoIntPtr_ptr; typedef MonoMethod *MonoMethod_ref; typedef MonoMethodInfo *MonoMethodInfo_ref; typedef MonoResolveTokenError *MonoResolveTokenError_ref; @@ -141,8 +136,6 @@ typedef MonoStringHandle MonoStringOutHandle; #define MONO_HANDLE_TYPE_WRAP_guchar_ptr ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_guint ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_const_guchar_ptr ICALL_HANDLES_WRAP_NONE -#define MONO_HANDLE_TYPE_WRAP_const_guint16_ref ICALL_HANDLES_WRAP_NONE -#define MONO_HANDLE_TYPE_WRAP_guint16 ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_guint32 ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_guint64 ICALL_HANDLES_WRAP_NONE #define MONO_HANDLE_TYPE_WRAP_int ICALL_HANDLES_WRAP_NONE @@ -171,7 +164,6 @@ typedef MonoStringHandle MonoStringOutHandle; #define MONO_HANDLE_TYPE_WRAP_MonoMethodInfo_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoPropertyInfo_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoType_ref ICALL_HANDLES_WRAP_VALUETYPE_REF -#define MONO_HANDLE_TYPE_WRAP_MonoIntPtr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoTypedRef_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_gint32_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_gint64_ref ICALL_HANDLES_WRAP_VALUETYPE_REF @@ -179,15 +171,12 @@ typedef MonoStringHandle MonoStringOutHandle; #define MONO_HANDLE_TYPE_WRAP_gsize_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_guint32_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_guint64_ref ICALL_HANDLES_WRAP_VALUETYPE_REF -#define MONO_HANDLE_TYPE_WRAP_guint16_ref ICALL_HANDLES_WRAP_VALUETYPE_REF -#define MONO_HANDLE_TYPE_WRAP_guint8_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_int_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_gint32_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_int_ptr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_char_ptr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_guint8_ptr_ref ICALL_HANDLES_WRAP_VALUETYPE_REF #define MONO_HANDLE_TYPE_WRAP_MonoResolveTokenError_ref ICALL_HANDLES_WRAP_VALUETYPE_REF -#define MONO_HANDLE_TYPE_WRAP_MonoIntPtr_ptr ICALL_HANDLES_WRAP_VALUETYPE_REF // HANDLE is not used just to avoid duplicate typedef warnings with some compilers. // gpointer == void* == HANDLE == FILE_HANDLE == PROCESS_HANDLE. diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index 384ddefd4c4a9d..a39cf2c832d26a 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -120,24 +120,6 @@ #include "mono/metadata/icall-signatures.h" #include "mono/utils/mono-signal-handler.h" -#ifdef ENABLE_NETCORE -#include -typedef uint16_t UChar; - -#include "pal_locale.h" -#include "pal_calendarData.h" -#include "pal_casing.h" -#include "pal_collation.h" -#include "pal_locale.h" -#include "pal_localeNumberData.h" -#include "pal_localeStringData.h" -#include "pal_icushim.h" -#include "pal_idna.h" -#include "pal_normalization.h" -#include "pal_timeZoneInfo.h" - -#endif - #if _MSC_VER #pragma warning(disable:4047) // FIXME differs in levels of indirection #endif @@ -1877,7 +1859,7 @@ type_from_parsed_name (MonoTypeNameParse *info, MonoStackCrawlMark *stack_mark, // is messed up when we go to construct the Local as the type arg... // // By contrast, if we started with Mine> we'd go in with assembly->image - // as the root and then even the detour into generics would still not cause issues when we went to load Local. + // as the root and then even the detour into generics would still not screw us when we went to load Local. if (!info->assembly.name && !type) { /* try mscorlib */ type = mono_reflection_get_type_checked (alc, rootimage, NULL, info, ignoreCase, TRUE, &type_resolve, error); @@ -3559,239 +3541,7 @@ ves_icall_System_RuntimeType_IsWindowsRuntimeObjectType (MonoError *error) mono_error_set_not_implemented (error, "%s", "System.RuntimeType.IsWindowsRuntimeObjectType"); return FALSE; } - #endif /* ENABLE_NETCORE */ -#ifdef ENABLE_NETCORE -/* -void -ves_icall_System_GlobalizationNative_ChangeCase (guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoBoolean bToUpper, MonoError *error) -{ - GlobalizationNative_ChangeCase (src, srcLen, dstBuffer, dstBufferCapacity, bToUpper); -} - -void -ves_icall_System_GlobalizationNative_ChangeCaseInvariant (guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoBoolean bToUpper, MonoError* error) -{ - GlobalizationNative_ChangeCaseInvariant (src, srcLen, dstBuffer, dstBufferCapacity, bToUpper); -} - -void -ves_icall_System_GlobalizationNative_ChangeCaseTurkish (guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoBoolean bToUpper, MonoError* error) -{ - GlobalizationNative_ChangeCaseTurkish (src, srcLen, dstBuffer, dstBufferCapacity, bToUpper); -} - -void -ves_icall_System_GlobalizationNative_CloseSortHandle (gpointer sortHandle, MonoError* error) -{ - GlobalizationNative_CloseSortHandle (sortHandle); -} - -gint32 -ves_icall_System_GlobalizationNative_CompareString (gpointer sortHandle, guint16_ref lpStr1, gint32 cwStr1Len, guint16_ref lpStr2, gint32 cwStr2Len, gint32 options, MonoError* error) -{ - guint32 ret = GlobalizationNative_CompareString (sortHandle, lpStr1, cwStr1Len, lpStr2, cwStr2Len, options); - return ret; -} - -gint32 -ves_icall_System_GlobalizationNative_CompareStringOrdinalIgnoreCase (guint16_ref lpStr1, gint32 cwStr1Len, guint16_ref lpStr2, gint32 cwStr2Len, MonoError* error) -{ - guint32 ret = GlobalizationNative_CompareStringOrdinalIgnoreCase (lpStr1, cwStr1Len, lpStr2, cwStr2Len); - return ret; -} - -gint32 -ves_icall_System_GlobalizationNative_EndsWith (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, MonoError* error) -{ - return GlobalizationNative_EndsWith (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options); -} - -gint32 -ves_icall_System_GlobalizationNative_EnumCalendarInfo (MonoDelegateHandle callback, MonoStringHandle localeName, guint16 calendarId, gint32 dataType, gpointer context, MonoError* error) -{ - gpointer ptr = mono_delegate_to_ftnptr_impl (callback, error); - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - return GlobalizationNative_EnumCalendarInfo (ptr, localeNameStr, calendarId, dataType, context); -} - -gint32 -ves_icall_System_GlobalizationNative_GetCalendarInfo (MonoStringHandle localeName, guint16 calendarId, gint32 dataType, guint16_ref result, gint32 resultCapacity, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - return GlobalizationNative_GetCalendarInfo (localeNameStr, calendarId, dataType, result, resultCapacity); -} - -gint32 -ves_icall_System_GlobalizationNative_GetCalendars (MonoStringHandle localeName, MonoArrayHandle calendars_handle, gint32 calendarsCapacity, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - gpointer calendars = mono_array_addr_with_size_internal (MONO_HANDLE_RAW(calendars_handle), 1, 0); - return GlobalizationNative_GetCalendars (localeNameStr, calendars, calendarsCapacity); -} - -gint32 -ves_icall_System_GlobalizationNative_GetDefaultLocaleName (guint16_ref value, guint32 valueLength, MonoError* error) -{ - return GlobalizationNative_GetDefaultLocaleName (value, valueLength); -} - -gint32 -ves_icall_System_GlobalizationNative_GetICUVersion (MonoError* error) -{ - return GlobalizationNative_GetICUVersion (); -} - -gint32 -ves_icall_System_GlobalizationNative_GetJapaneseEraStartDate (gint32 era, gint32_ref startYear, gint32_ref startMonth, gint32_ref startDay, MonoError* error) -{ - return GlobalizationNative_GetJapaneseEraStartDate (era, startYear, startMonth, startDay); -} - -gint32 -ves_icall_System_GlobalizationNative_GetLatestJapaneseEra (MonoError* error) -{ - return GlobalizationNative_GetLatestJapaneseEra (); -} - -MonoBoolean -ves_icall_System_GlobalizationNative_GetLocaleInfoGroupingSizes (MonoStringHandle localeName, gint32 localeGroupingDat, gint32_ref primaryGroupSize, gint32_ref secondaryGroupSize, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16(localeName); - return GlobalizationNative_GetLocaleInfoGroupingSizes (localeNameStr, localeGroupingDat, primaryGroupSize, secondaryGroupSize); -} - -MonoBoolean -ves_icall_System_GlobalizationNative_GetLocaleInfoInt (MonoStringHandle localeName, guint32 localeNumberData, guint32_ref value, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16(localeName); - return GlobalizationNative_GetLocaleInfoInt (localeNameStr, localeNumberData, value); -} - -MonoBoolean -ves_icall_System_GlobalizationNative_GetLocaleInfoString (MonoStringHandle localeName, guint32 localeStringData, guint16_ref value, guint32 valueLength, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - return GlobalizationNative_GetLocaleInfoString (localeNameStr, localeStringData, value, valueLength); -} - -MonoBoolean -ves_icall_System_GlobalizationNative_GetLocaleName (MonoStringHandle localeName, guint16_ref value, guint32 valueLength, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - return GlobalizationNative_GetLocaleName (localeNameStr, value, valueLength); -} - -gint32 -ves_icall_System_GlobalizationNative_GetLocales (MonoArrayHandle value, gint32 valueLength, MonoError* error) -{ - gint32 ret = 0; - MonoArray* value_ptr = MONO_HANDLE_RAW(value); - if (value_ptr == NULL) - ret = GlobalizationNative_GetLocales((UChar*)value_ptr, valueLength); - else { - mono_unichar2 *vpch = (mono_unichar2*) mono_array_addr_with_size_internal (value_ptr, 1, 0); - ret = GlobalizationNative_GetLocales (vpch, valueLength); - } - return ret; -} - -MonoBoolean -ves_icall_System_GlobalizationNative_GetLocaleTimeFormat (MonoStringHandle localeName, guint32 shortFormat, guint16_ref value, guint32 valueLength, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - return GlobalizationNative_GetLocaleTimeFormat (localeNameStr, shortFormat, value, valueLength); - -} - -gint32 -ves_icall_System_GlobalizationNative_GetSortHandle (MonoStringHandle sortName, gpointer_ptr ppSortHandle, MonoError* error) -{ - char* sortNameStr = mono_string_handle_to_utf8 (sortName, error); - return GlobalizationNative_GetSortHandle (sortNameStr, (SortHandle **)ppSortHandle); -} - -gint32 -ves_icall_System_GlobalizationNative_GetSortKey (gpointer sortHandle, guint16_ref str, guint32 strLength, guint8_ref sortKey, guint32 sortKeyLength, guint32 options, MonoError* error) -{ - return GlobalizationNative_GetSortKey (sortHandle, str, strLength, sortKey, sortKeyLength, options); -} - -gint32 -ves_icall_System_GlobalizationNative_GetSortVersion (gpointer sortHandle, MonoError* error) -{ - return GlobalizationNative_GetSortVersion (sortHandle); -} - -gint32 -ves_icall_System_GlobalizationNative_GetTimeZoneDisplayName (MonoStringHandle localeName, MonoStringHandle timeZoneId, gint32 type, guint16_ref result, gint32 resultLength, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - mono_unichar2* timeZoneIdStr = mono_string_handle_to_utf16 (timeZoneId); - return GlobalizationNative_GetTimeZoneDisplayName (localeNameStr, timeZoneIdStr, type, result, resultLength); -} - -gint32 -ves_icall_System_GlobalizationNative_IndexOf (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, gint32_ref pMatchedLength, MonoError* error) -{ - return GlobalizationNative_IndexOf (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options, pMatchedLength); -} - -gint32 -ves_icall_System_GlobalizationNative_IndexOfOrdinalIgnoreCase (guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 findLast, MonoError* error) -{ - return GlobalizationNative_IndexOfOrdinalIgnoreCase (lpTarget, cwTargetLength, lpSource, cwSourceLength, findLast); -} - -gint32 -ves_icall_System_GlobalizationNative_IsNormalized (gint32 normalizationForm, guint16_ref src, gint32 srcLen, MonoError* error) -{ - return GlobalizationNative_IsNormalized (normalizationForm, src, srcLen); -} - -gint32 -ves_icall_System_GlobalizationNative_IsPredefinedLocale (MonoStringHandle localeName, MonoError* error) -{ - mono_unichar2* localeNameStr = mono_string_handle_to_utf16 (localeName); - return GlobalizationNative_IsPredefinedLocale (localeNameStr); -} - -gint32 -ves_icall_System_GlobalizationNative_LastIndexOf (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, gint32_ref pMatchedLength, MonoError* error) -{ - return GlobalizationNative_LastIndexOf (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options, pMatchedLength); -} - -gint32 -ves_icall_System_GlobalizationNative_LoadICU (MonoError* error) -{ - return GlobalizationNative_LoadICU (); -} - -gint32 -ves_icall_System_GlobalizationNative_NormalizeString (gint32 normalizationForm, guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoError* error) -{ - return GlobalizationNative_NormalizeString (normalizationForm, src, srcLen, dstBuffer, dstBufferCapacity); -} - -gint32 -ves_icall_System_GlobalizationNative_StartsWith (gpointer sortHandle, guint16_ref lpTarget, gint32 cwTargetLength, guint16_ref lpSource, gint32 cwSourceLength, gint32 options, MonoError* error) -{ - return GlobalizationNative_StartsWith (sortHandle, lpTarget, cwTargetLength, lpSource, cwSourceLength, options); -} - -gint32 -ves_icall_System_GlobalizationNative_ToAscii (guint32 flags, guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoError* error) -{ - return GlobalizationNative_ToAscii (flags, src, srcLen, dstBuffer, dstBufferCapacity); -} - -gint32 -ves_icall_System_GlobalizationNative_ToUnicode (guint32 flags, guint16_ref src, gint32 srcLen, guint16_ref dstBuffer, gint32 dstBufferCapacity, MonoError* error) -{ - return GlobalizationNative_ToUnicode (flags, src, srcLen, dstBuffer, dstBufferCapacity); -}*/ -#endif void ves_icall_RuntimeMethodInfo_GetPInvoke (MonoReflectionMethodHandle ref_method, int* flags, MonoStringHandleOut entry_point, MonoStringHandleOut dll_name, MonoError *error) diff --git a/src/mono/mono/metadata/object-internals.h b/src/mono/mono/metadata/object-internals.h index 74569166210a93..0b369effebb52c 100644 --- a/src/mono/mono/metadata/object-internals.h +++ b/src/mono/mono/metadata/object-internals.h @@ -1647,30 +1647,6 @@ typedef struct { MonoProperty *prop; } CattrNamedArg; -#ifdef ENABLE_NETCORE -// Keep in sync with System.Runtime.Loader.AssemblyLoadContext.InternalState -typedef enum { - ALIVE = 0, - UNLOADING = 1 -} MonoManagedAssemblyLoadContextInternalState; - -// Keep in sync with System.Runtime.Loader.AssemblyLoadContext -typedef struct { - MonoObject object; - MonoObject *unload_lock; - MonoEvent *resolving_unmaned_dll; - MonoEvent *resolving; - MonoEvent *unloading; - MonoString *name; - gpointer *native_assembly_load_context; - gint64 id; - gint32 internal_state; - MonoBoolean is_collectible; -} MonoManagedAssemblyLoadContext; - -TYPED_HANDLE_DECL (MonoManagedAssemblyLoadContext); -#endif - /* All MonoInternalThread instances should be pinned, so it's safe to use the raw ptr. However * for uniformity, icall wrapping will make handles anyway. So this is the method for getting the payload. */ @@ -1761,9 +1737,6 @@ mono_string_handle_length (MonoStringHandle s); char * mono_string_handle_to_utf8 (MonoStringHandle s, MonoError *error); -mono_unichar2 * -mono_string_handle_to_utf16(MonoStringHandle s); - char * mono_string_to_utf8_image (MonoImage *image, MonoStringHandle s, MonoError *error); diff --git a/src/mono/mono/metadata/object.c b/src/mono/mono/metadata/object.c index 712d0c0fe4cc97..952b2be7c1cc0e 100644 --- a/src/mono/mono/metadata/object.c +++ b/src/mono/mono/metadata/object.c @@ -7848,12 +7848,6 @@ mono_string_handle_to_utf8 (MonoStringHandle s, MonoError *error) return mono_string_to_utf8_checked_internal (MONO_HANDLE_RAW (s), error); } -mono_unichar2* -mono_string_handle_to_utf16(MonoStringHandle s) -{ - return mono_string_to_utf16(MONO_HANDLE_RAW(s)); -} - /** * mono_string_to_utf8_ignore: * \param s a MonoString From a17b189a80aa2dead73130d5c0a473a2bbcaac91 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 27 Apr 2020 15:14:42 -0300 Subject: [PATCH 09/49] Removing unrelated changes --- src/mono/mono/metadata/icall.c | 2 +- src/mono/mono/metadata/object-internals.h | 24 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index a39cf2c832d26a..18c2c1e8267116 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -1859,7 +1859,7 @@ type_from_parsed_name (MonoTypeNameParse *info, MonoStackCrawlMark *stack_mark, // is messed up when we go to construct the Local as the type arg... // // By contrast, if we started with Mine> we'd go in with assembly->image - // as the root and then even the detour into generics would still not screw us when we went to load Local. + // as the root and then even the detour into generics would still not cause issues when we went to load Local. if (!info->assembly.name && !type) { /* try mscorlib */ type = mono_reflection_get_type_checked (alc, rootimage, NULL, info, ignoreCase, TRUE, &type_resolve, error); diff --git a/src/mono/mono/metadata/object-internals.h b/src/mono/mono/metadata/object-internals.h index 0b369effebb52c..9f7ef48a5ea820 100644 --- a/src/mono/mono/metadata/object-internals.h +++ b/src/mono/mono/metadata/object-internals.h @@ -1647,6 +1647,30 @@ typedef struct { MonoProperty *prop; } CattrNamedArg; +#ifdef ENABLE_NETCORE +// Keep in sync with System.Runtime.Loader.AssemblyLoadContext.InternalState +typedef enum { + ALIVE = 0, + UNLOADING = 1 +} MonoManagedAssemblyLoadContextInternalState; + +// Keep in sync with System.Runtime.Loader.AssemblyLoadContext +typedef struct { + MonoObject object; + MonoObject *unload_lock; + MonoEvent *resolving_unmaned_dll; + MonoEvent *resolving; + MonoEvent *unloading; + MonoString *name; + gpointer *native_assembly_load_context; + gint64 id; + gint32 internal_state; + MonoBoolean is_collectible; +} MonoManagedAssemblyLoadContext; + +TYPED_HANDLE_DECL (MonoManagedAssemblyLoadContext); +#endif + /* All MonoInternalThread instances should be pinned, so it's safe to use the raw ptr. However * for uniformity, icall wrapping will make handles anyway. So this is the method for getting the payload. */ From b570c23f69d7c281421d7cc493e83054404e8e2b Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 27 Apr 2020 16:58:31 -0300 Subject: [PATCH 10/49] removing unused include --- src/libraries/Native/Unix/Common/pal_compiler.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libraries/Native/Unix/Common/pal_compiler.h b/src/libraries/Native/Unix/Common/pal_compiler.h index 998ebc613f4d7a..406e409c2d19ac 100644 --- a/src/libraries/Native/Unix/Common/pal_compiler.h +++ b/src/libraries/Native/Unix/Common/pal_compiler.h @@ -33,6 +33,4 @@ #else #define EXTERN_C extern #endif // __cplusplus -#endif // EXTERN_C - -#include +#endif // EXTERN_C \ No newline at end of file From 2571f55ca30fece2a93f63c238077e29c4a34f1c Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 27 Apr 2020 17:00:30 -0300 Subject: [PATCH 11/49] Adding end of line in pal_compiler.h --- src/libraries/Native/Unix/Common/pal_compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Native/Unix/Common/pal_compiler.h b/src/libraries/Native/Unix/Common/pal_compiler.h index 406e409c2d19ac..8661443fc9f45a 100644 --- a/src/libraries/Native/Unix/Common/pal_compiler.h +++ b/src/libraries/Native/Unix/Common/pal_compiler.h @@ -33,4 +33,4 @@ #else #define EXTERN_C extern #endif // __cplusplus -#endif // EXTERN_C \ No newline at end of file +#endif // EXTERN_C From efa2cb55368f1a93f8044b3430a081be2fbd1f7a Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 29 Apr 2020 12:05:38 -0300 Subject: [PATCH 12/49] Trying to build on Linux --- src/mono/configure.ac | 8 ++++++-- src/mono/mono/metadata/Makefile.am | 28 ++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index c829de8c6f0c24..235a2fb59932cc 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6809,6 +6809,7 @@ if test x$target_osx = xyes; then ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" AC_MSG_NOTICE($ICU_CFLAGS) AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native fi CPPFLAGS=$ORIG_CPPFLAGS elif test x$host_win32 = xyes; then @@ -6825,10 +6826,11 @@ elif test x$host_linux = xyes; then AC_DEFINE(ICU_LIBS, [-licuuc, -licui18n], [adding -licuuc and -licui18n]) AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) - if test x$have_sys_icu = xyes; then - ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" + if test x$have_sys_icu = xyes; then + ICU_CFLAGS="-DTARGET_UNIX -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" AC_MSG_NOTICE($ICU_CFLAGS) AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native fi CPPFLAGS=$ORIG_CPPFLAGS fi @@ -6839,6 +6841,8 @@ AC_SUBST(LDFLAGS) AC_SUBST(CCLDFLAGS) AC_SUBST(ZLIB_CFLAGS) AC_SUBST(ICU_CFLAGS) +AC_SUBST(ICU_LIBS) +AC_SUBST(ICU_SHIM_PATH) # Update all submodules recursively to ensure everything is checked out if test "x$with_core" != "xonly"; then diff --git a/src/mono/mono/metadata/Makefile.am b/src/mono/mono/metadata/Makefile.am index 2618809c531fa6..1a2d1bf192f2a3 100644 --- a/src/mono/mono/metadata/Makefile.am +++ b/src/mono/mono/metadata/Makefile.am @@ -103,10 +103,6 @@ Z_LIBS=$(BUNDLE_ZLIB_PATH) endif endif -if HAVE_SYS_ICU -ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native -endif - noinst_LTLIBRARIES = libmonoruntime-config.la $(support_libraries) $(boehm_libraries) $(sgen_libraries) $(shim_libraries) lib_LTLIBRARIES = $(icall_table_libraries) $(ilgen_libraries) @@ -143,18 +139,18 @@ libmonoruntime_support_la_CFLAGS = $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @ shim_libraries = libmonoruntime-shimglobalization.la libmonoruntime_shimglobalization_la_SOURCES = \ - $(ICU_SHIM_PATH)/pal_calendarData.c \ - $(ICU_SHIM_PATH)/pal_casing.c \ - $(ICU_SHIM_PATH)/pal_collation.c \ - $(ICU_SHIM_PATH)/pal_idna.c \ - $(ICU_SHIM_PATH)/pal_locale.c \ - $(ICU_SHIM_PATH)/pal_localeNumberData.c \ - $(ICU_SHIM_PATH)/pal_localeStringData.c \ - $(ICU_SHIM_PATH)/pal_normalization.c \ - $(ICU_SHIM_PATH)/pal_timeZoneInfo.c \ - $(ICU_SHIM_PATH)/pal_icushim.c - -libmonoruntime_shimglobalization_la_LDFLAGS = $(ICU_LIBS) + @ICU_SHIM_PATH@/pal_calendarData.c \ + @ICU_SHIM_PATH@/pal_casing.c \ + @ICU_SHIM_PATH@/pal_collation.c \ + @ICU_SHIM_PATH@/pal_idna.c \ + @ICU_SHIM_PATH@/pal_locale.c \ + @ICU_SHIM_PATH@/pal_localeNumberData.c \ + @ICU_SHIM_PATH@/pal_localeStringData.c \ + @ICU_SHIM_PATH@/pal_normalization.c \ + @ICU_SHIM_PATH@/pal_timeZoneInfo.c \ + @ICU_SHIM_PATH@/pal_icushim.c + +libmonoruntime_shimglobalization_la_LDFLAGS = @ICU_LIBS@ libmonoruntime_shimglobalization_la_CPPFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/Common/ From 2459b39e4cfd7b8cf80b528fe641b3d14603f708 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 29 Apr 2020 12:07:52 -0300 Subject: [PATCH 13/49] Removing to do on windows --- src/mono/configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 235a2fb59932cc..9c0efa36243e68 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6812,8 +6812,6 @@ if test x$target_osx = xyes; then ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native fi CPPFLAGS=$ORIG_CPPFLAGS -elif test x$host_win32 = xyes; then - echo "TODO" elif test x$host_linux = xyes; then ORIG_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" From c233c3f5162537a0ce8ffdcfbf0b9b42f60de833 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 29 Apr 2020 12:11:00 -0300 Subject: [PATCH 14/49] Enabling only for NETCORE --- src/mono/mono/metadata/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/Makefile.am b/src/mono/mono/metadata/Makefile.am index 1a2d1bf192f2a3..d415a060eb0bc2 100644 --- a/src/mono/mono/metadata/Makefile.am +++ b/src/mono/mono/metadata/Makefile.am @@ -136,6 +136,7 @@ libmonoruntime_support_la_SOURCES = support.c libmonoruntime_support_la_LDFLAGS = $(Z_LIBS) libmonoruntime_support_la_CFLAGS = $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @ZLIB_CFLAGS@ +if ENABLE_NETCORE shim_libraries = libmonoruntime-shimglobalization.la libmonoruntime_shimglobalization_la_SOURCES = \ @@ -152,7 +153,7 @@ libmonoruntime_shimglobalization_la_SOURCES = \ libmonoruntime_shimglobalization_la_LDFLAGS = @ICU_LIBS@ libmonoruntime_shimglobalization_la_CPPFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/Common/ - +endif # # This library contains the icall tables if the runtime was configured with --disable-icall-tables From 2d419321b424813af5113dcd83f3efe24834010b Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 29 Apr 2020 12:47:59 -0300 Subject: [PATCH 15/49] removing usage of top_src_dir --- src/mono/configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 9c0efa36243e68..896c08f193874d 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6825,10 +6825,10 @@ elif test x$host_linux = xyes; then AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) if test x$have_sys_icu = xyes; then - ICU_CFLAGS="-DTARGET_UNIX -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" + ICU_CFLAGS="-DTARGET_UNIX -I/usr/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" AC_MSG_NOTICE($ICU_CFLAGS) AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) - ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native + ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native fi CPPFLAGS=$ORIG_CPPFLAGS fi From 13bd64da2cf8ce34bbdd93ce86c9b5ff72a0ab24 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 30 Apr 2020 16:55:40 -0300 Subject: [PATCH 16/49] Try to search on "dlopen(null" and if doesn't find try to search on libcoreclr.so --- src/mono/configure.ac | 65 ++++++++++++------------- src/mono/mono/metadata/Makefile.am | 2 +- src/mono/mono/metadata/native-library.c | 9 +++- src/mono/mono/utils/mono-dl-posix.c | 6 +-- 4 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 896c08f193874d..f379aab9584ec3 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6796,41 +6796,38 @@ AC_COMPILE_IFELSE( ]) # for icu shim -if test x$target_osx = xyes; then +if test x$with_core = xonly; then ORIG_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" - AC_CHECK_LIB(icucore, ucol_open, [], - [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) - - AC_DEFINE(ICU_LIBS, -licucore, [adding -licucore]) - - AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) - if test x$have_sys_icu = xyes; then - ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" - AC_MSG_NOTICE($ICU_CFLAGS) - AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) - ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native + CPPFLAGS="$CPPFLAGS -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" + + if test x$target_osx = xyes; then + AC_CHECK_LIB(icucore, ucol_open, [], + [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) + AC_DEFINE(ICU_LIBS, -licucore, [adding -licucore]) + AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) + if test x$have_sys_icu = xyes; then + ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" + AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native + fi + elif test x$host_linux = xyes; then + AC_CHECK_LIB(icuuc, main, [], + [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) + AC_CHECK_LIB(icui18n, main, [], + [AC_MSG_ERROR([Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform).])]) + AC_DEFINE(ICU_LIBS, [-licuuc, -licui18n], [adding -licuuc and -licui18n]) + AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) + if test x$have_sys_icu = xyes; then + ICU_CFLAGS="-DTARGET_UNIX -I/usr/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" + AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native + fi fi - CPPFLAGS=$ORIG_CPPFLAGS -elif test x$host_linux = xyes; then - ORIG_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" - AC_CHECK_LIB(icuuc, main, [], - [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) - AC_CHECK_LIB(icui18n, main, [], - [AC_MSG_ERROR([Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform).])]) - - AC_DEFINE(ICU_LIBS, [-licuuc, -licui18n], [adding -licuuc and -licui18n]) - - AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) - if test x$have_sys_icu = xyes; then - ICU_CFLAGS="-DTARGET_UNIX -I/usr/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" - AC_MSG_NOTICE($ICU_CFLAGS) - AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) - ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native - fi - CPPFLAGS=$ORIG_CPPFLAGS + CPPFLAGS=$ORIG_CPPFLAGS + AC_SUBST(ICU_CFLAGS) + AC_SUBST(ICU_LIBS) + AC_SUBST(ICU_SHIM_PATH) fi AC_SUBST(CFLAGS) @@ -6838,9 +6835,7 @@ AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) AC_SUBST(CCLDFLAGS) AC_SUBST(ZLIB_CFLAGS) -AC_SUBST(ICU_CFLAGS) -AC_SUBST(ICU_LIBS) -AC_SUBST(ICU_SHIM_PATH) + # Update all submodules recursively to ensure everything is checked out if test "x$with_core" != "xonly"; then diff --git a/src/mono/mono/metadata/Makefile.am b/src/mono/mono/metadata/Makefile.am index d415a060eb0bc2..2ac6b07dbf385f 100644 --- a/src/mono/mono/metadata/Makefile.am +++ b/src/mono/mono/metadata/Makefile.am @@ -152,7 +152,7 @@ libmonoruntime_shimglobalization_la_SOURCES = \ @ICU_SHIM_PATH@/pal_icushim.c libmonoruntime_shimglobalization_la_LDFLAGS = @ICU_LIBS@ -libmonoruntime_shimglobalization_la_CPPFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/Common/ +libmonoruntime_shimglobalization_la_CFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/Common/ endif # diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 91b88a79f8b323..b1abfba5105e16 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1238,7 +1238,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou new_scope = g_strdup (orig_scope); new_import = g_strdup (orig_import); #endif - +retry_with_libcoreclr: #ifdef ENABLE_NETCORE // FIXME: these flags are not getting passed correctly module = netcore_lookup_native_library (alc, image, new_scope, 0); @@ -1262,6 +1262,13 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou addr = pinvoke_probe_for_symbol (module, piinfo, new_import, &error_msg); if (!addr) { +#if defined(ENABLE_NETCORE) && !defined(HOST_WIN32) + if (strcmp (new_scope, "__Internal") == 0) { + g_free ((char *)new_scope); + new_scope = g_strdup ("libcoreclr.so"); + goto retry_with_libcoreclr; + } +#endif status_out->err_code = LOOKUP_PINVOKE_ERR_NO_SYM; status_out->err_arg = g_strdup (new_import); goto exit; diff --git a/src/mono/mono/utils/mono-dl-posix.c b/src/mono/mono/utils/mono-dl-posix.c index 1900a1acf5621b..a6c767c8285dbe 100644 --- a/src/mono/mono/utils/mono-dl-posix.c +++ b/src/mono/mono/utils/mono-dl-posix.c @@ -136,10 +136,10 @@ mono_dl_convert_flags (int flags) #ifdef ENABLE_NETCORE // Specifying both will default to LOCAL - if (flags & MONO_DL_LOCAL) - lflags |= RTLD_LOCAL; - else if (flags & MONO_DL_GLOBAL) + if (flags & MONO_DL_GLOBAL && !(flags & MONO_DL_LOCAL)) lflags |= RTLD_GLOBAL; + else + lflags |= RTLD_LOCAL; #else lflags = flags & MONO_DL_LOCAL ? RTLD_LOCAL : RTLD_GLOBAL; #endif From 5626e116281f693d0043a93f38420c921c5db69d Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 30 Apr 2020 18:20:51 -0300 Subject: [PATCH 17/49] Fix MacOs. --- src/mono/configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index f379aab9584ec3..013bccca6409b6 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6801,6 +6801,7 @@ if test x$with_core = xonly; then CPPFLAGS="$CPPFLAGS -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" if test x$target_osx = xyes; then + CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include" AC_CHECK_LIB(icucore, ucol_open, [], [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) AC_DEFINE(ICU_LIBS, -licucore, [adding -licucore]) From 5b6820a9bc4caf673d457bfca6cac6748e7a293e Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 30 Apr 2020 18:38:59 -0300 Subject: [PATCH 18/49] Compiling only when netcore for windows, and remove warning of label unused. --- src/mono/mono/metadata/native-library.c | 4 +++- src/mono/msvc/libmonoruntime.targets | 2 +- src/mono/msvc/libmonoruntime.targets.filters | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index b1abfba5105e16..ef66233eef647e 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1238,8 +1238,10 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou new_scope = g_strdup (orig_scope); new_import = g_strdup (orig_import); #endif -retry_with_libcoreclr: #ifdef ENABLE_NETCORE +#ifndef HOST_WIN32 +retry_with_libcoreclr: +#endif // FIXME: these flags are not getting passed correctly module = netcore_lookup_native_library (alc, image, new_scope, 0); #else diff --git a/src/mono/msvc/libmonoruntime.targets b/src/mono/msvc/libmonoruntime.targets index bc85f8c87451e6..7b797ee766ddcf 100644 --- a/src/mono/msvc/libmonoruntime.targets +++ b/src/mono/msvc/libmonoruntime.targets @@ -1,7 +1,7 @@ - + diff --git a/src/mono/msvc/libmonoruntime.targets.filters b/src/mono/msvc/libmonoruntime.targets.filters index 3ac39f156fdaee..5eda2fef489697 100644 --- a/src/mono/msvc/libmonoruntime.targets.filters +++ b/src/mono/msvc/libmonoruntime.targets.filters @@ -1,7 +1,7 @@  - + From 55f7fc9aa3642a9fb8dbb4751c03d09257e7f4bc Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 4 May 2020 10:10:28 -0300 Subject: [PATCH 19/49] Compilation on windows --- src/mono/msvc/libmonoruntime.targets.filters | 2 +- src/mono/msvc/shimglobalization.targets | 4 +--- src/mono/msvc/shimglobalization.targets.filters | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/mono/msvc/libmonoruntime.targets.filters b/src/mono/msvc/libmonoruntime.targets.filters index 5eda2fef489697..d59ba5b295cee9 100644 --- a/src/mono/msvc/libmonoruntime.targets.filters +++ b/src/mono/msvc/libmonoruntime.targets.filters @@ -1,7 +1,7 @@  - + diff --git a/src/mono/msvc/shimglobalization.targets b/src/mono/msvc/shimglobalization.targets index 18cdd4aafc832a..19bc337ba6c287 100644 --- a/src/mono/msvc/shimglobalization.targets +++ b/src/mono/msvc/shimglobalization.targets @@ -1,9 +1,6 @@ - - CompileAsCpp - CompileAsCpp @@ -49,5 +46,6 @@ + diff --git a/src/mono/msvc/shimglobalization.targets.filters b/src/mono/msvc/shimglobalization.targets.filters index 7b3baefee83353..58102225d2b043 100644 --- a/src/mono/msvc/shimglobalization.targets.filters +++ b/src/mono/msvc/shimglobalization.targets.filters @@ -82,10 +82,8 @@ - - From 78886b3c95b307f7c3b74c06dc4de31b22abb0ea Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 4 May 2020 11:02:02 -0300 Subject: [PATCH 20/49] Fix compilation on windows --- src/libraries/Native/Unix/Common/pal_compiler.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libraries/Native/Unix/Common/pal_compiler.h b/src/libraries/Native/Unix/Common/pal_compiler.h index 8661443fc9f45a..732dc9a9be936a 100644 --- a/src/libraries/Native/Unix/Common/pal_compiler.h +++ b/src/libraries/Native/Unix/Common/pal_compiler.h @@ -34,3 +34,7 @@ #define EXTERN_C extern #endif // __cplusplus #endif // EXTERN_C + +#ifndef MONO_API +#include +#endif \ No newline at end of file From 1e66f98530324dbc2a5cb4fee45387a49366204a Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 4 May 2020 11:18:16 -0300 Subject: [PATCH 21/49] Fixing what CoffeeFlux suggested. --- src/libraries/Native/Unix/Common/pal_compiler.h | 2 +- src/mono/configure.ac | 1 - src/mono/mono/metadata/icall-decl.h | 0 src/mono/mono/metadata/native-library.c | 1 + 4 files changed, 2 insertions(+), 2 deletions(-) mode change 100755 => 100644 src/mono/mono/metadata/icall-decl.h diff --git a/src/libraries/Native/Unix/Common/pal_compiler.h b/src/libraries/Native/Unix/Common/pal_compiler.h index 732dc9a9be936a..e066134c5974a9 100644 --- a/src/libraries/Native/Unix/Common/pal_compiler.h +++ b/src/libraries/Native/Unix/Common/pal_compiler.h @@ -37,4 +37,4 @@ #ifndef MONO_API #include -#endif \ No newline at end of file +#endif diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 013bccca6409b6..92a8513c7fdf6b 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6837,7 +6837,6 @@ AC_SUBST(LDFLAGS) AC_SUBST(CCLDFLAGS) AC_SUBST(ZLIB_CFLAGS) - # Update all submodules recursively to ensure everything is checked out if test "x$with_core" != "xonly"; then (cd $srcdir && scripts/update_submodules.sh) diff --git a/src/mono/mono/metadata/icall-decl.h b/src/mono/mono/metadata/icall-decl.h old mode 100755 new mode 100644 diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index ef66233eef647e..7474cf4ecee571 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1238,6 +1238,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou new_scope = g_strdup (orig_scope); new_import = g_strdup (orig_import); #endif + #ifdef ENABLE_NETCORE #ifndef HOST_WIN32 retry_with_libcoreclr: From b07315cf6c5caa29c5c99962d3a633f8be25c69b Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 4 May 2020 13:23:12 -0300 Subject: [PATCH 22/49] Fix MacOs. --- src/libraries/Native/Unix/Common/pal_compiler.h | 4 ---- src/mono/configure.ac | 2 -- 2 files changed, 6 deletions(-) diff --git a/src/libraries/Native/Unix/Common/pal_compiler.h b/src/libraries/Native/Unix/Common/pal_compiler.h index e066134c5974a9..8661443fc9f45a 100644 --- a/src/libraries/Native/Unix/Common/pal_compiler.h +++ b/src/libraries/Native/Unix/Common/pal_compiler.h @@ -34,7 +34,3 @@ #define EXTERN_C extern #endif // __cplusplus #endif // EXTERN_C - -#ifndef MONO_API -#include -#endif diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 92a8513c7fdf6b..2b50280eb06023 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6798,8 +6798,6 @@ AC_COMPILE_IFELSE( # for icu shim if test x$with_core = xonly; then ORIG_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" - if test x$target_osx = xyes; then CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include" AC_CHECK_LIB(icucore, ucol_open, [], From a9ed86561b2f97fac6697870d681d32462f417ff Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 4 May 2020 15:06:02 -0300 Subject: [PATCH 23/49] Fix windows compilation --- src/mono/msvc/libmono-dynamic.vcxproj | 8 ++++---- src/mono/msvc/libmonoruntime.vcxproj | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mono/msvc/libmono-dynamic.vcxproj b/src/mono/msvc/libmono-dynamic.vcxproj index 755c0e30f50b8a..3ce0ef8ea8b38a 100644 --- a/src/mono/msvc/libmono-dynamic.vcxproj +++ b/src/mono/msvc/libmono-dynamic.vcxproj @@ -97,7 +97,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -124,7 +124,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -148,7 +148,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) true Level3 true @@ -177,7 +177,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) true Level3 true diff --git a/src/mono/msvc/libmonoruntime.vcxproj b/src/mono/msvc/libmonoruntime.vcxproj index fc6c6293fec750..14e0c530bb4e84 100644 --- a/src/mono/msvc/libmonoruntime.vcxproj +++ b/src/mono/msvc/libmonoruntime.vcxproj @@ -97,7 +97,7 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -111,7 +111,7 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON));%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -125,7 +125,7 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true @@ -141,7 +141,7 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions;TARGET_WINDOWS;PALEXPORT=MONO_API + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions;TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true From 3d5d97b78f67b9e405516fb64c7565584cac568f Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Mon, 4 May 2020 15:56:45 -0300 Subject: [PATCH 24/49] Trying to fix android compilation. --- src/mono/configure.ac | 2 ++ src/mono/mono/metadata/Makefile.am | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 2b50280eb06023..b277d3abb6b465 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6807,6 +6807,7 @@ if test x$with_core = xonly; then if test x$have_sys_icu = xyes; then ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + AC_DEFINE(HAVE_SYS_ICU, 1, [Use static icu shim]) ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native fi elif test x$host_linux = xyes; then @@ -6819,6 +6820,7 @@ if test x$with_core = xonly; then if test x$have_sys_icu = xyes; then ICU_CFLAGS="-DTARGET_UNIX -I/usr/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) + AC_DEFINE(HAVE_SYS_ICU, 1, [Use static icu shim]) ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native fi fi diff --git a/src/mono/mono/metadata/Makefile.am b/src/mono/mono/metadata/Makefile.am index 2ac6b07dbf385f..1d9d179a0282f0 100644 --- a/src/mono/mono/metadata/Makefile.am +++ b/src/mono/mono/metadata/Makefile.am @@ -137,6 +137,7 @@ libmonoruntime_support_la_LDFLAGS = $(Z_LIBS) libmonoruntime_support_la_CFLAGS = $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @ZLIB_CFLAGS@ if ENABLE_NETCORE +if HAVE_SYS_ICU shim_libraries = libmonoruntime-shimglobalization.la libmonoruntime_shimglobalization_la_SOURCES = \ @@ -154,6 +155,7 @@ libmonoruntime_shimglobalization_la_SOURCES = \ libmonoruntime_shimglobalization_la_LDFLAGS = @ICU_LIBS@ libmonoruntime_shimglobalization_la_CFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/Common/ endif +endif # # This library contains the icall tables if the runtime was configured with --disable-icall-tables From 31200b39507037eab5faaafea34f1406880636d5 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 11:26:44 -0300 Subject: [PATCH 25/49] Unchanging permissions of this file. --- .../Native/Unix/System.Globalization.Native/pal_icushim.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c old mode 100755 new mode 100644 From 2d25950541f560031d0cc1b6eb8181cf127f03c2 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 13:56:06 -0300 Subject: [PATCH 26/49] Removing hardcoded include path. Fixing android compilation. --- src/mono/configure.ac | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index b277d3abb6b465..7d93dac47267dd 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6797,19 +6797,21 @@ AC_COMPILE_IFELSE( # for icu shim if test x$with_core = xonly; then - ORIG_CPPFLAGS=$CPPFLAGS + ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native if test x$target_osx = xyes; then - CPPFLAGS="$CPPFLAGS -I/usr/local/opt/icu4c/include" + ORIG_CPPFLAGS=$CPPFLAGS + # adding icu path to pkg_config_path + PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig + export PKG_CONFIG_PATH + CPPFLAGS="`pkg-config --cflags-only-I icu-uc`" AC_CHECK_LIB(icucore, ucol_open, [], [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) AC_DEFINE(ICU_LIBS, -licucore, [adding -licucore]) AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) if test x$have_sys_icu = xyes; then - ICU_CFLAGS="-DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -I/usr/local/opt/icu4c/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" - AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) - AC_DEFINE(HAVE_SYS_ICU, 1, [Use static icu shim]) - ICU_SHIM_PATH='$(top_srcdir)'/../libraries/Native/Unix/System.Globalization.Native + ICU_CFLAGS="$CPPFLAGS -DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" fi + CPPFLAGS=$ORIG_CPPFLAGS elif test x$host_linux = xyes; then AC_CHECK_LIB(icuuc, main, [], [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) @@ -6818,18 +6820,15 @@ if test x$with_core = xonly; then AC_DEFINE(ICU_LIBS, [-licuuc, -licui18n], [adding -licuuc and -licui18n]) AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) if test x$have_sys_icu = xyes; then - ICU_CFLAGS="-DTARGET_UNIX -I/usr/include -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" - AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) - AC_DEFINE(HAVE_SYS_ICU, 1, [Use static icu shim]) - ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native + ICU_CFLAGS="-DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" fi fi - CPPFLAGS=$ORIG_CPPFLAGS AC_SUBST(ICU_CFLAGS) AC_SUBST(ICU_LIBS) AC_SUBST(ICU_SHIM_PATH) fi +AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) From fbd44f2aefe987531285b107d7ac8370c1c5358f Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 14:23:28 -0300 Subject: [PATCH 27/49] Fixing what was suggested by @safern --- .../Native/Unix/System.Globalization.Native/pal_icushim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c index 68afaabc2e254c..27a09b4831c4f2 100755 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c @@ -3,10 +3,11 @@ // See the LICENSE file in the project root for more information. // +#include "pal_icushim_internal.h" + #if defined(TARGET_UNIX) #include #elif defined(TARGET_WINDOWS) -#include #include #include #include @@ -16,7 +17,6 @@ #include #include -#include "pal_icushim_internal.h" #include "pal_icushim.h" // Define pointers to all the used ICU functions From 2657cb611ec29ef57a1d2919323316672800352a Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 15:30:11 -0300 Subject: [PATCH 28/49] Changing what was suggested by safern --- .../System.Globalization.Native/pal_icushim.c | 2 +- .../System.Globalization/tests/IcuTests.cs | 3 +-- .../Globalization/GlobalizationMode.Mono.cs | 2 -- .../GlobalizationMode.Unix.Mono.cs | 1 + .../GlobalizationMode.Windows.Mono.cs | 21 ++----------------- 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c index 27a09b4831c4f2..445e40d35912f9 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim.c @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. // +#include #include "pal_icushim_internal.h" #if defined(TARGET_UNIX) @@ -12,7 +13,6 @@ #include #include #endif -#include #include #include #include diff --git a/src/libraries/System.Globalization/tests/IcuTests.cs b/src/libraries/System.Globalization/tests/IcuTests.cs index 8e862c910195fd..80533da8fb7d14 100644 --- a/src/libraries/System.Globalization/tests/IcuTests.cs +++ b/src/libraries/System.Globalization/tests/IcuTests.cs @@ -11,8 +11,7 @@ namespace System.Globalization.Tests public class IcuTests { private static bool IsIcuCompatiblePlatform => PlatformDetection.IsNotWindows || - (!PlatformDetection.IsMonoRuntime && - PlatformDetection.IsWindows10Version1903OrGreater); + PlatformDetection.IsWindows10Version1903OrGreater; [ConditionalFact(nameof(IsIcuCompatiblePlatform))] public static void IcuShouldBeUsedByDefault() diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs index 911499ea842e37..3789e292b7dce8 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs @@ -6,8 +6,6 @@ namespace System.Globalization { internal static partial class GlobalizationMode { - internal static bool Invariant { get; } = GetGlobalizationInvariantMode(); - private static bool GetInvariantSwitchValue() { string? val = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs index e3ca7ce6173663..75998b3bdefc75 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs @@ -8,6 +8,7 @@ namespace System.Globalization { internal partial class GlobalizationMode { + internal static bool Invariant { get; } = GetInvariantSwitchValue(); internal static bool UseNls => false; private static bool GetGlobalizationInvariantMode() diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs index 90d85339704df0..6380118156d96e 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs @@ -8,6 +8,7 @@ namespace System.Globalization { internal partial class GlobalizationMode { + internal static bool Invariant { get; } = GetInvariantSwitchValue(); internal static bool UseNls { get { return !Invariant && Interop.Globalization.LoadICU() == 0; @@ -15,25 +16,7 @@ internal static bool UseNls { } private static bool GetGlobalizationInvariantMode() { - bool invariantEnabled = GetInvariantSwitchValue(); - if (invariantEnabled) - return true; - - LoadICU(); - return false; - } - - // Keep this in a separate method to avoid loading the native lib in invariant mode - [MethodImpl(MethodImplOptions.NoInlining)] - private static void LoadICU() - { - int res = Interop.Globalization.LoadICU(); - if (res == 0) - { - string message = "Couldn't find a valid ICU package installed on the system. " + - "Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support."; - Environment.FailFast(message); - } + return Invariant; } } } From 1bebc323e59b5b83cfa6c1f30f0e8cb923b22efe Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 15:36:29 -0300 Subject: [PATCH 29/49] Changing what was suggested by safern --- .../src/System/Globalization/GlobalizationMode.Unix.Mono.cs | 2 +- .../System/Globalization/GlobalizationMode.Windows.Mono.cs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs index 75998b3bdefc75..70d7e7e3dc41f9 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.Mono.cs @@ -8,7 +8,7 @@ namespace System.Globalization { internal partial class GlobalizationMode { - internal static bool Invariant { get; } = GetInvariantSwitchValue(); + internal static bool Invariant { get; } = GetGlobalizationInvariantMode(); internal static bool UseNls => false; private static bool GetGlobalizationInvariantMode() diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs index 6380118156d96e..9b9c533e249720 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs @@ -14,9 +14,5 @@ internal static bool UseNls { return !Invariant && Interop.Globalization.LoadICU() == 0; } } - private static bool GetGlobalizationInvariantMode() - { - return Invariant; - } } } From 2bf4f5072cf61d550f9b1e46cb7d59d349e00b37 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 15:47:07 -0300 Subject: [PATCH 30/49] Update src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs Co-authored-by: Santiago Fernandez Madero --- .../System/Globalization/GlobalizationMode.Windows.Mono.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs index 9b9c533e249720..976e907a94ad64 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs @@ -9,10 +9,6 @@ namespace System.Globalization internal partial class GlobalizationMode { internal static bool Invariant { get; } = GetInvariantSwitchValue(); - internal static bool UseNls { - get { - return !Invariant && Interop.Globalization.LoadICU() == 0; - } - } + internal static bool UseNls { get; } = !Invariant && Interop.Globalization.LoadICU() == 0; } } From b483e41cfb31879bd2c5dacefabba18dc8cc7e8f Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 16:00:27 -0300 Subject: [PATCH 31/49] Fixing what safern explained. --- .../Globalization/GlobalizationMode.Mono.cs | 16 +++++++++++----- .../GlobalizationMode.Windows.Mono.cs | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs index 3789e292b7dce8..004176910513a7 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs @@ -6,12 +6,18 @@ namespace System.Globalization { internal static partial class GlobalizationMode { - private static bool GetInvariantSwitchValue() + private static bool GetInvariantSwitchValue() => + GetSwitchValue("System.Globalization.Invariant", "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"); + + private static bool GetSwitchValue(string switchName, string envVariable) { - string? val = Environment.GetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"); - if (val != null) - return bool.IsTrueStringIgnoreCase(val) || val.Equals("1"); - return false; + bool ret = false; + string? switchValue = Environment.GetEnvironmentVariable(envVariable); + if (switchValue != null) + { + ret = bool.IsTrueStringIgnoreCase(switchValue) || switchValue.Equals("1"); + } + return ret; } } } diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs index 976e907a94ad64..f1e44495c1e8f6 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs @@ -9,6 +9,8 @@ namespace System.Globalization internal partial class GlobalizationMode { internal static bool Invariant { get; } = GetInvariantSwitchValue(); - internal static bool UseNls { get; } = !Invariant && Interop.Globalization.LoadICU() == 0; + internal static bool UseNls { get; } = !Invariant && + (GetSwitchValue("System.Globalization.UseNls", "DOTNET_SYSTEM_GLOBALIZATION_USENLS") || + Interop.Globalization.LoadICU() == 0); } } From 376764ad11ef050717b82517fb39b37d32d44cbc Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 17:08:39 -0300 Subject: [PATCH 32/49] Fixing windows includes. --- src/mono/msvc/libmono-dynamic.vcxproj | 2 +- src/mono/msvc/libmonoruntime.vcxproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/msvc/libmono-dynamic.vcxproj b/src/mono/msvc/libmono-dynamic.vcxproj index 3ce0ef8ea8b38a..e2279472a6e6a5 100644 --- a/src/mono/msvc/libmono-dynamic.vcxproj +++ b/src/mono/msvc/libmono-dynamic.vcxproj @@ -176,7 +176,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) true Level3 diff --git a/src/mono/msvc/libmonoruntime.vcxproj b/src/mono/msvc/libmonoruntime.vcxproj index 14e0c530bb4e84..3063f73f5a4432 100644 --- a/src/mono/msvc/libmonoruntime.vcxproj +++ b/src/mono/msvc/libmonoruntime.vcxproj @@ -112,7 +112,7 @@ Level3 Disabled WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON));%(AdditionalIncludeDirectories) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase From 8327179f6ad1b1770aba9049664905bbb8e6078c Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 5 May 2020 20:58:35 -0300 Subject: [PATCH 33/49] Removing unused var. --- .../src/System/Globalization/GlobalizationMode.Mono.cs | 4 ++-- .../System/Globalization/GlobalizationMode.Windows.Mono.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs index 004176910513a7..3d7b5ca4866f24 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Mono.cs @@ -7,9 +7,9 @@ namespace System.Globalization internal static partial class GlobalizationMode { private static bool GetInvariantSwitchValue() => - GetSwitchValue("System.Globalization.Invariant", "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"); + GetSwitchValue("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT"); - private static bool GetSwitchValue(string switchName, string envVariable) + private static bool GetSwitchValue(string envVariable) { bool ret = false; string? switchValue = Environment.GetEnvironmentVariable(envVariable); diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs index f1e44495c1e8f6..a9b5e37d7b4900 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs @@ -10,7 +10,7 @@ internal partial class GlobalizationMode { internal static bool Invariant { get; } = GetInvariantSwitchValue(); internal static bool UseNls { get; } = !Invariant && - (GetSwitchValue("System.Globalization.UseNls", "DOTNET_SYSTEM_GLOBALIZATION_USENLS") || + (GetSwitchValue("DOTNET_SYSTEM_GLOBALIZATION_USENLS") || Interop.Globalization.LoadICU() == 0); } } From 5c06e567d440fee1784ecb65f7e9e4625f5126f7 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 6 May 2020 10:42:45 -0300 Subject: [PATCH 34/49] Changing what was suggested by @lateralusX --- src/mono/msvc/libmono-dynamic.vcxproj | 16 ++++++++-------- src/mono/msvc/libmonoruntime.vcxproj | 16 ++++++++-------- src/mono/msvc/mono.props | 6 ++++-- src/mono/msvc/shimglobalization.targets.filters | 6 ++---- .../GlobalizationMode.Windows.Mono.cs | 2 -- 5 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/mono/msvc/libmono-dynamic.vcxproj b/src/mono/msvc/libmono-dynamic.vcxproj index e2279472a6e6a5..27817b0e9d103d 100644 --- a/src/mono/msvc/libmono-dynamic.vcxproj +++ b/src/mono/msvc/libmono-dynamic.vcxproj @@ -96,8 +96,8 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -123,8 +123,8 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -147,8 +147,8 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) true Level3 true @@ -176,8 +176,8 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) true Level3 true diff --git a/src/mono/msvc/libmonoruntime.vcxproj b/src/mono/msvc/libmonoruntime.vcxproj index 3063f73f5a4432..4f7459503361d2 100644 --- a/src/mono/msvc/libmonoruntime.vcxproj +++ b/src/mono/msvc/libmonoruntime.vcxproj @@ -97,8 +97,8 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -111,8 +111,8 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE;$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -125,8 +125,8 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true @@ -141,8 +141,8 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions;TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) - $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION);$(SHIM_GLOBALIZATION_COMMON);%(AdditionalIncludeDirectories) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true diff --git a/src/mono/msvc/mono.props b/src/mono/msvc/mono.props index a870529a5689b8..502c5398527d25 100644 --- a/src/mono/msvc/mono.props +++ b/src/mono/msvc/mono.props @@ -45,8 +45,9 @@ $(MONO_LIBGC_INCLUDE_DIR) $(MONO_EGLIB_SOURCE_DIR) 610 - $(top_srcdir)/../libraries/Native/Unix/System.Globalization.Native - $(top_srcdir)/../libraries/Native/Unix/Common + $(top_srcdir)/../libraries/Native/Unix/System.Globalization.Native + $(top_srcdir)/../libraries/Native/Unix/Common + $(SHIM_GLOBALIZATION_COMMON);$(SHIM_GLOBALIZATION) $(MONO_DIR)/external/llvm-project/llvm/include @@ -60,6 +61,7 @@ HAVE_SGEN_GC;HAVE_MOVING_COLLECTOR;HAVE_WRITE_BARRIERS;HAVE_CONC_GC_AS_DEFAULT $(SGEN_DEFINES) + TARGET_WINDOWS;PALEXPORT=extern "C" __declspec(dllexport) libgcmonosgen.lib -sgen $(MONO_BUILD_DIR_PREFIX)sgen/ diff --git a/src/mono/msvc/shimglobalization.targets.filters b/src/mono/msvc/shimglobalization.targets.filters index 58102225d2b043..106d7b8717996c 100644 --- a/src/mono/msvc/shimglobalization.targets.filters +++ b/src/mono/msvc/shimglobalization.targets.filters @@ -81,9 +81,7 @@ - - - - + + diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs index a9b5e37d7b4900..abf2a603c21261 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Windows.Mono.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Runtime.CompilerServices; - namespace System.Globalization { From 1af719d1be666409c8a6e264ee278b5866b6347a Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Wed, 6 May 2020 16:28:35 -0300 Subject: [PATCH 35/49] Fixing test failure. --- src/mono/mono/mini/monovm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mono/mono/mini/monovm.c b/src/mono/mono/mini/monovm.c index d1aff44ed68f6a..32185645d985f4 100644 --- a/src/mono/mono/mini/monovm.c +++ b/src/mono/mono/mini/monovm.c @@ -181,6 +181,9 @@ parse_properties (int propertyCount, const char **propertyKeys, const char **pro } else if (prop_len == 30 && !strncmp (propertyKeys [i], "System.Globalization.Invariant", 30)) { // TODO: Ideally we should propagate this through AppContext options g_setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", propertyValues [i], TRUE); + } else if (prop_len == 27 && !strncmp (propertyKeys [i], "System.Globalization.UseNls", 27)) { + // TODO: Ideally we should propagate this through AppContext options + g_setenv ("DOTNET_SYSTEM_GLOBALIZATION_USENLS", propertyValues [i], TRUE); } else { #if 0 // can't use mono logger, it's not initialized yet. From 06460ff67da90b0c3f26c709fdd86cb642704bb2 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 7 May 2020 07:46:29 -0300 Subject: [PATCH 36/49] Changing includes order as suggested by @lateralusX --- src/mono/msvc/libmono-dynamic.vcxproj | 8 ++++---- src/mono/msvc/libmonoruntime.vcxproj | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mono/msvc/libmono-dynamic.vcxproj b/src/mono/msvc/libmono-dynamic.vcxproj index 27817b0e9d103d..c63be2c85ad72f 100644 --- a/src/mono/msvc/libmono-dynamic.vcxproj +++ b/src/mono/msvc/libmono-dynamic.vcxproj @@ -97,7 +97,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);$(SHIM_GLOBALIZATION_DEFINES);_DEBUG;%(PreprocessorDefinitions) 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -124,7 +124,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) Disabled $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);$(SHIM_GLOBALIZATION_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions) 4996;4018;4244;%(DisableSpecificWarnings) Level3 @@ -148,7 +148,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);$(SHIM_GLOBALIZATION_DEFINES);NDEBUG;%(PreprocessorDefinitions) true Level3 true @@ -177,7 +177,7 @@ /D /NODEFAULTLIB:LIBCD" " %(AdditionalOptions) true $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(MONO_LLVM_DEFAULT_INCLUDE_DIR);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) - WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);WIN64;NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;$(GC_DEFINES);MONO_DLL_EXPORT;LLVM_API_VERSION=$(MONO_LLVM_DEFAULT_API_VERSION);$(SHIM_GLOBALIZATION_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions) true Level3 true diff --git a/src/mono/msvc/libmonoruntime.vcxproj b/src/mono/msvc/libmonoruntime.vcxproj index 4f7459503361d2..2541712d4817e7 100644 --- a/src/mono/msvc/libmonoruntime.vcxproj +++ b/src/mono/msvc/libmonoruntime.vcxproj @@ -97,7 +97,7 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);$(SHIM_GLOBALIZATION_DEFINES);_DEBUG;%(PreprocessorDefinitions) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -111,7 +111,7 @@ Level3 Disabled - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);$(SHIM_GLOBALIZATION_DEFINES);WIN64;_DEBUG;%(PreprocessorDefinitions) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb ProgramDatabase @@ -125,7 +125,7 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);$(SHIM_GLOBALIZATION_DEFINES);NDEBUG;%(PreprocessorDefinitions) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true @@ -141,7 +141,7 @@ Level3 true - WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions);$(SHIM_GLOBALIZATION_DEFINES) + WIN32;WIN32_LEAN_AND_MEAN;_LIB;$(GC_DEFINES);$(SHIM_GLOBALIZATION_DEFINES);WIN64;NDEBUG;%(PreprocessorDefinitions) $(MONO_DIR);$(MONO_INCLUDE_DIR);$(LIBGC_CPPFLAGS_INCLUDE);$(GLIB_CFLAGS_INCLUDE);$(SHIM_GLOBALIZATION_INCLUDE_DIR);%(AdditionalIncludeDirectories) $(IntDir)$(TargetName).pdb true From 1a884adc9c28b9177f9c50ddc6b0c0e25647a81d Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 7 May 2020 13:36:25 -0300 Subject: [PATCH 37/49] Fix mono compilation --- src/mono/configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 7d93dac47267dd..7cdcac5fc5b3cc 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6796,6 +6796,7 @@ AC_COMPILE_IFELSE( ]) # for icu shim +ICU_SHIM_PATH=. if test x$with_core = xonly; then ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native if test x$target_osx = xyes; then @@ -6826,8 +6827,8 @@ if test x$with_core = xonly; then AC_SUBST(ICU_CFLAGS) AC_SUBST(ICU_LIBS) - AC_SUBST(ICU_SHIM_PATH) fi +AC_SUBST(ICU_SHIM_PATH) AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) AC_SUBST(CFLAGS) From dc17ef9c3c2cb403efdd343b53525e3b0f66ab4f Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 7 May 2020 19:29:02 -0300 Subject: [PATCH 38/49] Removing dynamic link to icu libraries. --- src/mono/configure.ac | 9 +++------ src/mono/mono/metadata/Makefile.am | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 7cdcac5fc5b3cc..938bfe65fb68f0 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6805,20 +6805,18 @@ if test x$with_core = xonly; then PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig export PKG_CONFIG_PATH CPPFLAGS="`pkg-config --cflags-only-I icu-uc`" - AC_CHECK_LIB(icucore, ucol_open, [], + AC_CHECK_LIB(icucore, ucol_open, LIBS=$LIBS, [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) - AC_DEFINE(ICU_LIBS, -licucore, [adding -licucore]) AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) if test x$have_sys_icu = xyes; then ICU_CFLAGS="$CPPFLAGS -DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" fi CPPFLAGS=$ORIG_CPPFLAGS elif test x$host_linux = xyes; then - AC_CHECK_LIB(icuuc, main, [], + AC_CHECK_LIB(icuuc, main, LIBS=$LIBS, [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) - AC_CHECK_LIB(icui18n, main, [], + AC_CHECK_LIB(icui18n, main, LIBS=$LIBS, [AC_MSG_ERROR([Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform).])]) - AC_DEFINE(ICU_LIBS, [-licuuc, -licui18n], [adding -licuuc and -licui18n]) AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) if test x$have_sys_icu = xyes; then ICU_CFLAGS="-DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" @@ -6826,7 +6824,6 @@ if test x$with_core = xonly; then fi AC_SUBST(ICU_CFLAGS) - AC_SUBST(ICU_LIBS) fi AC_SUBST(ICU_SHIM_PATH) AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) diff --git a/src/mono/mono/metadata/Makefile.am b/src/mono/mono/metadata/Makefile.am index 1d9d179a0282f0..6a4bf4e7238ebe 100644 --- a/src/mono/mono/metadata/Makefile.am +++ b/src/mono/mono/metadata/Makefile.am @@ -152,7 +152,6 @@ libmonoruntime_shimglobalization_la_SOURCES = \ @ICU_SHIM_PATH@/pal_timeZoneInfo.c \ @ICU_SHIM_PATH@/pal_icushim.c -libmonoruntime_shimglobalization_la_LDFLAGS = @ICU_LIBS@ libmonoruntime_shimglobalization_la_CFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/Common/ endif endif From 3bbdf1edbec5a96b0ed78f1e96a9024c98c99aa9 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Fri, 8 May 2020 12:26:05 -0300 Subject: [PATCH 39/49] Fixing side effect running System.Net.ServicePoint.Tests. --- .../src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs index 0fea7764808c25..a98d050e328a97 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs @@ -129,7 +129,13 @@ public void StartProfileOptimization(string? profile) // Invoked by Mono to resolve requests to load satellite assemblies. private static Assembly? MonoResolveUsingResolveSatelliteAssembly(IntPtr gchALC, string assemblyName) { - return ResolveSatelliteAssembly(gchALC, new AssemblyName(assemblyName)); + AssemblyLoadContext context; + // This check exists because the function can be called early in startup, before the default ALC is initialized + if (gchALC == IntPtr.Zero) + context = Default; + else + context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchALC).Target)!; + return context.ResolveSatelliteAssembly(new AssemblyName(assemblyName)); } private static AssemblyLoadContext GetAssemblyLoadContext(IntPtr gchManagedAssemblyLoadContext) From 2e45cbeb8b1e53b189b7863bef8b9a66aac0b8d6 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Fri, 8 May 2020 12:42:01 -0300 Subject: [PATCH 40/49] Moving implementation of ResolveSatelliteAssembly back to AssemblyLoadContext.CoreCLR.cs. --- .../Runtime/Loader/AssemblyLoadContext.CoreCLR.cs | 10 ++++++++++ .../src/System/Runtime/Loader/AssemblyLoadContext.cs | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs index 7b494115f72d61..997fa49107dcee 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs @@ -95,6 +95,16 @@ internal Assembly LoadFromInMemoryModule(IntPtr moduleHandle) } #endif + // This method is invoked by the VM to resolve a satellite assembly reference + // after trying assembly resolution via Load override without success. + private static Assembly? ResolveSatelliteAssembly(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) + { + AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!; + + // Invoke the ResolveSatelliteAssembly method + return context.ResolveSatelliteAssembly(assemblyName); + } + // This method is invoked by the VM when using the host-provided assembly load context // implementation. private static IntPtr ResolveUnmanagedDll(string unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index c958169fe579dc..80d7c00ea8d546 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -564,16 +564,6 @@ public void Dispose() return context.ResolveUsingLoad(assemblyName); } - // This method is invoked by the VM to resolve a satellite assembly reference - // after trying assembly resolution via Load override without success. - private static Assembly? ResolveSatelliteAssembly(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName) - { - AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target)!; - - // Invoke the ResolveSatelliteAssembly method - return context.ResolveSatelliteAssembly(assemblyName); - } - private Assembly? GetFirstResolvedAssemblyFromResolvingEvent(AssemblyName assemblyName) { Assembly? resolvedAssembly = null; From d83a61c23b864291c50af75e7c30d6c2f6763680 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Fri, 8 May 2020 15:51:22 -0300 Subject: [PATCH 41/49] Fixing side effect on Mac. --- src/mono/mono/metadata/native-library.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 7474cf4ecee571..5ef0bcd87bac37 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1268,7 +1268,11 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou #if defined(ENABLE_NETCORE) && !defined(HOST_WIN32) if (strcmp (new_scope, "__Internal") == 0) { g_free ((char *)new_scope); +#if defined(TARGET_OSX) + new_scope = g_strdup ("libcoreclr.dylib"); +#else new_scope = g_strdup ("libcoreclr.so"); +#endif goto retry_with_libcoreclr; } #endif From 11c7a3d825740646720573beb319945fffd4572c Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Sat, 9 May 2020 09:45:00 -0300 Subject: [PATCH 42/49] Fixing side when compiling with netcore configuration but without globalization shim files. --- src/mono/configure.ac | 50 ++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 938bfe65fb68f0..7934201d1080a7 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6798,32 +6798,34 @@ AC_COMPILE_IFELSE( # for icu shim ICU_SHIM_PATH=. if test x$with_core = xonly; then - ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native - if test x$target_osx = xyes; then - ORIG_CPPFLAGS=$CPPFLAGS - # adding icu path to pkg_config_path - PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig - export PKG_CONFIG_PATH - CPPFLAGS="`pkg-config --cflags-only-I icu-uc`" - AC_CHECK_LIB(icucore, ucol_open, LIBS=$LIBS, - [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) - AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) - if test x$have_sys_icu = xyes; then - ICU_CFLAGS="$CPPFLAGS -DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" - fi - CPPFLAGS=$ORIG_CPPFLAGS - elif test x$host_linux = xyes; then - AC_CHECK_LIB(icuuc, main, LIBS=$LIBS, - [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) - AC_CHECK_LIB(icui18n, main, LIBS=$LIBS, - [AC_MSG_ERROR([Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform).])]) - AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) - if test x$have_sys_icu = xyes; then - ICU_CFLAGS="-DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" + AC_CHECK_FILE($srcdir/../libraries/Native/Unix/System.Globalization.Native/pal_icushim.h, [have_shim_globalization=yes], [have_shim_globalization=no]) + if test x$have_shim_globalization = xyes; then + ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native + if test x$target_osx = xyes; then + ORIG_CPPFLAGS=$CPPFLAGS + # adding icu path to pkg_config_path + PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig + export PKG_CONFIG_PATH + CPPFLAGS="`pkg-config --cflags-only-I icu-uc`" + AC_CHECK_LIB(icucore, ucol_open, LIBS=$LIBS, + [AC_MSG_ERROR([Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.])]) + AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) + if test x$have_sys_icu = xyes; then + ICU_CFLAGS="$CPPFLAGS -DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" + fi + CPPFLAGS=$ORIG_CPPFLAGS + elif test x$host_linux = xyes; then + AC_CHECK_LIB(icuuc, main, LIBS=$LIBS, + [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) + AC_CHECK_LIB(icui18n, main, LIBS=$LIBS, + [AC_MSG_ERROR([Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform).])]) + AC_CHECK_HEADER(unicode/utypes.h, [have_sys_icu=yes], [have_sys_icu=no]) + if test x$have_sys_icu = xyes; then + ICU_CFLAGS="-DTARGET_UNIX -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" + fi fi + AC_SUBST(ICU_CFLAGS) fi - - AC_SUBST(ICU_CFLAGS) fi AC_SUBST(ICU_SHIM_PATH) AM_CONDITIONAL(HAVE_SYS_ICU, test x$have_sys_icu = xyes) From 2737b96c45d9ab15b966e157aaa4d0f9720467ca Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Sat, 9 May 2020 10:13:12 -0300 Subject: [PATCH 43/49] Fix cross compilation --- src/mono/configure.ac | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 7934201d1080a7..e7f4406a57904a 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6798,8 +6798,10 @@ AC_COMPILE_IFELSE( # for icu shim ICU_SHIM_PATH=. if test x$with_core = xonly; then - AC_CHECK_FILE($srcdir/../libraries/Native/Unix/System.Globalization.Native/pal_icushim.h, [have_shim_globalization=yes], [have_shim_globalization=no]) - if test x$have_shim_globalization = xyes; then + if test x$cross_compiling = xno; then + AC_CHECK_FILE($srcdir/../libraries/Native/Unix/System.Globalization.Native/pal_icushim.h, [have_shim_globalization=yes], [have_shim_globalization=no]) + fi + if test x$have_shim_globalization = xyes || x$cross_compiling = xyes; then ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native if test x$target_osx = xyes; then ORIG_CPPFLAGS=$CPPFLAGS From d9900802e5bcab4b7a57fcb5bc53491c9ff55beb Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Sat, 9 May 2020 11:29:24 -0300 Subject: [PATCH 44/49] Fix cross compilation --- src/mono/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index e7f4406a57904a..67b752bc499c7e 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6801,7 +6801,7 @@ if test x$with_core = xonly; then if test x$cross_compiling = xno; then AC_CHECK_FILE($srcdir/../libraries/Native/Unix/System.Globalization.Native/pal_icushim.h, [have_shim_globalization=yes], [have_shim_globalization=no]) fi - if test x$have_shim_globalization = xyes || x$cross_compiling = xyes; then + if test x$have_shim_globalization = xyes || test x$cross_compiling = xyes; then ICU_SHIM_PATH=../../../libraries/Native/Unix/System.Globalization.Native if test x$target_osx = xyes; then ORIG_CPPFLAGS=$CPPFLAGS From d7eefa3738f467658ef6f858352fe99dd3aeb4dc Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 12 May 2020 16:14:12 -0300 Subject: [PATCH 45/49] Fixing loading functions at __Internal on android x86. --- src/mono/mono/metadata/native-library.c | 2 +- src/mono/mono/utils/mono-dl.c | 24 ++++++++++++++++++++++++ src/mono/mono/utils/mono-dl.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 5ef0bcd87bac37..47fb17c43a09c4 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -758,7 +758,7 @@ netcore_lookup_native_library (MonoAssemblyLoadContext *alc, MonoImage *image, c // We allow a special name to dlopen from the running process namespace, which is not present in CoreCLR if (strcmp (scope, "__Internal") == 0) { if (!internal_module) - internal_module = mono_dl_open (NULL, MONO_DL_LAZY, &error_msg); + internal_module = mono_dl_open_self (&error_msg); module = internal_module; if (!module) { diff --git a/src/mono/mono/utils/mono-dl.c b/src/mono/mono/utils/mono-dl.c index 8b4aedd179ac91..72805b7ab6acb2 100644 --- a/src/mono/mono/utils/mono-dl.c +++ b/src/mono/mono/utils/mono-dl.c @@ -21,6 +21,7 @@ #include #include #include +#include // Contains LIBC_SO definition #ifdef HAVE_GNU_LIB_NAMES_H @@ -168,6 +169,29 @@ fix_libc_name (const char *name) } #endif +MonoDl* +mono_dl_open_self (char **error_msg) +{ +#if defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) + MonoDl *module; + if (error_msg) + *error_msg = NULL; + module = (MonoDl *) g_malloc (sizeof (MonoDl)); + if (!module) { + if (error_msg) + *error_msg = g_strdup ("Out of memory"); + return NULL; + } + mono_refcount_init (module, NULL); + module->handle = RTLD_DEFAULT; + module->dl_fallback = NULL; + module->full_name = NULL; + return module; +#else + return mono_dl_open (NULL, MONO_DL_LAZY, error_msg); +#endif +} + /** * mono_dl_open: * \param name name of file containing shared module diff --git a/src/mono/mono/utils/mono-dl.h b/src/mono/mono/utils/mono-dl.h index 6236d98b1e59b7..6efee6feabfd5b 100644 --- a/src/mono/mono/utils/mono-dl.h +++ b/src/mono/mono/utils/mono-dl.h @@ -43,6 +43,8 @@ char* mono_dl_build_path (const char *directory, const char *name, void ** MonoDl* mono_dl_open_runtime_lib (const char *lib_name, int flags, char **error_msg); +MonoDl* mono_dl_open_self (char **error_msg); + //Platform API for mono_dl const char* mono_dl_get_so_prefix (void); From 03bdce398c7695190caafc9d6d6889a4431c7431 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Tue, 12 May 2020 17:32:12 -0300 Subject: [PATCH 46/49] Adding include only for android. --- src/mono/mono/utils/mono-dl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/utils/mono-dl.c b/src/mono/mono/utils/mono-dl.c index 72805b7ab6acb2..1813614c7ad07e 100644 --- a/src/mono/mono/utils/mono-dl.c +++ b/src/mono/mono/utils/mono-dl.c @@ -21,7 +21,9 @@ #include #include #include +#if defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) #include +#endif // Contains LIBC_SO definition #ifdef HAVE_GNU_LIB_NAMES_H From 676b58ef8ed8ee495a4ab5f0167a604401abb9da Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Thu, 14 May 2020 10:53:21 -0300 Subject: [PATCH 47/49] Fixing android. --- src/mono/configure.ac | 5 ++++- src/mono/mono/metadata/native-library.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mono/configure.ac b/src/mono/configure.ac index 67b752bc499c7e..94c228bd8049ff 100644 --- a/src/mono/configure.ac +++ b/src/mono/configure.ac @@ -6815,7 +6815,10 @@ if test x$with_core = xonly; then if test x$have_sys_icu = xyes; then ICU_CFLAGS="$CPPFLAGS -DOSX_ICU_LIBRARY_PATH=AS_ESCAPE(\"/usr/lib/libicucore.dylib\", '\"') -DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations" fi - CPPFLAGS=$ORIG_CPPFLAGS + CPPFLAGS=$ORIG_CPPFLAGS + elif test x$platform_android = xyes; then + ICU_CFLAGS="-DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE -DTARGET_UNIX -DTARGET_ANDROID -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option" + have_sys_icu=yes elif test x$host_linux = xyes; then AC_CHECK_LIB(icuuc, main, LIBS=$LIBS, [AC_MSG_ERROR([Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform).])]) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 47fb17c43a09c4..2b04f0d6d83c17 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1271,7 +1271,11 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou #if defined(TARGET_OSX) new_scope = g_strdup ("libcoreclr.dylib"); #else +#if defined(TARGET_ANDROID) + new_scope = g_strdup ("libmonosgen-2.0.so"); +#else new_scope = g_strdup ("libcoreclr.so"); +#endif #endif goto retry_with_libcoreclr; } From e974e46ccd0676aba70597951e499fab2ddc9634 Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Fri, 15 May 2020 12:14:16 -0300 Subject: [PATCH 48/49] Fixing android compilation on mono. --- src/mono/mono/utils/mono-dl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/utils/mono-dl.c b/src/mono/mono/utils/mono-dl.c index 1813614c7ad07e..5834317c408f88 100644 --- a/src/mono/mono/utils/mono-dl.c +++ b/src/mono/mono/utils/mono-dl.c @@ -21,7 +21,7 @@ #include #include #include -#if defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) +#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) #include #endif @@ -171,10 +171,18 @@ fix_libc_name (const char *name) } #endif +/** + * mono_dl_open_self: + * \param error_msg pointer for error message on failure + * + * Returns a handle to the main program, on android x86 it's not possible to + * call dl_open(null), it returns a null handle, so this function returns RTLD_DEFAULT + * handle in this platform. + */ MonoDl* mono_dl_open_self (char **error_msg) { -#if defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) +#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) MonoDl *module; if (error_msg) *error_msg = NULL; From 464656a00421bcf6d9ce1d618b17e2c5b5514b4c Mon Sep 17 00:00:00 2001 From: Thays Grazia Date: Fri, 15 May 2020 13:35:24 -0300 Subject: [PATCH 49/49] Fixing android x64 has the same problem that there is in x86. --- src/mono/mono/utils/mono-dl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/utils/mono-dl.c b/src/mono/mono/utils/mono-dl.c index 5834317c408f88..32fc1daed7dbc7 100644 --- a/src/mono/mono/utils/mono-dl.c +++ b/src/mono/mono/utils/mono-dl.c @@ -21,7 +21,7 @@ #include #include #include -#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) +#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) #include #endif @@ -182,7 +182,7 @@ fix_libc_name (const char *name) MonoDl* mono_dl_open_self (char **error_msg) { -#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) +#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) MonoDl *module; if (error_msg) *error_msg = NULL;