Skip to content

Commit

Permalink
Enable building on arm64 machines
Browse files Browse the repository at this point in the history
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:
dotnet/core-setup#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.
  • Loading branch information
omajid committed Oct 17, 2019
1 parent f6af966 commit 4330dfd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Directory.Build.props
Expand Up @@ -7,6 +7,12 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<PropertyGroup>
<BuildArchitecture>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture.ToString().ToLowerInvariant())</BuildArchitecture>
<Architecture Condition="'$(Architecture)' == '' AND '$(BuildArchitecture)' == 'arm64'">$(BuildArchitecture)</Architecture>
<Architecture Condition="'$(Architecture)' == ''">x64</Architecture>
</PropertyGroup>

<PropertyGroup>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<DebugType>embedded</DebugType>
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Expand Up @@ -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. -->
Expand Down
6 changes: 3 additions & 3 deletions src/redist/targets/Crossgen.targets
Expand Up @@ -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)/$(MicrosoftNETCoreAppPackageVersion)</SharedFrameworkNameVersionPath>
<DIASymReaderCrossgenFilter>*</DIASymReaderCrossgenFilter>
Expand Down
4 changes: 2 additions & 2 deletions src/redist/targets/GenerateLayout.targets
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion src/redist/targets/GetRuntimeInformation.targets
Expand Up @@ -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>

Expand Down

0 comments on commit 4330dfd

Please sign in to comment.