Failing to link with libei.a in OTP build 24.2
Serge Aleynikov
serge@REDACTED
Wed Jan 12 14:56:16 CET 2022
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:
$ g++ -flto c_src/ei++.o c_src/exec.o c_src/exec_impl.o -lcap
-L"/usr/lib/erlang/lib/erl_interface-5.1/l
ib" -lei -o
/home/serge/projects/erl-libs/erlexec/priv/x86_64-pc-linux-gnu/exec-port
/usr/bin/ld: /usr/bin/ld: DWARF error: could not find abbrev number 14880
/tmp/ccAxA3JA.ltrans0.ltrans.o: in function
`ei::Serializer::decodeAtom(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<c
har> >&) [clone .constprop.0]':
<artificial>:(.text+0x24c): undefined reference to `ei_decode_atom'
/usr/bin/ld: /tmp/ccAxA3JA.ltrans0.ltrans.o: in function
`ei::Serializer::decodeString(std::__cxx11::basic_string<char,
std::char_traits<char>, s
td::allocator<char> >&) [clone .constprop.0]':
<artificial>:(.text+0x83f): undefined reference to `ei_get_type'
/usr/bin/ld: <artificial>:(.text+0x903): undefined reference to
`ei_decode_string'
/usr/bin/ld: /tmp/ccAxA3JA.ltrans0.ltrans.o: in function
`ei::Serializer::decodeStringOrBinary(std::__cxx11::basic_string<char,
std::char_traits<
char>, std::allocator<char> >&) [clone .constprop.0]':
<artificial>:(.text+0xa4e): undefined reference to `ei_get_type'
/usr/bin/ld: <artificial>:(.text+0xa84): undefined reference to
`ei_decode_binary'
/usr/bin/ld: /tmp/ccAxA3JA.ltrans0.ltrans.o: in function
`ei::CmdOptions::ei_decode(bool)':
<artificial>:(.text+0x3754): undefined reference to `ei_decode_list_header'
/usr/bin/ld: <artificial>:(.text+0x38fa): undefined reference to
`ei_get_type'
/usr/bin/ld: <artificial>:(.text+0x3937): undefined reference to
`ei_decode_tuple_header'
/usr/bin/ld: <artificial>:(.text+0x397f): undefined reference to
`ei_decode_atom'
/usr/bin/ld: <artificial>:(.text+0x3b42): undefined reference to
`ei_decode_atom'
...
Regards,
Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20220112/2883cd80/attachment.htm>
More information about the erlang-questions
mailing list