From e9805a297f4304242764bd7688573c122ea06167 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Mon, 20 Feb 2023 13:48:32 +0100 Subject: [PATCH 01/23] Add System.Globalization.Native builds for iOS-like platforms --- .../Microsoft.NETCore.Native.Unix.targets | 3 +-- src/native/libs/CMakeLists.txt | 3 +++ .../System.Globalization.Native/CMakeLists.txt | 14 +++++++++++++- .../System.Globalization.Native/configure.cmake | 2 +- src/native/libs/build-native.proj | 8 +++++++- src/native/libs/build-native.sh | 10 ++++++++++ 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index cf6622bddddd4b..5e658766735463 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -63,8 +63,7 @@ The .NET Foundation licenses this file to you under the MIT license. - - + diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt index f72e04b4005323..a764d83dee81cb 100644 --- a/src/native/libs/CMakeLists.txt +++ b/src/native/libs/CMakeLists.txt @@ -163,14 +163,17 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) if (CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) # skip for now elseif (CLR_CMAKE_TARGET_MACCATALYST) + add_subdirectory(System.Globalization.Native) add_subdirectory(System.Net.Security.Native) # System.Security.Cryptography.Native is intentionally disabled on iOS # it is only used for interacting with OpenSSL which isn't useful there elseif (CLR_CMAKE_TARGET_IOS) + add_subdirectory(System.Globalization.Native) add_subdirectory(System.Net.Security.Native) # System.Security.Cryptography.Native is intentionally disabled on iOS # it is only used for interacting with OpenSSL which isn't useful there elseif (CLR_CMAKE_TARGET_TVOS) + add_subdirectory(System.Globalization.Native) #add_subdirectory(System.Net.Security.Native) # no gssapi on tvOS, see https://developer.apple.com/documentation/gss # System.Security.Cryptography.Native is intentionally disabled on tvOS # it is only used for interacting with OpenSSL which isn't useful there diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 60a547b001e552..decec890ee4aad 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -13,7 +13,7 @@ if(CLR_CMAKE_TARGET_UNIX) add_compile_options(-Wno-extra-semi-stmt) add_compile_options(-Wno-unknown-warning-option) - if (NOT CLR_CMAKE_TARGET_ANDROID) + if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ICU_DIR) if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include") @@ -59,6 +59,11 @@ set(NATIVEGLOBALIZATION_SOURCES pal_normalization.c ) +if (DEFINED CMAKE_ICU_DIR) + include_directories(${CMAKE_ICU_DIR}/include) + link_libraries(${CMAKE_ICU_DIR}/lib) +endif() + if (LOCAL_BUILD) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c) @@ -69,6 +74,9 @@ if (LOCAL_BUILD) # For minipal files include_directories(../../) include_directories(${CMAKE_CURRENT_BINARY_DIR}) +elseif (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + add_definitions(-DSTATIC_ICU) + set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c) else() set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim.c) endif() @@ -97,6 +105,9 @@ if (GEN_SHARED_LIB) include(CMakeFindFrameworks) find_library(FOUNDATION Foundation REQUIRED) endif() + if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + find_library(ICUCORE icucore REQUIRED) + endif() add_library(System.Globalization.Native SHARED @@ -107,6 +118,7 @@ if (GEN_SHARED_LIB) target_link_libraries(System.Globalization.Native dl ${FOUNDATION} + ${ICUCORE} ) install_with_stripped_symbols (System.Globalization.Native PROGRAMS .) diff --git a/src/native/libs/System.Globalization.Native/configure.cmake b/src/native/libs/System.Globalization.Native/configure.cmake index adf3f49afbd60d..a8681f3b2aafed 100644 --- a/src/native/libs/System.Globalization.Native/configure.cmake +++ b/src/native/libs/System.Globalization.Native/configure.cmake @@ -1,4 +1,4 @@ -if(CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) +if(CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_APPLE) set(HAVE_SET_MAX_VARIABLE 1) set(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 1) else() diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index 7199673717bc33..74182dcc4a5f23 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -15,6 +15,10 @@ + + + + -keepnativesymbols <_CMakeArgs Condition="'$(CMakeArgs)' != ''"> $(CMakeArgs) + <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''"> -icudir "$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)/native" + <_BuildNativeCompilerArg Condition="'$(BuildNativeCompiler)' != ''"> $(BuildNativeCompiler) - <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs) $(Compiler) + <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs)$(_IcuDir) $(Compiler) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 934070b69357cf..d6b49aa793256a 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -7,6 +7,7 @@ __scriptpath="$(cd "$(dirname "$0")"; pwd -P)" __nativeroot="$__scriptpath" __RepoRootDir="$(cd "$__scriptpath"/../../..; pwd -P)" __artifactsDir="$__RepoRootDir/artifacts" +__icuDir="" handle_arguments() { @@ -16,6 +17,11 @@ handle_arguments() { __ShiftArgs=1 ;; + icudir|-icudir) + __icuDir="$2" + __ShiftArgs=1 + ;; + staticliblink|-staticliblink) __StaticLibLink=1 ;; @@ -141,6 +147,10 @@ elif [[ "$__TargetOS" == tvos ]]; then fi fi +if [[ -n "$__icuDir" ]]; then + __CMakeArgs="-DCMAKE_ICU_DIR=\"$__icuDir\" $__CMakeArgs" +fi + # Set the remaining variables based upon the determined build configuration __outConfig="${__outConfig:-"$__TargetOS-$__TargetArch-$__BuildType"}" __IntermediatesDir="$__RootBinDir/obj/native/$__outConfig" From 9092d1c7965056f90499b591b6e224570e77c5c6 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 08:28:52 +0100 Subject: [PATCH 02/23] Update package manifest --- .../pkg/sfx/Microsoft.NETCore.App/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props index 5f56e0eb0bbea6..dc2608d2a621bc 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props @@ -77,6 +77,7 @@ + From e78a32d8596ed3ade27c10445561aee07d6a290a Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 09:26:47 +0100 Subject: [PATCH 03/23] Move copying of ICU static libs and data files from Mono to libs.native --- src/mono/mono.proj | 12 ------------ src/native/libs/build-native.proj | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index d6a4a8fbdee567..dde3e3242d94e6 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -912,7 +912,6 @@ <_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)out\lib\$(MonoFileName) <_MonoRuntimeStaticFilePath Condition="'$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(MonoObjDir)out\lib\$(MonoStaticLibFileName) <_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or '$(TargetsWasi)' == 'true'">true - <_MonoIncludeIcuFiles Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true'">true <_MonoAotCrossFilePath>$(MonoObjCrossDir)out\bin\$(MonoAotCrossFileName) @@ -1029,19 +1028,8 @@ <_MonoICorDebugArtifacts Condition="'$(MonoMsCorDbi)' == 'true'" Include="$(MonoObjDir)out\lib\$(LibPrefix)mscordbi$(LibSuffix)"> $(RuntimeBinDir)$(LibPrefix)mscordbi$(LibSuffix) - - <_IcuArtifacts Condition="'$(_MonoIncludeIcuFiles)' == 'true'" - Include="$(_IcuLibdir)\libicuuc.a; - $(_IcuLibdir)\libicui18n.a; - $(_IcuLibdir)\libicudata.a; - $(_IcuLibdir)\*.dat" /> - - -keepnativesymbols <_CMakeArgs Condition="'$(CMakeArgs)' != ''"> $(CMakeArgs) - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''"> -icudir "$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)/native" + <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)/native + <_IcuDirArg Condition="'$(_IcuDir)' != ''"> -icudir "$(_IcuDir)" <_BuildNativeCompilerArg Condition="'$(BuildNativeCompiler)' != ''"> $(BuildNativeCompiler) - <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs)$(_IcuDir) $(Compiler) + <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs)$(_IcuDirArg) $(Compiler) + + <_IcuArtifacts Condition="'$(_IcuDir)' != ''" + Include="$(_IcuDir)/lib/libicuuc.a; + $(_IcuDir)/lib/libicui18n.a; + $(_IcuDir)/lib/libicudata.a; + $(_IcuDir)/lib/*.dat" /> + + + From c83a2dc81d9dd9ef7a5b00d7b249f8773e7a899d Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 10:57:11 +0100 Subject: [PATCH 04/23] Mono: Link static ICU shim only into Mono shared libraries --- src/mono/mono/mini/CMakeLists.txt | 19 ++++++++++++++++++- src/mono/wasi/runtime/CMakeLists.txt | 1 + src/mono/wasm/runtime/CMakeLists.txt | 1 + .../CMakeLists.txt | 5 +---- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 2e2893bc878d9e..eec6adc57cca87 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -82,6 +82,9 @@ if(HAVE_SYS_ICU) if(ICU_LIBDIR) set(ICU_LDFLAGS "-L${ICU_LIBDIR}") endif() + + add_library(icu_shim_objects OBJECT "${icu_shim_sources}") + set(HAVE_ICU_SHIM 1) endif() # @@ -349,7 +352,11 @@ if(HOST_WIN32) set_source_files_properties(${ZLIB_SOURCES} PROPERTIES COMPILE_OPTIONS "/wd4005;/wd4127;/wd4131;/wd4244") endif() +<<<<<<< HEAD set(monosgen-sources "${icu_shim_sources};${mini_sources};${ZLIB_SOURCES}") +======= +set(monosgen-sources "${metadata_sources};${utils_sources};${sgen_sources};${mini_sources};${ZLIB_SOURCES}") +>>>>>>> 819cdfa264a (Mono: Link static ICU shim only into Mono shared libraries) add_library(monosgen-objects OBJECT "${monosgen-sources}") target_link_libraries (monosgen-objects PRIVATE monoapi eglib_api utils_objects sgen_objects metadata_objects) @@ -378,6 +385,9 @@ if(NOT DISABLE_SHARED_LIBS) endif(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X) set_target_properties(monosgen-shared PROPERTIES OUTPUT_NAME ${MONO_SHARED_LIB_NAME}) target_link_libraries(monosgen-shared PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects) + if(HAVE_ICU_SHIM) + target_link_libraries(monosgen-shared PRIVATE icu_shim_objects) + endif() target_include_directories (monosgen-shared PRIVATE monoapi) if(TARGET_WIN32) # on Windows the import library for the shared mono library will have the same name as the static library, @@ -435,6 +445,9 @@ if(NOT DISABLE_SHARED_LIBS) add_library(${frameworkconfig} SHARED $) target_compile_definitions(${frameworkconfig} PRIVATE -DMONO_DLL_EXPORT) target_link_libraries(${frameworkconfig} PRIVATE monoapi eglib_objects utils_objects sgen_objects metadata_objects) + if(HAVE_ICU_SHIM) + target_link_libraries(${frameworkconfig} PRIVATE icu_shim_objects) + endif() target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(ICU_LDFLAGS) @@ -539,7 +552,11 @@ if(NOT DISABLE_EXECUTABLES) if(MONO_CROSS_COMPILE_EXECUTABLE_NAME) set_target_properties(mono-sgen PROPERTIES OUTPUT_NAME mono-aot-cross) endif() - target_link_libraries(mono-sgen PRIVATE monoapi eglib_api monosgen-static ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) + target_link_libraries(mono-sgen PRIVATE monoapi eglib_api monosgen-static) + if(HAVE_ICU_SHIM) + target_link_libraries(mono-sgen PRIVATE icu_shim_objects) + endif() + target_link_libraries(mono-sgen PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) # Alpine Linux implements ucontext in a different library if(CLR_CMAKE_HOST_ALPINE_LINUX AND TARGET_S390X) target_link_libraries(mono-sgen PRIVATE ucontext) diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index a1320ffbe1c3a3..c0b8f0eb9b1f1c 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -31,6 +31,7 @@ target_link_libraries(dotnet ${MONO_ARTIFACTS_DIR}/libmonosgen-2.0.a ${MONO_ARTIFACTS_DIR}/libmono-icall-table.a ${NATIVE_BIN_DIR}/libSystem.Native.a + ${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a ) diff --git a/src/mono/wasm/runtime/CMakeLists.txt b/src/mono/wasm/runtime/CMakeLists.txt index dab32f84e060c2..e4e633b54692c0 100644 --- a/src/mono/wasm/runtime/CMakeLists.txt +++ b/src/mono/wasm/runtime/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries(dotnet ${MONO_ARTIFACTS_DIR}/libmono-profiler-aot.a ${MONO_ARTIFACTS_DIR}/libmono-profiler-browser.a ${NATIVE_BIN_DIR}/libSystem.Native.a + ${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a) set_target_properties(dotnet PROPERTIES diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index decec890ee4aad..06193f13937392 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -90,10 +90,6 @@ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) endif() -if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) - set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} entrypoints.c) -endif() - if (MSVC) set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX) endif() @@ -127,6 +123,7 @@ endif() add_library(System.Globalization.Native-Static STATIC ${NATIVEGLOBALIZATION_SOURCES} + entrypoints.c ) if(CLR_CMAKE_TARGET_UNIX) From 628cb70e05d493b6972d3748df54a185542265fe Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 13:27:21 +0100 Subject: [PATCH 05/23] Include ICU .dat files in LibrariesRuntimeFiles --- eng/liveBuilds.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets index 5df409f12a2591..fdb7c97d77da3e 100644 --- a/eng/liveBuilds.targets +++ b/eng/liveBuilds.targets @@ -170,6 +170,7 @@ - + From 2edeebd68fb0d2be9a663187431c567a5a6f12a7 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 16:16:55 +0100 Subject: [PATCH 07/23] Fix configuration options for WASM/WASI builds --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 2 +- src/native/libs/System.Globalization.Native/config.h.in | 3 ++- src/native/libs/System.Globalization.Native/configure.cmake | 3 ++- .../libs/System.Globalization.Native/pal_icushim_static.c | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 06193f13937392..c9f60e127c5482 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -74,7 +74,7 @@ if (LOCAL_BUILD) # For minipal files include_directories(../../) include_directories(${CMAKE_CURRENT_BINARY_DIR}) -elseif (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) +elseif (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) add_definitions(-DSTATIC_ICU) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c) else() diff --git a/src/native/libs/System.Globalization.Native/config.h.in b/src/native/libs/System.Globalization.Native/config.h.in index 89399903e8ddac..933a3d0c5c419d 100644 --- a/src/native/libs/System.Globalization.Native/config.h.in +++ b/src/native/libs/System.Globalization.Native/config.h.in @@ -1,4 +1,5 @@ #pragma once #cmakedefine01 HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -#cmakedefine01 HAVE_SET_MAX_VARIABLE \ No newline at end of file +#cmakedefine01 HAVE_SET_MAX_VARIABLE +#cmakedefine01 HAVE_UCOL_CLONE \ No newline at end of file diff --git a/src/native/libs/System.Globalization.Native/configure.cmake b/src/native/libs/System.Globalization.Native/configure.cmake index a8681f3b2aafed..8163745c4c20ae 100644 --- a/src/native/libs/System.Globalization.Native/configure.cmake +++ b/src/native/libs/System.Globalization.Native/configure.cmake @@ -1,6 +1,7 @@ -if(CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_APPLE) +if(CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_APPLE OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) set(HAVE_SET_MAX_VARIABLE 1) set(HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 1) + set(HAVE_UCOL_CLONE 0) else() include(CheckCSourceCompiles) include(CheckSymbolExists) 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 69fcbb03ae31ab..3661a6d1f11495 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -134,7 +134,7 @@ cstdlib_load_icu_data(const char *path) goto error; } - file_buf = malloc(sizeof(char) * (file_buf_size + 1)); + file_buf = malloc(sizeof(char) * (unsigned long)(file_buf_size + 1)); if (file_buf == NULL) { @@ -148,7 +148,7 @@ cstdlib_load_icu_data(const char *path) goto error; } - fread(file_buf, sizeof(char), file_buf_size, fp); + fread(file_buf, sizeof(char), (unsigned long)file_buf_size, fp); if (ferror( fp ) != 0) { log_shim_error("Unable to read ICU dat file"); From 5ec149fe30743c826058903602ebefb39763a843 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 16:56:04 +0100 Subject: [PATCH 08/23] Update src/libraries/native-binplace.proj to include ICU .dat files --- src/libraries/native-binplace.proj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/native-binplace.proj b/src/libraries/native-binplace.proj index 867fadd3c4637e..b6d10ef00c6d98 100644 --- a/src/libraries/native-binplace.proj +++ b/src/libraries/native-binplace.proj @@ -24,6 +24,7 @@ + From 3156ff7590d96864793d218dc2f56df86b842639 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 17:02:48 +0100 Subject: [PATCH 09/23] List correct libraries in link_libraries --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index c9f60e127c5482..c0babedea97577 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -61,7 +61,7 @@ set(NATIVEGLOBALIZATION_SOURCES if (DEFINED CMAKE_ICU_DIR) include_directories(${CMAKE_ICU_DIR}/include) - link_libraries(${CMAKE_ICU_DIR}/lib) + link_libraries(${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a) endif() if (LOCAL_BUILD) From 556fc43ddccc96dcd891a2b05e34750c217b5409 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 17:06:40 +0100 Subject: [PATCH 10/23] Fix iOS build after the link fix :/ --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index c0babedea97577..23b515baa7a77b 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -62,6 +62,7 @@ set(NATIVEGLOBALIZATION_SOURCES if (DEFINED CMAKE_ICU_DIR) include_directories(${CMAKE_ICU_DIR}/include) link_libraries(${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a) + link_libraries(stdc++) endif() if (LOCAL_BUILD) From a92c289b5e03c6856b7129c44431c35fd01840b9 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 21 Feb 2023 20:25:12 +0100 Subject: [PATCH 11/23] Use correct ICU build for browser-wasm-threads builds --- src/native/libs/build-native.proj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index 27cff5f6d927ad..06e21ce33e8ae5 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -35,7 +35,10 @@ <_KeepNativeSymbolsBuildArg Condition="'$(KeepNativeSymbols)' != 'false'"> -keepnativesymbols <_CMakeArgs Condition="'$(CMakeArgs)' != ''"> $(CMakeArgs) - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)/native + <_RuntimeVariant /> + <_RuntimeVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">-threads + + <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native <_IcuDirArg Condition="'$(_IcuDir)' != ''"> -icudir "$(_IcuDir)" <_BuildNativeCompilerArg Condition="'$(BuildNativeCompiler)' != ''"> $(BuildNativeCompiler) - <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs)$(_IcuDirArg) $(Compiler) + <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs)$(_IcuDirArg)$(_UsePThreads) $(Compiler) diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index d6b49aa793256a..36722763f69bc2 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -7,7 +7,6 @@ __scriptpath="$(cd "$(dirname "$0")"; pwd -P)" __nativeroot="$__scriptpath" __RepoRootDir="$(cd "$__scriptpath"/../../..; pwd -P)" __artifactsDir="$__RepoRootDir/artifacts" -__icuDir="" handle_arguments() { @@ -22,6 +21,10 @@ handle_arguments() { __ShiftArgs=1 ;; + usepthreads|-usepthreads) + __usePThreads=1 + ;; + staticliblink|-staticliblink) __StaticLibLink=1 ;; @@ -44,6 +47,8 @@ __SkipConfigure=0 __StaticLibLink=0 __UnprocessedBuildArgs= __VerboseBuild=false +__icuDir="" +__usePThreads=0 source "$__RepoRootDir"/eng/native/build-commons.sh @@ -71,7 +76,7 @@ elif [[ "$__TargetOS" == wasi ]]; then export WASI_SDK_PATH="${WASI_SDK_PATH%/}/" export CLR_CC="$WASI_SDK_PATH"bin/clang export TARGET_BUILD_ARCH=wasm - __CMakeArgs="-DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$WASI_SDK_PATH -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PATH/share/cmake/wasi-sdk.cmake" + __CMakeArgs="-DCLR_CMAKE_TARGET_OS=wasi -DCLR_CMAKE_TARGET_ARCH=wasm -DWASI_SDK_PREFIX=$WASI_SDK_PATH -DCMAKE_TOOLCHAIN_FILE=$WASI_SDK_PATH/share/cmake/wasi-sdk.cmake $__CMakeArgs" elif [[ "$__TargetOS" == ios || "$__TargetOS" == iossimulator ]]; then # nothing to do here true @@ -150,6 +155,7 @@ fi if [[ -n "$__icuDir" ]]; then __CMakeArgs="-DCMAKE_ICU_DIR=\"$__icuDir\" $__CMakeArgs" fi +__CMakeArgs="-DCMAKE_USE_PTHREADS=$__usePThreads $__CMakeArgs" # Set the remaining variables based upon the determined build configuration __outConfig="${__outConfig:-"$__TargetOS-$__TargetArch-$__BuildType"}" From 560e08f59abdbaba3c7b58be92ccbfbfd2ca53f0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 22 Feb 2023 13:06:10 +0100 Subject: [PATCH 16/23] Fix WASI linking --- src/mono/wasi/runtime/CMakeLists.txt | 1 + src/mono/wasi/wasi.proj | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index c0b8f0eb9b1f1c..7ab112d8f5427b 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -33,6 +33,7 @@ target_link_libraries(dotnet ${NATIVE_BIN_DIR}/libSystem.Native.a ${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a + stdc++ ) set_target_properties(dotnet PROPERTIES diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index a7f58f0aac4f63..8b54f4e3d64804 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -14,6 +14,7 @@ <_WasiDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp + <_WasiLinkUndefinedSymbolsFile>$(NativeBinDir)src\symbols.undefined false @@ -81,6 +82,8 @@ -Wl,- - export=malloc, - - export=free, - - export=__heap_base, - - export=__data_end \ -Wl,-z --> + <_WasiLinkUndefinedSymbols Include="icudt68_dat" /> + <_WasiLinkFlags Include="-Wl,--allow-undefined-file,$(_WasiLinkUndefinedSymbolsFile)" /> @@ -137,6 +140,10 @@ Lines="@(_WasiLinkFlags)" WriteOnlyWhenDifferent="true" Overwrite="true" /> + From a57c67e4d0ec94597d82d17589302d68db169371 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 23 Feb 2023 21:38:42 +0100 Subject: [PATCH 17/23] Revert WASI changes after rebase --- src/mono/wasi/runtime/CMakeLists.txt | 1 - src/mono/wasi/wasi.proj | 7 ------- 2 files changed, 8 deletions(-) diff --git a/src/mono/wasi/runtime/CMakeLists.txt b/src/mono/wasi/runtime/CMakeLists.txt index 7ab112d8f5427b..c0b8f0eb9b1f1c 100644 --- a/src/mono/wasi/runtime/CMakeLists.txt +++ b/src/mono/wasi/runtime/CMakeLists.txt @@ -33,7 +33,6 @@ target_link_libraries(dotnet ${NATIVE_BIN_DIR}/libSystem.Native.a ${NATIVE_BIN_DIR}/libSystem.Globalization.Native.a ${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a - stdc++ ) set_target_properties(dotnet PROPERTIES diff --git a/src/mono/wasi/wasi.proj b/src/mono/wasi/wasi.proj index 8b54f4e3d64804..a7f58f0aac4f63 100644 --- a/src/mono/wasi/wasi.proj +++ b/src/mono/wasi/wasi.proj @@ -14,7 +14,6 @@ <_WasiDefaultsRspPath>$(NativeBinDir)src\wasi-default.rsp <_WasiCompileRspPath>$(NativeBinDir)src\wasi-compile.rsp <_WasiLinkRspPath>$(NativeBinDir)src\wasi-link.rsp - <_WasiLinkUndefinedSymbolsFile>$(NativeBinDir)src\symbols.undefined false @@ -82,8 +81,6 @@ -Wl,- - export=malloc, - - export=free, - - export=__heap_base, - - export=__data_end \ -Wl,-z --> - <_WasiLinkUndefinedSymbols Include="icudt68_dat" /> - <_WasiLinkFlags Include="-Wl,--allow-undefined-file,$(_WasiLinkUndefinedSymbolsFile)" /> @@ -140,10 +137,6 @@ Lines="@(_WasiLinkFlags)" WriteOnlyWhenDifferent="true" Overwrite="true" /> - From 83715188999c084c4db3bb7e8b8ab52e15bc5eff Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 23 Feb 2023 22:47:20 +0100 Subject: [PATCH 18/23] Try to fix builds on Windows --- src/native/libs/build-native.cmd | 11 +++++++++++ src/native/libs/build-native.proj | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index aadcb949ec102d..4f624117e23b32 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -19,6 +19,8 @@ set __TargetOS=windows set CMAKE_BUILD_TYPE=Debug set "__LinkLibraries= " set __Ninja=1 +set __icuDir="" +set __usePThreads=0 :Arg_Loop :: Since the native build requires some configuration information before msbuild is called, we have to do some manual args parsing @@ -43,6 +45,9 @@ if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) if /i [%1] == [msbuild] ( set __Ninja=0&&shift&goto Arg_Loop) +if /i [%1] == [icudir] ( set __icuDir=%2&&shift&&shift&goto Arg_Loop) +if /i [%1] == [usepthreads] ( set __usePThreads=1&&shift&goto Arg_Loop) + shift goto :Arg_Loop @@ -61,6 +66,12 @@ set __cmakeRepoRoot=%__repoRoot:\=/% set __ExtraCmakeParams="-DCMAKE_REPO_ROOT=%__cmakeRepoRoot%" set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" +if NOT %__icuDir% == "" ( + set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_ICU_DIR=%__icuDir%" +) +set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_USE_PTHREADS=%__usePThreads%" + + if [%__outConfig%] == [] set __outConfig=%__TargetOS%-%__BuildArch%-%CMAKE_BUILD_TYPE% if %__CMakeBinDir% == "" ( diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index 520ddb3839c79e..7c8c77101a88fc 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -9,6 +9,16 @@ <_BuildNativeOutConfig>$(NetCoreAppCurrent)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) <_BuildNativeArgs>$(TargetArchitecture) $(Configuration) outconfig $(_BuildNativeOutConfig) -os $(_BuildNativeTargetOS) <_BuildNativeArgs Condition="'$(OfficialBuildId)' != ''">$(_BuildNativeArgs) /p:OfficialBuildId="$(OfficialBuildId)" + + <_RuntimeVariant /> + <_RuntimeVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">-threads + <_UsePThreads /> + <_UsePThreads Condition="'$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'"> usepthreads + + <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native + <_IcuDirArg Condition="'$(_IcuDir)' != ''"> icudir "$(_IcuDir)" + + <_BuildNativeArgs>$(_BuildNativeArgs)$(_IcuDirArg)$(_UsePThreads) @@ -35,20 +45,12 @@ <_KeepNativeSymbolsBuildArg Condition="'$(KeepNativeSymbols)' != 'false'"> -keepnativesymbols <_CMakeArgs Condition="'$(CMakeArgs)' != ''"> $(CMakeArgs) - <_RuntimeVariant /> - <_RuntimeVariant Condition="'$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'">-threads - <_UsePThreads /> - <_UsePThreads Condition="'$(MonoWasmBuildVariant)' == 'multithread' or '$(MonoWasmBuildVariant)' == 'perftrace'"> -usepthreads - - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native - <_IcuDirArg Condition="'$(_IcuDir)' != ''"> -icudir "$(_IcuDir)" - <_BuildNativeCompilerArg Condition="'$(BuildNativeCompiler)' != ''"> $(BuildNativeCompiler) - <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs)$(_IcuDirArg)$(_UsePThreads) $(Compiler) + <_BuildNativeUnixArgs>$(_BuildNativeArgs)$(_ProcessorCountArg)$(_PortableBuildArg)$(_CrossBuildArg)$(_BuildNativeCompilerArg)$(_KeepNativeSymbolsBuildArg)$(_CMakeArgs) $(Compiler) From fa9b2ff6fc6659092508802ecba3649187601ef0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 4 Mar 2023 11:53:35 +0100 Subject: [PATCH 19/23] Remove unnecessary icucore change --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 77b59eb2f9e55f..0a7d4d9f4582a9 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -112,9 +112,6 @@ if (GEN_SHARED_LIB) include(CMakeFindFrameworks) find_library(FOUNDATION Foundation REQUIRED) endif() - if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) - find_library(ICUCORE icucore REQUIRED) - endif() add_library(System.Globalization.Native SHARED @@ -125,7 +122,6 @@ if (GEN_SHARED_LIB) target_link_libraries(System.Globalization.Native dl ${FOUNDATION} - ${ICUCORE} ) install_with_stripped_symbols (System.Globalization.Native PROGRAMS .) From 5d0700a22ba083c4b75a5bc80d76e1f99e71dfaf Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 4 Mar 2023 11:54:11 +0100 Subject: [PATCH 20/23] Remove unnecessary empty line --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 0a7d4d9f4582a9..9cd454e171f912 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -74,7 +74,6 @@ if (CMAKE_USE_PTHREADS) add_linker_flag(-pthread) endif() - if (LOCAL_BUILD) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_icushim_static.c) From 8e07a43544f48e5a81e52e47da1b97ea5afc3ad0 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 4 Mar 2023 11:55:56 +0100 Subject: [PATCH 21/23] Wrap icu_trace_data in `#if defined(ICU_TRACING)` --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 3 --- .../libs/System.Globalization.Native/pal_icushim_static.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 9cd454e171f912..088579d58dfb7b 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -14,9 +14,6 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) add_compile_options(-Wno-extra-semi-stmt) add_compile_options(-Wno-unknown-warning-option) - # pal_icushim_static.c(41,24): error G026380BD: unused function 'icu_trace_data' - add_compile_options(-Wno-unused-function) - if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ICU_DIR) if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) 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 3661a6d1f11495..272bffa8e2ea59 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -38,12 +38,14 @@ static void log_icu_error(const char* name, UErrorCode status) log_shim_error("ICU call %s failed with error #%d '%s'.", name, status, statusText); } +#if defined(ICU_TRACING) static void U_CALLCONV icu_trace_data(const void* context, int32_t fnNumber, int32_t level, const char* fmt, va_list args) { char buf[1000]; utrace_vformat(buf, sizeof(buf), 0, fmt, args); printf("[ICUDT] %s: %s\n", utrace_functionName(fnNumber), buf); } +#endif static int32_t load_icu_data(const void* pData); From 3c823b8c7f27e5940150e7ba5037e88e5ade80bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 24 Apr 2023 15:27:51 +0200 Subject: [PATCH 22/23] Fix "unused parameter 'symbolVersion'" error --- src/native/libs/System.Globalization.Native/pal_icushim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim.c b/src/native/libs/System.Globalization.Native/pal_icushim.c index a9388786e79460..e8e6382f086036 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim.c @@ -436,6 +436,7 @@ static void InitializeVariableMaxAndTopPointers(char* symbolVersion) #if defined(TARGET_OSX) || defined(TARGET_ANDROID) // OSX and Android always run against ICU version which has ucol_setMaxVariable. // We shouldn't come here. + (void)symbolVersion; assert(false); #elif defined(TARGET_WINDOWS) char symbolName[SYMBOL_NAME_SIZE]; From 42ae53532b6c85999e543c0a967f13b1b62afbc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Tue, 25 Apr 2023 17:36:53 +0200 Subject: [PATCH 23/23] Fix NativeAOT build for Apple Mobile The coreclr CMake "includes" the src/native directory so it doesn't go through build-native.sh. --- src/coreclr/runtime.proj | 9 +++++++++ .../libs/System.Globalization.Native/CMakeLists.txt | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index 7f8edcc93a7813..8d5410c4eab667 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -2,12 +2,17 @@ ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs + <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native + + + + + + <_CoreClrBuildArg Include="-cmakeargs -DCMAKE_ICU_DIR="$(_IcuDir)"" /> + + <_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd <_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 46d627f362ad40..37191a7123affd 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -15,7 +15,7 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) add_compile_options(-Wno-unknown-warning-option) if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ICU_DIR) - if (CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) + if (CLR_CMAKE_TARGET_OSX) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include") endif() @@ -26,7 +26,7 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) return() endif() - if(CLR_CMAKE_TARGET_OSX OR CLR_CMAKE_TARGET_MACCATALYST) + if(CLR_CMAKE_TARGET_OSX) add_definitions(-DOSX_ICU_LIBRARY_PATH="/usr/lib/libicucore.dylib") add_definitions(-DU_DISABLE_RENAMING) else()