From 4330dfdf747c0e8e57a43328a1ddcaaac453589e Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Tue, 8 Oct 2019 17:02:29 -0400 Subject: [PATCH] Enable building on arm64 machines 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 57495f27c176..6533c352ecbd 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 eded82bcf5a2..ee8f4be5cbc8 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -87,7 +87,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 428e3c261dd4..a03569a94246 100644 --- a/src/redist/targets/Crossgen.targets +++ b/src/redist/targets/Crossgen.targets @@ -5,14 +5,14 @@ runtime.$(SharedFrameworkRid).microsoft.netcore.app - <_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)/$(MicrosoftNETCoreAppPackageVersion)/tools$(_crossDir)/crossgen$(ExeExtension) - $(SharedFrameworkRid) - x64_arm64 + x64_arm64 x86_arm x64_arm + $(SharedFrameworkRid) $(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppPackageVersion)/runtimes/$(LibCLRJitRid)/native/$(DynamicLibPrefix)clrjit$(DynamicLibExtension) $(RedistLayoutPath)shared/$(SharedFrameworkName)/$(MicrosoftNETCoreAppPackageVersion) * diff --git a/src/redist/targets/GenerateLayout.targets b/src/redist/targets/GenerateLayout.targets index 5a1773915aa9..952f9a3048ad 100644 --- a/src/redist/targets/GenerateLayout.targets +++ b/src/redist/targets/GenerateLayout.targets @@ -25,11 +25,11 @@ $(CoreSetupRid) - x64 + $(Architecture) $(CoreSetupRid) - x64 + $(Architecture) dotnet-host$(InstallerStartSuffix)-$(SharedHostVersion)-$(SharedFrameworkInstallerFileRid)$(InstallerExtension) dotnet-hostfxr$(InstallerStartSuffix)-$(HostFxrVersion)-$(SharedFrameworkInstallerFileRid)$(InstallerExtension) diff --git a/src/redist/targets/GetRuntimeInformation.targets b/src/redist/targets/GetRuntimeInformation.targets index ff9ee1781528..121352d09f2e 100644 --- a/src/redist/targets/GetRuntimeInformation.targets +++ b/src/redist/targets/GetRuntimeInformation.targets @@ -13,7 +13,6 @@ linux linux - x64 $(OSName)-$(Architecture)