Skip to content

Initial .NET Framework ARM64 support#60735

Merged
jaredpar merged 6 commits intodotnet:mainfrom
jaredpar:arm64
Apr 19, 2022
Merged

Initial .NET Framework ARM64 support#60735
jaredpar merged 6 commits intodotnet:mainfrom
jaredpar:arm64

Conversation

@jaredpar
Copy link
Copy Markdown
Member

@jaredpar jaredpar commented Apr 13, 2022

This adds the initial support for Roslyn producing .NET Framework ARM64
binaries. This is necessary because on an ARM64 machine a binary tagged
as AnyCPU will actually run under X64 emulation. This meas the Roslyn
tools will run out of the box but they do so under emulation which is
significantly slower. In order to get the performance expected the
binaries need to be targetted to ARM64 so they run natively.

There are a few challenges here. The first is that there is not a
concept of multi-targeting between <PlatformTarget> values. In order
to support producing both AnyCPU and ARM64 EXEs we are going to make
use of shared projects for csc, vbc and VBCSCompiler. The bulk of the
code will be in the shared project with the actual project files toggling
the PlatformTarget and TargetFramework elements.

The second challenge is there are no CI machines with .NET Framework
ARM64 installed on them. The only way to run tests is to do so manually
on a machine. There are 3 test failures when I did this but they are
pretty minor issues. Nothing that would block us getting the binaries
out for the rest of the effort to move forward.

The overall effort here and remaining work items are tracked here

#59421

@jaredpar
Copy link
Copy Markdown
Member Author

Actually hold off on reviewing for now, I think I found a way to have a sane unified build.

@jaredpar jaredpar marked this pull request as draft April 14, 2022 17:37
@RikkiGibson RikkiGibson self-assigned this Apr 14, 2022
This adds the initial support for Roslyn producing .NET Framework ARM64
binaries. This is necessary because on an ARM64 machine a binary tagged
as AnyCPU will actually run under X64 emulation. This meas the Roslyn
tools will run out of the box but they do so under emulation which is
significantly slower. In order to get the performance expected the
binaries need to be targetted to ARM64 so they run natively.

The challenge here is there is not concept of multi-targeting between
<PlatformTarget> values. In order to support producing both AnyCPU
and ARM64 EXEs we are going to make use of shared projects for csc,
vbc and VBCSCompiler. The bulk of the code will be in the shared
project with the actual project files toggling the PlatformTarget
and TargetFramework elements.
@jaredpar jaredpar marked this pull request as ready for review April 15, 2022 03:17
@jaredpar
Copy link
Copy Markdown
Member Author

Okay this change is ready for review now that I've redone the build work. I've separated this out into two commits:

  1. The first commit is about doing the work such that we can produce two copies of csc, vbc and VBCSCompiler in net472: an AnyCPU and ARM64 variant.
  2. The second commit is about updating our DiaSym layer so that it properly loads the .arm64 version of the native binaries

@jaredpar
Copy link
Copy Markdown
Member Author

@RikkiGibson, @dotnet/roslyn-infrastructure PTAL

</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand what these projects are. Where did they come from? Does VS need to be installed in order to build these?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what they are either but it's boiler plate in every .shproj hence included here. Perhaps @rainersigwald, or @baronfel know the reason for them existing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, sorry. My assumption would be that it lights up VS functionality but isn't required at build time.

<Compile Include="..\CommandLine\BuildProtocol.cs" />
<Compile Include="..\CommandLine\ConsoleUtil.cs" />
<Compile Include="..\CommandLine\NativeMethods.cs" />
<Compile Include="..\CommandLine\CompilerServerLogger.cs" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that those four Compile items are the only things you transferred over from the now removed CommandLine.projitems import.
Did other properties (like Import_RootNamespace) not need to be copied here as well?

<StartupObject>Microsoft.CodeAnalysis.VisualBasic.CommandLine.Program</StartupObject>
<ServerGarbageCollection>true</ServerGarbageCollection>
<GenerateMicrosoftCodeAnalysisCommitHashAttribute>true</GenerateMicrosoftCodeAnalysisCommitHashAttribute>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this was not in vbc.csproj previously. Was that a bug you fixed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's meant that untracked sources, build inputs that aren't in GitHub, weren't being embedded. This would break rebuild verification. A bit niche at the moment but a subtle issue I noticed when doing this work

@jcouv jcouv self-assigned this Apr 18, 2022
Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 2). Only minor questions

Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 4)

jaredpar and others added 2 commits April 18, 2022 20:40
Co-authored-by: David Barbet <dibarbet@gmail.com>
@jaredpar jaredpar enabled auto-merge (squash) April 19, 2022 03:41
@jaredpar jaredpar merged commit 423e928 into dotnet:main Apr 19, 2022
@ghost ghost added this to the Next milestone Apr 19, 2022
@jaredpar jaredpar deleted the arm64 branch April 19, 2022 15:10
@dibarbet dibarbet modified the milestones: Next, 17.3.P1 Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants