Comments (34)
Thank you for the super quick responses!
from silk.net.
Thanks for helping diagnose and fix it!
from silk.net.
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.
from silk.net.
Are you using .NET Framework/Mono? That targets file does not apply otherwise.
from silk.net.
If you are not using Framework/Mono, I would be curious if you could try moving the dylib into runtimes/osx-arm64
and see if it works then. If so, then this is indeed a bug in our packaging.
from silk.net.
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
from silk.net.
Does it work if you use dotnet publish or dotnet run with a runtime identifier specified?
from silk.net.
Moved the file, but it gets put back on Run. Any tip on how I can try this properly?
from silk.net.
Does it work if you use dotnet publish or dotnet run with a runtime identifier specified?
dotnet run -r osx-arm64 -> same issue
dotnet run -r osx-x64 -> wrong CPU error (to make sure...)
dotnet run -r osx -> unknown runtime
from silk.net.
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 runtimes/osx
.)
from silk.net.
% dotnet run --no-build
A
B
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.
from silk.net.
Oh... I remembered now to look at the system Console:
Exception Type: EXC_CRASH (SIGKILL (Code Signature Invalid))
Exception Codes: 0x0000000000000001, 0x0000000000000000
Termination Reason: Namespace CODESIGNING, Code 2 Invalid Page
from silk.net.
What's the output of file runtimes/osx/native/libSDL2-2.0.dylib
?
from silk.net.
That one is both x64 and arm, but:
codesign --verify bin/Debug/net8.0/runtimes/osx/native/libSDL2-2.0.dylib
bin/Debug/net8.0/runtimes/osx/native/libSDL2-2.0.dylib: invalid signature (code or signature have been modified)
In architecture: arm64
(fine for Skia and libwgpu (from your WebGPU))
from silk.net.
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?
from silk.net.
I've signed it myself (overwriting the existing signature), and then it runs. So it is definitely the wrong signature.
from silk.net.
Did you do ad-hoc signing or use an actual certificate?
from silk.net.
Actual certificate in this case. Let me find how to sign ad-hoc...
I do seem to understand clang auto-signs when it builds on macOS, so that might explain why the wgpu binary is signed correctly.
EDIT: Ad-hoc (using '-' as certificate) also works fine
from silk.net.
'broken' signature:
Identifier=libSDL2-55554944bb706839cb39394db041064fbfb14ef3
Format=Mach-O universal (x86_64 arm64)
CodeDirectory v=20400 size=11881 flags=0x2(adhoc) hashes=362+5 location=embedded
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=0 size=12
After I signed it adhoc:
Identifier=libSDL2-2-55554944bb706839cb39394db041064fbfb14ef3
Format=Mach-O universal (x86_64 arm64)
CodeDirectory v=20400 size=11787 flags=0x2(adhoc) hashes=362+2 location=embedded
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=0 size=12
from silk.net.
Well, we also build SDL on macOS (using xcodebuild
even), so the resulting binaries should be ad-hoc signed. My current suspicion is that the signature for the Arm64 portion somehow gets corrupted when we lipo
the x64 and Arm64 binaries together. 🤔
I don't have a macOS system, though, so hard for me to investigate this.
from silk.net.
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.
A difference I see is the 'size'.
I'd think you need to sign after lipo?
Can I try building this whole thing locally?
from silk.net.
I'd think you need to sign after lipo?
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... 🤔
Can I try building this whole thing locally?
Clone the repo and do git submodule update --init --recursive build/submodules/SDL
, followed by ./build.sh sdl2
to perform the build.
- This just builds the SDL native binaries, so you shouldn't need anything except .NET SDK 7 (for NUKE) and Xcode.
- Do not clone the entire repository recursively since we have a lot of huge submodules (and some of them don't even clone cleanly).
You can find the build logic here: https://github.com/dotnet/Silk.NET/blob/main/build/nuke/Native/SDL2.cs
from silk.net.
Any chance I can forcably use dotnet sdk 8?
EDIT: Bunch of env changes got me access to 7 now. Building...
from silk.net.
Last line of the build: :)
[ERR] SDL2: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: warning: changes being made to the file will invalidate the code signature in: /Users/joskuijpers/Developer/Silk.NET/src/Native/Silk.NET.SDL.Native/runtimes/osx/native/libSDL2-2.0.dylib (for architecture x86_64)
[ERR] SDL2: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: warning: changes being made to the file will invalidate the code signature in: /Users/joskuijpers/Developer/Silk.NET/src/Native/Silk.NET.SDL.Native/runtimes/osx/native/libSDL2-2.0.dylib (for architecture arm64)
from silk.net.
You can have multiple .NET SDKs installed side-by-side. One way is to use the dotnet-install scripts, e.g. dotnet-install -v <sdk version>
.
from silk.net.
That'd do it 🤦
from silk.net.
You can have multiple .NET SDKs installed side-by-side. One way is to use the dotnet-install scripts, e.g.
dotnet-install -v <sdk version>
.
Yeah, but one install was through brew, so it kept taking the brew version. Should switch to botnet-install...
from silk.net.
Interestingly:
codesign --verify src/Native/Silk.NET.SDL.Native/runtimes/osx/native/libSDL2-2.0.dylib
succeeds
from silk.net.
Hm. I mean, it does make sense that strip
would invalidate the signature if it doesn't re-ad-hoc-sign it.
But codesign --verify
then succeeding? That's strange. Does macOS have some special-casing going on for binaries built on the current system?
from silk.net.
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
from silk.net.
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 codesign --verify
? If we can confirm that it verifies on your system only because you built it, then I think we have sufficient information to know that we indeed just need to ad-hoc sign after stripping.
from silk.net.
Alright, I can do that. I made a PR anyways: #2174
from silk.net.
@Perksey I have uploaded the files to https://github.com/joskuijpers/Silk.NET/tree/testsign/src/Native/Silk.NET.SDL.Native/runtimes/osx/native
from silk.net.
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>
from silk.net.
Related Issues (20)
- Make WindowOptions a class HOT 1
- Re-enable ANGLE native builds HOT 1
- Build Assimp with Draco support HOT 1
- Input related callbacks in GLFW cause an AccessViolationException HOT 2
- Build SwiftShader native package for `win-arm64` HOT 4
- Build Vulkan Loader native package for `win-arm64` HOT 8
- Build Vkd3d shader compiler native package for `linux-arm` and `linux-arm64`
- OpenGL glTextureParameteri symbol not found on macOS HOT 1
- Silk.NET.Core.Loader.DefaultPathResolver does not check the directory of its own assembly HOT 1
- Build DXVK native package for `linux-arm`, `linux-arm64`, and `win-arm64`
- Hi, is NV_DX_interop2 missing for WGL.Extensions? HOT 16
- Silk.NET is awesome, but no CUDA? HOT 1
- GetUniformLocation() returns -1 on Nvidia HOT 9
- SDL2 gone on publish HOT 5
- Add MeshOptimizer Bindings HOT 1
- Error when trying to use TextureStorage3D on Android HOT 5
- Changed behavior when setting GLFW StandardCursor
- MAUI project on Android using OpenXR HOT 1
- Native symbol not found (Symbol: vkCreateSwapchainKHR) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from silk.net.