Skip to content

Commit

Permalink
Enable hosted builds on arm64
Browse files Browse the repository at this point in the history
To enable building core-setup on arm64 (hosted, not cross compiled), we
need to do a few things:

- Set the right TargetArchitecture

  Use the currently running architecture to decide whether to default to
  x64 or to switch to arm64 when TargetArchitecture is not specified

- 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 host, 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

- Use a version of SourceLink that supports arm64

  We need to upgrade SourceLink to a version that contains
  dotnet/sourcelink#288. This commit just
  updates it to the latest version.

Fixes #7653
  • Loading branch information
omajid committed Aug 13, 2019
1 parent 6f3ead3 commit 9b7c172
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
</PropertyGroup>

<PropertyGroup>
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
<HostArch>$([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture)</HostArch>
<TargetArchitecture Condition="'$(TargetArchitecture)' == '' AND '$(HostArch)' == 'Arm64'">arm64</TargetArchitecture>
<TargetArchitecture Condition="'$(TargetArchitecture)' == ''">x64</TargetArchitecture>
<Platform Condition="'$(Platform)'==''">$(TargetArchitecture)</Platform>
</PropertyGroup>
<!--
Expand Down Expand Up @@ -398,4 +400,4 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<MicrosoftTargetingPackPrivateWinRTPackageVersion>1.0.5</MicrosoftTargetingPackPrivateWinRTPackageVersion>
<MicrosoftDiaSymReaderNativePackageVersion>1.7.0</MicrosoftDiaSymReaderNativePackageVersion>
<!-- Infrastructure and test-only. -->
<MicrosoftSourceLinkVersion>1.0.0-beta2-18618-05</MicrosoftSourceLinkVersion>
<MicrosoftSourceLinkVersion>1.0.0-beta2-19367-01</MicrosoftSourceLinkVersion>
</PropertyGroup>
<!--Package names-->
<PropertyGroup>
Expand Down
21 changes: 19 additions & 2 deletions src/pkg/packaging-tools/framework.dependency.targets
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@
<PropertyGroup>
<_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' == 'Windows_NT'">/x86_arm</_crossDir>
<_crossDir Condition="'$(TargetArchitecture)' == 'arm' AND '$(OS)' != 'Windows_NT'">/x64_arm</_crossDir>
<_crossDir Condition="'$(TargetArchitecture)' == 'arm64'">/x64_arm64</_crossDir>
<!-- Only use x64_arm64 when cross compiling. Use normal executible when compiling on arm64 itself. -->
<_crossDir Condition="'$(TargetArchitecture)' == 'arm64' AND '$(HostArch)' != 'Arm64'">/x64_arm64</_crossDir>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -251,10 +252,26 @@
</PropertyGroup>

<PropertyGroup Condition="'@(_runtimeJIT)' != ''">
<_jitPath>%(_runtimeJIT.FullPath)</_jitPath>
<_runtimeJITFilterDir>$([System.IO.Path]::DirectorySeparatorChar)$(PackageRID)$([System.IO.Path]::DirectorySeparatorChar)</_runtimeJITFilterDir>
</PropertyGroup>

<!-- It is possible for _runtimeJIT to pick up 2 jit files:
one for cross compilation and one for native compilation. -->
<ItemGroup Condition="'@(_runtimeJIT)' != '' AND '$(_crossDir)' == ''">
<_filteredRuntimeJIT Include="%(_runtimeJIT.Identity)" Condition="'@(_runtimeJIT->Contains($(_runtimeJITFilterDir)))' == 'True'" />
</ItemGroup>

<PropertyGroup Condition="'@(_runtimeJIT)' != ''">
<_jitPath>%(_filteredRuntimeJIT.FullPath)</_jitPath>
<_jitPath Condition="'$(_crossDir)' != ''">$(_jitPackageDir)runtimes$(_crossDir)/native/$(LibraryFilePrefix)clrjit$(LibraryFileExtension)</_jitPath>
</PropertyGroup>

<Message Importance="high" Text="XXX ### *** === +++ This is PackageRID: $(PackageRID)"/>
<Message Importance="high" Text="XXX ### *** === +++ This is _runtimeJIT: @(_runtimeJIT)"/>
<Message Importance="high" Text="XXX ### *** === +++ This is _runtimeJITFilterDir: $(_runtimeJITFilterDir)"/>
<Message Importance="high" Text="XXX ### *** === +++ This is _filteredRuntimeJIT: @(_filteredRuntimeJIT)"/>
<Message Importance="high" Text="XXX ### *** === +++ This is _jitPath: $(_jitPath)"/>

<PropertyGroup Condition="'@(_fxSystemRuntime)' != ''">
<_fxLibDirectory>%(_fxSystemRuntime.RootDir)%(_fxSystemRuntime.Directory)</_fxLibDirectory>
</PropertyGroup>
Expand Down

0 comments on commit 9b7c172

Please sign in to comment.