8bitbubsy / ft2-clone

Fasttracker 2 clone for Windows/macOS/Linux
https://16-bits.org
BSD 3-Clause "New" or "Revised" License
736 stars 48 forks source link

Support Apple M1 #14

Closed odaki closed 3 years ago

odaki commented 3 years ago

Hello, Olav Sørensen.

First of all, I want to thank you for your continuous development. I admire you and your project.

I recently bought a development machine with an Apple M1 processor. The macOS version you are distributing is working fine. I built it natively on arm64 so that it would run more optimally, and I tried to make it a Universal binary.

You don't need to merge it, but I will tell you the work I did in the form of a pull request for your reference.

I have made the built binaries available in my repository. https://github.com/odaki/ft2-clone/releases/tag/v1.42-private

Thanks.

8bitbubsy commented 3 years ago

Pretty sure the .gitignore is needed in the MacOS folder, or else you won't get that folder when you do a pull of the whole branch (because it's empty), and thus the compiler can't output its binaries there.

odaki commented 3 years ago

Thanks for the explanation. I was thinking there must be a reason for this, but now I understand.

I'll try to create it in the build script with mkdir -p if it doesn't exist, what do you think?

8bitbubsy commented 3 years ago

That's a better solution than having the .gitignore file, thanks.

8bitbubsy commented 3 years ago

Will the universal binary compile on macOS Catalina on an x86_64 mac? I don't have an M1 Mac, and I don't want to merge stuff without testing it first.

odaki commented 3 years ago

Will the universal binary compile on macOS Catalina on an x86_64 Mac?

Yes.

build_on_catalina

The build log is attached for your reference. build.log

I don't have an M1 Mac, and I don't want to merge stuff without testing it first.

I agree with your thoughts and want to respect them. If you are able to build on the M1 Mac, please support Universal binaries.

Please keep up the great work.

Thank you.

8bitbubsy commented 3 years ago

I will of course make a universal binary and support M1 if this works. =) So all I need is MacOSX11.1.SDK? I assume that SDL2.framework (latest version) is universal as well and works on M1 too?

odaki commented 3 years ago

I will of course make a universal binary and support M1 if this works. =)

It it very nice to hear that!

So all I need is MacOSX11.1.SDK?

You will also need arm64 compatible clang, but if you are using Xcode 12.3, then you are ready for the MacOS11.1 SDK and clang.

odaki@MBP13 ft2-clone % xcodebuild -version                                        
Xcode 12.3
Build version 12C33

I assume that SDL2.framework (latest version) is universal as well and works on M1 too?

Yes, it works fine on M1 too.

As you wrote, SDL2 has been a universal binary since it was released late last year.

odaki@MBP13 ft2-clone % lipo -detailed_info /Library/Frameworks/SDL2.framework/SDL2
Fat header in: /Library/Frameworks/SDL2.framework/SDL2
fat_magic 0xcafebabe
nfat_arch 2
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    capabilities 0x0
    offset 16384
    size 1573360
    align 2^14 (16384)
architecture arm64
    cputype CPU_TYPE_ARM64
    cpusubtype CPU_SUBTYPE_ARM64_ALL
    capabilities 0x0
    offset 1605632
    size 1206464
    align 2^14 (16384)
odaki@MBP13 ft2-clone % 
8bitbubsy commented 3 years ago

Alright, cool. I'll look into this later, maybe in a few days. Btw, I don't really want to merge your pull request, as I want to have different filenames, and I want to update the old macos script to fetch version number and make a DMG like your new one.

alexmyczko commented 3 years ago

odaki you going to create brew formulas?

odaki commented 3 years ago

@8bitbubsy You don't need to merge my works. Please follow your own rules, and keep it concise and consistent. I like your simple and clean programs and methods.

odaki commented 3 years ago

@alexmyczko I have no plans to make brew formulas. I'm a brew user and I like brew, but I don't understand how to write formulas.

8bitbubsy commented 3 years ago

I can't get it to compile on my MacBook Pro w/ Catalina using make-macos-universal.sh. It gives many errors about not finding include headers. Do I really need those SDK files? And where can I get them?

EDIT: I changed the x86_64 build to use MacOSX.sdk, and now it compiles.

odaki commented 3 years ago

You can get the old sdk by XcodeLegacy. https://github.com/devernay/xcodelegacy

8bitbubsy commented 3 years ago

I have now added the new make-script to the new v1.43 version of the FT2 clone released just now, and I also added the universal binary on 16-bits.org.

I also gave the pt2-clone the same treatment.