Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local build for System.Globalization shim #72896

Merged
merged 28 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
aed8b64
Add local build for System.Globalization shim
Jul 24, 2022
ec90686
Merge branch 'dotnet:main' into build
smhmhmd Aug 2, 2022
f2fa736
Incorporate review feedback
smhmhmd Aug 2, 2022
d8dabf2
Fix IlCompilerPackagePath
smhmhmd Aug 2, 2022
e548415
Address review feedback
smhmhmd Aug 2, 2022
6075e03
Incorporate review feedback
smhmhmd Aug 4, 2022
5256276
Merge branch 'dotnet:main' into build
smhmhmd Aug 8, 2022
3fcba3d
Address feedback from 08/04
Aug 8, 2022
3eba2de
Merge branch 'dotnet:main' into build
smhmhmd Aug 16, 2022
2f440a0
Fix DirectPInvoke for library built by user
Aug 16, 2022
9bf52ca
Merge branch 'dotnet:main' into build
smhmhmd Aug 22, 2022
de4b4fc
Merge branch 'dotnet:main' into build
smhmhmd Sep 1, 2022
e59cc03
Feedback on 08/25: rename static-build, "source_code" and cleanup com…
Aug 31, 2022
b51f34c
Merge branch 'dotnet:main' into build
smhmhmd Sep 1, 2022
1acc76f
Merge branch 'dotnet:main' into build
smhmhmd Sep 2, 2022
556dcf3
Merge branch 'dotnet:main' into build
smhmhmd Sep 2, 2022
4a67db0
Feedback on 09/02
Sep 3, 2022
ff907cf
Move file includes to previous itemgroup
Sep 4, 2022
0a11c50
Move file includes to previous itemgroup
smhmhmd Sep 4, 2022
68eac73
Merge branch 'build' of https://github.com/smhmhmd/runtime into build
smhmhmd Sep 4, 2022
907c322
Merge branch 'dotnet:main' into build
smhmhmd Sep 4, 2022
e5c2c51
Update section in compiling.md
smhmhmd Sep 4, 2022
40bf9be
Update src/coreclr/nativeaot/docs/compiling.md
jkotas Sep 5, 2022
5f9e7a7
Update src/coreclr/nativeaot/docs/compiling.md
jkotas Sep 5, 2022
e4fdcfa
Update src/coreclr/nativeaot/docs/compiling.md
jkotas Sep 5, 2022
7a96d14
Update src/coreclr/nativeaot/docs/compiling.md
smhmhmd Sep 5, 2022
8323197
Update src/installer/pkg/projects/Microsoft.DotNet.ILCompiler/Microso…
smhmhmd Sep 5, 2022
bca6da8
Merge branch 'dotnet:main' into build
smhmhmd Sep 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ The .NET Foundation licenses this file to you under the MIT license.
<NetCoreAppNativeLibrary Include="@(NetCoreAppNativeLibrary->'%(Identity)')">
<EscapedPath>$(IlcFrameworkNativePath)lib%(Identity).a</EscapedPath>
</NetCoreAppNativeLibrary>
<NativeLibrary Include="$(NugetPackageRoot)/microsoft.dotnet.ilcompiler/7.0.0-dev/shim_source_code/libs/System.Globalization.Native/build/libSystem.Globalization.Native-Static.a" Condition="'$(LocalSystemGlobalizationNative)' != ''"/>
jkotas marked this conversation as resolved.
Show resolved Hide resolved
<NativeLibrary Include="@(NetCoreAppNativeLibrary->'%(EscapedPath)')" />
<StaticICULibs Include="/usr/lib/x86_64-linux-gnu/libicuio.a;/usr/lib/x86_64-linux-gnu/libicutu.a;/usr/lib/x86_64-linux-gnu/libicui18n.a;/usr/lib/x86_64-linux-gnu/libicuuc.a;/usr/lib/x86_64-linux-gnu/libicudata.a" Condition="'$(LocalSystemGlobalizationNative)' != '' And Exists('/usr/lib/x86_64-linux-gnu/libicuio.a')" />
jkotas marked this conversation as resolved.
Show resolved Hide resolved
<StaticICULibs Include="/usr/lib/libicuio.a;/usr/lib/libicutu.a;/usr/lib/libicui18n.a;/usr/lib/libicuuc.a;/usr/lib/libicudata.a" Condition="'$(LocalSystemGlobalizationNative)' != '' And Exists('/usr/lib/libicuio.a')" />
</ItemGroup>

