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

Can not compile using lime on Apple Silicon - possibly wrong arch for neko installed? #10937

Closed
winterismute opened this issue Jan 22, 2023 · 6 comments · Fixed by #10996
Closed
Milestone

Comments

@winterismute
Copy link

Hello there, I am on an M2 machine and Ventura 13.1, and I am trying to compile a haxeflixel game. I have to say I have setup haxeflixel with no problems on a previous M1 machine with I think Monterey, but it is not working here.
What I do is essentially:

brew install haxe

And then

haxelib install lime
haxelib install openfl
haxelib install flixel
haxelib install flixel-addons

as suggested in the page https://haxeflixel.com/documentation/install-haxeflixel/ . I expose lime in the meantime to /usr/local/bin (in the way lime setup suggests), but what I get from eg. lime test html5 is:

Called from lime/_internal/backend/native/NativeCFFI.hx line 609
Called from lime/system/CFFI.hx line 172
Called from lime/system/CFFI.hx line 306
Uncaught exception - Could not find NekoAPI interface.
Called from ? line 1
Called from CommandLineTools.hx line 1904
Called from CommandLineTools.hx line 22
Called from a C function
Called from CommandLineTools.hx line 125
Called from CommandLineTools.hx line 640
Called from lime/tools/PlatformTarget.hx line 98
Called from HTML5Platform.hx line 489
Called from lime/text/Font.hx line 139
Called from lime/text/Font.hx line 462
Called from a C function
Called from /Users/runner/hostedtoolcache/haxe/4.2.5/x64/std/neko/Lib.hx line 43
Uncaught exception - load.c(237) : Failed to load library : /Users/MYUSER/Library/haxelib/lime/8,0,0//ndll/Mac64/lime.ndll (dlopen(/Users/MYUSER/Library/haxelib/lime/8,0,0//ndll/Mac64/lime.ndll, 0x0001): tried: '/Users/MYUSER/Library/haxelib/lime/8,0,0//ndll/Mac64/lime.ndll' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/MYUSER/Library/haxelib/lime/8,0,0//ndll/Mac64/lime.ndll' (no such file), '/Users/MYUSER/Library/haxelib/lime/8,0,0//ndll/Mac64/lime.ndll' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/Users/MYUSER/Library/haxelib/lime/8,0,0/ndll/Mac64/lime.ndll' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/MYUSER/Library/haxelib/lime/8,0,0/ndll/Mac64/lime.ndll' (no such file), '/Users/MYUSER/Library/haxelib/lime/8,0,0/ndll/Mac64/lime.ndll' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')))

Do you have any idea why this might be happening?

@tobil4sk
Copy link
Member

The problem is that it is mistaking the architecture for x86_64, so it is trying to load from the Mac64 directory which causes the error.

Haxe generates the neko code which determines the architecture and from there decides what path the ndll should be loaded from. This can be found here:

(EIf (call p (loadp "sys_is64" 0) [],op "=" es (op "+" es (int p 64)),None),p);

So it makes use of the sys_is64 neko function, which is defined here:
https://github.com/HaxeFoundation/neko/blob/adc9215289995b2ae983c2b1974cf07c76695c69/libs/std/sys.c#L228-234

As you can see, the value returned depends on the define NEKO_64BITS, which is defined here:
https://github.com/HaxeFoundation/neko/blob/adc9215289995b2ae983c2b1974cf07c76695c69/vm/neko.h.in#L77-L79

So what we need is another function in neko that checks for arm64 architectures, and if it returns true, load from MacArm64 instead of Mac64 (assuming this is the correct directory).

Lime.ndll (or any other ndll) also has to be generated in the correct directory for the correct architecture. This depends on whether hxcpp has the required support for arm64, which may already be the case. This can be tested by compiling lime.ndll from source on an M1 system and confirming whether a ./ndll/MacArm64/lime.ndll file is created.

@tobil4sk
Copy link
Member

tobil4sk commented Mar 1, 2023

With some hacky workarounds it is now possible to build lime projects on Apple Silicon. See openfl/lime#1640 for more information.

@winterismute
Copy link
Author

Hi @tobil4sk, thank you a lot for having looked into this!
I was reading openfl/lime#1640, it seems it suggests doing haxelib run lime rebuild mac -DHXCPP_ARM64 in order to force a recompilation of lime, however that does not seem to work on my laptop, maybe because it only works after your changes are integrated and released? My haxelib and lime come from brew, my lime version is 8.0.1.

@tobil4sk
Copy link
Member

tobil4sk commented Mar 2, 2023

Yes, it requires installing lime from the forked version or waiting for the changes to be merged. I've updated my last comment in the openfl/lime#1640 thread with more detailed instructions about how to install.

@winterismute
Copy link
Author

@tobil4sk This is now part of 4.3 which has been released, no? Sorry the bother...

@tobil4sk
Copy link
Member

tobil4sk commented Apr 9, 2023

The Haxe/Neko side of this has been handled in 4.3.0, but Lime will still need some modifications to properly support building/running projects Apple Silicon. So the rest of this is being tracked in openfl/lime#1640.

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

Successfully merging a pull request may close this issue.

3 participants