Compiling HashLink on macOS Apple Silicon

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!

11 Likes

Howdy hello! In case anybody else runs into an issue with this - the instructions here worked, but you may also need to modify CFLAGS and LIBFLAGS in the Makefile to reference /usr/local/Homebrew instead of /usr/local, since Homebrew may have placed the files inside a subdirectory.

succesfully built 1.13 version on m1 mac! thanks!
without CFLAGS and LIBFLAGS renaming everything worked perfectly.

boroda$ ./hl
HL/JIT 1.13.0 (c)2015-2022 Haxe Foundation
  Usage : hl [--debug <port>] [--debug-wait] <file>

Has there been any progress in making the VSCode debugger work on Apple Silicon now that HashLink compiles flawlessly on that architecture?