WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: readline undefined symbol  (Read 5012 times)

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
readline undefined symbol
« on: April 04, 2021, 10:02:49 AM »
TC 12.0 x86_64

/usr/local/bin/awk from gawk.tcz reports

Code: [Select]
$ printf '\tTAB' | /use/local/bin/awk '/\t/'
symbol lookup error: /usr/local/lib/libreadline.so.8: undefined symbol: UP

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: readline undefined symbol
« Reply #1 on: April 04, 2021, 11:38:29 AM »
Hi polikuo
Does this show anything missing:
Code: [Select]
ldd /usr/local/lib/libreadline.so.8

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: readline undefined symbol
« Reply #2 on: April 04, 2021, 12:05:45 PM »
Not really

Here are some tests

Code: [Select]
tc@box: ~ $ ldd /usr/local/lib/libreadline.so.8
        linux-vdso.so.1 (0x00007ffe2f1c1000)
        libc.so.6 => /lib/libc.so.6 (0x00007fa07e9f5000)
        /lib/ld-linux-x86-64.so.2 (0x00007fa07ebe0000)
tc@box: ~ $ /lib/ld-linux-x86-64.so.2 --verify /usr/local/lib/libreadline.so.8
tc@box: ~ $ echo $?
2
tc@box: ~ $ ldd /usr/lib/libc.so
/usr/lib/libc.so: error while loading shared libraries: /usr/lib/libc.so: invalid ELF header
tc@box: ~ $ /lib/ld-linux-x86-64.so.2 --verify /usr/lib/libc.so
tc@box: ~ $ echo $?
1
tc@box: ~ $ ldd /lib/libc.so.6
        /lib/ld-linux-x86-64.so.2 (0x00007f1e918e3000)
        linux-vdso.so.1 (0x00007ffcb71fb000)
tc@box: ~ $ /lib/ld-linux-x86-64.so.2 --verify /lib/libc.so.6
tc@box: ~ $ echo $?
0
tc@box: ~ $ ldd /usr/local/bin/awk
        linux-vdso.so.1 (0x00007fffd0335000)
        libreadline.so.8 => /usr/local/lib/libreadline.so.8 (0x00007f880aa4e000)
        libmpfr.so.6 => /usr/local/lib/libmpfr.so.6 (0x00007f880a79f000)
        libgmp.so.10 => /usr/local/lib/libgmp.so.10 (0x00007f880a71d000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007f880a718000)
        libm.so.6 => /lib/libm.so.6 (0x00007f880a5f4000)
        libc.so.6 => /lib/libc.so.6 (0x00007f880a470000)
        /lib/ld-linux-x86-64.so.2 (0x00007f880aab5000)
tc@box: ~ $ /lib/ld-linux-x86-64.so.2 --verify /usr/local/bin/awk
tc@box: ~ $ echo $?
0
tc@box: ~ $ nm /usr/local/lib/libreadline.so.8 | grep UP
                 U UP
« Last Edit: April 04, 2021, 12:11:19 PM by polikuo »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: readline undefined symbol
« Reply #3 on: April 04, 2021, 01:19:08 PM »
Hmm - normally readline should depend on ncursesw - I'll take a look tomorrow.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: readline undefined symbol
« Reply #4 on: April 04, 2021, 04:04:34 PM »
Hi polikuo
...
Code: [Select]
tc@box: ~ $ ldd /usr/lib/libc.so
/usr/lib/libc.so: error while loading shared libraries: /usr/lib/libc.so: invalid ELF header
...
The  libc.so  library tends to be very stable and rarely changes since everything (including the kernel) depends on it. So
seeing another  libc.so  in  /usr/lib/  struck me as odd. Turns out it is provided by  glibc_base-dev.tcz  and is not a shared
library at all. It appears to contain directives for the linker. Run this and see for yourself:
Code: [Select]
cat /usr/lib/libc.so

Quote
...
Code: [Select]
tc@box: ~ $ nm /usr/local/lib/libreadline.so.8 | grep UP
                 U UP
The  U  means that symbol  UP  is undefined and is expected to be found in an external executable (dependency).
I see  UP  defined in  libncursesw.so.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: readline undefined symbol
« Reply #5 on: April 05, 2021, 02:04:29 AM »
I've checked readline in both tc-12.x x86 and x86_64 and both give this:
Code: [Select]
$ ldd /usr/local/lib/libreadline.so.8
        linux-vdso.so.1 (0x00007fffe78aa000)
        libncursesw.so.6 => /usr/local/lib/libncursesw.so.6 (0x00007f3eabd3e000)
        libc.so.6 => /lib/libc.so.6 (0x00007f3eabbb1000)
        /lib/ld-linux-x86-64.so.2 (0x00007f3eabde5000)

Code: [Select]
$ nm /usr/local/lib/libreadline.so.8 | grep UP
nm: /usr/local/lib/libreadline.so.8: no symbols

Code: [Select]
$ printf '\tTAB' | /use/local/bin/awk '/\t/'
sh: /use/local/bin/awk: not found

Are you working with a locally compiled version of readline?

Offline polikuo

  • Hero Member
  • *****
  • Posts: 714
Re: readline undefined symbol
« Reply #6 on: April 05, 2021, 02:40:38 AM »
Are you working with a locally compiled version of readline?

Oops  :-[

Sorry for the noise, I totally forgot about that I haven't reboot yet.

I was trying to build gcc and all the deps natively to see the difference in performance.

Code: [Select]
CXXFLAGS='-march=native -mtune=native -Ofast -pipe -fuse-linker-plugin -flto -fno-exceptions -fno-rtti'
tce-load -fi tool-ncursesw
../configure --with-curses

I guess simply overwriting the current ncursesw with "-fi" is not the way to go.
« Last Edit: April 05, 2021, 02:48:06 AM by polikuo »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: readline undefined symbol
« Reply #7 on: April 05, 2021, 03:57:47 AM »
You might want to explicitly state your cpu (-march=haswell in my case) - I'm not convinced that all source code will use it otherwise.

You can check by running ./configure in the gmp source code, or:
Code: [Select]
$ gcc -mcpu=native -march=native -Q --help=target

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: readline undefined symbol
« Reply #8 on: April 05, 2021, 08:37:21 AM »
Hi Juanito
...
Code: [Select]
$ nm /usr/local/lib/libreadline.so.8 | grep UP
nm: /usr/local/lib/libreadline.so.8: no symbols
...
Thank you for posting that. I was getting that result with every library I tried under TC10 x86 even though midnight commander
showed that symbols were present. I don't know why  nm  couldn't list symbols, but  readelf  could:
Code: [Select]
tc@E310:~$ readelf -s /usr/local/lib/libreadline.so.7 | grep UP
   274: 00000000     0 OBJECT  GLOBAL DEFAULT  UND UP
tc@E310:~$ readelf -s /usr/local/lib/libncursesw.so.6 | grep UP
   329: 00043d04     4 OBJECT  GLOBAL DEFAULT   22 UP
tc@E310:~$

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Re: readline undefined symbol
« Reply #9 on: April 05, 2021, 12:17:33 PM »
nm lists static symbols by default, which we usually strip. Use "nm -D" on dynamic libraries.
The only barriers that can stop you are the ones you create yourself.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: readline undefined symbol
« Reply #10 on: April 05, 2021, 03:17:03 PM »
Hi curaga
That worked. Thank you.