-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Question/Enhancement: Native Apple Silicon builds for macOS? #2985
Comments
Definitely something on the roadmap, as I use arm64 mac for a lot of my development! |
Managed to create a universal build by using For anyone curious, I have created a script to automate the process. Sept. 26 update: You no longer need to do the madness above, the FunkinCrew lime fork was updated for ARM64 support and already includes NDLLs for ARM64 and Intel, and Haxe 4.3.5+ is now Universal on macOS. #!/bin/bash
# This is a script that will build Friday Night Funkin' twice. One for Apple Silicon (ARM), and one for Intel (x86_64).
# The resulting builds are combined using `lipo` to output a Universal (ARM+Intel) build.
# Pre-build: Cleanup build files.
if [ -d export/release/macos/bin/Funkin.app ]; then
rm -r export/release/macos/bin/Funkin.app
fi
if [ -d export/release/macos/bin/Funkin-ARM.app ]; then
rm -r export/release/macos/bin/Funkin-ARM.app
fi
if [ -d export/release/macos/bin/Funkin-Intel.app ]; then
rm -r export/release/macos/bin/Funkin-Intel.app
fi
# Step 1: Move the ARM NDLL to the Intel folder (Mac64).
# We use the ARM lime library for compiling on Intel due to linking issues with ApplicationMain
if [ ! -f .haxelib/lime/git/ndll/Mac64/lime-intel.ndll ]; then
mv ".haxelib/lime/git/ndll/Mac64/lime.ndll" ".haxelib/lime/git/ndll/Mac64/lime-intel.ndll"
fi
cp ".haxelib/lime/git/ndll/MacArm64/lime.ndll" ".haxelib/lime/git/ndll/Mac64/lime.ndll"
# Step 2: Build the ARM version.
echo -e ""
echo -e "\033[1;33m\033[1m/***************************************\\"
echo -e " ***** COMPILING THE ARM BUILD *****"
echo -e "\\***************************************/\033[0m"
echo -e ""
lime build mac
if [ ! -f export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin ]; then
echo -e "\033[1;31m\033[1mThe ARM build has failed! Exiting...\033[0m"
exit 1
else
mv export/release/macos/bin/Funkin.app export/release/macos/bin/Funkin-ARM.app
fi
# Step 3: Build the Intel Version.
echo -e ""
echo -e "\033[1;33m\033[1m/***************************************\\"
echo -e " ***** COMPILING THE INTEL BUILD *****"
echo -e "\\***************************************/\033[0m"
echo -e ""
arch -x86_64 lime build mac -DHXCPP_X64
if [ ! -f export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin ]; then
echo -e "\033[1;31m\033[1mThe Intel build has failed! Exiting...\033[0m"
exit 1
else
mv export/release/macos/bin/Funkin.app export/release/macos/bin/Funkin-Intel.app
fi
# Step 4: COMBINE!
# This is a mess, I know.
echo -e ""
echo -e "\033[1;33m\033[1m/***************************************\\"
echo -e "***** MAKING A UNIVERSAL BINARY *****"
echo -e "\\***************************************/\033[0m"
echo -e ""
# Make a copy of the ARM build, this will be the resulting Universal build.
cp -R export/release/macos/bin/Funkin-ARM.app export/release/macos/bin/Funkin.app
# Remove the ARM binaries inside the ARM copy.
rm export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin
rm export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll
# Move the ARM libraries inside Funkin-ARM to the Universal build.
# This will have the "-ARM" suffix.
cp export/release/macos/bin/Funkin-ARM.app/Contents/MacOS/Funkin export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin-ARM
cp export/release/macos/bin/Funkin-ARM.app/Contents/MacOS/lime.ndll export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll-ARM
# Move the Intel libraries inside Funkin-Intel to the Universal build.
# This will have the "-Intel" suffix.
cp export/release/macos/bin/Funkin-Intel.app/Contents/MacOS/Funkin export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin-Intel
cp .haxelib/lime/git/ndll/Mac64/lime-intel.ndll export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll-Intel
# Use `lipo` to create Universal binaries.
# This is done by combining ARM and Intel versions of `lime.ndll` and `Funkin` respectively.
lipo -create -output export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin-Intel export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin-ARM
lipo -create -output export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll-Intel export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll-ARM
# Remove the leftover files.
rm export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin-ARM
rm export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll-ARM
rm export/release/macos/bin/Funkin.app/Contents/MacOS/Funkin-Intel
rm export/release/macos/bin/Funkin.app/Contents/MacOS/lime.ndll-Intel
# Remove the separate ARM and Intel builds.
rm -r export/release/macos/bin/Funkin-ARM.app
rm -r export/release/macos/bin/Funkin-Intel.app
# Success!
echo -e "\033[1;32mSuccess! You should see a Universal version of Funkin.app in export/release/macos/bin\033[0m"
# Post-build: Rename the Intel NDLL.
mv ".haxelib/lime/git/ndll/Mac64/lime-intel.ndll" ".haxelib/lime/git/ndll/Mac64/lime.ndll" |
hell yah |
but how do i build it for arm64 on a intel computer? because i want to make a universal build as well |
I only made this script with ARM64 Macs in mind. Lime allows you to cross-compile to arm64 using the |
i know but i wanna do it for other mods |
I've been able to compile for arm64 now :) I have a branch on our internal repo that I've been getting fixed up and all that. I'll have to look into all that |
Sweet! Glad to see arm64 compilation went smoothly. |
yeah i actually develop and test FNF on my apple silicon laptop probably more than I do at my windows machine by now haha! i actually completely forgot to update the apple silicon for the update though... lol.. i was getting trolled with lipo lol... I think i will close this issue however since its like 99% done and just needs to compile / publish a universal version and figure out that workflow! |
Please check for duplicates or similar issues before creating this issue.
What is your suggestion, and why should it be implemented?
With the recent changes to lime (see the 8.2.0-Dev branch and #1640), building lime NDLL's and compiling projects on native ARM is now possible.
By porting over some changes from the FunkinCrew fork of lime, I managed to hack together a build for ARM!
So I decided to compare the 2 (Native ARM vs Rosetta Intel), both of them are running off of the
main
branch.Here are the compilation times, I am using a modified version of lime which is based of the 8.2.0-Dev branch, with changes ported from the FunkinCrew fork in order to make Funkin' compile properly.
ARM (959.05 Seconds):
Intel (3817.11 Seconds):
Unfortunately, aside from compilation, there kind of(?) actually isn't much to talk about in terms of performance. Both of them seem to mostly run in the same FPS. With the small differences in FPS being confined to stuff like the Freeplay Menu.
One (significant?) performance boost I did encounter was with the chart editor... mainly from spamming notes in "Live Input Mode"
ChartEditorSpam_APPLESILICON.mp4
ChartEditorSpam_INTEL.mp4
The text was updated successfully, but these errors were encountered: