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 15 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 @@ -52,7 +52,7 @@ The .NET Foundation licenses this file to you under the MIT license.

<ItemGroup>
<NetCoreAppNativeLibrary Include="System.Native" />
<NetCoreAppNativeLibrary Include="System.Globalization.Native" />
<NetCoreAppNativeLibrary Include="System.Globalization.Native" Condition="'$(StaticICULinking)' != 'true'" />
<NetCoreAppNativeLibrary Include="System.IO.Compression.Native" />
<NetCoreAppNativeLibrary Include="System.Net.Security.Native" />
<NetCoreAppNativeLibrary Include="System.Security.Cryptography.Native.Apple" Condition="'$(TargetOS)' == 'OSX'" />
Expand All @@ -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="$(IntermediateOutputPath)/libs/System.Globalization.Native/build/libSystem.Globalization.Native.a" Condition="'$(StaticICULinking)' == 'true'"/>
<DirectPInvoke Include="libSystem.Globalization.Native" Condition="'$(StaticICULinking)' == 'true'"/>
<NativeLibrary Include="@(NetCoreAppNativeLibrary->'%(EscapedPath)')" />
<StaticICULibs Include="-Wl,-Bstatic -licuio -licutu -licui18n -licuuc -licudata -Wl,-Bdynamic" Condition="'$(StaticICULinking)' == 'true'" />
jkotas marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

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

<Exec Command="$(IlcHostPackagePath)/native/src/libs/System.Globalization.Native/local-build/build.sh $(IlcHostPackagePath)/ $(IntermediateOutputPath)" Condition="'$(StaticICULinking)' == 'true'"/>

<ItemGroup>
<LinkerArg Include="@(NativeLibrary)" />
<LinkerArg Include="--sysroot=$(SysRoot)" Condition="'$(SysRoot)' != ''" />
Expand All @@ -91,6 +96,7 @@ The .NET Foundation licenses this file to you under the MIT license.
<LinkerArg Include="-lz" />
<LinkerArg Include="-lrt" Condition="'$(TargetOS)' != 'OSX'" />
<LinkerArg Include="-licucore" Condition="'$(TargetOS)' == 'OSX'" />
<LinkerArg Include="@(StaticICULibs)" Condition="'$(StaticICULinking)' == 'true'" />
<LinkerArg Include="-dynamiclib" Condition="'$(TargetOS)' == 'OSX' and '$(NativeLib)' == 'Shared'" />
<LinkerArg Include="-shared" Condition="'$(TargetOS)' != 'OSX' and '$(NativeLib)' == 'Shared'" />
<!-- binskim warning BA3001 PIE disabled on executable -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<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="native/src/libs/System.Globalization.Native"/>
jkotas marked this conversation as resolved.
Show resolved Hide resolved
<File Include="$(MSBuildThisFileDirectory)\..\..\..\..\native\libs\System.Globalization.Native\local-build\*" TargetPath="native/src/libs/System.Globalization.Native/local-build"/>
<File Include="$(MSBuildThisFileDirectory)\..\..\..\..\native\minipal\*" TargetPath="native/src/minipal"/>
<File Include="$(MSBuildThisFileDirectory)\..\..\..\..\native\libs\Common\*" TargetPath="native/src/libs/Common"/>
</ItemGroup>
</Target>

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

project(System.Globalization.Native.Local.Build C)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # Only Linux for now

configure_file(../config.h.in config.h)
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
${NATIVEGLOBALIZATION_SOURCES}
)

add_definitions(-DPALEXPORT=EXTERN_C -DTARGET_UNIX -DSTATIC_ICU -DSTATIC_SHIM_COMPILE)
jkotas marked this conversation as resolved.
Show resolved Hide resolved

target_compile_options(System.Globalization.Native PUBLIC -std=gnu99 -fPIC -fno-omit-frame-pointer -fstack-protector-strong)

target_include_directories (System.Globalization.Native PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../ ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/Common ${CMAKE_CURRENT_BINARY_DIR})

else()
message( FATAL_ERROR "Static builds are supported only on Linux" )
endif()
26 changes: 26 additions & 0 deletions src/native/libs/System.Globalization.Native/local-build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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).
# This file is not used during the dotnet runtime build.

# Currently, only Linux is supported

SHIM_SOURCE_DIR=$1/native/src
INTERMEDIATE_OUTPUT_PATH=$2

if [ -d "$SHIM_SOURCE_DIR" ]; then
LOCAL_SHIM_DIR="$INTERMEDIATE_OUTPUT_PATH"/libs/System.Globalization.Native/build
mkdir -p "$LOCAL_SHIM_DIR" && cd "$LOCAL_SHIM_DIR"
if [ $? -ne 0 ]; then echo "build.sh::ERROR: Cannot use local build directory"; exit 1; fi
cmake -S "$SHIM_SOURCE_DIR/libs/System.Globalization.Native/" "$SHIM_SOURCE_DIR/libs/System.Globalization.Native/local-build"
if [ $? -ne 0 ]; then echo "build.sh::ERROR: cmake failed"; exit 1; fi
make VERBOSE=1 -j
if [ $? -ne 0 ]; then echo "build.sh::ERROR: Build failed"; exit 1; fi
fi

exit 0
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