dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.87k stars 4.63k forks source link

[Windows ARM] Building libraries from Visual Studio results in an x64 compiler being used #104548

Open eiriktsarpalis opened 1 month ago

eiriktsarpalis commented 1 month ago

Even though my VS process is arm64:

image

Building libraries projects results in an x64 compiler process being used:

image

Digging deeper, it appears this is issue is specific to dotnet/runtime infrastructure which by default uses an OOB compiler that doesn't support arm64:

image

I should stress that this has major impact on build performance. For reference, building System.Text.Json.sln from the CLI using the arm64 sdk takes 32 seconds whereas building the same solution from VS takes 8 minutes.

dotnet-policy-service[bot] commented 1 month ago

Tagging subscribers to this area: @dotnet/runtime-infrastructure See info in area-owners.md if you want to be subscribed.

jkotas commented 1 month ago

it appears this is issue is specific to dotnet/runtime infrastructure which by default uses an OOB compiler

We do this to allows us to get faster end-to-end validation of new C# features and gives us agility with working around bugs. You can see number of instances in the history of the versions file where we took advantage of this - https://github.com/dotnet/runtime/issues/65317 has a bunch of examples.

teo-tsirpanis commented 1 month ago

is issue is specific to dotnet/runtime infrastructure

Does it reproduce when building a regular project with the built-in C# compiler? It would be weird if it did not: one of the ways for an executable to run on .NET Framework on native ARM64 architecture is to target .NET Framework 4.8.1, and the built-in csc.exe targets 4.7.2. See dotnet/core#7709 for more details about .NET Framework on ARM64.

One other way to enable it would be with a special manifest element, and I have opened dotnet/roslyn#74285 to add it. As a workaround @eiriktsarpalis you can force VBCSCompiler.exe to run on ARM64 by setting a special registry key.

eiriktsarpalis commented 1 month ago

Does it reproduce when building a regular project with the built-in C# compiler?

Nope, standard projects using the inbox compiler run as arm64 processes.

eiriktsarpalis commented 1 month ago

As a workaround @eiriktsarpalis you can force VBCSCompiler.exe to run on ARM64 by setting a special registry key.

Very cool, this solved my problem. For anyone interested you can create the following DWORD values:

set to the hex value of aa64.

eiriktsarpalis commented 1 month ago

Leaving open until the changes are absorbed in runtime and we revert https://github.com/dotnet/runtime/pull/104812