|
| 1 | +From 4b5c617203cfb9d2c1b12995e12d819fba6d7b6f Mon Sep 17 00:00:00 2001 |
| 2 | +From: Omair Majid < [email protected]> |
| 3 | +Date: Tue, 8 Oct 2019 17:02:29 -0400 |
| 4 | +Subject: [PATCH] Enable building on arm64 machines |
| 5 | + |
| 6 | +With this commit, I can build core-sdk on RHEL 8 on arm64 directly, |
| 7 | +without cross compilation. |
| 8 | + |
| 9 | +Bump the sourcelink version to pick up the ability to parse git info |
| 10 | +without depending on libgit2sharp. This allows sourcelink to work on |
| 11 | +arm64. The version is the same as the one recently added to core-setup: |
| 12 | +https://github.com/dotnet/core-setup/pull/7696 |
| 13 | + |
| 14 | +Introduce a new 'BuildArchitecture' msbuild property that contains the host |
| 15 | +architecture (arm64, x64, etc). This is the architecture of the |
| 16 | +currently running machine, and may be different from the architecture we |
| 17 | +are targetting in the case of cross compilation. |
| 18 | + |
| 19 | +There's a gotcha with BuildArchitecture: under Visual Studio (an x86) process, |
| 20 | +we generally want a x64 architecture. So try and restrict it to arm64 only. |
| 21 | + |
| 22 | +Use BuildArchitecture to determine whether _crossDir and LibCLRJitRid need to |
| 23 | +be special-cased for arm64 or or not. |
| 24 | +--- |
| 25 | + Directory.Build.props | 6 ++++++ |
| 26 | + eng/Versions.props | 2 +- |
| 27 | + src/redist/targets/Crossgen.targets | 6 +++--- |
| 28 | + src/redist/targets/GenerateLayout.targets | 4 ++-- |
| 29 | + src/redist/targets/GetRuntimeInformation.targets | 1 - |
| 30 | + 5 files changed, 12 insertions(+), 7 deletions(-) |
| 31 | + |
| 32 | +diff --git a/Directory.Build.props b/Directory.Build.props |
| 33 | +index b65a72410..be3834859 100644 |
| 34 | +--- a/Directory.Build.props |
| 35 | ++++ b/Directory.Build.props |
| 36 | +@@ -7,6 +7,12 @@ |
| 37 | + <PackageLicenseExpression>MIT</PackageLicenseExpression> |
| 38 | + </PropertyGroup> |
| 39 | + |
| 40 | ++ <PropertyGroup> |
| 41 | ++ <BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture> |
| 42 | ++ <Architecture Condition="'$(BuildArchitecture)' == 'arm64'">$(BuildArchitecture)</Architecture> |
| 43 | ++ <Architecture Condition="'$(Architecture)' == ''">x64</Architecture> |
| 44 | ++ </PropertyGroup> |
| 45 | ++ |
| 46 | + <PropertyGroup> |
| 47 | + <TreatWarningsAsErrors>True</TreatWarningsAsErrors> |
| 48 | + <DebugType>embedded</DebugType> |
| 49 | +diff --git a/eng/Versions.props b/eng/Versions.props |
| 50 | +index 344a325bf..37e478e72 100644 |
| 51 | +--- a/eng/Versions.props |
| 52 | ++++ b/eng/Versions.props |
| 53 | +@@ -87,7 +87,7 @@ |
| 54 | + <VersionToolsVersion>$(BuildTasksFeedToolVersion)</VersionToolsVersion> |
| 55 | + <DotnetDebToolVersion>2.0.0</DotnetDebToolVersion> |
| 56 | + <MicrosoftNETTestSdkVersion>15.8.0</MicrosoftNETTestSdkVersion> |
| 57 | +- <MicrosoftSourceLinkVersion>1.0.0-beta2-18618-05</MicrosoftSourceLinkVersion> |
| 58 | ++ <MicrosoftSourceLinkVersion>1.0.0-beta2-19367-01</MicrosoftSourceLinkVersion> |
| 59 | + </PropertyGroup> |
| 60 | + <PropertyGroup> |
| 61 | + <!-- pinned dependency. This package is not being produced outside of the 2.0 branch of corefx and should not change. --> |
| 62 | +diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets |
| 63 | +index 8d3091307..931dff2d9 100644 |
| 64 | +--- a/src/redist/targets/Crossgen.targets |
| 65 | ++++ b/src/redist/targets/Crossgen.targets |
| 66 | +@@ -5,14 +5,14 @@ |
| 67 | + |
| 68 | + <PropertyGroup> |
| 69 | + <RuntimeNETCoreAppPackageName>runtime.$(SharedFrameworkRid).microsoft.netcore.app</RuntimeNETCoreAppPackageName> |
| 70 | +- <_crossDir Condition="'$(Architecture)' == 'arm64'">/x64_arm64</_crossDir> |
| 71 | ++ <_crossDir Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' != 'arm64'">/x64_arm64</_crossDir> |
| 72 | + <_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">/x86_arm</_crossDir> |
| 73 | + <_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'linux'">/x64_arm</_crossDir> |
| 74 | + <CrossgenPath>$(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppPackageVersion)/tools$(_crossDir)/crossgen$(ExeExtension)</CrossgenPath> |
| 75 | +- <LibCLRJitRid Condition="!$(Architecture.StartsWith('arm'))">$(SharedFrameworkRid)</LibCLRJitRid> |
| 76 | +- <LibCLRJitRid Condition="'$(Architecture)' == 'arm64'">x64_arm64</LibCLRJitRid> |
| 77 | ++ <LibCLRJitRid Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' == 'x64'">x64_arm64</LibCLRJitRid> |
| 78 | + <LibCLRJitRid Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">x86_arm</LibCLRJitRid> |
| 79 | + <LibCLRJitRid Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'linux'">x64_arm</LibCLRJitRid> |
| 80 | ++ <LibCLRJitRid Condition="'$(LibCLRJitRid)' == ''">$(SharedFrameworkRid)</LibCLRJitRid> |
| 81 | + <LibCLRJitPath>$(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppPackageVersion)/runtimes/$(LibCLRJitRid)/native/$(DynamicLibPrefix)clrjit$(DynamicLibExtension)</LibCLRJitPath> |
| 82 | + <SharedFrameworkNameVersionPath>$(RedistLayoutPath)shared/$(SharedFrameworkName)/$(MicrosoftNETCoreAppRuntimewinx64PackageVersion)</SharedFrameworkNameVersionPath> |
| 83 | + <DIASymReaderCrossgenFilter>*</DIASymReaderCrossgenFilter> |
| 84 | +diff --git a/src/redist/targets/GenerateLayout.targets b/src/redist/targets/GenerateLayout.targets |
| 85 | +index d2a0b6fd1..a0bcf6f35 100644 |
| 86 | +--- a/src/redist/targets/GenerateLayout.targets |
| 87 | ++++ b/src/redist/targets/GenerateLayout.targets |
| 88 | +@@ -25,11 +25,11 @@ |
| 89 | + |
| 90 | + <!-- Use the "x64" Rid when downloading Linux shared framework 'DEB' installer files. --> |
| 91 | + <SharedFrameworkInstallerFileRid>$(CoreSetupRid)</SharedFrameworkInstallerFileRid> |
| 92 | +- <SharedFrameworkInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' OR '$(IsRPMBasedDistro)' == 'true' ">x64</SharedFrameworkInstallerFileRid> |
| 93 | ++ <SharedFrameworkInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' OR '$(IsRPMBasedDistro)' == 'true' ">$(Architecture)</SharedFrameworkInstallerFileRid> |
| 94 | + |
| 95 | + <!-- Use the "x64" Rid when downloading Linux runtime dependencies Debian package. --> |
| 96 | + <RuntimeDepsInstallerFileRid>$(CoreSetupRid)</RuntimeDepsInstallerFileRid> |
| 97 | +- <RuntimeDepsInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' ">x64</RuntimeDepsInstallerFileRid> |
| 98 | ++ <RuntimeDepsInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' ">$(Architecture)</RuntimeDepsInstallerFileRid> |
| 99 | + |
| 100 | + <DownloadedSharedHostInstallerFileName Condition=" '$(InstallerExtension)' != '' ">dotnet-host$(InstallerStartSuffix)-$(SharedHostVersion)-$(SharedFrameworkInstallerFileRid)$(InstallerExtension)</DownloadedSharedHostInstallerFileName> |
| 101 | + <DownloadedHostFxrInstallerFileName Condition=" '$(InstallerExtension)' != '' ">dotnet-hostfxr$(InstallerStartSuffix)-$(HostFxrVersion)-$(SharedFrameworkInstallerFileRid)$(InstallerExtension)</DownloadedHostFxrInstallerFileName> |
| 102 | +diff --git a/src/redist/targets/GetRuntimeInformation.targets b/src/redist/targets/GetRuntimeInformation.targets |
| 103 | +index 3b14d1203..f49c7262f 100644 |
| 104 | +--- a/src/redist/targets/GetRuntimeInformation.targets |
| 105 | ++++ b/src/redist/targets/GetRuntimeInformation.targets |
| 106 | +@@ -13,7 +13,6 @@ |
| 107 | + <OSName Condition=" '$(OSName)' == '' AND '$(IsLinux)' == 'True' ">linux</OSName> |
| 108 | + <OSPlatform Condition=" '$(OSPlatform)' == '' AND '$(IsLinux)' == 'True' ">linux</OSPlatform> |
| 109 | + |
| 110 | +- <Architecture Condition=" '$(Architecture)' == '' ">x64</Architecture> |
| 111 | + <Rid Condition=" '$(Rid)' == '' ">$(OSName)-$(Architecture)</Rid> |
| 112 | + </PropertyGroup> |
| 113 | + |
| 114 | +-- |
| 115 | +2.18.1 |
| 116 | + |
0 commit comments