From 17b5d95d8be3f634e0547dfdde6cc09d29a95ed0 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Thu, 7 Nov 2019 11:33:59 -0500 Subject: [PATCH] Enable building on arm64 machines (#4102) With this commit, I can build core-sdk on RHEL 8 on arm64 directly, without cross compilation. Bump the sourcelink version to pick up the ability to parse git info without depending on libgit2sharp. This allows sourcelink to work on arm64. The version is the same as the one recently added to core-setup: https://github.com/dotnet/core-setup/pull/7696 Introduce a new 'BuildArchitecture' msbuild property that contains the host architecture (arm64, x64, etc). This is the architecture of the currently running machine, and may be different from the architecture we are targetting in the case of cross compilation. There's a gotcha with BuildArchitecture: under Visual Studio (an x86) process, we generally want a x64 architecture. So try and restrict it to arm64 only. Use BuildArchitecture to determine whether _crossDir and LibCLRJitRid need to be special-cased for arm64 or or not. --- Directory.Build.props | 6 ++++++ eng/Versions.props | 2 +- src/redist/targets/Crossgen.targets | 6 +++--- src/redist/targets/GenerateLayout.targets | 4 ++-- src/redist/targets/GetRuntimeInformation.targets | 1 - 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 02487bf33aac..e63ff8273550 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,6 +7,12 @@ MIT + + $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant()) + $(BuildArchitecture) + x64 + + True embedded diff --git a/eng/Versions.props b/eng/Versions.props index 0f64d277101a..4c942f39e056 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -122,7 +122,7 @@ $(BuildTasksFeedToolVersion) 2.0.0 15.8.0 - 1.0.0-beta2-18618-05 + 1.0.0-beta2-19367-01 diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets index 47adeabea742..3fccba0e697c 100644 --- a/src/redist/targets/Crossgen.targets +++ b/src/redist/targets/Crossgen.targets @@ -5,14 +5,14 @@ microsoft.netcore.app.runtime.$(SharedFrameworkRid) - <_crossDir Condition="'$(Architecture)' == 'arm64'">/x64_arm64 + <_crossDir Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' != 'arm64'">/x64_arm64 <_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">/x86_arm <_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'linux'">/x64_arm $(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/tools$(_crossDir)/crossgen$(ExeExtension) - $(SharedFrameworkRid) - x64_arm64 + x64_arm64 x86_arm x64_arm + $(SharedFrameworkRid) $(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppRuntimePackageVersion)/runtimes/$(LibCLRJitRid)/native/$(DynamicLibPrefix)clrjit$(DynamicLibExtension) $(RedistLayoutPath)shared/$(SharedFrameworkName)/$(MicrosoftNETCoreAppRuntimePackageVersion) * diff --git a/src/redist/targets/GenerateLayout.targets b/src/redist/targets/GenerateLayout.targets index 24aedd08f0a4..1d1c0d4352f6 100644 --- a/src/redist/targets/GenerateLayout.targets +++ b/src/redist/targets/GenerateLayout.targets @@ -48,11 +48,11 @@ $(CoreSetupRid) - x64 + $(Architecture) $(CoreSetupRid) - x64 + $(Architecture) x64 x86 diff --git a/src/redist/targets/GetRuntimeInformation.targets b/src/redist/targets/GetRuntimeInformation.targets index 695a5690838e..cd75c251bfae 100644 --- a/src/redist/targets/GetRuntimeInformation.targets +++ b/src/redist/targets/GetRuntimeInformation.targets @@ -13,7 +13,6 @@ linux linux - x64 $(OSName)-$(Architecture)