<ItemGroup Condition="'$(TargetOS)' == 'OSX'">
Expand All @@ -74,8 +77,11 @@ The .NET Foundation licenses this file to you under the MIT license.
<NativeFramework Include="GSS" />
</ItemGroup>

<Exec Command="if [ -d $(NugetPackageRoot)/microsoft.dotnet.ilcompiler/7.0.0-dev/shim_source_code ]; then cd $(NugetPackageRoot)/microsoft.dotnet.ilcompiler/7.0.0-dev/shim_source_code/libs/System.Globalization.Native/ %26%26 cp CMakeLists-standalone.txt CMakeLists.txt %26%26 cp config-standalone.h config.h %26%26 mkdir -p build %26%26 cd build %26%26 cmake ../ %26%26 make -j; fi" Condition="'$(LocalSystemGlobalizationNative)' != ''"/>
jkotas marked this conversation as resolved.
Show resolved Hide resolved

<ItemGroup>
<LinkerArg Include="@(NativeLibrary)" />
<LinkerArg Include="@(StaticICULibs)" Condition="'$(LocalSystemGlobalizationNative)' != ''" />
jkotas marked this conversation as resolved.
Show resolved Hide resolved
<LinkerArg Include="--sysroot=$(SysRoot)" Condition="'$(SysRoot)' != ''" />
<LinkerArg Include="--target=$(TargetTriple)" Condition="'$(TargetTriple)' != ''" />
<LinkerArg Include="-g" Condition="$(NativeDebugSymbols) == 'true'" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<File Include="$(CoreCLRBuildIntegrationDir)*" TargetPath="build" />
<File Include="$(CoreCLRILCompilerDir)netstandard\*" TargetPath="tools/netstandard" />
<File Include="sdk\Sdk.props" TargetPath="Sdk" />
<File Include="$(MSBuildThisFileDirectory)\..\..\..\..\native\libs\System.Globalization.Native\*" TargetPath="shim_source_code/libs/System.Globalization.Native"/>
jkotas marked this conversation as resolved.
Show resolved Hide resolved
<File Include="$(MSBuildThisFileDirectory)\..\..\..\..\native\minipal\*" TargetPath="shim_source_code/minipal"/>
<File Include="$(MSBuildThisFileDirectory)\..\..\..\..\native\libs\Common\*" TargetPath="shim_source_code/libs/Common"/>
</ItemGroup>
</Target>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.6)

project(System.Globalization.Native.User.Machine.Build C)

include(configure.cmake)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Only Linux for now
jkotas marked this conversation as resolved.
Show resolved Hide resolved

set(NATIVEGLOBALIZATION_SOURCES
pal_calendarData.c
pal_casing.c
pal_collation.c
pal_idna.c
pal_locale.c
pal_localeNumberData.c
pal_localeStringData.c
pal_normalization.c
pal_icushim.c
pal_icushim_native_static.c
pal_timeZoneInfo.c
)

add_library(System.Globalization.Native-Static
STATIC
${NATIVEGLOBALIZATION_SOURCES}
)

add_compile_options(-Wno-switch-enum)
add_compile_options(-Wno-covered-switch-default)

# Workaround for warnings produced by ICU headers
add_compile_options(-Wno-reserved-id-macro)
add_compile_options(-Wno-documentation)
add_compile_options(-Wno-documentation-unknown-command)

# Workaround for https://unicode-org.atlassian.net/browse/ICU-20601
add_compile_options(-Wno-extra-semi-stmt)
add_compile_options(-Wno-unknown-warning-option)

