From 20fc1adf2ada01a4a1fc7934706d2b641acbb9f4 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 11 Nov 2019 16:26:14 -0500 Subject: [PATCH] Support building for arm64 on arm64 (*nix) (#15354) This commit allows ASP.NET Core to be built on arm64 machines directly, without relying on cross-compilation. There's a few changes in here: 1. Ask msbuild to look into the BuildArchitecture By default, our build systems assums the machine is x64. This modifies the build configuration to check the architecture of the currently running build machine, and set BuildArchitecture to that. 2. Fix crossgen in Microsoft.AspNetCore.App.Runtime We run crossgen for supported architectures (including x64 and arm64). For that, we need a jit that we can point crossgen to. Generally, we can rely on the build scripts to find the right `libclrjit.so`. However, arm64 has multiple `libclirjit.so`, for different use-cases. There's one for arm64 (for running on arm64) and there's another one for cross-compiling for arm64 on x64. We need to figure out and use the right one explicitly rather than assuming the right one gets picked up. See https://github.com/dotnet/core-setup/pull/8468 for similar changes made in core-setup. This also needs https://github.com/aspnet/AspNetCore/pull/14790 to fully work on arm64. --- Directory.Build.props | 1 + .../src/Microsoft.AspNetCore.App.Runtime.csproj | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index b3dc903387..1bd59d7312 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -108,6 +108,7 @@ win osx linux + $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()) x64 $(TargetOsName)-$(TargetArchitecture) diff --git a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj index 4c4298a92d..f843ded124 100644 --- a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj +++ b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj @@ -90,15 +90,17 @@ This package is an internal implementation of the .NET Core SDK and is not meant : %3B + x64_arm + x64_arm64 + x86_arm + crossgen $(CrossgenToolFileName).exe $(CrossgenToolFileName) - x64_arm\$(CrossgenToolPackagePath) - x64_arm64\$(CrossgenToolPackagePath) - x86_arm\$(CrossgenToolPackagePath) + $(CrossCompileDirectory)\$(CrossgenToolPackagePath) $([System.IO.Path]::Combine('$(NuGetPackageRoot)', 'microsoft.netcore.app.runtime.$(RuntimeIdentifier)', '$(MicrosoftNETCoreAppRuntimeVersion)')) $([MSBuild]::EnsureTrailingSlash('$(RuntimePackageRoot)')) @@ -293,7 +295,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant --> $(IntermediateOutputPath)crossgen\ - $(CrossgenToolDir)$(LibPrefix)clrjit$(LibExtension) + + $(RuntimePackageRoot)runtimes\$(RuntimeIdentifier)\native\$(LibPrefix)clrjit$(LibExtension) + $(RuntimepackageRoot)runtimes\$(CrossCompileDirectory)\native\$(LibPrefix)clrjit$(LibExtension)