Magick.NET icon indicating copy to clipboard operation
Magick.NET copied to clipboard

Support macOS ARM64 (Apple Silicon)

Open JunielKatarn opened this issue 3 years ago • 24 comments

Is your feature request related to a problem? Please describe

Not a problem. Enhancement.

Describe the solution you'd like

  • Generate a build variant for osx-arm64.

Describe alternatives you've considered

None available

Additional context

If the build system for the native shared libraries uses the XCode toolchain on macOS, this enhancement should be trivial to produce.

JunielKatarn avatar Jul 27 '21 23:07 JunielKatarn

I don't think GitHub currently offers support for managed arm64 builds. Feel free to open up a pull requests in https://github.com/dlemstra/Magick.Native if it is trivial to add support for this.

dlemstra avatar Jul 30 '21 18:07 dlemstra

I don't think GitHub currently offers support for managed arm64 builds. Feel free to open up a pull requests in https://github.com/dlemstra/Magick.Native if it is trivial to add support for this.

@dlemstra Does this mean Magick.Native is built using Github actions?

If so, you're probably right, and I'll hold for that platform support and then submit a PR.

JunielKatarn avatar Jul 30 '21 22:07 JunielKatarn

Magick.Native is indeed build with GitHub actions.

dlemstra avatar Aug 10 '21 19:08 dlemstra

Magick.Native is indeed build with GitHub actions.

Looks like the needed image (macOS Big Sur) needed to produce Apple Silicon binaries is on a private preview. https://github.com/actions/virtual-environments/issues/2486

Apparently, you can request early access here: https://github.com/actions/virtual-environments/blob/main/docs/macos-11-onboarding.md

I think your eventual request would be approved because of the value and usage of this library.

JunielKatarn avatar Aug 11 '21 08:08 JunielKatarn

@dlemstra GitHub actions seems to officially support macOS 11.

Maybe this would enable native ARM64 builds? I'll submit a PR soon.

https://github.com/actions/virtual-environments

JunielKatarn avatar Sep 09 '21 06:09 JunielKatarn

Is it possible to build Magick.NET and Magick.Native locally for arm64?

konistehrad avatar Sep 28 '21 21:09 konistehrad

Maybe? I don't have access to an arm64 machine so I don't know.

dlemstra avatar Sep 28 '21 21:09 dlemstra

Is it possible to build Magick.NET and Magick.Native locally for arm64?

It very much should. Assuming @dlemstra uses "standard" macOS tools to build the native bits, it should be pretty simple to just add the arm64 target and it should build the same.

For building, you don't even need an Apple Silicon machine; just their latest OS (Big Sur).

I may take a stab at it this week.

JunielKatarn avatar Sep 28 '21 22:09 JunielKatarn

I'd appreciate the assist on this. I've had a lot of trouble getting the Homebrew-based tooling to collect the dependencies and compile Magick.Native. It's very likely that I simply don't understand the structure of the project very well.

konistehrad avatar Sep 29 '21 14:09 konistehrad

I need this too. Actually, this is the only thing left that prevents me from creating an Apple Silicon version of my .NET 6 app. Let me know if I can help you in any way.

PS: At least the .NET / C# and Swift compilers seem to have no problems creating Apple Silicon binaries on the GitHub Actions infrastructure (macOS x64).

sschultze avatar Oct 05 '21 11:10 sschultze

I have an Apple M1 and a project that utilize Magick.NET. I'm getting an error at runtime and was hoping someone can point me to the right direction to resolve.

Please note: we only get the error when running on dotnet 6.0 with Apple M1. Running on dotnet 5.0 with x64 is fine.

In my csproj file, I have the following defined

<PackageReference Include="Magick.NET.Core" Version="8.3.3" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="8.3.3" />

At rumtime, we get this error

Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware: Error: An unhandled exception has occurred while executing the request.