add_definitions(-D_GNU_SOURCE -g -fPIC -DBUILDENV_DEBUG=1 -DDEBUG -DDISABLE_CONTRACTS -DHOST_64BIT -DHOST_AMD64 -DHOST_UNIX -DPALEXPORT=EXTERN_C -DTARGET_64BIT -DTARGET_AMD64 -DTARGET_LINUX -DTARGET_UNIX -DURTBLDENV_FRIENDLY=Debug -D_DBG -D_DEBUG -D_FILE_OFFSET_BITS=64 -DUSE_ICUSHIM_STATIC_BUILD -Wno-unused-variable)

target_compile_options(System.Globalization.Native-Static PUBLIC -std=gnu99 -Wno-declaration-after-statement -D_GNU_SOURCE -g -fPIC -O0 -g -Wall -Wno-null-conversion -fno-omit-frame-pointer -fms-extensions -fwrapv -fstack-protector-strong -Werror)

target_include_directories (System.Globalization.Native-Static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../Common ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../)

endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
jkotas marked this conversation as resolved.
Show resolved Hide resolved

#define HAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS 1
jkotas marked this conversation as resolved.
Show resolved Hide resolved
#define HAVE_SET_MAX_VARIABLE 1
12 changes: 12 additions & 0 deletions src/native/libs/System.Globalization.Native/pal_icushim.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#include "pal_icushim.h"

#if defined(USE_ICUSHIM_STATIC_BUILD)
#include "pal_icushim_native_static.h"
#endif

// Define pointers to all the used ICU functions
#define PER_FUNCTION_BLOCK(fn, lib, required) TYPEOF(fn)* fn##_ptr;
FOR_ALL_ICU_FUNCTIONS
Expand Down Expand Up @@ -481,6 +485,10 @@ int32_t GlobalizationNative_LoadICU()
FOR_ALL_ICU_FUNCTIONS
ValidateICUDataCanLoad();

#if defined(USE_ICUSHIM_STATIC_BUILD)
jkotas marked this conversation as resolved.
Show resolved Hide resolved
InitWithStaticLibICUFunctions();
#endif

InitializeVariableMaxAndTopPointers(symbolVersion);
InitializeUColClonePointers(symbolVersion);

