-
-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL API not loading on M-series Mac #2173
Comments
The way https://github.com/dotnet/Silk.NET/blob/main/src/Native/Silk.NET.SDL.Native/build/net461/Ultz.Native.SDL.targets is set up, it should set 'osx-x64' even on ARM (due to the 64bit check). This means it will look in runtimes/osx-x64/native. It is not there. |
Are you using .NET Framework/Mono? That targets file does not apply otherwise. |
If you are not using Framework/Mono, I would be curious if you could try moving the dylib into |
I am not no. :D I barely know what I am doing on the native part. I see here that the libs got added here, but no config for OSX |
Does it work if you use dotnet publish or dotnet run with a runtime identifier specified? |
Moved the file, but it gets put back on Run. Any tip on how I can try this properly? |
dotnet run -r osx-arm64 -> same issue |
Do something like this: $ dotnet build
$ cp bin/Debug/net8.0/runtimes/osx/native/libSDL2-2.0.dylib bin/Debug/net8.0/runtimes/osx-arm64/native # replace net8.0 as appropriate
$ dotnet run --no-build Does this work? (Basically trying to determine if the runtime is even attempting to pick up anything from |
Exits with Error code 137 (SIGKILL) No :( With this code: unsafe
{
Console.WriteLine("A");
SdlProvider.InitFlags = Sdl.InitVideo | Sdl.InitEvents;
Console.WriteLine("B");
var sdl = SdlProvider.SDL.Value;
Console.WriteLine("C");
} Sidenote: my osx/ also contains libSkiaSharp, which works fine. |
Oh... I remembered now to look at the system Console:
Termination Reason: Namespace CODESIGNING, Code 2 Invalid Page |
What's the output of |
That one is both x64 and arm, but:
(fine for Skia and libwgpu (from your WebGPU)) |
I don't really know how code signing works on macOS. Is there a way to turn off the enforcement just to see if that's the cause of the issue? |
I've signed it myself (overwriting the existing signature), and then it runs. So it is definitely the wrong signature. |
Did you do ad-hoc signing or use an actual certificate? |
Actual certificate in this case. Let me find how to sign ad-hoc... EDIT: Ad-hoc (using '-' as certificate) also works fine |
'broken' signature:
After I signed it adhoc:
|
Well, we also build SDL on macOS (using I don't have a macOS system, though, so hard for me to investigate this. |
I'm glad to help you figure it out :) To be sure, I've renamed the file to something else, and an existing signature survives that. (I am not sure myself what the signature signs). So the identifier being libSDL2 instead of 2-2 should not be an issue. I'd think you need to sign after lipo? Can I try building this whole thing locally? |
That may be it. My understanding is that each arch portion of a fat binary has its own signature, but maybe you also need to sign the combined fat binary at the end... 🤔
Clone the repo and do
You can find the build logic here: https://github.com/dotnet/Silk.NET/blob/main/build/nuke/Native/SDL2.cs |
Any chance I can forcably use dotnet sdk 8? EDIT: Bunch of env changes got me access to 7 now. Building... |
Last line of the build: :)
|
You can have multiple .NET SDKs installed side-by-side. One way is to use the dotnet-install scripts, e.g. |
That'd do it 🤦 |
Yeah, but one install was through brew, so it kept taking the brew version. Should switch to botnet-install... |
Interestingly:
succeeds |
Hm. I mean, it does make sense that But |
I have no idea. I can make a PR with extra code-signing at the end. Then I think Github can try running it, and I can verify |
That's a bit involved due to the way our native builds are triggered (it's not as simple as a PR). But, I think @Perksey daily-drives macOS, so maybe you can upload the binary you just built for him to |
Alright, I can do that. I made a PR anyways: #2174 |
@Perksey I have uploaded the files to https://github.com/joskuijpers/Silk.NET/tree/testsign/src/Native/Silk.NET.SDL.Native/runtimes/osx/native |
For now I have a workaround: <Target Name="Codesign" AfterTargets="Build">
<Exec Command="codesign --force --sign - $(TargetDir)/runtimes/osx/native/libSDL2-2.0.dylib" />
</Target> |
Thank you for the super quick responses! |
Thanks for helping diagnose and fix it! |
Summary
I am unable to load the SDL API on my Mac, even though the same code works on Windows.
Steps to reproduce
Added Silk.NET.SDL to my project
Then with this code, this works fine on a Windows 64bit (Win10) machine:
On my MBP, it fails in creating the API (also when using GetApi). It exits before it reaches the line after acquiring the API.
I've looked at the resource folder: libSDL2-2.0.dylib is available in
runtimes/osx/native
, the rest of the Silk libraries are inruntimes/osx-arm64
.Comments
Maybe the library is not being found in the right place? I tried to find how the build system works for ARM but not successfully yet.
The text was updated successfully, but these errors were encountered: