Re: Failing to link with libei.a in OTP build 24.2

Luke Bakken <[email protected]> Wed, 12 Jan 2022 07:15:16 -0800
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CADFEJufTJUWQ10TJXkFM8MwvJcsx77JVXyPgMdqAOHRLwDy27w@mail.gmail.com>
Hi Serge,

I could try to reproduce (and maybe fix) this using my Arch
environment if you'd like to provide source code I could compile.

Thanks -
Luke

On Wed, Jan 12, 2022 at 5:56 AM Serge Aleynikov <[email protected]> wrote:
>
> I am using Arch Linux and have the latest OTP 24.2 installed.  When trying to build a project that depends on libei.a I am getting undefined references of "ei_*" functions.  This doesn't happen when I download and build erlang OTP from sources.  Investigating this issue shows that the 24.2 Erlang/OTP package included in Arch distribution has libei.a built with LTO
>
> $ nm /usr/lib/erlang/lib/erl_interface-5.1/lib/libei.a | head -10
> /usr/bin/nm: ei_connect.o: plugin needed to handle lto object
>
> ei_connect.o:
> 0000000000000001 C __gnu_lto_slim
>
> ei_resolve.o:
> 0000000000000001 C __gnu_lto_slim
>
> eirecv.o:
> 0000000000000001 C __gnu_lto_slim
>
>
> whereas the manually built one doesn't seem to use LTO:
>
> $ nm /opt/sw/erlang/24.2/lib/erlang/lib/erl_interface-5.1/lib/libei.a | head -10
>
> ei_connect.o:
>                 U clock
>                 U close
>                 U __ctype_b_loc
> 0000000000000140 t dyn_gethostbyname_r
> 00000000000048f0 T ei_accept
>                 U ei_accept_ctx_t__
> 0000000000003560 T ei_accept_tmo
> 0000000000003430 T ei_close_connection
>
>
> What's the correct linking options when building projects using libei.a in OTP 24.2? Adding "-flto" flag doesn't seem to help: