Skip to content
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

Compilation fails on native silicon. #21

Open
jdoege opened this issue Aug 29, 2021 · 3 comments
Open

Compilation fails on native silicon. #21

jdoege opened this issue Aug 29, 2021 · 3 comments

Comments

@jdoege
Copy link

jdoege commented Aug 29, 2021

Compiling on an M1 Macbook pro, the scrollWheelUpdate function (around line 4794) uses a ABI function called objc_msgSend_fpret. This is an x86_64 related function not available on aarch64. On a guess, I tried replacing it with just objc_msgSend and the demo with the colorful boxes seemd to work. I have no idea if the scrollWheelUpdate function works. I then replaced that with this:

#if defined(__aarch64__) // change for native Apple silicon
            double deltaY = ((double (*)(id, SEL))objc_msgSend)(theEvent, deltaYSel);
#else
            double deltaY = ((double (*)(id, SEL))objc_msgSend_fpret)(theEvent, deltaYSel);
#endif

and things still seem to work. This was the only change needed to get it to compile. An unrelated warning remains, however:

olcPixelGameEngine.h:3290:14: 'SetDecalMode' overrides a member function but is not marked 'override'

@MumflrFumperdink
Copy link
Owner

Hi!

Thank you for suggesting this update. Unfortunately, I do not have an M1 MacBook, so I cannot test anything out in that regard, although I suspect that this replacement does not return an actual double and more of a random bit of memory. If you can test objc_msgSend and it does not work with scrolling, can you try replacing it with objc_msgSend_fpret2 (don't know if it works, just seen it out there).

I just want to see if this change actually functions properly. A lot of the information on this stuff online only talks about PowerPC (PPC) macs vs intel (i386) macs, none talk about M1 macs, so I don't have a lot to go off of. Again, thank you for suggesting this!

@jdoege
Copy link
Author

jdoege commented Aug 31, 2021

I found this: https://www.mikeash.com/pyblog/objc_msgsends-new-prototype.html

fpret is said to be an x86-64 thing. Maybe casting it will be sufficient?

If I ever get to using the scroll wheel, I guess I'll find out.

I am happy to test anything you do on an M1.

@MumflrFumperdink
Copy link
Owner

Yeah, it would be great if you could test this. Scrolling isn't essential, but it would be very nice if it worked on all Macs.

MumflrFumperdink added a commit that referenced this issue Oct 24, 2021
The objc_msgSend_fpret function needs to be replaced with the objc_msgSend function for M1 macs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants