Commit 7646e76
Add local build for System.Globalization shim (#72896)
* Add local build for System.Globalization shim
Bundle the System.Globalization.Native shim sources into the native AOT toolchain package and compile them automatically using C/C++ compiler on the target machine.
Compiling of the shim sources using C/C++ compiler is done during dotnet publish as follows:
dotnet publish /p:LocalSystemGlobalizationNative=1 -bl -r linux-x64
This change is 'opt-in', it is enabled only by using /p:LocalSystemGlobalizationNative=1
* Incorporate review feedback
* Copy shim source code into users Obj directory at IntermediateOutputPath and compile
** $ ls -al obj/Debug/net7.0/linux-x64/shim_source_code/libs/System.Globalization.Native/build/libSystem.Globalization.Native-Static.a
* Add shell script for readability
* Add copyright headers
* Fix IlCompilerPackagePath
Add change that was part of previous commit
* Address review feedback
* Include existing pal_icushim_static.c by using STATIC_ICU define
* Use IlcSdkPath to copy shim source code
* Incorporate review feedback
* Remove USE_ICUSHIM_STATIC_BUILD in pal_icushim.c
* Rename shim_source_code to source_code in Microsoft.DotNet.ILCompiler.pkgproj and script
* Regular config is used, config-standalone.h is removed
* IlcPath/.. is replaced to make the ".." go away
* Address feedback from 08/04
* Rename option to ICUStaticLinking
* Remove <Message ..
* Compile without copying sources
* Trim list of defines
* Emit error when run on Linux in CMakeLists.txt
* Move StaticICULibs to near licucore on Mac
* Use only IlcHostPackagePath
* Fix DirectPInvoke for library built by user
* Feedback on 08/25: rename static-build, "source_code" and cleanup compile defs
* Remove IlcHostPackagePath check
* StaticICULinking property is true/false
* Remove -g and -fPIC from definitions
* Use minimal warning level
* Remove -DHOST_AMD64
* Remove -O0
* Remove -fms-extensions -fwrapv
* Standardize on "local build"
* Rename build-nativeaot-shim-standalone.sh to build.sh
* Script name in the error message should match the actual script name
* Rename source_code to native/src
Test code:
$ cat Program.cs
using System.Globalization;
namespace CurrentCulture
{
class Program
{
static void Main(string[] args)
{
double val = 1235.56;
Console.WriteLine($"Current culture: {CultureInfo.CurrentCulture.Name}");
Console.WriteLine(val);
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
Console.WriteLine($"Current culture: {CultureInfo.CurrentCulture.Name}");
Console.WriteLine(val);
}
}
}
$ cat hello-4.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>hello_4</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
$ cat nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="repositoryPath" value="/home/ubuntu/runtime/artifacts/packages/Debug/Shipping" />
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
</packageSources>
</configuration>
Test code build:
rm ./bin/Debug/net7.0/linux-arm64/native/hello-4
~/dotnet-sdk/dotnet clean
~/dotnet-sdk/dotnet publish /p:PublishAot=true /p:StaticICULinking=true -bl -r linux-arm64 --self-contained -v d 2>&1 > log
./bin/Debug/net7.0/linux-arm64/native/hello-4
Tested on x86-64 and arm64
* Feedback on 09/02
* Incorporated change to use only src/native/libs/System.Globalization.Native/CMakeLists.txt
* Conditionalized CMakeLists.txt for local build
* Moved the build.sh into parent as local_build.sh and removed local-build directory.
* Rename STATIC_SHIM_COMPILE to LOCAL_BUILD
* Move file includes to previous itemgroup
Move the includes in Microsoft.DotNet.ILCompiler.pkgproj to
<ItemGroup Condition="'$(PackageTargetRuntime)' != ''">
* Move file includes to previous itemgroup
Move the includes in Microsoft.DotNet.ILCompiler.pkgproj to
<ItemGroup Condition="'$(PackageTargetRuntime)' != ''">
* Update section in compiling.md
* Add "Using statically linked ICU" to compiling.md
* Remove define check for LOCAL_BUILD in CMakeLists.txt
* Update src/coreclr/nativeaot/docs/compiling.md
* Update src/coreclr/nativeaot/docs/compiling.md
* Update src/coreclr/nativeaot/docs/compiling.md
* Update src/coreclr/nativeaot/docs/compiling.md
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
* Update src/installer/pkg/projects/Microsoft.DotNet.ILCompiler/Microsoft.DotNet.ILCompiler.pkgproj
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
Co-authored-by: Samiullah Mohammed <ubuntu@ip-172-31-24-113>
Co-authored-by: Ubuntu <ubuntu@ip-10-0-0-223.us-west-1.compute.internal>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>1 parent 96072f2 commit 7646e76
File tree
7 files changed
+82
-2
lines changed- src
- coreclr/nativeaot
- BuildIntegration
- docs
- installer/pkg/projects/Microsoft.DotNet.ILCompiler
- native/libs/System.Globalization.Native
7 files changed
+82
-2
lines changedLines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| 83 | + | |
| 84 | + | |
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
| |||
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| 102 | + | |
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | 60 | | |
62 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
63 | 75 | | |
64 | 76 | | |
65 | 77 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
0 commit comments