-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Support for Apple Silicon? #479
Comments
Hi @bartgrantham, I wonder if you are using Go 1.16 which is the Go version that supports Apple ARM64? I don't have an M1 machine so I haven't made sure that it works on an Apple ARM64 machine. I will find a way to get access to an Apple ARM64 machine so I can make sure it works and update you here. Update: I found Scaleway which seems to provide Apple ARM64 machine for rent which costs roughly $0.12 per hour so I will try that! |
Yes, I am running 1.16. I might look into figuring out what is going wrong later today, do you have suggestions? |
Do you have SDL2 installed? What's the the output of I searched a little and found that someone seems to fix it by running |
Appears to all be arm64, as expected. I installed with brew (
|
I am so, so, so, so sorry! I just realized I was running the amd64 version of 1.16 by accident! It worked with the correct compiler. I hope you didn't spend much time diagnosing it. Well, now that I have it compiling, are there tests you'd like me to do? |
@bartgrantham Ooh I'm glad that it worked! I'm still waiting for Scaleway to have stock of M1 servers as apparently they ran out of stock 😹 To test it, you could try running the examples at |
|
@bartgrantham Thanks for testing it! It seems like I can finally rent an M1 machine so I will check and fix those examples some time this weekend. |
Hi @bartgrantham, about those I managed to fix it by allowing the Go linker tool to be executed which maybe isn't needed if you're using After I did the above, I could run all of the examples that had the |
I tried a very simple I'm using the .pkg version of the Go toolchain, so all those binaries are already trusted. At least the couple I clicked on in |
Hmm I wonder what happened.. I tried switching my set up to use .pkg version of Go and Homebrew versions of SDL2 packages (previously I compiled them myself alongside their dependencies) and they seem to build and run still. I noticed all the examples that involve SDL2_ttf, SDL2_mix, or SDL2_image seem to crash on your set up while the ones that use SDL2 and/or SDL2_gfx don't crash. Would you happen to have a clue of what the reason could be? Could they come from different sources somehow or were they built differently? |
So strange! You are also using Big Sur, Go 1.16, and Apple Silicon?
They were all installed with Are these examples based on SDL C examples? I'm wondering if I should turn my eye toward SDL. I've assumed that homebrew published a proper and tested SDL for Apple Silicon, but maybe not? |
@bartgrantham Yup, now I'm using Big Sur, Go 1.16, and Apple Silicon. I think The Homebrew packages should be fine since I could run the examples with them.. I wonder if it helps to force build from scratch. For example, does the same thing still happen when you run If those are not the issues, I wonder if you could run |
I just did a
Just tried
Tried this, still killed.
Tried this, still killed. :( I did |
Stepping through the program with delve works. (!) Even just doing delve kicked up a security dialog about permissions, I thought it was another XCode annoyance and didn't pay close attention so I can't remember exactly what it said, I wish I had. I wonder if it's something fundamentally different about how delve builds an app than |
@bartgrantham It certainly sounds like macOS doesn't want the program to run for some reason. I don't have anything that isn't just another shot in the dark. I wish I could replicate your set-up... Could you attach the executable for |
Attached. I'm going to assume it's something on my system with Big Sur's permissions system, but if you could give it a try it would be helpful to have confirmation of this. Thank you! |
Thanks! I managed to run it even as a fresh new user. I downloaded and extracted the go-sdl2-examples repository and put the executable at the I also wrote C version of the program here: // drawing-text.c
#include <SDL.h>
#include <SDL_ttf.h>
static const char *fontPath = "../../assets/test.ttf";
static const int fontSize = 32;
int main()
{
SDL_Window *window;
TTF_Font *font;
SDL_Surface *surface;
SDL_Surface *text;
SDL_Color textColor;
SDL_Rect surfaceRect;
SDL_Event event;
SDL_bool running;
int ret = 0;
ret = TTF_Init();
if (ret != 0) {
goto out;
}
ret = SDL_Init(SDL_INIT_VIDEO);
if (ret != 0) {
goto out;
}
window = SDL_CreateWindow("Drawing text", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);
if (!window) {
ret = 1;
goto out;
}
surface = SDL_GetWindowSurface(window);
font = TTF_OpenFont(fontPath, fontSize);
textColor = (SDL_Color) {255, 0, 0, 255};
text = TTF_RenderUTF8_Blended(font, "Hello, World!", textColor);
if (!text) {
ret = 1;
goto out;
}
surfaceRect = (SDL_Rect) {400 - (text->w / 2), 300 - (text->h / 2), 0, 0};
ret = SDL_BlitSurface(text, NULL, surface, &surfaceRect);
if (ret != 0) {
goto out;
}
SDL_UpdateWindowSurface(window);
running = SDL_TRUE;
while (running) {
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
running = SDL_FALSE;
break;
}
}
SDL_Delay(16);
}
out:
TTF_CloseFont(font);
SDL_DestroyWindow(window);
SDL_Quit();
TTF_Quit();
return ret;
} If you put it inside the
After that, could you try running P.S. I accidentally closed the issue! I have re-opened it now. |
Tried your C example: also SIGKILL'ed! Ok, I think this really drives it home: something is screwy on my system. Probably with permissions but it's going to require some investigation to figure out. Thank you SO MUCH for your help in diagnosing this. I think you can probably close this issue since it appears you now have M1 support generally. I'll come back and update the issue if I figure out what's going on. |
Investigating in
What's odd is that library is signed, at least adhoc:
Still digging... |
Oh well. I guess the old joke about the computer scientist, "how about we get out of the car and get back in and see if it starts?", holds true. Here's my updated report:
Thank you do much for all the help!! I'll leave this open as a reminder to include |
Thank you too for trying all my attempts to solve it and helping me narrow down the issue! I'm really glad that you found the root of the problem and fixed it. Certainly, I will keep this issue open as well and update you here when I manage to build and put the static library in the repo for macOS M1 😃 |
Just to let you know that I managed (I think) to build darwin/arm64 static library for SDL2 which is on the However, I'm encountering stumbling blocks with the other SDL2_* libraries so I'm still working that out.. |
in theory the following should work for cross compiling to M1:
But still haven't managed to get anything to compile, using catalina as the development machine for now. |
Are the commands for compiling the static libraries available somewhere? |
Replying for myself: https://github.com/veandco/sdl2-static-library-build-scripts I'm in a process of getting my hands on a arm mac, and once it arrives I intend on having a go at getting the static libs made for arm. |
Linking to the dynamic libraries provided by homebrew on a m1pro mac seems to work. Had to do a single monkeypatch due to sdl2_ttf version mismatch. Still need to figure out the static libs |
And silly me, the monkeypatch I did was only necesserry becase I didn't update go-sdl2. |
In trying to install on an M1 machine I am getting a very, very long list of linker errors, ending with:
I'm not sure why its trying to build for x64_64, I'm just doing a straightforward install with:
as suggested in the documentation. I can see that the included static libs in
.go-sdl2-libs
don't include "darwin_amd64" versions, so that will also need addressing.Let me know if I've done something wrong here, otherwise I'm looking forward to enjoying SDL2 again in the near future.
The text was updated successfully, but these errors were encountered: