Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

QDK is broken when ARM64 .NET 6 SDK is installed #1273

Open
filipw opened this issue Nov 29, 2021 · 11 comments
Open

QDK is broken when ARM64 .NET 6 SDK is installed #1273

filipw opened this issue Nov 29, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@filipw
Copy link
Contributor

filipw commented Nov 29, 2021

Describe the bug

Since .NET 6 introduced the split into how the ARM64 and x64 SDKs are installed, the experience with Q# is broken on ARM (where things used to work OK through emulation). I can only speak about MacOS here, but it could be that other platforms experience the same.

If you have .NET 6 ARM SDK installed, and x64 versions of SDK 5.x.x and 3.1.x, the "dotnet" command from the CLI points to the ARM SDK.

  • ARM SDK is now located at /usr/local/share/dotnet
  • x64 SDK is now located at /usr/local/share/dotnet/x64

This leads to a lot of things breaking in Q# such as, trying to run/compile the program does not work:

dotnet run
/Users/filipw/.nuget/packages/microsoft.quantum.sdk/0.19.2109165653/Sdk/Sdk.targets(62,5): error MSB3073: The command "dotnet "/Users/filipw/.nuget/packages/microsoft.quantum.sdk/0.19.2109165653/DefaultItems/../tools/utils/Microsoft.Quantum.Sdk.BuildConfiguration.dll" -v Normal --output "obj/qsharp/config/qsc.config" --QscReferences "(/Users/filipw/.nuget/packages/microsoft.quantum.csharpgeneration/0.19.2109165653/build//../lib/netstandard2.1/Microsoft.Quantum.CSharpGeneration.dll, -1)"" exited with code 134. [/Users/filipw/dev/qsharp-code/qpe/qpe.csproj]

The actual problem is ARM incompatibility:

Unhandled exception. System.BadImageFormatException: Could not load file or assembly '/Users/filipw/.nuget/packages/microsoft.quantum.sdk/0.19.2109165653/tools/utils/Microsoft.Quantum.Sdk.BuildConfiguration.dll'. An attempt was made to load a program with an incorrect format.

The current workaround, although not ideal is to export the x64 path as dotnet, which bypasses the native ARM SDK

export PATH=/usr/local/share/dotnet/x64:$PATH

though doing this globally is of course not really feasible so it's needed per terminal session which is not great.

To Reproduce

Setup NET 6 SDK according to the instructions in dotnet/sdk#22380

Expected behavior

Either everything works out of the box, or I have an option to provide custom path to the "dotnet" executabale, rather than QDK taking it from the path. In the latter case, I could just point it at /usr/local/share/dotnet/x64

System information

  • MacOS Monterey 12.0.1, M1 2020
  • QDK 0.19.2109165653

dotnet info:

(base) /Users/filipw » dotnet --info                                                                                                                                                                                                                                              ~  
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.0
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100/

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

dotnet x64 info

(base) /Users/filipw » dotnet64 --info                                                                                                                                                                                                                                         ~ 1 ↵ 
.NET SDK (reflecting any global.json):
 Version:   5.0.403
 Commit:    bf9d168ac2

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.0
 OS Platform: Darwin
 RID:         osx-x64
 Base Path:   /usr/local/share/dotnet/x64/sdk/5.0.403/

Host (useful for support):
  Version: 5.0.12
  Commit:  7211aa01b3

.NET SDKs installed:
  3.1.415 [/usr/local/share/dotnet/x64/sdk]
  5.0.403 [/usr/local/share/dotnet/x64/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.21 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.12 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.21 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.12 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
@filipw filipw added bug Something isn't working needs triage An initial review by a maintainer is needed labels Nov 29, 2021
@ricardo-espinoza
Copy link
Contributor

Thanks for the report, @filipw! We're currently working on adding support for .NET6 in the QDK, and we'll consider this issue as part of the work we're doing.

@bettinaheim bettinaheim removed the needs triage An initial review by a maintainer is needed label Dec 15, 2021
@k4rtik
Copy link
Contributor

k4rtik commented May 18, 2022

I believe .net6 support was added a few weeks ago, but I am still getting this same issue:

PlatiniumM1Pro in ~/Projects/runSayHello via .NET v6.0.104 🎯 net6.0
❯ dotnet run
/Users/kartik/.nuget/packages/microsoft.quantum.sdk/0.24.208024/Sdk/Sdk.targets(62,5): error MSB3073: The command "dotnet "/Users/kartik/.nuget/packages/microsoft.quantum.sdk/0.24.208024/DefaultItems/../tools/utils/Microsoft.Quantum.Sdk.BuildConfiguration.dll" -v Normal --output "obj/qsharp/config/qsc.config" --QscReferences "(/Users/kartik/.nuget/packages/microsoft.quantum.csharpgeneration/0.24.208024/build//../lib/netstandard2.1/Microsoft.Quantum.CSharpGeneration.dll, -1)"" exited with code 134. [/Users/kartik/Projects/runSayHello/runSayHello.csproj]

The build failed. Fix the build errors and run again.

@rodrmoya
Copy link

same here, on a M1 Mac mini, with latest Microsoft.Quantum.ProjectTemplates so definitely still not fixed

@k4rtik
Copy link
Contributor

k4rtik commented Jul 20, 2022

@ricardo-espinoza is there any possibility to fix this issue? It seems the x64-simulation workaround that @filipw had described in the OP does not work anymore.

EDIT: it still works, but requires extra hoops to jump.

@socialsorcery
Copy link

Currently trying the workaround suggested by @k4rtik but this does still seem to be an issue on my M1 Max MacBook. Additionally, running in a container (such as mcr.microsoft.com/quantum/samples) doesn't work either, presumably because the container is only trying it's best to pretend it's x86 without actually emulating it properly.

@devloperrobin
Copy link

I thought I'd give it a try with the latest version of dotnet and quantum SDK, but it's still broken with .NET 7 and QDK version 0.27.238334.

@filipw
Copy link
Contributor Author

filipw commented Nov 30, 2022

Unfortunately yes, it is still broken (yesterday was the 1st birthday of the bug report 🎂😀) - but the workaround with using the old simulator, and the x64 Rosetta emulation still works (although it's far from ideal)

@lmarangio
Copy link

Still not working on Mac M1 2020 :/

@filipw
Copy link
Contributor Author

filipw commented Jun 5, 2023

A good alternative at this point is to compile to QIR and use a QIR runner instead

@ricardo-espinoza ricardo-espinoza removed their assignment Jun 5, 2023
@pascal1609
Copy link

still not working on Mac M1 with Venture 13.1.

@k4rtik
Copy link
Contributor

k4rtik commented Dec 8, 2023

I believe they released a new QDK that works universally: https://github.com/microsoft/qsharp

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants