- In general, binaries built just for x86 architecture will automatically be run in x86 mode
- You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
- You can force command-line apps by prefixing with
arch -x86_64
, for examplearch -x86_64 go
- Running a shell in this mode means you don't have to prefix commands:
arch -x86_64 zsh
thengo
or whatever - Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.
Not all toolchains and libraries properly support M1 arm64 chips just yet. Although automatic x86 mode works pretty well, more complex build toolchains use multiple programs that should all be building for the same architecture. Since we often use Homebrew to install these toolchains, it might be best to install the x86 "version" of Homebrew, otherwise it will install arm64 versions of things.
Just be sure to run the Homebrew install command in an x86 shell
$ arch -x86_64 zsh
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
From here, as long as you're in this x86 zsh shell, you can use Homebrew as usual to install x86 packages:
$ brew install go
You'll know it's the right version because it will install into /usr/local
instead of the usual /opt
.
This also means you can install both versions of Homebrew, and arm64 packages will live under the /opt
instance.
However, unless necessary I wouldn't recommend it because I can imagine accidentally using the wrong version
pretty easily. If you only have one version, you can install packages without entering x86 zsh, just prefix with arch -x86_64
:
$ arch -x86_64 brew install go
If you install both versions, you'll also need to specify the full path to the brew
binary as one will live under /opt
and one will live under /usr/local
.
If you duplicate your terminal application (Terminal, iTerm, etc) and set the new one to "Open using Rosetta", then you have a quick way into a terminal and shell in either mode. Thanks for the tip @tmc
Although used in the examples, if you just want to work with Go, you should be able to just use GOARCH
to produce an x86_64 binary using an arm64 go binary. This probably won't work so smoothly if you're using CGO.
Remember you can always use the file
command on a binary to see what architecture its built for.
@Iron-Ham
arch -x86_64 <command>
should do the job.