Broken on Apple silicon M1 arm64 machines
preston opened this issue · 8 comments
After building on an M1 macOS machine successfully with a brew install dotnet
v6.0.103, running the project results in the following error attempting to link in an x64 library. How do you build and run on machines using Apple's current M1 chips? The link printed by the runtime leads me to believe this should work somehow.
`
➜ fhir-codegen git:(main) dotnet run --project src/fhir-codegen-cli
Failed to load Q, error: dlopen(/opt/homebrew/Cellar/dotnet/6.0.103/libexec/host/fxr/6.0.3/libhostfxr.dylib, 0x0001): tried: '/opt/homebrew/Cellar/dotnet/6.0.103/libexec/host/fxr/6.0.3/libhostfxr.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
The library libhostfxr.dylib was found, but loading it from /opt/homebrew/Cellar/dotnet/6.0.103/libexec/host/fxr/6.0.3/libhostfxr.dylib failed
- Installing .NET Core prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=2063366
`
Hi @preston , the main branch is still running on DotNet Core 3.1.
The dev
branch has been fully migrated to .Net 6.0. It has not been merged yet because there is quite a bit of new development happening on it yet and I want a bit more progress before changing over the main branch.
That said, all of the existing functionality from the main
branch should work and should contain no breaking changes.
The dev
branch has been merged into main
, though still at 2.0.0-beta1
. Local testing has worked, with no further external complaints.
@GinoCanessa Update: I'm trying on main again, and the problem still persists. It seems to fail effectively due to dotnet/efcore#24971 , which is significant because it will fail on every macOS machine released in the last few years, which use Apple's M1- and M2-family SOC silicon. Is there something fundamentally not available in whatever the "hostfxr" library is that will not work on ARM chips? I'd like to avoid beating my head against the wall if it's just not going to work with the current SDK builds. :)
@preston , I am not sure what is happening on your machine - perhaps something with brew? I went and grabbed my M1 mac, and everything runs fine on 6.0.100
, 6.0.202
, and (latest) 6.0.401
. I simply ran the installer from https://dotnet.microsoft.com/en-us/download for ARM-64 (in each case... today I installed 401
to double-check).
I tested both the UI:
dotnet run --project src/FhirCodeGenBlazor/FhirCodeGenBlazor.csproj
and the CLI:
dotnet run --project src/fhir-codegen-cli/fhir-codegen-cli.csproj --language-help
Both run as expected. Looking at the issue you link, I will note that nothing in this repo uses Entity Framework.
If you run a command like dotnet --list-sdks
, what is it coming back with? Looking at dotnet/runtime#49712 , that error message was coming back from some SDK build/installation/compatibility issues (specifically in preview builds).
From what I've been reading there may have been some issues in prior runtime builds that messed up library architecture loading.. or something like that. On my M1 I've completely uninstalled the homebrew versions and am using the SDK and runtime downloads direct from Microsoft at https://dotnet.microsoft.com/en-us/download/dotnet/6.0 , but am still getting references to "x64" in the error ("install the runtime in the global location [/usr/local/share/dotnet/x64]"). I have a personal M2 that is "cleaner" I'm going to try next.
`
➜ fhir-codegen git:(main) dotnet --version
6.0.401
➜ fhir-codegen git:(main) dotnet run -p src/fhir-codegen-test-cli/fhir-codegen-test-cli.csproj
Warning NETSDK1174: The abbreviation of -p for --project is deprecated. Please use --project.
A fatal error occurred. The required library libhostfxr.dylib could not be found.
If this is a self-contained application, that library should exist in [/Users/preston/Developer/git/fhir-codegen/src/fhir-codegen-test-cli/bin/Debug/netcoreapp3.1/].
If this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet/x64] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].
The .NET Core runtime can be found at:
➜ fhir-codegen git:(main) dotnet --list-sdks
6.0.401 [/usr/local/share/dotnet/sdk]
`
Have you pulled this repo recently? It looks like it is looking for libraries from .Net Core 3.1, which has been out of the main branch for at least 6 months.
AHAHAHA I was using the old TargetFramework definition and not "net6.0":
Thank you -- I should have caught that! Sorry for the stupid issue.. 😞
All good - glad that it is resolved!