Expand Down Expand Up @@ -538,6 +546,10 @@ void GlobalizationNative_InitICUFunctions(void* icuuc, void* icuin, const char*
FOR_ALL_ICU_FUNCTIONS
ValidateICUDataCanLoad();

#if defined(USE_ICUSHIM_STATIC_BUILD)
InitWithStaticLibICUFunctions();
#endif

InitializeVariableMaxAndTopPointers(symbolVersion);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#include <unicode/ucurr.h>
jkotas marked this conversation as resolved.
Show resolved Hide resolved
jkotas marked this conversation as resolved.
Show resolved Hide resolved
#include <unicode/ucal.h>
#include <unicode/uchar.h>
#include <unicode/ucol.h>
#include <unicode/udat.h>
#include <unicode/udata.h>
#include <unicode/udatpg.h>
#include <unicode/uenum.h>
#include <unicode/uidna.h>
#include <unicode/uldnames.h>
#include <unicode/ulocdata.h>
#include <unicode/unorm2.h>
#include <unicode/unum.h>
#include <unicode/ures.h>
#include <unicode/usearch.h>
#include <unicode/utf16.h>
#include <unicode/utypes.h>
#include <unicode/urename.h>
#include <unicode/ustring.h>
#include "pal_icushim_native_static.h"

#define PER_FUNCTION_BLOCK(fn) __typeof(fn)* fn##_ptr = fn;

// List of all functions from the ICU libraries that are used in the System.Globalization.Native.so
#define FOR_ALL_UNCONDITIONAL_STATIC_ICU_FUNCTIONS \
PER_FUNCTION_BLOCK(u_charsToUChars) \
PER_FUNCTION_BLOCK(u_getVersion) \
PER_FUNCTION_BLOCK(u_strcmp) \
PER_FUNCTION_BLOCK(u_strcpy) \
PER_FUNCTION_BLOCK(u_strlen) \
PER_FUNCTION_BLOCK(u_strncpy) \
PER_FUNCTION_BLOCK(u_tolower) \
PER_FUNCTION_BLOCK(u_toupper) \
PER_FUNCTION_BLOCK(u_uastrncpy) \
PER_FUNCTION_BLOCK(ubrk_close) \
PER_FUNCTION_BLOCK(ubrk_openRules) \
PER_FUNCTION_BLOCK(ucal_add) \
PER_FUNCTION_BLOCK(ucal_close) \
PER_FUNCTION_BLOCK(ucal_get) \
PER_FUNCTION_BLOCK(ucal_getAttribute) \
PER_FUNCTION_BLOCK(ucal_getKeywordValuesForLocale) \
PER_FUNCTION_BLOCK(ucal_getLimit) \
PER_FUNCTION_BLOCK(ucal_getNow) \
PER_FUNCTION_BLOCK(ucal_getTimeZoneDisplayName) \
PER_FUNCTION_BLOCK(ucal_open) \
PER_FUNCTION_BLOCK(ucal_openTimeZoneIDEnumeration) \
PER_FUNCTION_BLOCK(ucal_set) \
PER_FUNCTION_BLOCK(ucal_setMillis) \
PER_FUNCTION_BLOCK(ucol_close) \
PER_FUNCTION_BLOCK(ucol_closeElements) \
PER_FUNCTION_BLOCK(ucol_getOffset) \
PER_FUNCTION_BLOCK(ucol_getRules) \
PER_FUNCTION_BLOCK(ucol_getSortKey) \
PER_FUNCTION_BLOCK(ucol_getStrength) \
PER_FUNCTION_BLOCK(ucol_getVersion) \
PER_FUNCTION_BLOCK(ucol_next) \
PER_FUNCTION_BLOCK(ucol_previous) \
PER_FUNCTION_BLOCK(ucol_open) \
PER_FUNCTION_BLOCK(ucol_openElements) \
PER_FUNCTION_BLOCK(ucol_openRules) \
PER_FUNCTION_BLOCK(ucol_setAttribute) \
PER_FUNCTION_BLOCK(ucol_strcoll) \
PER_FUNCTION_BLOCK(udat_close) \
PER_FUNCTION_BLOCK(udat_countSymbols) \
PER_FUNCTION_BLOCK(udat_format) \
PER_FUNCTION_BLOCK(udat_getSymbols) \
PER_FUNCTION_BLOCK(udat_open) \
PER_FUNCTION_BLOCK(udat_setCalendar) \
PER_FUNCTION_BLOCK(udat_toPattern) \
PER_FUNCTION_BLOCK(udatpg_close) \
PER_FUNCTION_BLOCK(udatpg_getBestPattern) \
PER_FUNCTION_BLOCK(udatpg_open) \
PER_FUNCTION_BLOCK(uenum_close) \
PER_FUNCTION_BLOCK(uenum_count) \
PER_FUNCTION_BLOCK(uenum_next) \
PER_FUNCTION_BLOCK(uidna_close) \
PER_FUNCTION_BLOCK(uidna_nameToASCII) \
PER_FUNCTION_BLOCK(uidna_nameToUnicode) \
PER_FUNCTION_BLOCK(uidna_openUTS46) \
PER_FUNCTION_BLOCK(uloc_canonicalize) \
PER_FUNCTION_BLOCK(uloc_countAvailable) \
PER_FUNCTION_BLOCK(uloc_getAvailable) \
PER_FUNCTION_BLOCK(uloc_getBaseName) \
PER_FUNCTION_BLOCK(uloc_getCharacterOrientation) \
PER_FUNCTION_BLOCK(uloc_getCountry) \
PER_FUNCTION_BLOCK(uloc_getDefault) \
PER_FUNCTION_BLOCK(uloc_getDisplayCountry) \
PER_FUNCTION_BLOCK(uloc_getDisplayLanguage) \
PER_FUNCTION_BLOCK(uloc_getDisplayName) \
PER_FUNCTION_BLOCK(uloc_getISO3Country) \
PER_FUNCTION_BLOCK(uloc_getISO3Language) \
PER_FUNCTION_BLOCK(uloc_getKeywordValue) \
PER_FUNCTION_BLOCK(uloc_getLanguage) \
PER_FUNCTION_BLOCK(uloc_getLCID) \
PER_FUNCTION_BLOCK(uloc_getName) \
PER_FUNCTION_BLOCK(uloc_getParent) \
PER_FUNCTION_BLOCK(uloc_setKeywordValue) \
PER_FUNCTION_BLOCK(ulocdata_getCLDRVersion) \
PER_FUNCTION_BLOCK(ulocdata_getMeasurementSystem) \
PER_FUNCTION_BLOCK(unorm2_getNFCInstance) \
PER_FUNCTION_BLOCK(unorm2_getNFDInstance) \
PER_FUNCTION_BLOCK(unorm2_getNFKCInstance) \
PER_FUNCTION_BLOCK(unorm2_getNFKDInstance) \
PER_FUNCTION_BLOCK(unorm2_isNormalized) \
PER_FUNCTION_BLOCK(unorm2_normalize) \
PER_FUNCTION_BLOCK(unum_close) \
PER_FUNCTION_BLOCK(unum_getAttribute) \
PER_FUNCTION_BLOCK(unum_getSymbol) \
PER_FUNCTION_BLOCK(unum_open) \
PER_FUNCTION_BLOCK(unum_toPattern) \
PER_FUNCTION_BLOCK(ures_close) \
PER_FUNCTION_BLOCK(ures_getByKey) \
PER_FUNCTION_BLOCK(ures_getSize) \
PER_FUNCTION_BLOCK(ures_getStringByIndex) \
PER_FUNCTION_BLOCK(ures_open) \
PER_FUNCTION_BLOCK(usearch_close) \
PER_FUNCTION_BLOCK(usearch_first) \
PER_FUNCTION_BLOCK(usearch_getBreakIterator) \
PER_FUNCTION_BLOCK(usearch_getMatchedLength) \
PER_FUNCTION_BLOCK(usearch_last) \
PER_FUNCTION_BLOCK(usearch_openFromCollator) \
PER_FUNCTION_BLOCK(usearch_setPattern) \
PER_FUNCTION_BLOCK(usearch_setText)

#define FOR_ALL_OS_CONDITIONAL_STATIC_ICU_FUNCTIONS \
PER_FUNCTION_BLOCK(ucurr_forLocale) \
PER_FUNCTION_BLOCK(ucurr_getName) \
PER_FUNCTION_BLOCK(uldn_close) \
PER_FUNCTION_BLOCK(uldn_keyValueDisplayName) \
PER_FUNCTION_BLOCK(uldn_open)

// The following are the list of the ICU APIs which are optional. If these APIs exist in the ICU version we load at runtime, then we'll use it.
// Otherwise, we'll just not provide the functionality to users which needed these APIs.
#define FOR_ALL_OPTIONAL_STATIC_ICU_FUNCTIONS \
PER_FUNCTION_BLOCK(ucal_getWindowsTimeZoneID) \
PER_FUNCTION_BLOCK(ucal_getTimeZoneIDForWindowsID) \
PER_FUNCTION_BLOCK(ucol_setMaxVariable)

// ucol_setVariableTop is deprecated
// ucol_safeClone is deprecated

#define FOR_ALL_STATIC_ICU_FUNCTIONS \
FOR_ALL_UNCONDITIONAL_STATIC_ICU_FUNCTIONS \
FOR_ALL_OPTIONAL_STATIC_ICU_FUNCTIONS \
FOR_ALL_OS_CONDITIONAL_STATIC_ICU_FUNCTIONS

void InitWithStaticLibICUFunctions()
{
FOR_ALL_STATIC_ICU_FUNCTIONS
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

void InitWithStaticLibICUFunctions(void);