Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ARM32 & ARM64 as AvailablePlatforms #16802

Merged
merged 3 commits into from
Apr 21, 2021

Conversation

benvillalobos
Copy link
Member

@benvillalobos benvillalobos commented Apr 8, 2021

Fixes dotnet/msbuild#5951

Context

.NET 5 is adding support for Windows ARM64. Visual Studio .NET Core projects should allow you target ARM64 in addition to x86/x64/arm32.

This is planned to be based off of the AvailablePlatforms property.

Changes Made

In Microsoft.NET.Sdk.targets, added conditional propertygroups based on TargetFrameworkIdentifier and TargetFrameworkVersion to add ARM32/64 as a platform.

Testing

Needs dotnet/project-system#7081 to account for AvailablePlatforms so we can see it in the Platform Target dropdown under project properties.

Notes

What we're trying to apply ARM to:

Version Windows Linux macOS
.NET Core 2.1 x86, x64 x86, x64, arm32 x64
.NET Core 3.1 x86, x64, arm32 x86, x64, arm32, arm64 x64
.NET 5 x86, x64, arm64 (console only) x86, x64, arm32, arm64 x64

Todo

  • Find the "correct" location to place these propertygroups.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@dsplaisted
Copy link
Member

I'd suggest using the built-in VersionGreaterThanOrEquals method (or similar) for version comparisons. Example:

Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '5.0'))">

@benvillalobos
Copy link
Member Author

I double checked that the leading v in TargetFrameworkVersion wouldn't be a problem when calling VersionGreaterThanOrEquals. Looks like SimpleVersion is used under the hood and that handles it for us.

@benvillalobos
Copy link
Member Author

@dsplaisted Is there a better location to place these checks?

@dsplaisted
Copy link
Member

This looks like a fine place to put this. But I think we probably don't want to have the IsOSPlatform checks. What if I'm building on Windows but am going to be deploying on Linux? Shouldn't I be able to specify arm64 even for .NET Core 3.1?

@benvillalobos
Copy link
Member Author

@dsplaisted After just talking about this in standup: We don't really have a way to check what OS is being targeted.

Because of that I'm not sure how we can limit which OS we can provide the arm64 build option vs the arm32 build option. (/cc: @tommcdon) Looks like the best we can do is:

NetCoreApp2.1: allow arm32
netcore3.1: allow arm64 (with console app limitation)
net5.0: allow arm64 (with console app limitation)
(can be simplified to netcore3.1+: allow arm64)

Sounds to me like we should add conditional warnings/errors for combinations of platform/currentOS that aren't supported.

@tommcdon
Copy link
Member

tommcdon commented Apr 9, 2021

Looks like the best we can do is:

NetCoreApp2.1: allow arm32
netcore3.1: allow arm64 (with console app limitation)
net5.0: allow arm64 (with console app limitation)
(can be simplified to netcore3.1+: allow arm64)

One small tweak to the table - we support arm64 winforms and WPF in .NET 6, and we are in the process of adding macOS apple silicon. Another note is that the "console app" limitation includes support for kestrel (.net core 3.1+). I'm not sure if it changes the constraints or design, just calling out that we have more supported arm64 platforms/project types. cc @richlander

@benvillalobos
Copy link
Member Author

The project-type & platform limitations are a bit confusing. We want to allow ARM64 on net5.0, but only for console apps on windows and everything else in linux. But we can't tell what OS we're targeting. How would we accomplish this?

Should the project-type limitation exist regardless of the platform? ie. "Console only" extends to both windows and linux.

@dsplaisted would appreciate your take on this.

@dsplaisted
Copy link
Member

I think you have to be liberal. If there isn't a target OS, then you have to allow ARM64 if there is any OS where the project could run as ARM64.

There are some cases where you know the target OS. The TargetPlatformIdentifier might be Windows (there isn't a TargetPlatformIdentifier for Linux). Also if a RuntimeIdentifier is specified it probably tells you which OS is being targeted. If you want to try to cover those cases I think you'd want to get a PM to define the scenarios and what we want to do for them.

@richlander
Copy link
Member

I don't understand the console-specific check for Windows Arm64. ASP.NET Core works on Windows Arm64.

I'd like to see a list of projects configurations that should fail this test and those that should pass. I'm having trouble reverse engineering this from the issue. Can you provide that?

@marcpopMSFT
Copy link
Member

@richlander @tommcdon Ben has changed it to allow arm32 for anything 2.1 and up and arm64 for anything 3.1 and up. This could allow customers to select it in a configuration it would fail but trying to block only the cases that will fail will potentially be complex and error-prone. Is this more liberal approach reasonable to you?

@richlander
Copy link
Member

That sounds good, at least as a starting point where we can collect more feedback.

FYI: We dropped support for Windows Arm32 with .NET 5.

@benvillalobos
Copy link
Member Author

@richlander @marcpopMSFT thanks for confirming. Opening this as ready for review then.

@benvillalobos benvillalobos marked this pull request as ready for review April 15, 2021 23:08
@benvillalobos benvillalobos merged commit 4a5e71e into dotnet:main Apr 21, 2021
@benvillalobos benvillalobos deleted the arm64-support branch April 21, 2021 21:03
@marcpopMSFT
Copy link
Member

@tommcdon This went into main and so will be available in dev17. Should we consider this for 5.0.3xx as well so it will be in 16.10+?

@tommcdon
Copy link
Member

@marcpopMSFT I agree we should consider this for 5.0.3xx.

@marcpopMSFT
Copy link
Member

@benvillalobos mind creating a 5.0.3xx version of this change?

@benvillalobos benvillalobos restored the arm64-support branch April 28, 2021 16:38
@benvillalobos
Copy link
Member Author

@marcpopMSFT Created here: #17253

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ARM64 as a supported architecture
5 participants