higan-emu / higan

higan is a multi-system emulator focused on accuracy, preservation, and configurability.
Other
1.19k stars 112 forks source link

Update the CI script to build fat x86_64/ARM binaries for macOS #149

Open sofakng opened 3 years ago

sofakng commented 3 years ago

Are there any efforts to port this to the Apple M1 chip?

I'm not sure if there is x86 assembly (I'm guessing yes?) but I would be great to have a native version for better optimizations, etc.

Screwtapello commented 3 years ago

When the Apple M1 chip was first released, somebody on the official discord bought one and compiled higan (and bsnes), and it just worked first time, no porting needed.

A thing we could do is to make sure macOS binaries (nightlies and releases) include both x86_64 and ARM support. I'm not sure what's involved in that (I assume step 1 is for GitHub to update their XCode version, I don't know if they've already done that), but if it's not too complex I would accept a PR for that.

jchv commented 3 years ago

There is some assembly in libco, but it doesn't matter since libco is already ported to many architectures including AArch64.

The WIP n64 and psx JITs are both hardcoded using x86 assembly. Those cores need to be excluded from the build until the JIT is ported. (I have done some partial work on this, but haven't pushed it anywhere.)

Otherwise Higan compiles perfectly fine on M1. You do need to specify local=false to Make because otherwise the Makefile will try to apply -march=native and it won't work.

sofakng commented 3 years ago

Thanks ... I've modified the GNUMakefile (inside byuu) to set local to false. It compiles several files but then errors:

Compiling higan/n64/interface/interface.cpp ...
In file included from ../higan/n64/interface/interface.cpp:1:
In file included from ../higan/n64/n64.hpp:7:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/nmmintrin.h:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/smmintrin.h:13:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/tmmintrin.h:13:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/pmmintrin.h:13:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/emmintrin.h:13:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/xmmintrin.h:13:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/mmintrin.h:33:5: error: 
      use of undeclared identifier '__builtin_ia32_emms'; did you mean
      '__builtin_isless'?
    __builtin_ia32_emms();
    ^

Here is the full log: log.txt

jchv commented 3 years ago

Ah, sorry; I mean to say that the n64 and ps1 cores need to be manually removed. Set the cores variable to remove the ps1 and n64 cores. Just as a note, you do not need to edit the Makefile; you can specify these things as arguments to make, like:

make -j12 local=false cores="sfc gb gba ..."

(Good low hanging fruit would be automatically not including ps1 and n64 on platforms where the JIT isn't ported yet.)

sofakng commented 3 years ago

Oh, I'm really sorry... I missed the part where you mentioned excluding the PSX and N64 cores.

I've excluded them and it compiles fine. I'll go ahead and close this issue. Thanks so much for the help!

sofakng commented 3 years ago

Sorry - I've re-opened this issue. I see that you changed the title and it would be great to have ARM binaries (ie. Apple M1) to be built automatically. Thanks!