Fine-tuning Erlang build on macOS using .kerlrc file

almirsarajcic

almirsarajcic

Created 5 months ago

Use all your cores for compilation on Apple Silicon, configure your Erlang build to use the OpenSSL library, and skip installing anything extra like ODBC and WX widgets by putting the following in your ~/.kerlrc file. That will speed up your Erlang installation as well as your development.

KERL_CONFIGURE_OPTIONS="\
--disable-debug \
--disable-jit \
--disable-silent-rules \
--enable-darwin-64bit \
--enable-dynamic-ssl-lib \
--enable-gettimeofday-as-os-system-time \
--enable-hipe \
--enable-kernel-poll \
--enable-shared-zlib \
--enable-smp-support \
--enable-threads \
--with-dynamic-trace=dtrace \
--with-ssl=$(brew --prefix openssl) \
--without-javac \
--without-jinterface \
--without-odbc \
--without-wx
"

Make sure you install openssl using brew install openssl.

For this to work, you must use mise instead of asdf because asdf doesn’t respect the ~/.kerlrc file (https://github.com/asdf-vm/asdf-erlang/issues/181).

If you’re just starting out, the easiest way to set up the whole environment is by visiting https://phx.tools. While installing, we use the configuration from your ~/.kerlrc file.

Credits for the Apple Silicon fix go to José Valim, but I can’t find the original tweet.