System.TypeInitializationException: The type initializer for 'NativeMagickSettings' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'Magick.Native-Q8-x64.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libMagick.Native-Q8-x64.dll, 0x0001): tried: 'libMagick.Native-Q8-x64.dll' (no such file), '/usr/local/lib/libMagick.Native-Q8-x64.dll' (no such file), '/usr/lib/libMagick.Native-Q8-x64.dll' (no such file), '/Users/tiendinh/Projects/oraid/OraIdApi/OraIdApi/libMagick.Native-Q8-x64.dll' (no such file), '/usr/local/lib/libMagick.Native-Q8-x64.dll' (no such file), '/usr/lib/libMagick.Native-Q8-x64.dll' (no such file)
   at ImageMagick.Environment.NativeMethods.X64.Environment_Initialize()
   at ImageMagick.Environment.NativeEnvironment.Initialize() in /_/src/Magick.NET/Native/Helpers/Environment.cs:line 47
   at ImageMagick.Environment.Initialize() in /_/src/Magick.NET/Helpers/Environment.cs:line 19
   at ImageMagick.MagickSettings.NativeMagickSettings..cctor() in /_/src/Magick.NET/Native/Settings/MagickSettings.cs:line 230
   --- End of inner exception stack trace ---
   at ImageMagick.MagickSettings.NativeMagickSettings..ctor() in /_/src/Magick.NET/Native/Settings/MagickSettings.cs:line 246
   at ImageMagick.MagickSettings..ctor() in /_/src/Magick.NET/Settings/MagickSettings.cs:line 33
   at ImageMagick.MagickImage..ctor() in /_/src/Magick.NET/MagickImage.cs:line 39
   at ImageMagick.MagickImage..ctor(Stream stream) in /_/src/Magick.NET/MagickImage.cs:line 187

The line of code that throw the error is

var image = new MagickImage(stream);

It looks like it trying to find the file Magick.Native-Q8-x64.dll. Not sure why, our project is referencing Magick.NET-Q8-AnyCPU

timdinhdotcom avatar Nov 11 '21 05:11 timdinhdotcom

Maybe Magick.NET needs to be upgraded to target/support .NET 6 first?

For reference, .NET 6 was just released this week and it's the first version to support macOS/ARM64.

JunielKatarn avatar Nov 11 '21 05:11 JunielKatarn

This project doesn't support ARM64 and that is why you are getting that exception @timdinhdotcom.

dlemstra avatar Nov 11 '21 05:11 dlemstra

Does anyone know how to complete this lib to run on M1?

fahelmoreira avatar Nov 12 '21 13:11 fahelmoreira

ImageMagick is supported native on M1 mac so adding support for this shouldn't be that complicated, right? please correct me if I'm wrong

fahelmoreira avatar Nov 12 '21 13:11 fahelmoreira

Feel free to open a pull request in the Magick.Native project to add support for this @fahelmoreira if you think this is not complicated?

dlemstra avatar Nov 12 '21 14:11 dlemstra

I'll be happy to! if someone can send me the documentation for this project since I am not familiar with this project. I pull the code but I'm having some issues building this project. but yeah! I would be glad to help! 🙂

fahelmoreira avatar Nov 12 '21 15:11 fahelmoreira

You will need to compile the Magick.Native project with ARM64 support. That project is the native library that is used by this project.

dlemstra avatar Nov 12 '21 16:11 dlemstra

Ok, I'm running this on a mac and it looks like that is the install.sh is incompleted when compared to the install.ps1, there are a lot of methods missing

fahelmoreira avatar Nov 12 '21 17:11 fahelmoreira

Has there been any progress on macOS Support? Would be great! 🙏

ghostbutter-games avatar Apr 18 '22 02:04 ghostbutter-games

There is no progress and this probably needs to be done through cross compilation. Let's hope someone picks this up.

dlemstra avatar Apr 18 '22 08:04 dlemstra

I don't need this anymore, moved to ImageSharp because of missing arm64 support. (Hope it is okay to mention it, you seem to be involved in this project also.)

sschultze avatar Apr 18 '22 13:04 sschultze

That could be an alternative depending on which formats you need to read so I don't mind you mentioning that. But I now just don't have the time to struggle with the GitHub CI and get a cross compilation to work.

dlemstra avatar Apr 18 '22 13:04 dlemstra

Is there any update on this? Thanks.

imuller avatar Jul 20 '22 19:07 imuller

If I have followed the the linked threads correctly - apple silicon support has been merged into magick.Native and we are just waiting for the github CI and dotnet wrappers to get this working?

marstaik avatar Oct 24 '22 19:10 marstaik

It will become available in the next release of Magick.NET but I am not able to give you an estimate when this will become available.

dlemstra avatar Oct 24 '22 20:10 dlemstra