Skip to content

Commit

Permalink
Enable System.Globalization.Native for NativeAOT (#69297)
Browse files Browse the repository at this point in the history
Fixes #68889
  • Loading branch information
jkotas committed May 13, 2022
1 parent b1f6d21 commit 9d06449
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Expand Up @@ -38,6 +38,7 @@ The .NET Foundation licenses this file to you under the MIT license.
</ItemGroup>

<ItemGroup>
<NetCoreAppNativeLibrary Include="System.Globalization.Native" />
<NetCoreAppNativeLibrary Include="System.IO.Compression.Native" />
</ItemGroup>

Expand Down
Expand Up @@ -5,14 +5,9 @@ namespace System.Globalization
{
internal static partial class GlobalizationMode
{
#if NATIVEAOT
// NATIVEAOT-TODO: Enable Icu on Windows
internal static bool UseNls { get; } = !Invariant;
#else
internal static bool UseNls { get; } = !Invariant &&
(AppContextConfigHelper.GetBooleanConfig("System.Globalization.UseNls", "DOTNET_SYSTEM_GLOBALIZATION_USENLS") ||
!LoadIcu());
#endif

private static bool LoadIcu()
{
Expand Down
23 changes: 23 additions & 0 deletions src/native/libs/System.Globalization.Native/CMakeLists.txt
Expand Up @@ -121,3 +121,26 @@ if(NOT CLR_CMAKE_TARGET_OSX AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMA
)
endif()
endif()

if(CLR_CMAKE_TARGET_WIN32)
if(STATIC_LIBS_ONLY)
add_library(System.Globalization.Native.Aot
STATIC
${NATIVEGLOBALIZATION_SOURCES}
)
target_compile_options(System.Globalization.Native.Aot PRIVATE /guard:cf-)
target_compile_options(System.Globalization.Native.Aot PRIVATE /GL-)

add_library(System.Globalization.Native.Aot.GuardCF
STATIC
${NATIVEGLOBALIZATION_SOURCES}
)
target_compile_options(System.Globalization.Native.Aot.GuardCF PRIVATE /GL-)

target_link_libraries(System.Globalization.Native.Aot ${__LinkLibraries})
target_link_libraries(System.Globalization.Native.Aot.GuardCF ${__LinkLibraries})

install_static_library(System.Globalization.Native.Aot aotsdk nativeaot)
install_static_library(System.Globalization.Native.Aot.GuardCF aotsdk nativeaot)
endif()
endif()

0 comments on commit 9d06449

Please sign in to comment.