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

Allow for native Apple M1 ARM builds! #1298

Merged
merged 6 commits into from
Mar 12, 2024

Conversation

bluebandit21
Copy link
Member

In 2020, Apple introduced their own ARM chip, the M1, which replaced the Intel x86_64 chips they had been using.
Consequently, all modern macs run on ARM processors and run ARM code.

Etterna has only been able to work on them because Apple provided Rosetta v2, a translation layer allowing our x86_64 mac builds to be dynamically JIT-d into ARM code, which can be run.

However, this JIT process has some overhead and produces less efficient code than code compiled for the target processor in the first place, and more importantly Rosetta v2 will have support dropped for it at some point in the future.

This PR allows Etterna to be built for Apple Silicon targets, and is an important first step in the process of automatically generating Apple-Silicon-compatible releases.

The other two major components are telling GHA to build for Apple Silicion targets, and notarizing our executable so it can actually be distributed (see: #1292)

Depends-on: #1297 , as without it Etterna will not compile for macOS at all, even for a x86_64 target.

The version of the macOS sdk we're using doesn't implement it,
 see more detailed in-code comment included in this commit
First (pretty obviously), don't set the preprocessor
 define "CPU_X86_64" if we're not actually targeting
 x86_64 :)

Secondly, don't set some linker flags that seem to
 cause problems on aarch64 builds -- with them
 present, launching the binary under lldb exits with
 "Malformed Mach-O file" and regular launches fail
 with mysterious error codes.
-- Having tested myself, it seems to work just fine
 without them set; I believe that even for x86_64
 they were added by accident! (See in-code comment)
If we're targeting a native M1 aarch64 build, obviously we don't
 want to tell FFMpeg to build for x86_64 :)
It doesn't make set a deployment target earlier than the first OS
 that actually supports the CPU :)
We only actually use cpuid.h on Linux, and including it causes
 a problem for M1 builds because it doesn't exist outside x86_64!
The calc code uses x86_64 SIMD instrinsics for speed.
However, those are unavailable on ARM.

SSE2Neon provides ARM equivalents of each missing instruction
 using ARM's Neon SIMD instructions, providing equivalent
 speed for the majority of x86_64 SIMD instructions :)
@poco0317 poco0317 merged commit a75c40a into etternagame:develop Mar 12, 2024
4 of 11 checks passed
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 this pull request may close these issues.

2 participants