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 5 commits
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,9 @@ 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="$(IntermediateOutputPath)/shim_source_code/libs/System.Globalization.Native/build/libSystem.Globalization.Native-Static.a" Condition="'$(LocalSystemGlobalizationNative)' != ''"/>
<NativeLibrary Include="@(NetCoreAppNativeLibrary->'%(EscapedPath)')" />
<StaticICULibs Include="-Wl,-Bstatic -licuio -licutu -licui18n -licuuc -licudata -Wl,-Bdynamic" Condition="'$(LocalSystemGlobalizationNative)' != ''" />
</ItemGroup>

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

<Exec Command="$(IlcSdkPath)/../shim_source_code/libs/System.Globalization.Native/build-nativeaot-shim-standalone.sh $(IlcSdkPath)/../ $(IntermediateOutputPath)" Condition="'$(LocalSystemGlobalizationNative)' != ''"/>

<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,45 @@
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_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 -DSTATIC_ICU -DSTATIC_SHIM_COMPILE)
jkotas marked this conversation as resolved.
Show resolved Hide resolved

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

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,36 @@
#!/bin/sh

# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
#

# This script is used only for building libSystem.Globalization.Native.a
# in the end-user's computer for NativeAOT purposes (static linking).
# It is not used during the dotnet runtime build.

# Currently, only Linux is supported

SHIM_SOURCE_DIR=$1/shim_source_code
INTERMEDIATE_OUTPUT_PATH=$2

if [ -d "$SHIM_SOURCE_DIR" ]; then
cp -r "$SHIM_SOURCE_DIR" "$INTERMEDIATE_OUTPUT_PATH"
jkotas marked this conversation as resolved.
Show resolved Hide resolved
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: Cannot copy into $INTERMEDIATE_OUTPUT_PATH"; exit 1; fi
LOCAL_SHIM_DIR="$INTERMEDIATE_OUTPUT_PATH"/shim_source_code/libs/System.Globalization.Native
cd "$LOCAL_SHIM_DIR"
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: Cannot cd into $LOCAL_SHIM_DIR"; exit 1; fi
cp CMakeLists-standalone.txt CMakeLists.txt
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: Cannot copy CMakeLists.txt"; exit 1; fi
cp config-standalone.h config.h
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: Cannot copy config.h"; exit 1; fi
mkdir -p build
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: Cannot mkdir build directory"; exit 1; fi
cd build
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: Build directory does not exist"; exit 1; fi
cmake ../
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: cmake failed"; exit 1; fi
make -j;
if [ $? -ne 0 ]; then echo "build-standalone.sh::ERROR: Build failed"; exit 1; fi
fi

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//

#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
4 changes: 4 additions & 0 deletions src/native/libs/System.Globalization.Native/pal_icushim.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#include "pal_icushim_internal_android.h"
#else

#if !defined(STATIC_SHIM_COMPILE)
#define U_DISABLE_RENAMING 1
#endif

// All ICU headers need to be included here so that all function prototypes are
// available before the function pointers are declared below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,17 @@ const char* GlobalizationNative_GetICUDTName(const char* culture)

int32_t GlobalizationNative_LoadICU(void)
{
#if !defined(STATIC_SHIM_COMPILE)
// Static NativeAOT compilation does not have
// GlobalizationNative_LoadICUData() as entrypoint
if (!isDataSet)
{
// don't try to locate icudt.dat automatically if mono_wasm_load_icu_data wasn't called
// and fallback to invariant mode
return 0;
}
#endif

UErrorCode status = 0;
UVersionInfo version;
// Request the CLDR version to perform basic ICU initialization and find out
Expand Down