-
Notifications
You must be signed in to change notification settings - Fork 77
Description
MacOS seems to like to maintain the same architecture for executables when running them. This means that if a process running on Rosetta tries to run a universal Mach-O executable, supporting both x86_64 and arm64, MacOS will also just run it via Rosetta instead of doing so natively.
In the context of doorstop - Steam's build for MacOS is currently x86_64 and runs via Rosetta meaning if the game is launched with the doorstop run script via Steam's launch options the game will be launched via Rosetta if it's shipped with a universal binary.
I've opened #79 with a proposed fix for this.
Example:
Minimal reproducible example of this behaviour, not doorstop specific but might better demonstrate what I mean.
main.c
// Compile a universal binary:
// gcc main.c -arch arm64 -arch x86_64 -o main
#include <stdio.h>
int main() {
#if defined(__aarch64__) || defined(__arm64__)
printf("arm64\n");
#elif defined(__x86_64__)
printf("x86_64\n");
#else
printf("unknown\n");
#endif
return 0;
}
When running through my native terminal we get the expected arm64 version:
❯ ./main
arm64
Similarly if we launch it indirectly via sh
. (native terminal => sh gets launched natively => main gets launched natively)
❯ /bin/sh -c "exec ./main"
arm64
But if we use arch
to run sh
via Rosetta, the exec will also launch the executable via Rosetta:
❯ arch -x86_64 /bin/sh -c "exec ./main"
x86_64