|
| 1 | +From e2946a26c11be7f7f0c223721a5b14f58f2ea240 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Omair Majid < [email protected]> |
| 3 | +Date: Mon, 11 Nov 2019 13:37:40 -0500 |
| 4 | +Subject: [PATCH] Support building for arm64 on arm64 (*nix) |
| 5 | + |
| 6 | +This commit allows ASP.NET Core to be built on arm64 machines directly, |
| 7 | +without relying on cross-compilation. |
| 8 | + |
| 9 | +There's a few changes in here: |
| 10 | + |
| 11 | +1. Ask msbuild to look into the BuildArchitecture |
| 12 | + |
| 13 | + By default, our build systems assums the machine is x64. This |
| 14 | + modifies the build configuration to check the architecture of the |
| 15 | + currently running build machine, and set BuildArchitecture to that. |
| 16 | + |
| 17 | +2. Fix crossgen in Microsoft.AspNetCore.App.Runtime |
| 18 | + |
| 19 | + We run crossgen for supported architectures (including x64 and |
| 20 | + arm64). For that, we need a jit that we can point crossgen to. |
| 21 | + Generally, we can rely on the build scripts to find the right |
| 22 | + `libclrjit.so`. However, arm64 has multiple `libclirjit.so`, for |
| 23 | + different use-cases. There's one for arm64 (for running on arm64) and |
| 24 | + there's another one for cross-compiling for arm64 on x64. We need to |
| 25 | + figure out and use the right one explicitly rather than assuming the |
| 26 | + right one gets picked up. |
| 27 | + |
| 28 | + See https://github.com/dotnet/core-setup/pull/8468 for similar |
| 29 | + changes made in core-setup. |
| 30 | + |
| 31 | +This also needs https://github.com/aspnet/AspNetCore/pull/14790 to fully |
| 32 | +work on arm64. |
| 33 | +--- |
| 34 | + Directory.Build.props | 1 + |
| 35 | + .../src/Microsoft.AspNetCore.App.Runtime.csproj | 12 ++++++++---- |
| 36 | + 2 files changed, 9 insertions(+), 4 deletions(-) |
| 37 | + |
| 38 | +diff --git a/Directory.Build.props b/Directory.Build.props |
| 39 | +index b3dc903387f..1bd59d73121 100644 |
| 40 | +--- a/Directory.Build.props |
| 41 | ++++ b/Directory.Build.props |
| 42 | +@@ -108,6 +108,7 @@ |
| 43 | + <TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Windows'))">win</TargetOsName> |
| 44 | + <TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">osx</TargetOsName> |
| 45 | + <TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Linux'))">linux</TargetOsName> |
| 46 | ++ <BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture> |
| 47 | + <TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture> |
| 48 | + <TargetRuntimeIdentifier>$(TargetOsName)-$(TargetArchitecture)</TargetRuntimeIdentifier> |
| 49 | + |
| 50 | +diff --git a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj |
| 51 | +index 4c4298a92da..f843ded1241 100644 |
| 52 | +--- a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj |
| 53 | ++++ b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj |
| 54 | +@@ -90,15 +90,17 @@ This package is an internal implementation of the .NET Core SDK and is not meant |
| 55 | + <PathSeparator Condition="'$(PathSeparator)' == ''">:</PathSeparator> |
| 56 | + <PathSeparator Condition=" '$(TargetOsName)' == 'win' ">%3B</PathSeparator> |
| 57 | + |
| 58 | ++ <CrossCompileDirectory Condition=" '$(TargetRuntimeIdentifier)' == 'linux-arm' ">x64_arm</CrossCompileDirectory> |
| 59 | ++ <CrossCompileDirectory Condition=" '$(TargetArchitecture)' == 'arm64' AND '$(BuildArchitecture)' != 'arm64' ">x64_arm64</CrossCompileDirectory> |
| 60 | ++ <CrossCompileDirectory Condition=" '$(TargetRuntimeIdentifier)' == 'win-arm' ">x86_arm</CrossCompileDirectory> |
| 61 | ++ |
| 62 | + <!-- Crossgen executable name --> |
| 63 | + <CrossgenToolFileName>crossgen</CrossgenToolFileName> |
| 64 | + <CrossgenToolFileName Condition=" '$(TargetOsName)' == 'win' ">$(CrossgenToolFileName).exe</CrossgenToolFileName> |
| 65 | + <!-- Default crossgen executable relative path --> |
| 66 | + <CrossgenToolPackagePath>$(CrossgenToolFileName)</CrossgenToolPackagePath> |
| 67 | + <!-- Disambiguated RID-specific crossgen executable relative path --> |
| 68 | +- <CrossgenToolPackagePath Condition=" '$(TargetRuntimeIdentifier)' == 'linux-arm' ">x64_arm\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> |
| 69 | +- <CrossgenToolPackagePath Condition=" '$(TargetRuntimeIdentifier)' == 'linux-arm64' OR '$(TargetRuntimeIdentifier)' == 'linux-musl-arm64' ">x64_arm64\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> |
| 70 | +- <CrossgenToolPackagePath Condition=" '$(TargetRuntimeIdentifier)' == 'win-arm' ">x86_arm\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> |
| 71 | ++ <CrossgenToolPackagePath Condition=" '$(CrossCompileDirectory)' != '' ">$(CrossCompileDirectory)\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> |
| 72 | + |
| 73 | + <MicrosoftNETCoreAppRuntimeIdentifier>$(RuntimeIdentifier)</MicrosoftNETCoreAppRuntimeIdentifier> |
| 74 | + <MicrosoftNETCoreAppRuntimeIdentifier Condition="'$(TargetOsName)' != 'osx'">$(SourceBuildRuntimeIdentifier)</MicrosoftNETCoreAppRuntimeIdentifier> |
| 75 | +@@ -293,7 +295,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant |
| 76 | + <PropertyGroup> |
| 77 | + <CrossgenToolDir>$(IntermediateOutputPath)crossgen\</CrossgenToolDir> |
| 78 | + <CrossgenPlatformAssembliesDir>$(IntermediateOutputPath)platformAssemblies\</CrossgenPlatformAssembliesDir> |
| 79 | +- <CoreCLRJitPath>$(CrossgenToolDir)$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath> |
| 80 | ++ <!-- Pick the right coreclr jit based on whether we are cross-compiling or not --> |
| 81 | ++ <CoreCLRJitPath Condition="'$(CrossCompileDirectory)' == ''">$(RuntimePackageRoot)runtimes\$(RuntimeIdentifier)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath> |
| 82 | ++ <CoreCLRJitPath Condition="'$(CrossCompileDirectory)' != ''">$(RuntimepackageRoot)runtimes\$(CrossCompileDirectory)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath> |
| 83 | + </PropertyGroup> |
| 84 | + |
| 85 | + <ItemGroup> |
0 commit comments