asdf-erlang icon indicating copy to clipboard operation
asdf-erlang copied to clipboard

OTP 24 compilation error on macOS Monterey 12.3 Mac M1

Open rrmartins opened this issue 2 years ago • 8 comments

I'm trying to install erlang version 24.2 on a macbook m1 with macOS 12.3 Monterey and I'm having this compilation error.

Build failed.
/bin/sh: line 1: 55135 Segmentation fault: 11  erlc -W -Werror +debug_info -DUSE_ESOCK=true -DENABLE_MEGACO_FLEX_SCANNER=true -DMEGACO_REENTRANT_FLEX_SCANNER=true -Dmegaco_parser_inline -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/et/ebin -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/megaco/ebin +'{parse_transform,sys_pre_attributes}' +'{attribute,insert,app_vsn,"megaco-4.2"}' -I../../include -o../../ebin megaco_flex_scanner.erl
make[5]: *** [../../ebin/megaco_flex_scanner.beam] Error 139
make[5]: *** Waiting for unfinished jobs....
/bin/sh: line 1: 55134 Segmentation fault: 11  erlc -W -Werror +debug_info -DUSE_ESOCK=true -DENABLE_MEGACO_FLEX_SCANNER=true -DMEGACO_REENTRANT_FLEX_SCANNER=true -Dmegaco_parser_inline -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/et/ebin -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/megaco/ebin +'{parse_transform,sys_pre_attributes}' +'{attribute,insert,app_vsn,"megaco-4.2"}' -I../../include -o../../ebin megaco_flex_scanner_handler.erl
make[5]: *** [../../ebin/megaco_flex_scanner_handler.beam] Error 139
make[4]: *** [opt] Error 2
make[3]: *** [opt] Error 2
make[2]: *** [opt] Error 2
make[1]: *** [opt] Error 2
make: *** [libs] Error 2

rrmartins avatar Apr 01 '22 12:04 rrmartins

I am trying to install erlang version 24.0 on Macbook Pro M1 with Mac osX 12.3.1 Monterey and this is the error I am getting:

export KERL_CONFIGURE_OPTIONS="--with-ssl=`brew --prefix openssl`"
asdf install erlang 24.0
asdf_24.0 is not a kerl-managed Erlang/OTP installation
The asdf_24.0 build has been deleted
Extracting source code
Building Erlang/OTP 24.0 (asdf_24.0), please wait...
APPLICATIONS DISABLED (See: $HOME/.asdf/plugins/erlang/kerl-home/builds/asdf_24.0/otp_build_24.0.log)
 * odbc           : ODBC library - link check failed

DOCUMENTATION INFORMATION (See: $HOME/.asdf/plugins/erlang/kerl-home/builds/asdf_24.0/otp_build_24.0.log)
 * documentation  :
 *                  fop is missing.
 *                  Using fakefop to generate placeholder PDF files.

Build failed.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
5 warnings generated.
make[2]: *** [opt] Error 2
make[1]: *** [opt] Error 2
make: *** [libs] Error 2

Please see $HOME/.asdf/plugins/erlang/kerl-home/builds/asdf_24.0/otp_build_24.0.log for full details.

The error at the bottom of the otp_build_24.0.log file is below:

/opt/homebrew/include/wx-3.1/wx/stc/stc.h:2489:27: note: expanded from macro 'wxSTC_INDIC1_MASK'
#define wxSTC_INDIC1_MASK wxSTC_DEPRECATED_MACRO_VALUE(0x40,\
                          ^
/opt/homebrew/include/wx-3.1/wx/stc/stc.h:2473:9: note: expanded from macro 'wxSTC_DEPRECATED_MACRO_VALUE'
        _Pragma(wxSTC_STRINGIFY(GCC warning msg)) value
        ^
<scratch space>:102:6: note: expanded from here
 GCC warning "wxSTC_INDIC1_MASK is deprecated. Style byte indicators are no longer used."
     ^
