Trying to Understand Arch Behavior of Fat Binaries on M3 Mac
Aug 05, 20242 min read
Installing Python 3.12 on macOS using the official python.org-provided macOS universal installer provides a fat python3.12 binary:
On my M3 MacBook Air, opening iTerm starts zsh running as a native arm64 process:
Running Python in that environment defaults to executing the arm64 one, as expected:
We can force zsh to run under x86_64 emulation (this simulates a scenario where a parent process provides only x86_64 arch):
Running Python in the same way as above in this environment will now choose the x86_64 arch from the fat binary:
This is similar to using the python3.12-intel64 binary (which is a x86_64-only binary, as it says on the tin) to run the universal binary in a subprocess — the universal binary will choose the x86_64 arch by default:
To get the subprocess to choose the arm64 arch from a x86_64 parent process, we need to force it: