diff --git a/build-source-tarball.sh b/build-source-tarball.sh
index f47598ce98..fc48d7c4aa 100755
--- a/build-source-tarball.sh
+++ b/build-source-tarball.sh
@@ -12,6 +12,32 @@ if [ -z "${1:-}" ]; then
exit 1
fi
+# Use uname to determine what the CPU is.
+cpuname=$(uname -p)
+# Some Linux platforms report unknown for platform, but the arch for machine.
+if [[ "$cpuname" == "unknown" ]]; then
+ cpuname=$(uname -m)
+fi
+
+case $cpuname in
+ aarch64)
+ targetArchitecture=arm64
+ ;;
+ amd64|x86_64)
+ targetArchitecture=x64
+ ;;
+ armv7l)
+ targetArchitecture=arm
+ ;;
+ i686)
+ targetArchitecture=x86
+ ;;
+ *)
+ echo "Unknown CPU $cpuname detected, treating it as x64"
+ targetArchitecture=x64
+ ;;
+esac
+
TARBALL_ROOT=$1
shift
@@ -217,20 +243,20 @@ cp $SCRIPT_ROOT/support/tarball/build.sh $TARBALL_ROOT/build.sh
mkdir -p $TARBALL_ROOT/packages/prebuilt
mkdir -p $TARBALL_ROOT/packages/source-built
find $SCRIPT_ROOT/packages/restored/ -name '*.nupkg' -exec cp {} $TARBALL_ROOT/packages/prebuilt/ \;
-find $SCRIPT_ROOT/bin/obj/x64/Release/nuget-packages -name '*.nupkg' -exec cp {} $TARBALL_ROOT/packages/prebuilt/ \;
+find $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/nuget-packages -name '*.nupkg' -exec cp {} $TARBALL_ROOT/packages/prebuilt/ \;
# Copy reference-packages from bin dir to reference-packages directory.
# See corresponding change in dir.props to change ReferencePackagesBasePath conditionally in offline build.
mkdir -p $TARBALL_ROOT/packages/reference
-cp -r $SCRIPT_ROOT/bin/obj/x64/Release/reference-packages/source $TARBALL_ROOT/packages/reference/source
-cp -r $SCRIPT_ROOT/bin/obj/x64/Release/reference-packages/staging $TARBALL_ROOT/packages/reference/staging
+cp -r $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/reference-packages/source $TARBALL_ROOT/packages/reference/source
+cp -r $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/reference-packages/staging $TARBALL_ROOT/packages/reference/staging
# Copy tarballs to ./packages/archive directory
mkdir -p $TARBALL_ROOT/packages/archive
-cp -r $SCRIPT_ROOT/bin/obj/x64/Release/external-tarballs/*.tar.gz $TARBALL_ROOT/packages/archive/
+cp -r $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/external-tarballs/*.tar.gz $TARBALL_ROOT/packages/archive/
# Copy generated source from bin to src/generatedSrc
-cp -r $SCRIPT_ROOT/bin/obj/x64/Release/generatedSrc $TARBALL_ROOT/src/generatedSrc
+cp -r $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/generatedSrc $TARBALL_ROOT/src/generatedSrc
if [ -e $SCRIPT_ROOT/testing-smoke/smoke-test-packages ]; then
cp -rf $SCRIPT_ROOT/testing-smoke/smoke-test-packages $TARBALL_ROOT/packages
@@ -238,7 +264,7 @@ fi
echo 'Removing source-built packages from tarball prebuilts...'
-for built_package in $(find $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/ -name '*.nupkg' | tr '[:upper:]' '[:lower:]')
+for built_package in $(find $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/ -name '*.nupkg' | tr '[:upper:]' '[:lower:]')
do
if [ -e $TARBALL_ROOT/packages/prebuilt/$(basename $built_package) ]; then
rm $TARBALL_ROOT/packages/prebuilt/$(basename $built_package)
@@ -251,16 +277,16 @@ done
echo 'Copying source-built packages to tarball to replace packages needed before they are built...'
mkdir -p $TARBALL_ROOT/packages/source-built
cp -r $SCRIPT_ROOT/Tools/source-built/coreclr-tools $TARBALL_ROOT/packages/source-built/
-cp $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/*Arcade*.nupkg $TARBALL_ROOT/packages/source-built/
-cp $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/*SourceLink*.nupkg $TARBALL_ROOT/packages/source-built/
-cp $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/*Build*Tasks*.nupkg $TARBALL_ROOT/packages/source-built/
-cp $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/runtime*.nupkg $TARBALL_ROOT/packages/source-built/
-cp $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/*DotNetHost*.nupkg $TARBALL_ROOT/packages/source-built/
-cp $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/*DotNetAppHost*.nupkg $TARBALL_ROOT/packages/source-built/
+cp $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/*Arcade*.nupkg $TARBALL_ROOT/packages/source-built/
+cp $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/*SourceLink*.nupkg $TARBALL_ROOT/packages/source-built/
+cp $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/*Build*Tasks*.nupkg $TARBALL_ROOT/packages/source-built/
+cp $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/runtime*.nupkg $TARBALL_ROOT/packages/source-built/
+cp $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/*DotNetHost*.nupkg $TARBALL_ROOT/packages/source-built/
+cp $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/*DotNetAppHost*.nupkg $TARBALL_ROOT/packages/source-built/
# Setup package version props to include both source-built and running PackageVersions.props
-mkdir --parents $TARBALL_ROOT/bin/obj/x64/Release/
-cp $SCRIPT_ROOT/support/tarball/PackageVersions.props $TARBALL_ROOT/bin/obj/x64/Release/
+mkdir --parents $TARBALL_ROOT/bin/obj/$targetArchitecture/Release/
+cp $SCRIPT_ROOT/support/tarball/PackageVersions.props $TARBALL_ROOT/bin/obj/$targetArchitecture/Release/
if [ $INCLUDE_LEAK_DETECTION -eq 1 ]; then
echo 'Building leak detection MSBuild tasks...'
@@ -270,7 +296,7 @@ fi
echo 'Removing reference-only packages from tarball prebuilts...'
-for ref_package in $(find $SCRIPT_ROOT/bin/obj/x64/Release/reference-packages/packages-to-delete/ -name '*.nupkg' | tr '[:upper:]' '[:lower:]')
+for ref_package in $(find $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/reference-packages/packages-to-delete/ -name '*.nupkg' | tr '[:upper:]' '[:lower:]')
do
if [ -e $TARBALL_ROOT/packages/prebuilt/$(basename $ref_package) ]; then
rm $TARBALL_ROOT/packages/prebuilt/$(basename $ref_package)
@@ -328,7 +354,7 @@ fi
echo 'Removing source-built, previously source-built packages and reference packages from il pkg src...'
OLDIFS=$IFS
-allBuiltPkgs=(`ls $SCRIPT_ROOT/bin/obj/x64/Release/blob-feed/packages/*.nupkg | xargs -n1 basename | tr '[:upper:]' '[:lower:]'`)
+allBuiltPkgs=(`ls $SCRIPT_ROOT/bin/obj/$targetArchitecture/Release/blob-feed/packages/*.nupkg | xargs -n1 basename | tr '[:upper:]' '[:lower:]'`)
pushd $TARBALL_ROOT/packages/reference/staging/
ilSrcPaths=(`find . -maxdepth 2 -mindepth 2`)
popd
diff --git a/dir.props b/dir.props
index 965a724761..d989983b44 100644
--- a/dir.props
+++ b/dir.props
@@ -2,6 +2,9 @@
Release
+
+ $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())
+ $(BuildArchitecture)
x64
@@ -201,7 +204,7 @@
-
+
diff --git a/patches/aspnetcore/0001-Don-t-call-dotnet-without-path.patch b/patches/aspnetcore/0001-Don-t-call-dotnet-without-path.patch
index f2371c6b17..a4f82cbadf 100644
--- a/patches/aspnetcore/0001-Don-t-call-dotnet-without-path.patch
+++ b/patches/aspnetcore/0001-Don-t-call-dotnet-without-path.patch
@@ -1,14 +1,14 @@
-From b7a4992bfa45d3b1c00e095b0b1e7d860b347b50 Mon Sep 17 00:00:00 2001
+From c9ceade354813f98ca291757e7d1657d0959ee4e Mon Sep 17 00:00:00 2001
From: Chris Rummel
Date: Wed, 23 Oct 2019 20:04:55 -0500
-Subject: [PATCH 01/10] Don't call dotnet without path
+Subject: [PATCH 01/13] Don't call dotnet without path
---
eng/common/tools.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/eng/common/tools.sh b/eng/common/tools.sh
-index 757d5b9..5a4cfeb 100755
+index 757d5b9ea4..5a4cfeb1f0 100755
--- a/eng/common/tools.sh
+++ b/eng/common/tools.sh
@@ -340,9 +340,9 @@ function MSBuild {
@@ -25,5 +25,5 @@ index 757d5b9..5a4cfeb 100755
local toolset_dir="${_InitializeToolset%/*}"
local logger_path="$toolset_dir/$_InitializeBuildToolFramework/Microsoft.DotNet.Arcade.Sdk.dll"
--
-1.8.3.1
+2.18.0
diff --git a/patches/aspnetcore/0002-Use-non-portable-NETCoreAppRuntime-for-crossgen.patch b/patches/aspnetcore/0002-Use-non-portable-NETCoreAppRuntime-for-crossgen.patch
index 9242a7bdcf..d4e14358a4 100644
--- a/patches/aspnetcore/0002-Use-non-portable-NETCoreAppRuntime-for-crossgen.patch
+++ b/patches/aspnetcore/0002-Use-non-portable-NETCoreAppRuntime-for-crossgen.patch
@@ -1,7 +1,7 @@
-From bec8be99172078645255a96cc012a1d2a95da8df Mon Sep 17 00:00:00 2001
+From 528f9457371651668d1923b27cdd5b761f8f2441 Mon Sep 17 00:00:00 2001
From: dseefeld
Date: Tue, 29 Oct 2019 18:19:03 +0000
-Subject: [PATCH 02/10] Use non-portable NETCoreAppRuntime for crossgen
+Subject: [PATCH 02/13] Use non-portable NETCoreAppRuntime for crossgen
---
eng/Dependencies.props | 1 +
@@ -9,7 +9,7 @@ Subject: [PATCH 02/10] Use non-portable NETCoreAppRuntime for crossgen
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/eng/Dependencies.props b/eng/Dependencies.props
-index 2e11857..b49aee2 100644
+index 2e11857b1b..b49aee2a5c 100644
--- a/eng/Dependencies.props
+++ b/eng/Dependencies.props
@@ -110,6 +110,7 @@ and are generated based on the last package release.
@@ -21,7 +21,7 @@ index 2e11857..b49aee2 100644
diff --git a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj
-index 4c4298a..edad46b 100644
+index 4c4298a92d..edad46be14 100644
--- a/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj
+++ b/src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj
@@ -100,7 +100,9 @@ This package is an internal implementation of the .NET Core SDK and is not meant
@@ -45,5 +45,5 @@ index 4c4298a..edad46b 100644
Platform=$(TargetArchitecture)
--
-1.8.3.1
+2.18.0
diff --git a/patches/aspnetcore/0003-Conditionally-set-PackAsToolShimRID.patch b/patches/aspnetcore/0003-Conditionally-set-PackAsToolShimRID.patch
index 13dac39c0c..47328b47c2 100644
--- a/patches/aspnetcore/0003-Conditionally-set-PackAsToolShimRID.patch
+++ b/patches/aspnetcore/0003-Conditionally-set-PackAsToolShimRID.patch
@@ -1,14 +1,14 @@
-From f7b62cf3e579babe120deb06be418541c717388c Mon Sep 17 00:00:00 2001
+From 87371172f24562810552567b15890eefc9d57249 Mon Sep 17 00:00:00 2001
From: dseefeld
Date: Thu, 31 Oct 2019 20:38:26 +0000
-Subject: [PATCH 03/10] Conditionally set PackAsToolShimRID
+Subject: [PATCH 03/13] Conditionally set PackAsToolShimRID
---
Directory.Build.targets | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.targets b/Directory.Build.targets
-index db3cea5..518b5e6 100644
+index db3cea59f1..518b5e6246 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -46,7 +46,7 @@
@@ -21,5 +21,5 @@ index db3cea5..518b5e6 100644
win-x64;win-x86
--
-1.8.3.1
+2.18.0
diff --git a/patches/aspnetcore/0004-Exclude-analyzer-for-source-build.patch b/patches/aspnetcore/0004-Exclude-analyzer-for-source-build.patch
index d9f86f8438..cb2f3c413e 100644
--- a/patches/aspnetcore/0004-Exclude-analyzer-for-source-build.patch
+++ b/patches/aspnetcore/0004-Exclude-analyzer-for-source-build.patch
@@ -1,14 +1,14 @@
-From ff7c8a971e21f847db4a9f762c6232a859aebbd1 Mon Sep 17 00:00:00 2001
+From bbd6cbebda9e08a49725b66d9130f76469479413 Mon Sep 17 00:00:00 2001
From: adaggarwal
Date: Thu, 14 Nov 2019 16:52:25 +0000
-Subject: [PATCH 04/10] Exclude analyzer for source-build
+Subject: [PATCH 04/13] Exclude analyzer for source-build
---
Directory.Build.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Directory.Build.props b/Directory.Build.props
-index 2fe19bd..0bc8b25 100644
+index 2fe19bde83..0bc8b25ecc 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -95,7 +95,7 @@
@@ -21,5 +21,5 @@ index 2fe19bd..0bc8b25 100644
--
-1.8.3.1
+2.18.0
diff --git a/patches/aspnetcore/0005-Import-PackageVersions.props.patch b/patches/aspnetcore/0005-Import-PackageVersions.props.patch
index 54a24af33d..bf2980c56e 100644
--- a/patches/aspnetcore/0005-Import-PackageVersions.props.patch
+++ b/patches/aspnetcore/0005-Import-PackageVersions.props.patch
@@ -1,17 +1,17 @@
-From 938dad01514f3a4d7bf8f5c8b976cee3d43cdae0 Mon Sep 17 00:00:00 2001
+From 2812263dd785904cf8edd68f258d78d82c3cea59 Mon Sep 17 00:00:00 2001
From: adaggarwal
Date: Thu, 14 Nov 2019 16:55:29 +0000
-Subject: [PATCH 05/10] Import PackageVersions.props
+Subject: [PATCH 05/13] Import PackageVersions.props
---
eng/Versions.props | 3 +++
1 file changed, 3 insertions(+)
diff --git a/eng/Versions.props b/eng/Versions.props
-index fd988d1..71384d1 100644
+index a3e611aa4b..37797a5219 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
-@@ -264,6 +264,9 @@
+@@ -267,6 +267,9 @@
$(XunitVersion)
1.0.19249.1
@@ -22,5 +22,5 @@ index fd988d1..71384d1 100644
--
-1.8.3.1
+2.18.0
diff --git a/patches/aspnetcore/0006-Exclude-some-projects-from-source-build.patch b/patches/aspnetcore/0006-Exclude-some-projects-from-source-build.patch
index ecdf9b10ad..218ced32d4 100644
--- a/patches/aspnetcore/0006-Exclude-some-projects-from-source-build.patch
+++ b/patches/aspnetcore/0006-Exclude-some-projects-from-source-build.patch
@@ -1,14 +1,14 @@
-From 8de8ac124fdc61fef00c21aa9f4e03e1eeaa46f1 Mon Sep 17 00:00:00 2001
+From 494311a11525c9ca8ce44cff9d6de39802d1dbc6 Mon Sep 17 00:00:00 2001
From: adaggarwal
Date: Thu, 14 Nov 2019 16:57:39 +0000
-Subject: [PATCH 06/10] Exclude some projects from source-build
+Subject: [PATCH 06/13] Exclude some projects from source-build
---
Directory.Build.props | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Directory.Build.props b/Directory.Build.props
-index 0bc8b25..88411a3 100644
+index 0bc8b25ecc..88411a30b2 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -18,9 +18,11 @@
@@ -24,5 +24,5 @@ index 0bc8b25..88411a3 100644
+ crossgen
+ $(CrossgenToolFileName).exe
+
+ $(CrossgenToolFileName)
+
+- x64_arm\$(CrossgenToolPackagePath)
+- x64_arm64\$(CrossgenToolPackagePath)
+- x86_arm\$(CrossgenToolPackagePath)
++ $(CrossCompileDirectory)\$(CrossgenToolPackagePath)
+
+ $(RuntimeIdentifier)
+ $(SourceBuildRuntimeIdentifier)
+@@ -295,7 +297,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)
+
+
+
+--
+2.18.0
+
diff --git a/patches/core-sdk/0003-Enable-building-on-arm64-machines.patch b/patches/core-sdk/0003-Enable-building-on-arm64-machines.patch
new file mode 100644
index 0000000000..51937e726e
--- /dev/null
+++ b/patches/core-sdk/0003-Enable-building-on-arm64-machines.patch
@@ -0,0 +1,103 @@
+From 4b5c617203cfb9d2c1b12995e12d819fba6d7b6f 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 b65a72410..be3834859 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/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 @@
+
+
+ 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 d2a0b6fd1..a0bcf6f35 100644
+--- a/src/redist/targets/GenerateLayout.targets
++++ b/src/redist/targets/GenerateLayout.targets
+@@ -25,11 +25,11 @@
+
+
+ $(CoreSetupRid)
+- x64
++ $(Architecture)
+
+
+ $(CoreSetupRid)
+- x64
++ $(Architecture)
+
+ x64
+ x86
+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 @@
+ linux
+ linux
+
+- x64
+ $(OSName)-$(Architecture)
+
+
+--
+2.18.1
+
diff --git a/patches/core-setup/0004-Enable-building-for-arm64-on-arm64.patch b/patches/core-setup/0004-Enable-building-for-arm64-on-arm64.patch
new file mode 100644
index 0000000000..f8a38287ff
--- /dev/null
+++ b/patches/core-setup/0004-Enable-building-for-arm64-on-arm64.patch
@@ -0,0 +1,81 @@
+From c02027bfee1c523006430183d37c1b61072d5ed8 Mon Sep 17 00:00:00 2001
+From: Omair Majid
+Date: Fri, 4 Oct 2019 16:08:59 -0400
+Subject: [PATCH] Enable building for arm64 on arm64
+
+To enable building core-setup on arm64 machines (not cross compiled), we need
+to do a few things:
+
+- Set the right TargetArchitecture
+
+ When `TargetArchitecture` is not explicitly specified and when the currently
+ running architecture is Arm64, use arm64 as the `TargetArchitecture`. Don't
+ always use the currently running architecture as that doesn't play well with
+ an x86 Visual Studio trying to create x64 builds.
+
+- Use the right coreclr JIT
+
+ If we are cross-compiling, we need to use the x86_arm64 libclrjit.so. But if
+ we are building on an arm64 machine, we need to filter the list of found
+ libclrjit.so files to pick the normal-RID (eg, linux-arm64) libclrjit.so from
+ the two:
+
+ ./.packages/transport.runtime.linux-arm64.microsoft.netcore.jit//runtimes/linux-arm64/native/libclrjit.so
+ ./.packages/transport.runtime.linux-arm64.microsoft.netcore.jit//runtimes/x64_arm64/native/libclrjit.so
+---
+ Directory.Build.props | 4 +++-
+ src/pkg/packaging-tools/framework.dependency.targets | 7 +++----
+ 2 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/Directory.Build.props b/Directory.Build.props
+index a53af2f09f..a7e9169c91 100644
+--- a/Directory.Build.props
++++ b/Directory.Build.props
+@@ -94,6 +94,8 @@
+
+
+
++ $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())
++ $(BuildArchitecture)
+ x64
+ $(TargetArchitecture)
+
+@@ -398,4 +400,4 @@
+ true
+
+
+-
+\ No newline at end of file
++
+diff --git a/src/pkg/packaging-tools/framework.dependency.targets b/src/pkg/packaging-tools/framework.dependency.targets
+index 3e7afc5483..14ac018b02 100644
+--- a/src/pkg/packaging-tools/framework.dependency.targets
++++ b/src/pkg/packaging-tools/framework.dependency.targets
+@@ -254,7 +254,7 @@
+
+ <_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' == 'Windows_NT'">/x86_arm
+ <_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' != 'Windows_NT'">/x64_arm
+- <_crossDir Condition="'$(TargetArchitecture)' == 'arm64'">/x64_arm64
++ <_crossDir Condition="'$(TargetArchitecture)' == 'arm64' AND '$(BuildArchitecture)' != 'arm64'">/x64_arm64
+
+
+
+@@ -272,7 +272,6 @@
+
+ <_runtimeCLR Include="$(_runtimePackageDir)**/$(LibraryFilePrefix)coreclr$(LibraryFileExtension)" />
+ <_runtimeCoreLib Include="$(_runtimePackageDir)**/native/System.Private.CoreLib.dll" />
+- <_runtimeJIT Include="$(_jitPackageDir)**/$(LibraryFilePrefix)clrjit$(LibraryFileExtension)" />
+ <_fxSystemRuntime Include="$(_corefxPackageDir)**/System.Runtime.dll" />
+ <_windowsWinMD Include="$(_winmdPackageDir)**/Windows.winmd" />
+ <_diaSymReaderAssembly Include="$(_diaSymReaderPackageDir)**\Microsoft.DiaSymReader.Native.*.dll" />
+@@ -287,8 +286,8 @@
+ <_coreLibDirectory>%(_runtimeCoreLib.RootDir)%(_runtimeCoreLib.Directory)
+
+
+-
+- <_jitPath>%(_runtimeJIT.FullPath)
++
++ <_jitPath Condition="'$(_crossDir)' == ''">$(_jitPackageDir)runtimes/$(PackageRID)/native/$(LibraryFilePrefix)clrjit$(LibraryFileExtension)
+ <_jitPath Condition="'$(_crossDir)' != ''">$(_jitPackageDir)runtimes$(_crossDir)/native/$(LibraryFilePrefix)clrjit$(LibraryFileExtension)
+
+
diff --git a/patches/corefx/0004-Enable-build-on-hosted-arm64.patch b/patches/corefx/0004-Enable-build-on-hosted-arm64.patch
new file mode 100644
index 0000000000..fa16d54a19
--- /dev/null
+++ b/patches/corefx/0004-Enable-build-on-hosted-arm64.patch
@@ -0,0 +1,46 @@
+From d36274c31cc30a946c023b7a5bb5c6fa1ff86625 Mon Sep 17 00:00:00 2001
+From: Omair Majid
+Date: Tue, 20 Aug 2019 13:40:19 -0400
+Subject: [PATCH] Enable build on hosted arm64
+
+This is attempt #2. The first attempt was commit
+176da26d634fd760d7c8c99956f2e8d3f7d485e7.
+
+Initialize HostArch to the arch-style used in RIDs directly by
+converting things to lowercase.
+
+Use the HostArch for the tool runtime instead of assuming x64.
+---
+ Directory.Build.props | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/Directory.Build.props b/Directory.Build.props
+index fe1f406a02d7..dae20af84cc1 100644
+--- a/Directory.Build.props
++++ b/Directory.Build.props
+@@ -64,9 +64,9 @@
+ netcoreapp
+ $(DefaultOSGroup)
+ Debug
+- $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture)
+- arm
+- arm64
++ $([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant)
++ arm
++ arm64
+ x64
+
+
+@@ -135,9 +135,10 @@
+ <_runtimeOS Condition="'$(_runtimeOS)' == 'tizen.4.0.0'">linux
+ <_runtimeOS Condition="'$(_runtimeOS)' == 'tizen.5.0.0'">linux
+ <_runtimeOS Condition="'$(PortableBuild)' == 'true'">$(_portableOS)
+- $(_runtimeOS)-x64
++ $(_runtimeOS)-x64
++ $(_runtimeOS)-$(HostArch)
+
+- linux-x64
++ linux-x64
+
+
+ win-x64
diff --git a/repos/aspnetcore.proj b/repos/aspnetcore.proj
index 97dd5ab45e..f923ea8c97 100644
--- a/repos/aspnetcore.proj
+++ b/repos/aspnetcore.proj
@@ -14,6 +14,8 @@
$(BuildCommandArgs) --configuration $(Configuration)
$(BuildCommandArgs) --ci
$(BuildCommandArgs) -bl
+
+ $(BuildCommandArgs) --arch $(Platform)
$(BuildCommandArgs) /p:BuildNodeJs=false
$(BuildCommandArgs) /p:SourceBuildRuntimeIdentifier=$(OverrideTargetRid)
$(BuildCommandArgs) /p:UseAppHost=false
diff --git a/repos/core-sdk.proj b/repos/core-sdk.proj
index eb716bf220..c2046f0196 100644
--- a/repos/core-sdk.proj
+++ b/repos/core-sdk.proj
@@ -6,7 +6,7 @@
$(TargetRid.Substring(0, $(TargetRid.IndexOf("-"))))
$(BuildCommandArgs) /p:Rid=$(TargetRid)
- $(BuildCommandArgs) /p:AspNetCoreSharedFxInstallerRid=linux-x64
+ $(BuildCommandArgs) /p:AspNetCoreSharedFxInstallerRid=linux-$(Platform)
$(BuildCommandArgs) /p:OSName=$(OSNameOverride)
$(BuildCommandArgs) /p:CoreSetupRid=freebsd-x64 /p:PortableBuild=true
diff --git a/repos/core-setup.proj b/repos/core-setup.proj
index 79526d143b..68e94cc3b0 100644
--- a/repos/core-setup.proj
+++ b/repos/core-setup.proj
@@ -14,7 +14,7 @@
$(BuildArguments) $(FlagParameterPrefix)configuration $(Configuration)
$(BuildArguments) $(FlagParameterPrefix)ci
$(BuildArguments) /p:PortableBuild=$(OverridePortable)
- $(BuildArguments) /p:TargetArchitecture=$(Platform) /p:DisableCrossgen=true /p:CrossBuild=true
+ $(BuildArguments) /p:TargetArchitecture=$(Platform) /p:DisableCrossgen=true /p:CrossBuild=true
$(BuildArguments) /p:BuildDebPackage=false
$(BuildArguments) /p:BuildAllPackages=true
$(BuildArguments) /p:RestoreAllBuildRids=false
@@ -29,7 +29,7 @@
$(BuildArguments) $(FlagParameterPrefix)nodereuse $(ArcadeFalseBoolBuildArg)
$(ProjectDirectory)/build$(ShellExtension) $(BuildArguments)
- $(ArmEnvironmentVariables) $(BuildCommand)
+ $(ArmEnvironmentVariables) $(BuildCommand)
false
$(ProjectDirectory)artifacts/packages/$(Configuration)/Shipping/
diff --git a/repos/coreclr.proj b/repos/coreclr.proj
index 6fb737af92..01a2df0a17 100644
--- a/repos/coreclr.proj
+++ b/repos/coreclr.proj
@@ -10,7 +10,7 @@
$(BuildArguments) -nopgooptimize
$(BuildArguments) msbuildonunsupportedplatform
$(BuildArguments) cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=TRUE
- $(BuildArguments) skipnuget cross -skiprestore cmakeargs -DFEATURE_GDBJIT=TRUE
+ $(BuildArguments) skipnuget cross -skiprestore cmakeargs -DFEATURE_GDBJIT=TRUE
$(BuildArguments) -clang6.0 /p:PortableBuild=true