2 min read | by Jordi Prats
On Apple Silicon-based Macs we have the arch command that will allow us to to run a selected architecture of a universal binary. By default, the operating system will select the architecture that most closely matches the processor type.
The arch command can be used to alter the operating system's normal selection order.
Rosetta is a software translation layer developed by Apple for their macOS operating system that allows Macs with Apple silicon (M1, M2...) to run software that was built for Intel-based Macs. This is accomplished by translating the instructions in the software from the Intel x86-64 architecture to the ARM64 architecture used by Apple silicon.
Rosetta is not a virtual machine or an emulator in the traditional sense, as it doesn't run the original instructions directly on the new processor. Instead, it translates them on the fly as needed.
We can test it by running the uname -m
command (that returns the architecture we are running) with the arch command selecting first x86_64 and then arm64:
$ arch -x86_64 /bin/bash -c 'uname -m'
x86_64
$ arch -arm64 /bin/bash -c 'uname -m'
arm64
Some binarnies might not be build for the architectures we need, we can use lipo to test it:
$ lipo -info /bin/bash
Architectures in the fat file: /bin/bash are: x86_64 arm64e
Posted on 30/08/2023