Building haxe on mac m1

I’m trying to build haxe from source on mac m1.
I’m using these instructions: haxe/BUILDING.md at development · HaxeFoundation/haxe · GitHub
And I’m getting error:
mbedtls_stubs.c:23:10: fatal error: 'mbedtls/config.h' file not found

I’ve installed mbedtls with homebrew and I have this file in “/opt/homebrew/include/mbedtls/debug.h”
I think I need to pass C include path to dune, but I cannot find a way to do this. Also I will need to pass library path, so that it will find .a files for the libraries.

I’ve tried creating C_INCLUDE_PATH=/opt/homebrew/include environment variable but this did not help.

I was able to fix this error by running something like

   curl -L https://github.com/ARMmbed/mbedtls/archive/v$MBEDTLS_VERSION.tar.gz | tar xz
   cd mbedtls-$MBEDTLS_VERSION
   make && make install

I’ve found this in build-mac.yml file.
I think it did put files to “/usr/local/include” and “/usr/local/lib” folders.

I’m now getting another compilation issues though…

I don’t know how different building HashLink is compared to the Haxe compiler, but I found that using the Apple Silicon version of Homebrew didn’t work to build HashLink. I needed to do some special things to force the HashLink build process use the Intel version of Homebrew instead.

So maybe there are similar requirements for the Haxe compiler. Here’s the thread where I posted my findings for HashLink. Maybe it’ll provide some clues:

2 Likes

I’m not sure why, but it did not worked out with x86_64 brew.
But I’ve finally managed to build arm64 version, which is fine for me. That’s what has worked for me:

brew install zlib
brew install pcre
brew install mbedtls@2
brew unlink mbedtls
brew link mbedtls@2
export CPATH="/opt/homebrew/include:/opt/homebrew/opt/zlib/include:$CPATH"
make STATICLINK=1 "LIB_PARAMS=/opt/homebrew/opt/zlib/lib/libz.a /opt/homebrew/lib/libpcre.a /opt/homebrew/lib/libmbedtls.a /opt/homebrew/lib/libmbedcrypto.a /opt/homebrew/lib/libmbedx509.a -cclib '-framework Security -framework CoreFoundation'"