OpenJK icon indicating copy to clipboard operation
OpenJK copied to clipboard

Add support for compiling on Apple m1

Open jaiko opened this issue 2 years ago • 7 comments

This adds support for compiling on Apple M1 processors.

Apple also now requires all applications on M1 to be signed, so the following will need to be run on the bundle:

codesign --force --deep --sign - openjk.aarch64.app

jaiko avatar Jan 28 '22 21:01 jaiko

@xycaleth this is working extremely well on my m1 Mac.

jaiko avatar Jan 31 '22 18:01 jaiko

This worked for me too, although the dylibs were not added to the app bundles. After manually adding it worked fine.

shinra-electric avatar Feb 01 '22 01:02 shinra-electric

@shinra-electric they were getting added for me on make install. How were you building it?

jaiko avatar Feb 01 '22 03:02 jaiko

Sorry, I just did make rather than make install.

But I just tried it now, and the install part failed:

`CMake Error at code/cmake_install.cmake:49 (file): file INSTALL cannot make directory "/usr/local/JediAcademy/openjk_sp.aarch64.app": No such file or directory. Call Stack (most recent call first): cmake_install.cmake:44 (include)

make: *** [install] Error 1`

Edit: I added -DCMAKE_INSTALL_PREFIX=/path/to/GameData to the cmake command (as well as release mode) and it built correctly.

I then codesigned as above, and it worked fine.

Sorry for the bother.

shinra-electric avatar Feb 01 '22 12:02 shinra-electric

compiled openJK for m1 mac multiplayer works like a charm but once i start the singleplayer and press begin game it crashes without any logs

https://user-images.githubusercontent.com/90422656/153231383-bfaa13d7-1f19-47e8-9c6b-eccfff474cc5.mp4

this is what happens after freeze when i open from terminal openjk_sp.aarch64.app/Contents/MacOS/openjk_sp.aarch64

------- Game Initialization ------- gamename: OpenJK gamedate: Feb 9 2022 ^3WARNING: Event out of range on BOTH_RUN4 in models/players/_humanoid/animevents.cfg tty]Assertion failed: (keyFrame < animations[animNum].numFrames), function ParseAnimationEvtBlock, file NPC_stats.cpp, line 501. ----- CL_Shutdown ----- tty]openjk_sp.aarch64(16064,0x104568580) malloc: error for object 0x125892200: pointer being freed was not allocated openjk_sp.aarch64(16064,0x104568580) malloc: set a breakpoint in malloc_error_break to debug openjk_sp.aarch64(16064,0x104568580) malloc: Incorrect checksum for freed object 0x125892200: probably modified after being freed. Corrupt value: 0x0 openjk_sp.aarch64(16064,0x104568580) malloc: *** set a breakpoint in malloc_error_break to debug

Reinstalled all the gamefiles from steam and got this error:

image

justindx7 avatar Feb 09 '22 15:02 justindx7

The issue @justindx7 is experiencing is probably related to the vm entryPoint being declared as function with variadic parameters in the engine while the module expects fixed parameters for vmMain (the used entryPoint). Apple warns about this: https://developer.apple.com/documentation/apple-silicon/addressing-architectural-differences-in-your-macos-code

I ran into this in December when I had the chance to compile and test a few things on an M1 Mac. This was my commit back then: https://github.com/Daggolin/OpenJK/commit/5c7bd3955fc495f2779033a317cc2af972fecc0b

Daggolin avatar Feb 09 '22 18:02 Daggolin

Already been fixed in ioquake3, quake3e, etlegacy and ETe and probably iortcw as well. Should be easy to incorporate the fix @Daggolin

ensiform avatar Feb 09 '22 22:02 ensiform

I can confirm locally that the PR is working. @jaiko could you rebase your branch on main again please? Who would be able to review (and land) the PR?

dirkschulze avatar Oct 24 '22 20:10 dirkschulze

can someone provide the makefile & command necessary to run make install here ?

also has an m1 compatible fix been merged yet? @jaiko 's branch seems to be the latest one but seems to be behind now

chris-larsen avatar Apr 27 '23 02:04 chris-larsen

Obsoleted by #1164

Razish avatar Sep 17 '23 04:09 Razish