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

Building lime.ndll on Apple Silicon Mac #1640

Closed
8 tasks done
tobil4sk opened this issue Feb 27, 2023 · 13 comments
Closed
8 tasks done

Building lime.ndll on Apple Silicon Mac #1640

tobil4sk opened this issue Feb 27, 2023 · 13 comments

Comments

@tobil4sk
Copy link
Member

tobil4sk commented Feb 27, 2023

Created this to keep track of the status of native Apple Silicon builds of the lime.ndll.

Todo:

After applying these patches, it is possible to build the ndll and build/run projects as expected.

@player-03
Copy link
Contributor

For any changes involving submodules, please start with the 8.2.0 branch and submit changes to that branch.

The branch includes a build guide that may help debug, but still feel free to ask if not.

@tobil4sk
Copy link
Member Author

tobil4sk commented Mar 1, 2023

Created a new branch based on 8.2.0 as suggested. The linker error was due to a problem with the libpixman patch, which I have explained in more detail here: openfl/libpixman#1.

I've created a new PR with the 8.2.0 based branch, which allows for a successful build of the lime.ndll on arm64 Mac with haxelib run lime rebuild mac -DHXCPP_ARM64: #1642. This also requires the most recent development version of hxcpp. I've pasted the installation instructions in case anyone is interested:

Expand for detailed installation instructions
# install updated hxcpp with arm64 building support
haxelib git hxcpp https://github.com/HaxeFoundation/hxcpp.git

# clone forked version of lime from PR #1642
git clone https://github.com/soccertutor/lime.git --branch fix/m1-build-ndll --recursive

# set lime library path
haxelib dev lime ./lime

# rebuild lime
haxelib run lime rebuild mac -DHXCPP_ARM64

Since the ndll is still loaded from the Mac64 path for now, we had to move the new arm64 binary:

cd $(haxelib libpath lime)
rm ndll/Mac64/lime.ndll
cp ndll/MacArm64/lime-64.ndll ndll/Mac64/lime.ndll

We also ran into this issue: #1750. We managed to work around it by creating symlinks in /usr/local/bin and /usr/local/lib, see:
https://brettterpstra.com/2022/09/28/homebrew-and-slash-usr-slash-local-slash-bin-on-m1-macs/
.

UPDATE: It looks like /usr/local/lib may no longer be a default path for dyld anymore, see #1750.

Despite having to use these awkward workarounds, openfl test mac -DHXCPP_ARM64 now successfully runs our project. UPDATE: Seems to only build successfully with the -clean flag.

@tobil4sk tobil4sk changed the title Building lime.ndll on M1 Mac Building lime.ndll on Apple Silicon Mac Mar 1, 2023
@JonnycatMeow
Copy link

how whould i build the macos arm64 dll on a x86_64 and i have xcode

@ido-pluto
Copy link

For some reason after installing the lime fork and doing all the steps, I got a segmentation fault

openfl test html5 -DHXCPP_ARM64
Could not link to neko.
Called from lime/_internal/backend/native/NativeCFFI.hx line 613
Called from lime/system/CFFI.hx line 171
Called from lime/system/CFFI.hx line 294
Uncaught exception - Segmentation fault 

If I put the MacArm64/lime-64.ndll into ndll/Mac/lime.ndll
Is seems to work, but only for:

openfl test mac -DHXCPP_ARM64

@tobil4sk
Copy link
Member Author

openfl test html5 -DHXCPP_ARM64

@ido-pluto The html5 target doesn't use hxcpp or lime.ndll so there is no need to build here with the -DHXCPP_ARM64 flag. However, it does seem odd that this causes a segmentation fault, there could be something wrong with the conditional compilation in my PR.

@player-03
Copy link
Contributor

Lime does use the ndll when building, which could explain the error.

If so, there's a second solution: the -eval flag skips lime.ndll when building. The flag was only recently merged into 8.2.0-Dev, so you'd need to pull that first.

@bguiz
Copy link

bguiz commented Dec 1, 2023

👋 Ran into this as well - any closer to this being resolved?

@ido-pluto
Copy link

Use the x86 version of haxe without brew (from the website). This works without any issue

@bguiz
Copy link

bguiz commented Dec 1, 2023

Ah will give this a go - thanks!

Use the x86 version of haxe without brew (from the website).

Related: Any chance we could get the x86 version on homebrew?

@joshtynjala
Copy link
Member

Related: Any chance we could get the x86 version on homebrew?

I learned a while back that there are now two different versions of Homebrew. One for Intel and one for Apple Silicon, and you can actually install both on the same computer.

I needed the Intel version on my M1 Mac to locally build HashLink binaries a while back, and I mentioned what I did to install Intel Hombrew on the Haxe forums. Maybe it'll help you out.

https://community.haxe.org/t/compiling-hashlink-on-macos-apple-silicon/3150

tobil4sk referenced this issue May 10, 2024
This seems to be required with Xcode 15, but was not required previously
@tobil4sk
Copy link
Member Author

tobil4sk commented Jul 5, 2024

Now that the PRs have been merged, it is possible to build lime.ndll on apple silicon and build and run projects, with the following requirements:

  • Universal mac build of haxe (4.3.5 or above), or install via arm64 homebrew.
  • Lime from git:
haxelib git lime https://github.com/openfl/lime
  • swf from git
haxelib git swf https://github.com/openfl/swf
  • hxcpp from git
haxelib git hxcpp https://github.com/HaxeFoundation/hxcpp

Then run:

lime rebuild swf
lime rebuild mac

So I think it's time to close this issue!

@tobil4sk tobil4sk closed this as completed Jul 5, 2024
@tobil4sk
Copy link
Member Author

tobil4sk commented Jul 9, 2024

how whould i build the macos arm64 dll on a x86_64 and i have xcode

Also, in the develop branch you can now pass the -arm64 flag to do this:

lime rebuild mac -arm64

Same requirements as above (particularly for hxcpp).

@Just-Feeshy
Copy link
Contributor

Love to see this completed

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

7 participants