eShop icon indicating copy to clipboard operation
eShop copied to clipboard

Apple ARM Processors Require Rosetta 2 to Build for gRPC Build Tools Support

Open tebeco opened this issue 1 year ago • 19 comments

I don't think this repository can be build on MacOs / Apple Sillicon

  • NO GOAL: depends on Rosetta
  • GOAL: Having the tooling "just works"
$ git clone https://github.com/dotnet/eShop

$ dotnet tool restore
# this repo is missing dotnet tool manifest for ef
$ dotnet new tool-manifest
$ dotnet tool install dotnet-ef
$ git add ./.config
$ git commit -m "Add required file for dotnet tool to avoid relying on a global computer state"

$ sudo dotnet workload restore
# dotnet workload is still bugged and require sudo on non-windows
# https://github.com/dotnet/sdk/issues/18585

$ dotnet restore eShop.Web.slnf
$ dotnet build eShop.Web.slnf
# should work

Current Result: This repo depends on a package that is yet to be Apple ARM compliant:

dotnet build eShop.Web.slnf
MSBuild version 17.8.3+195e7f5a3 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.

  Restore operation started

  4 libraries restored in 0,07 seconds

  EventBus -> ~/dev/github/eshop/src/EventBus/bin/Debug/net8.0/EventBus.dll
  Ordering.Domain -> ~/dev/github/eshop/src/Ordering.Domain/bin/Debug/net8.0/Ordering.Domain.dll
  eShop.ServiceDefaults -> ~/dev/github/eshop/src/eShop.ServiceDefaults/bin/Debug/net8.0/eShop.ServiceDefaults.dll
  WebAppComponents -> ~/dev/github/eshop/src/WebAppComponents/bin/Debug/net8.0/WebAppComponents.dll
  IntegrationEventLogEF -> ~/dev/github/eshop/src/IntegrationEventLogEF/bin/Debug/net8.0/IntegrationEventLogEF.dll
  Mobile.Bff.Shopping -> ~/dev/github/eshop/src/Mobile.Bff.Shopping/bin/Debug/net8.0/Mobile.Bff.Shopping.dll
  Ordering.Infrastructure -> ~/dev/github/eshop/src/Ordering.Infrastructure/bin/Debug/net8.0/Ordering.Infrastructure.dll
  EventBusRabbitMQ -> ~/dev/github/eshop/src/EventBusRabbitMQ/bin/Debug/net8.0/EventBusRabbitMQ.dll
  WebhookClient -> ~/dev/github/eshop/src/WebhookClient/bin/Debug/net8.0/WebhookClient.dll
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: The specified task executable "~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc" could not be run. System.ComponentModel.Win32Exception (86): An error occurred trying to start process '~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc' with working directory '~/dev/github/eshop/src/Basket.API'. Bad CPU type in executable [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: The specified task executable "~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc" could not be run. System.ComponentModel.Win32Exception (86): An error occurred trying to start process '~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc' with working directory '~/dev/github/eshop/src/WebApp'. Bad CPU type in executable [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [~/dev/github/eshop/src/WebApp/WebApp.csproj]
  Identity.API -> ~/dev/github/eshop/src/Identity.API/bin/Debug/net8.0/Identity.API.dll
  PaymentProcessor -> ~/dev/github/eshop/src/PaymentProcessor/bin/Debug/net8.0/PaymentProcessor.dll
  OrderProcessor -> ~/dev/github/eshop/src/OrderProcessor/bin/Debug/net8.0/OrderProcessor.dll
  Webhooks.API -> ~/dev/github/eshop/src/Webhooks.API/bin/Debug/net8.0/Webhooks.API.dll
  Ordering.API -> ~/dev/github/eshop/src/Ordering.API/bin/Debug/net8.0/Ordering.API.dll
  Catalog.API -> ~/dev/github/eshop/src/Catalog.API/bin/Debug/net8.0/Catalog.API.dll
  Ordering.UnitTests -> ~/dev/github/eshop/tests/Ordering.UnitTests/bin/Debug/net8.0/Ordering.UnitTests.dll
  Catalog.FunctionalTests -> ~/dev/github/eshop/tests/Catalog.FunctionalTests/bin/Debug/net8.0/Catalog.FunctionalTests.dll
  Ordering.FunctionalTests -> ~/dev/github/eshop/tests/Ordering.FunctionalTests/bin/Debug/net8.0/Ordering.FunctionalTests.dll

Build FAILED.

~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: The specified task executable "~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc" could not be run. System.ComponentModel.Win32Exception (86): An error occurred trying to start process '~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc' with working directory '~/dev/github/eshop/src/Basket.API'. Bad CPU type in executable [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [~/dev/github/eshop/src/Basket.API/Basket.API.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003: The specified task executable "~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc" could not be run. System.ComponentModel.Win32Exception (86): An error occurred trying to start process '~/.nuget/packages/grpc.tools/2.59.0/tools/macosx_x64/protoc' with working directory '~/dev/github/eshop/src/WebApp'. Bad CPU type in executable [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [~/dev/github/eshop/src/WebApp/WebApp.csproj]
~/.nuget/packages/grpc.tools/2.59.0/build/_protobuf/Google.Protobuf.Tools.targets(291,5): error MSB6003:    at Microsoft.Build.Utilities.ToolTask.Execute() [~/dev/github/eshop/src/WebApp/WebApp.csproj]
    0 Warning(s)
    2 Error(s)

Time Elapsed 00:00:02.14

Grpc.Tools only ship for macos x64 apparently, until Google actually update their package for Apple Silicon, should this repo offer an alternative way of using GRPC like for example protobuff-net ?

tebeco avatar Feb 17 '24 13:02 tebeco

Per https://github.com/grpc/grpc/issues/25755, there's no ETA for when the macOS arm64 binaries will be available. There are a few workarounds mentioned in that grpc issue as well.

cc @JamesNK @mgravell in case you have any thoughts

adityamandaleeka avatar Mar 01 '24 17:03 adityamandaleeka

does moving to protobuff-net.grpc would address that ?

tebeco avatar Mar 01 '24 17:03 tebeco

It's not a priority for us to avoid using Rosetta in our build process. But if you determine that the above tool works we'd be happy to consider a PR that uses it.

mikekistler avatar Apr 12 '24 18:04 mikekistler

Hey, not sure what's the status, I'm running (aka building) this on Apple's Ms processor no problem (the dev certificate for Aspire was a tricky one, otherwise works).

peterblazejewicz avatar May 04 '24 20:05 peterblazejewicz

I have updated instructions in this PR: https://github.com/dotnet/eShop/pull/353 If you are running preview 7 you will need to checkout aspire-preview7 branch

jamesmontemagno avatar May 07 '24 23:05 jamesmontemagno

can you re-open that issue @jamesmontemagno ? The link PR just changed a few line on a README

current status: this repo won't build on Apple Silicon

the issue that the MSFT / Grpc implementation is not usable on MacOs Unless the repo change to protobuf-net.GRPC or so that does not rely on Google protoc, this issue should stay open

tebeco avatar May 08 '24 12:05 tebeco

@tebeco I am on an Apple M1 and was able to get it to run. Let's re-open it, but update the title with more information about the specific issue. As is, the directions build and run the project out of the box, but may need to document the grpc items.

jamesmontemagno avatar May 08 '24 13:05 jamesmontemagno

I want to clarify here that you have Rosetta turned off? That is the main issue here?

jamesmontemagno avatar May 08 '24 13:05 jamesmontemagno

Yep it's because you previously installed Rosetta 2

And it probably is silently depending on Rosetta 2 for running protoc i don't think requiring Rosetta 2 on apple silicon for dotnet core should be a pre requisite for XPlat runtime/tooling

as far as i recall google tooling is nearly always ultra late to the game when it's for compatibility with technology that isn't theirs

so the short term here would be to find a way to either commit the generated code or moving out of the google tooling that is not compliant

tebeco avatar May 08 '24 13:05 tebeco

Thanks for the information here. I will adjust and update the title of this issue.

Since this is a requirement of the library and it is an open ticket, I will document Rosetta 2 is required when running on Apple Silicon.

jamesmontemagno avatar May 08 '24 14:05 jamesmontemagno

I will document Rosetta 2 is required when running on Apple Silicon.

I think depending on Rosetta 2 being mandatory for MacOS sort of means that the tooling is not XPlat yet, am I wrong ?

Is it possible with GRPC Build Tools to commit the generated code and disable call to protoc via MsBuild Condition ? so that on macOS it wouldn't be hurting

else the alternative is to use a toolchain that is not the google one. Apple ARM is now 4 years old and we can see the investment wasn't exactly great even before ARM.

tebeco avatar May 08 '24 17:05 tebeco

I'll reiterate what @mikekistler said above:

It's not a priority for us to avoid using Rosetta in our build process.

The fact that this sample happens to use tooling as part of the build process that isn't native arm64 isn't super interesting IMO. It affects neither the performance/functionality of the sample nor the educational value. Moreover, adding extra logic or committing generated code as you suggested above might actually lead to more confusion--keep in mind that this sample app is supposed to reflect best practices for how to do things. Having Rosetta disabled seems to be very uncommon (as one data point, you're the only person who has reported this, despite there being many devs trying this sample on macOS).

Consider chiming in on the grpc issue to voice support for the arm64 versions of the tools.

adityamandaleeka avatar May 08 '24 18:05 adityamandaleeka

@JamesNK Is this something we can raise again on the gRPC tooling side? https://github.com/grpc/grpc/issues/25755

adityamandaleeka avatar May 08 '24 18:05 adityamandaleeka

I'll reiterate what @mikekistler said above:

It's not a priority for us to avoid using Rosetta in our build process.

The fact that this sample happens to use tooling as part of the build process that isn't native arm64 isn't super interesting IMO. It affects neither the performance/functionality of the sample nor the educational value. Moreover, adding extra logic or committing generated code as you suggested above might actually lead to more confusion--keep in mind that this sample app is supposed to reflect best practices for how to do things. Having Rosetta disabled seems to be very uncommon (as one data point, you're the only person who has reported this, despite there being many devs trying this sample on macOS).

Consider chiming in on the grpc issue to voice support for the arm64 versions of the tools.

I understand what you're saying but it's not constructive from either side. The issue is existing since 2021, and this is not the first gRPC issue where we're saying multi-year delay reactivity from Google (just re-iterating)

My previous post added 2 possibles solutions, the first one would be to keep the repo as/is BUT add Condition within MSBuild to avoid running protoc as part of the build ... and get these file pre-generated / added to the repo for MacOs, that's all

Is it something that the MSFT GRPC tools for AspNetcore support ? OptOut running protoc and instead have the <proto containing a mapping to a .cs file for example

tebeco avatar May 08 '24 18:05 tebeco

I'm afraid doing something non-standard here for this case isn't a priority for us in this sample application, for the reasons I mentioned above. If there was widespread demand for this, we may consider doing something but as it stands this isn't something we want to address.

adityamandaleeka avatar May 09 '24 23:05 adityamandaleeka

@JamesNK Is this something we can raise again on the gRPC tooling side? grpc/grpc#25755

This should probably be done regardless of the presence of Rosetta 2 or not on devices.

tebeco avatar May 14 '24 06:05 tebeco