gen/wxe_init.cpp:613:57: warning: wxSTC_INDIC0_MASK is deprecated. Style byte indicators are no longer used. [-W#pragma-messages]
    { WXE_ATOM_define, "wxSTC_INDIC0_MASK", rt.make_int(wxSTC_INDIC0_MASK) },
                                                        ^
/opt/homebrew/include/wx-3.1/wx/stc/stc.h:2487:27: note: expanded from macro 'wxSTC_INDIC0_MASK'
#define wxSTC_INDIC0_MASK wxSTC_DEPRECATED_MACRO_VALUE(0x20,\
                          ^
/opt/homebrew/include/wx-3.1/wx/stc/stc.h:2473:9: note: expanded from macro 'wxSTC_DEPRECATED_MACRO_VALUE'
        _Pragma(wxSTC_STRINGIFY(GCC warning msg)) value
        ^
<scratch space>:105:6: note: expanded from here
 GCC warning "wxSTC_INDIC0_MASK is deprecated. Style byte indicators are no longer used."
     ^
gen/wxe_wrapper_5.cpp:2165:29: error: taking the address of a temporary object of type 'wxBitmap' [-Waddress-of-temporary]
  const wxBitmap * Result = &This->GetBitmap();
                            ^~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
make[3]: *** [aarch64-apple-darwin21.4.0/wxe_wrapper_5.o] Error 1
make[3]: *** Waiting for unfinished jobs....
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
5 warnings generated.
make[2]: *** [opt] Error 2
make[1]: *** [opt] Error 2
make: *** [libs] Error 2

kxkannan avatar Apr 30 '22 15:04 kxkannan

@kxkannan If you don't need the Erlang Observer, you can bypass that error by providing the --without-wx flag to KERL_CONFIGURE_OPTIONS. See this thread on Elixir Forum.

supernintendo avatar May 23 '22 22:05 supernintendo

I was able to install Erlang OTP 24 on macOS Monterey 12.3.1 with the M1 chip.

I had to combine some information I found across the internet. I wrote an article with the steps I followed. Some coworkers got it worked also with this steps, maybe they can help more people.

How to install Erlang and Elixir on macOS with Apple M1 Chip

mdapper avatar Jun 29 '22 17:06 mdapper

I was able to install Erlang OTP 24 on macOS Monterey 12.3.1 with the M1 chip.

I had to combine some information I found across the internet. I wrote an article with the steps I followed. Some coworkers got it worked also with this steps, maybe they can help more people.

How to install Erlang and Elixir on macOS with Apple M1 Chip

You are disabling wx-widgets in your configure flags.

export KERL_CONFIGURE_OPTIONS="... --without-javac --without-wx --without-odbc"

In my case I need an erlang with working observer (--with-wx) and jinterface (--with-javac).

I did try to patch wxwidgets with the following:

WXWIDGETS_PATH="$(brew edit wxwidgets --print-path)"
cd `dirname $WXWIDGETS_PATH`
git apply --recount - << 'EOF'
diff --git a/Formula/wxwidgets.rb b/Formula/wxwidgets.rb
index 68bc267df45..618bcae75f2 100644
--- a/Formula/wxwidgets.rb
+++ b/Formula/wxwidgets.rb
@@ -44,7 +44,6 @@ class Wxwidgets < Formula
       "--enable-std_string",
       "--enable-svg",
       "--enable-unicode",
-      "--enable-webviewwebkit",
       "--with-expat",
       "--with-libjpeg",
       "--with-libpng",
@@ -54,6 +53,7 @@ class Wxwidgets < Formula
       "--disable-precomp-headers",
       # This is the default option, but be explicit
       "--disable-monolithic",
+      "--enable-compat28"
     ]

     if OS.mac?
EOF
brew install wxwidgets --build-from-source

However it didn't help. Does anyone have a solution?

iilyak avatar Jul 18 '22 14:07 iilyak

I'm trying to install erlang version 24.2 on a macbook m1 with macOS 12.3 Monterey and I'm having this compilation error.

