From ed6510ede147a98cef8743f937601b6b9f7714a4 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 26 Jun 2023 10:21:39 +0200 Subject: [PATCH 1/3] Mark places related to loading --- src/libraries/Common/src/Interop/Interop.ICU.cs | 2 +- src/libraries/Common/src/Interop/Interop.ICU.iOS.cs | 2 +- .../Globalization/GlobalizationMode.LoadICU.Unix.cs | 2 +- .../Globalization/GlobalizationMode.LoadICU.iOS.cs | 2 +- .../src/System/Globalization/GlobalizationMode.Unix.cs | 2 +- .../System.Globalization.Native/pal_icushim_static.c | 2 +- src/native/libs/System.Globalization.Native/pal_locale.m | 4 ++-- src/tasks/AppleAppBuilder/Templates/runtime.m | 9 ++++++--- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.ICU.cs b/src/libraries/Common/src/Interop/Interop.ICU.cs index 99fcbe0d66383..f47f7eb381a63 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Globalization - { + {// [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICU")] internal static partial int LoadICU(); diff --git a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs index 6a20612dc47ee..c5f902970e96e 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Globalization - { + {// [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICUData", StringMarshalling = StringMarshalling.Utf8)] internal static partial int LoadICUData(string? path); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs index c91596d3dee99..a3207217f22cc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs @@ -4,7 +4,7 @@ namespace System.Globalization { internal static partial class GlobalizationMode - { + {// private static int LoadICU() => Interop.Globalization.LoadICU(); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs index cf3185101e608..4dd336e070ed6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs @@ -6,7 +6,7 @@ namespace System.Globalization internal static partial class GlobalizationMode { private static int LoadICU() - { + {// return Interop.Globalization.LoadICUData((string?)AppContext.GetData("ICU_DAT_FILE_PATH")); // we handle a null path in the native code } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index 46850d3d090df..8bfedf1147763 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -38,7 +38,7 @@ private static string GetIcuLoadFailureMessage() // These strings can't go into resources, because a resource lookup requires globalization, which requires ICU if (OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS()) - { + {// return "Unable to load required ICU Globalization data. Please see https://aka.ms/dotnet-missing-libicu for more information"; } else diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index ebf271429573e..1fe5c1078dd1d 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -169,7 +169,7 @@ cstdlib_load_icu_data(const char *path) int32_t GlobalizationNative_LoadICUData(const char* path) -{ +{// #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) if (path && path[0] != '/') { diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index c26e89b601829..e8d766b71929e 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -572,7 +572,7 @@ Returns time format information (in native format, it needs to be converted to . #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) -{ +{// NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; @@ -580,7 +580,7 @@ Returns time format information (in native format, it needs to be converted to . } const char* GlobalizationNative_GetICUDataPathFallback(void) -{ +{// NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; return strdup([dataPath UTF8String]); } diff --git a/src/tasks/AppleAppBuilder/Templates/runtime.m b/src/tasks/AppleAppBuilder/Templates/runtime.m index b05389f09f6bd..0dbc1f7fcaa6c 100644 --- a/src/tasks/AppleAppBuilder/Templates/runtime.m +++ b/src/tasks/AppleAppBuilder/Templates/runtime.m @@ -256,7 +256,7 @@ #ifdef DIAGNOSTIC_PORTS setenv ("DOTNET_DiagnosticPorts", DIAGNOSTIC_PORTS, true); #endif - +// char **managed_argv; int argi = get_managed_args (&managed_argv); @@ -267,8 +267,11 @@ char icu_dat_path [1024]; int res; - - res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt.dat"); +//#if defined(HYBRID_GLOBALIZATION) + res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt_hybrid.dat"); +//#else + //res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt.dat"); +///#endif assert (res > 0); // TODO: set TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS and NATIVE_DLL_SEARCH_DIRECTORIES From e340518edba331d8c54221c5134ca95c598d0ddf Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 26 Jun 2023 14:19:31 +0200 Subject: [PATCH 2/3] Remove not needed comments --- src/libraries/Common/src/Interop/Interop.ICU.cs | 2 +- src/libraries/Common/src/Interop/Interop.ICU.iOS.cs | 2 +- .../Globalization/GlobalizationMode.LoadICU.Unix.cs | 2 +- .../Globalization/GlobalizationMode.LoadICU.iOS.cs | 2 +- .../src/System/Globalization/GlobalizationMode.Unix.cs | 2 +- .../System.Globalization.Native/pal_icushim_static.c | 2 +- .../libs/System.Globalization.Native/pal_locale.m | 4 ++-- src/tasks/AppleAppBuilder/Templates/runtime.m | 10 +++++----- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.ICU.cs b/src/libraries/Common/src/Interop/Interop.ICU.cs index f47f7eb381a63..99fcbe0d66383 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Globalization - {// + { [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICU")] internal static partial int LoadICU(); diff --git a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs index c5f902970e96e..6a20612dc47ee 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.iOS.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Globalization - {// + { [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICUData", StringMarshalling = StringMarshalling.Utf8)] internal static partial int LoadICUData(string? path); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs index a3207217f22cc..c91596d3dee99 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.Unix.cs @@ -4,7 +4,7 @@ namespace System.Globalization { internal static partial class GlobalizationMode - {// + { private static int LoadICU() => Interop.Globalization.LoadICU(); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs index 4dd336e070ed6..cf3185101e608 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.LoadICU.iOS.cs @@ -6,7 +6,7 @@ namespace System.Globalization internal static partial class GlobalizationMode { private static int LoadICU() - {// + { return Interop.Globalization.LoadICUData((string?)AppContext.GetData("ICU_DAT_FILE_PATH")); // we handle a null path in the native code } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index 8bfedf1147763..46850d3d090df 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -38,7 +38,7 @@ private static string GetIcuLoadFailureMessage() // These strings can't go into resources, because a resource lookup requires globalization, which requires ICU if (OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || OperatingSystem.IsWatchOS()) - {// + { return "Unable to load required ICU Globalization data. Please see https://aka.ms/dotnet-missing-libicu for more information"; } else diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index 1fe5c1078dd1d..ebf271429573e 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -169,7 +169,7 @@ cstdlib_load_icu_data(const char *path) int32_t GlobalizationNative_LoadICUData(const char* path) -{// +{ #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) if (path && path[0] != '/') { diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index e8d766b71929e..c26e89b601829 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -572,7 +572,7 @@ Returns time format information (in native format, it needs to be converted to . #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) -{// +{ NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; @@ -580,7 +580,7 @@ Returns time format information (in native format, it needs to be converted to . } const char* GlobalizationNative_GetICUDataPathFallback(void) -{// +{ NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; return strdup([dataPath UTF8String]); } diff --git a/src/tasks/AppleAppBuilder/Templates/runtime.m b/src/tasks/AppleAppBuilder/Templates/runtime.m index 0dbc1f7fcaa6c..94a4502f1f9c0 100644 --- a/src/tasks/AppleAppBuilder/Templates/runtime.m +++ b/src/tasks/AppleAppBuilder/Templates/runtime.m @@ -256,7 +256,7 @@ #ifdef DIAGNOSTIC_PORTS setenv ("DOTNET_DiagnosticPorts", DIAGNOSTIC_PORTS, true); #endif -// + char **managed_argv; int argi = get_managed_args (&managed_argv); @@ -267,11 +267,11 @@ char icu_dat_path [1024]; int res; -//#if defined(HYBRID_GLOBALIZATION) +#if defined(HYBRID_GLOBALIZATION) res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt_hybrid.dat"); -//#else - //res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt.dat"); -///#endif +#else + res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt.dat"); +#endif assert (res > 0); // TODO: set TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS and NATIVE_DLL_SEARCH_DIRECTORIES From 33b123aae6ba4504f093da1c3bdfd9678f21fdef Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 26 Jun 2023 17:52:31 +0200 Subject: [PATCH 3/3] Fix loading icudt_hybrid.dat file --- src/tasks/AppleAppBuilder/Xcode.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 616d267f53af9..dc01dadd30e8f 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -256,7 +256,7 @@ public string GenerateCMake( bool useNativeAOTRuntime = false) { // bundle everything as resources excluding native files - var predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt_*" }; + var predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; predefinedExcludes = predefinedExcludes.Concat(excludes).ToList(); if (!preferDylibs) { @@ -268,7 +268,8 @@ public string GenerateCMake( } string[] resources = Directory.GetFileSystemEntries(workspace, "", SearchOption.TopDirectoryOnly) - .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase)))) + .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase) && + !(hybridGlobalization ? Path.GetFileName(f) == "icudt_hybrid.dat" : Path.GetFileName(f) == "icudt.dat")))) .ToArray(); if (string.IsNullOrEmpty(nativeMainSource))