Unable to install erlang 21.3.8.17 with asdf

I’ve been having issues installing older erlang versions recently and I’m not sure if I’ve broken something in my development environment. I’m trying to install erlang 21.3 with:
asdf install erlang 21.3.8.17
But it is failing with:

Build failed.
make[4]: *** [x86_64-unknown-linux-gnu/Makefile:665: /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/bin/x86_64-unknown-linux-gnu/erl_call] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: Leaving directory '/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src'
make[3]: *** [Makefile:30: opt] Error 2
make[3]: Leaving directory '/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src'
make[2]: *** [/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/make/otp_subdir.mk:29: opt] Error 2
make[2]: Leaving directory '/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface'
make[1]: *** [/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/make/otp_subdir.mk:29: opt] Error 2
make[1]: Leaving directory '/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib'
make: *** [Makefile:490: libs] Error 2

Looking at the build log it looks like the issue is that ld is failing:

/usr/bin/ld: /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(eirecv.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: multiple definition of `ei_default_socket_callbacks'; /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(ei_connect.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: first defined here
/usr/bin/ld: /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(send.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: multiple definition of `ei_default_socket_callbacks'; /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(ei_connect.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: first defined here
/usr/bin/ld: /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(send_reg.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: multiple definition of `ei_default_socket_callbacks'; /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(ei_connect.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: first defined here
/usr/bin/ld: /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(epmd_port.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: multiple definition of `ei_default_socket_callbacks'; /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(ei_connect.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: first defined here
/usr/bin/ld: /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(ei_portio.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: multiple definition of `ei_default_socket_callbacks'; /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/libei.a(ei_connect.o):/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src/misc/ei_portio.h:50: first defined here
 RANLIB	/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/obj/x86_64-unknown-linux-gnu/liberl_interface.a
collect2: error: ld returned 1 exit status
make[4]: *** [x86_64-unknown-linux-gnu/Makefile:665: /home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/bin/x86_64-unknown-linux-gnu/erl_call] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: Leaving directory '/home/jason/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_src_21.3.8.17/lib/erl_interface/src'
make[3]: *** [Makefile:30: opt] Error 2

Are other people getting similar errors? Does this point to an issue with my environment somehow?

This seems relevant: Erlang -- Erl_interface Release Notes

Fix link error “multiple definition of `ei_default_socket_callbacks’” for gcc version 10 or when built with gcc option -fno-common. Error exists since OTP-21.3.

Own Id: OTP-16412 Aux Id: PR-2503

Although I don’t know what version of erlang that is in. Did that change not make it to the 21.3.8.17 that I’m trying to install?

Edit:
Okay it looks like the bug was fixed in ei_portio.h: avoid ODR violation of 'ei_default_socket_callbacks' by trofi · Pull Request #2503 · erlang/otp · GitHub (although I can’t find a link for OTP-16412 anywhere). However it looks like that fix was only included in 22.3 which means that I may be unable to build any erlang versions earlier than 22.3 (which is what I seem to have been encountering). Am I getting that right? If so, what would be the best way to suggest backporting that fix to earlier versions of Erlang?

Edit 2: I raised an issue at asdf-erlang (although I’m not sure if that’s the best place) Unable to install erlang versions earlier than 22.3 · Issue #159 · asdf-vm/asdf-erlang · GitHub

Did you try installing any other otp version? I’m trying to install the otp 22.x but I’m not able to. I have already installed otp 23 using asdf but not able to install otp 22 along with that.

I tried the same command asdf install erlang 21.3.8.17

with some relevent envs from https://github.com/asdf-vm/asdf-erlang/issues/116

export KERL_CONFIGURE_OPTIONS="--without-javac --with-ssl=$(brew --prefix openssl)"
export CFLAGS="-O2 -g -fno-stack-check"

Output

asdf install erlang 21.3.8.17
asdf_21.3.8.17 is not a kerl-managed Erlang/OTP installation
No build named asdf_21.3.8.17
Downloading OTP-21.3.8.17.tar.gz to /Users/jawakar/.asdf/plugins/erlang/kerl-home/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0    132      0 --:--:-- --:--:-- --:--:--   132
100 51.5M    0 51.5M    0     0   332k      0 --:--:--  0:02:38 --:--:-- 1049k
Extracting source code
Building Erlang/OTP 21.3.8.17 (asdf_21.3.8.17), please wait...
/Users/jawakar/.asdf/plugins/erlang/kerl: line 661: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild: No such file or directory

APPLICATIONS DISABLED (See: /Users/jawakar/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_build_21.3.8.17.log)
 * jinterface     : Java compiler disabled by user

DOCUMENTATION INFORMATION (See: /Users/jawakar/.asdf/plugins/erlang/kerl-home/builds/asdf_21.3.8.17/otp_build_21.3.8.17.log)
 * documentation  : 
 *                  fop is missing.
 *                  Using fakefop to generate placeholder PDF files.

Erlang/OTP 21.3.8.17 (asdf_21.3.8.17) has been successfully built
Installing Erlang/OTP 21.3.8.17 (asdf_21.3.8.17) in /Users/jawakar/.asdf/installs/erlang/21.3.8.17...
        You can activate this installation running the following command:
. /Users/jawakar/.asdf/installs/erlang/21.3.8.17/activate
Later on, you can leave the installation typing:
kerl_deactivate
Cleaning up compilation products for 
Cleaned up compilation products for  under /Users/jawakar/.asdf/plugins/erlang/kerl-home/builds

Erlang 21.3.8.17 has been installed. Activate globally with:

    asdf global erlang 21.3.8.17

Activate locally in the current folder with:

    asdf local erlang 21.3.8.17

Let me know how I can help.

1 Like

I haven’t had any trouble installing erlang 22.3 and higher.

I still get the same error with those flags. Are you using GCC 10.x?

Okay, for me on Arch Linux after installing the gcc-9 package this command worked:

env CC=gcc-9 asdf install erlang 21.3.8.17

2 Likes

I updated the asdf-erlang wiki to include this instruction. I also needed this