The current instructions to build HashLink on macOS don’t work on new Apple Silicon CPUs. However, I think that I’ve figured out how build for x86_64 on Apple Silicon.
First, install the Intel version of Homebrew using the following command:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
You can have both Apple Silicon and Intel versions of Homebrew installed at the same time because the Apple Silicon version uses /opt/homebrew and the Intel version uses /usr/local/.
Once you get the right version of Homebrew, you need to run slightly different commands when building HashLink.
When the HashLink build instructions say to run
brew bundle, you must run it with the Intel version (you might not need the
arch -x86_64 part of this command, but I used it to be safe)
arch -x86_64 /usr/local/bin/brew bundle
Then, when running
make, you must add
arch -x86_64 before it (the arch part definitely not optional on this command) to ensure that it compiles for Intel instead of Apple Silicon.
arch -x86_64 make
When it builds successfully, you can run
./hl to verify that it worked. Here’s the output that I see:
HL/JIT 1.12.0 (c)2015-2020 Haxe Foundation Usage : hl [--debug <port>] [--debug-wait] <file>
Hopefully, this helps someone else!