Build failed.
/bin/sh: line 1: 55135 Segmentation fault: 11  erlc -W -Werror +debug_info -DUSE_ESOCK=true -DENABLE_MEGACO_FLEX_SCANNER=true -DMEGACO_REENTRANT_FLEX_SCANNER=true -Dmegaco_parser_inline -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/et/ebin -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/megaco/ebin +'{parse_transform,sys_pre_attributes}' +'{attribute,insert,app_vsn,"megaco-4.2"}' -I../../include -o../../ebin megaco_flex_scanner.erl
make[5]: *** [../../ebin/megaco_flex_scanner.beam] Error 139
make[5]: *** Waiting for unfinished jobs....
/bin/sh: line 1: 55134 Segmentation fault: 11  erlc -W -Werror +debug_info -DUSE_ESOCK=true -DENABLE_MEGACO_FLEX_SCANNER=true -DMEGACO_REENTRANT_FLEX_SCANNER=true -Dmegaco_parser_inline -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/et/ebin -pa /Users/rrmartins/.asdf/plugins/erlang/kerl-home/builds/asdf_24.2/otp_src_24.2/lib/megaco/ebin +'{parse_transform,sys_pre_attributes}' +'{attribute,insert,app_vsn,"megaco-4.2"}' -I../../include -o../../ebin megaco_flex_scanner_handler.erl
make[5]: *** [../../ebin/megaco_flex_scanner_handler.beam] Error 139
make[4]: *** [opt] Error 2
make[3]: *** [opt] Error 2
make[2]: *** [opt] Error 2
make[1]: *** [opt] Error 2
make: *** [libs] Error 2

Have you made any progress on this?

sheehan1102 avatar Aug 31 '23 15:08 sheehan1102

You need to disable JIT.

The following combination of options worked for me

#!/bin/bash
openssl=`brew --prefix [email protected]`
KERL_CONFIGURE_OPTIONS=(
    --disable-debug
    --disable-silent-rules
    --enable-kernel-poll
    --enable-threads
    --disable-sctp
    --enable-dynamic-ssl-lib
    --enable-shared-zlib
    --enable-smp-support
    --enable-darwin-64bit
    --enable-native-libs
    --enable-wx
    --disable-jit
    --disable-hipe
    --with-javac
    --with-ssl=${openssl}
)

export KERL_CONFIGURE_OPTIONS="${KERL_CONFIGURE_OPTIONS[@]}"
export KERL_CONFIGURE_DISABLE_APPLICATIONS="odbc megaco"
export CFLAGS="-Wno-error=implicit-function-declaration -O2 -g -fno-stack-check"

iilyak avatar Aug 31 '23 16:08 iilyak

@iilyak A lot of the flags you have listed don't seem to exist, I'm guessing because the kerl docs I think you referenced are very old. 😅

The ones below won't work according to the Erlang building docs.

--disable-debug
--disable-silent-rules
--enable-kernel-poll # Enabled by default, probably don't need it
--enable-threads
--disable-sctp
--enable-dynamic-ssl-lib # Enabled by default, probably don't need it
--enable-shared-zlib # There is `--{enable,disable}-builtin-zlib` and `--with-ssl-zlib=PATH` though
--enable-smp-support # There is `--disable-smp-require-native-atomics` though
--enable-darwin-64bit
--enable-native-libs
--enable-wx # There is `--without-wx`. I previously used `--with-wx-config`, which also isn't a thing anymore...
--disable-hipe
--with-javac # I don't know if this does anything without a path since `javac` is included by default, but I usually use `--without-javac`

So I think all you really need is:

KERL_CONFIGURE_OPTIONS=(
    --disable-jit
    --with-ssl=${openssl}
)

And for the exports at the end:

# This seems fine, here is the full list if you are curious: https://www.erlang.org/doc/applications
export KERL_CONFIGURE_DISABLE_APPLICATIONS="odbc megaco"

# `-Wno-error=implicit-function-declaration`: I have no idea if we should use this: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-function-declaration
# `-O2` # This seems fine, though the `kerl` docs use level 3 which is interesting: https://github.com/kerl/kerl#using-shell-export-command-in-kerlrc
# `-g` # This includes debug information, which I prefer!
# `-fno-stack-check`: I think this is now the default on macOS? https://github.com/search?q=repo%3Aerlang%2Fotp%20no-stack-check&type=code
export CFLAGS="-Wno-error=implicit-function-declaration -O2 -g -fno-stack-check"

I also like having these for having local doc sources:

export KERL_BUILD_DOCS="yes"
export KERL_DOC_TARGETS="man html chunks"

😄

Nezteb avatar Nov 08 '23 21:11 Nezteb

Thank you @Nezteb for filtering out the noise from my response.

iilyak avatar Nov 09 '23 00:11 iilyak