forked from dotnet/source-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This chnage allows source-build to be cloned and built on arm64 machines. I have tested this on RHEL 8 aarch64. This change includes backports of the following pull-requests which have been merged into their respective master branches: - dotnet/aspnetcore#14790 - dotnet/aspnetcore#15354 - dotnet/installer#4102 - dotnet/core-setup#8468 - dotnet/corefx#40453
- Loading branch information
Showing
14 changed files
with
410 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
patches/aspnetcore/0009-Support-global.json-on-arm64-as-well.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From 84d274a8f3d416b0a5bd999e3d1c43ae1535e38f Mon Sep 17 00:00:00 2001 | ||
From: Omair Majid <omajid@redhat.com> | ||
Date: Wed, 23 Oct 2019 15:43:57 -0400 | ||
Subject: [PATCH] Support global.json on arm64 as well | ||
|
||
arcade uses the runtime section of global.json to decide which | ||
architecture + runtime combination needs to be installed. | ||
|
||
With https://github.com/dotnet/arcade/pull/4132 arcade can install | ||
foreign SDKs in separate locations correctly. | ||
|
||
This change, suggested by @dougbu, makes arcade always install the | ||
runtime for the local architecture (which means it should work on arm64 | ||
and x64) as well as the x86 architecture (skipped on Linux). | ||
|
||
This gets us a working SDK/Runtime combo on arm64. | ||
--- | ||
global.json | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/global.json b/global.json | ||
index 602f4f44e17..40dec559cc9 100644 | ||
--- a/global.json | ||
+++ b/global.json | ||
@@ -5,7 +5,7 @@ | ||
"tools": { | ||
"dotnet": "3.0.100-preview8-013656", | ||
"runtimes": { | ||
- "dotnet/x64": [ | ||
+ "dotnet": [ | ||
"$(MicrosoftNETCoreAppRuntimeVersion)" | ||
], | ||
"dotnet/x86": [ |
85 changes: 85 additions & 0 deletions
85
patches/aspnetcore/0010-Support-building-for-arm64-on-arm64-nix.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
From e2946a26c11be7f7f0c223721a5b14f58f2ea240 Mon Sep 17 00:00:00 2001 | ||
From: Omair Majid <omajid@redhat.com> | ||
Date: Mon, 11 Nov 2019 13:37:40 -0500 | ||
Subject: [PATCH] Support building for arm64 on arm64 (*nix) | ||
|
||
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 b3dc903387f..1bd59d73121 100644 | ||
--- a/Directory.Build.props | ||
+++ b/Directory.Build.props | ||
@@ -108,6 +108,7 @@ | ||
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Windows'))">win</TargetOsName> | ||
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('OSX'))">osx</TargetOsName> | ||
<TargetOsName Condition=" '$(TargetOsName)' == '' AND $([MSBuild]::IsOSPlatform('Linux'))">linux</TargetOsName> | ||
+ <BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture> | ||
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture> | ||
<TargetRuntimeIdentifier>$(TargetOsName)-$(TargetArchitecture)</TargetRuntimeIdentifier> | ||
|
||
diff --git a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj | ||
index 4c4298a92da..f843ded1241 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 | ||
<PathSeparator Condition="'$(PathSeparator)' == ''">:</PathSeparator> | ||
<PathSeparator Condition=" '$(TargetOsName)' == 'win' ">%3B</PathSeparator> | ||
|
||
+ <CrossCompileDirectory Condition=" '$(TargetRuntimeIdentifier)' == 'linux-arm' ">x64_arm</CrossCompileDirectory> | ||
+ <CrossCompileDirectory Condition=" '$(TargetArchitecture)' == 'arm64' AND '$(BuildArchitecture)' != 'arm64' ">x64_arm64</CrossCompileDirectory> | ||
+ <CrossCompileDirectory Condition=" '$(TargetRuntimeIdentifier)' == 'win-arm' ">x86_arm</CrossCompileDirectory> | ||
+ | ||
<!-- Crossgen executable name --> | ||
<CrossgenToolFileName>crossgen</CrossgenToolFileName> | ||
<CrossgenToolFileName Condition=" '$(TargetOsName)' == 'win' ">$(CrossgenToolFileName).exe</CrossgenToolFileName> | ||
<!-- Default crossgen executable relative path --> | ||
<CrossgenToolPackagePath>$(CrossgenToolFileName)</CrossgenToolPackagePath> | ||
<!-- Disambiguated RID-specific crossgen executable relative path --> | ||
- <CrossgenToolPackagePath Condition=" '$(TargetRuntimeIdentifier)' == 'linux-arm' ">x64_arm\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> | ||
- <CrossgenToolPackagePath Condition=" '$(TargetRuntimeIdentifier)' == 'linux-arm64' OR '$(TargetRuntimeIdentifier)' == 'linux-musl-arm64' ">x64_arm64\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> | ||
- <CrossgenToolPackagePath Condition=" '$(TargetRuntimeIdentifier)' == 'win-arm' ">x86_arm\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> | ||
+ <CrossgenToolPackagePath Condition=" '$(CrossCompileDirectory)' != '' ">$(CrossCompileDirectory)\$(CrossgenToolPackagePath)</CrossgenToolPackagePath> | ||
|
||
<RuntimePackageRoot>$([System.IO.Path]::Combine('$(NuGetPackageRoot)', 'microsoft.netcore.app.runtime.$(RuntimeIdentifier)', '$(MicrosoftNETCoreAppRuntimeVersion)'))</RuntimePackageRoot> | ||
<RuntimePackageRoot>$([MSBuild]::EnsureTrailingSlash('$(RuntimePackageRoot)'))</RuntimePackageRoot> | ||
@@ -293,7 +295,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant | ||
--> | ||
<PropertyGroup> | ||
<CrossgenToolDir>$(IntermediateOutputPath)crossgen\</CrossgenToolDir> | ||
- <CoreCLRJitPath>$(CrossgenToolDir)$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath> | ||
+ <!-- Pick the right coreclr jit based on whether we are cross-compiling or not --> | ||
+ <CoreCLRJitPath Condition="'$(CrossCompileDirectory)' == ''">$(RuntimePackageRoot)runtimes\$(RuntimeIdentifier)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath> | ||
+ <CoreCLRJitPath Condition="'$(CrossCompileDirectory)' != ''">$(RuntimepackageRoot)runtimes\$(CrossCompileDirectory)\native\$(LibPrefix)clrjit$(LibExtension)</CoreCLRJitPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> |
116 changes: 116 additions & 0 deletions
116
patches/core-sdk/0001-Enable-building-on-arm64-machines.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
From 4b5c617203cfb9d2c1b12995e12d819fba6d7b6f Mon Sep 17 00:00:00 2001 | ||
From: Omair Majid <omajid@redhat.com> | ||
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 b65a72410..be3834859 100644 | ||
--- a/Directory.Build.props | ||
+++ b/Directory.Build.props | ||
@@ -7,6 +7,12 @@ | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
</PropertyGroup> | ||
|
||
+ <PropertyGroup> | ||
+ <BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture> | ||
+ <Architecture Condition="'$(BuildArchitecture)' == 'arm64'">$(BuildArchitecture)</Architecture> | ||
+ <Architecture Condition="'$(Architecture)' == ''">x64</Architecture> | ||
+ </PropertyGroup> | ||
+ | ||
<PropertyGroup> | ||
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
<DebugType>embedded</DebugType> | ||
diff --git a/eng/Versions.props b/eng/Versions.props | ||
index 344a325bf..37e478e72 100644 | ||
--- a/eng/Versions.props | ||
+++ b/eng/Versions.props | ||
@@ -87,7 +87,7 @@ | ||
<VersionToolsVersion>$(BuildTasksFeedToolVersion)</VersionToolsVersion> | ||
<DotnetDebToolVersion>2.0.0</DotnetDebToolVersion> | ||
<MicrosoftNETTestSdkVersion>15.8.0</MicrosoftNETTestSdkVersion> | ||
- <MicrosoftSourceLinkVersion>1.0.0-beta2-18618-05</MicrosoftSourceLinkVersion> | ||
+ <MicrosoftSourceLinkVersion>1.0.0-beta2-19367-01</MicrosoftSourceLinkVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<!-- pinned dependency. This package is not being produced outside of the 2.0 branch of corefx and should not change. --> | ||
diff --git a/src/redist/targets/Crossgen.targets b/src/redist/targets/Crossgen.targets | ||
index 8d3091307..931dff2d9 100644 | ||
--- a/src/redist/targets/Crossgen.targets | ||
+++ b/src/redist/targets/Crossgen.targets | ||
@@ -5,14 +5,14 @@ | ||
|
||
<PropertyGroup> | ||
<RuntimeNETCoreAppPackageName>runtime.$(SharedFrameworkRid).microsoft.netcore.app</RuntimeNETCoreAppPackageName> | ||
- <_crossDir Condition="'$(Architecture)' == 'arm64'">/x64_arm64</_crossDir> | ||
+ <_crossDir Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' != 'arm64'">/x64_arm64</_crossDir> | ||
<_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">/x86_arm</_crossDir> | ||
<_crossDir Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'linux'">/x64_arm</_crossDir> | ||
<CrossgenPath>$(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppPackageVersion)/tools$(_crossDir)/crossgen$(ExeExtension)</CrossgenPath> | ||
- <LibCLRJitRid Condition="!$(Architecture.StartsWith('arm'))">$(SharedFrameworkRid)</LibCLRJitRid> | ||
- <LibCLRJitRid Condition="'$(Architecture)' == 'arm64'">x64_arm64</LibCLRJitRid> | ||
+ <LibCLRJitRid Condition="'$(Architecture)' == 'arm64' and '$(BuildArchitecture)' == 'x64'">x64_arm64</LibCLRJitRid> | ||
<LibCLRJitRid Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'win'">x86_arm</LibCLRJitRid> | ||
<LibCLRJitRid Condition="'$(Architecture)' == 'arm' And '$(OSName)' == 'linux'">x64_arm</LibCLRJitRid> | ||
+ <LibCLRJitRid Condition="'$(LibCLRJitRid)' == ''">$(SharedFrameworkRid)</LibCLRJitRid> | ||
<LibCLRJitPath>$(NuGetPackageRoot)/$(RuntimeNETCoreAppPackageName)/$(MicrosoftNETCoreAppPackageVersion)/runtimes/$(LibCLRJitRid)/native/$(DynamicLibPrefix)clrjit$(DynamicLibExtension)</LibCLRJitPath> | ||
<SharedFrameworkNameVersionPath>$(RedistLayoutPath)shared/$(SharedFrameworkName)/$(MicrosoftNETCoreAppRuntimewinx64PackageVersion)</SharedFrameworkNameVersionPath> | ||
<DIASymReaderCrossgenFilter>*</DIASymReaderCrossgenFilter> | ||
diff --git a/src/redist/targets/GenerateLayout.targets b/src/redist/targets/GenerateLayout.targets | ||
index d2a0b6fd1..a0bcf6f35 100644 | ||
--- a/src/redist/targets/GenerateLayout.targets | ||
+++ b/src/redist/targets/GenerateLayout.targets | ||
@@ -25,11 +25,11 @@ | ||
|
||
<!-- Use the "x64" Rid when downloading Linux shared framework 'DEB' installer files. --> | ||
<SharedFrameworkInstallerFileRid>$(CoreSetupRid)</SharedFrameworkInstallerFileRid> | ||
- <SharedFrameworkInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' OR '$(IsRPMBasedDistro)' == 'true' ">x64</SharedFrameworkInstallerFileRid> | ||
+ <SharedFrameworkInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' OR '$(IsRPMBasedDistro)' == 'true' ">$(Architecture)</SharedFrameworkInstallerFileRid> | ||
|
||
<!-- Use the "x64" Rid when downloading Linux runtime dependencies Debian package. --> | ||
<RuntimeDepsInstallerFileRid>$(CoreSetupRid)</RuntimeDepsInstallerFileRid> | ||
- <RuntimeDepsInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' ">x64</RuntimeDepsInstallerFileRid> | ||
+ <RuntimeDepsInstallerFileRid Condition=" '$(IsDebianBaseDistro)' == 'true' ">$(Architecture)</RuntimeDepsInstallerFileRid> | ||
|
||
<DownloadedSharedHostInstallerFileName Condition=" '$(InstallerExtension)' != '' ">dotnet-host$(InstallerStartSuffix)-$(SharedHostVersion)-$(SharedFrameworkInstallerFileRid)$(InstallerExtension)</DownloadedSharedHostInstallerFileName> | ||
<DownloadedHostFxrInstallerFileName Condition=" '$(InstallerExtension)' != '' ">dotnet-hostfxr$(InstallerStartSuffix)-$(HostFxrVersion)-$(SharedFrameworkInstallerFileRid)$(InstallerExtension)</DownloadedHostFxrInstallerFileName> | ||
diff --git a/src/redist/targets/GetRuntimeInformation.targets b/src/redist/targets/GetRuntimeInformation.targets | ||
index 3b14d1203..f49c7262f 100644 | ||
--- a/src/redist/targets/GetRuntimeInformation.targets | ||
+++ b/src/redist/targets/GetRuntimeInformation.targets | ||
@@ -13,7 +13,6 @@ | ||
<OSName Condition=" '$(OSName)' == '' AND '$(IsLinux)' == 'True' ">linux</OSName> | ||
<OSPlatform Condition=" '$(OSPlatform)' == '' AND '$(IsLinux)' == 'True' ">linux</OSPlatform> | ||
|
||
- <Architecture Condition=" '$(Architecture)' == '' ">x64</Architecture> | ||
<Rid Condition=" '$(Rid)' == '' ">$(OSName)-$(Architecture)</Rid> | ||
</PropertyGroup> | ||
|
||
-- | ||
2.18.1 | ||
|
Oops, something went wrong.