haampie / libtree

ldd as a tree
MIT License
2.67k stars 60 forks source link

'make check' fails on '08_nodeflib' #80

Open artyom-poptsov opened 2 years ago

artyom-poptsov commented 2 years ago

Hello,

when I try to run tests, '08_nodeflib' fails:

/tmp/guix-build-libtree-3.1.1.drv-0/source/tests/08_nodeflib$ make check
echo 'int f(){return 1;}' | cc -z nodefaultlib -Wl,--no-as-needed -shared -Wl,-soname,lib_nodefaultlib.so -o lib_nodefaultlib.so -x c -
echo 'int g(){return 1;}' | cc -Wl,--no-as-needed -shared -Wl,-soname,lib_defaultlib.so -o lib_defaultlib.so -x c -
echo 'extern int f(); extern int g(); int main(){return f() + g();}' | cc -z nodefaultlib -o exe_a -Wl,--enable-new-dtags '-Wl,-rpath,$ORIGIN' -x c - -L. -l_nodefaultlib -l_defaultlib
echo 'extern int g(); int main(){return g();}' | cc -z nodefaultlib -o exe_b -Wl,--disable-new-dtags '-Wl,-rpath,$ORIGIN' -x c - -L. -l_defaultlib
! ../../libtree -vvv exe_a # should likely not find libc
exe_a 
├── lib_nodefaultlib.so [runpath]
│   └── libc.so.6 [runpath]
│       └── ld-linux-x86-64.so.2 [ld.so.conf]
├── lib_defaultlib.so [runpath]
│   └── libc.so.6 [runpath]
│       └── ld-linux-x86-64.so.2 [ld.so.conf]
└── libc.so.6 [runpath]
    └── ld-linux-x86-64.so.2 [ld.so.conf]
make: *** [Makefile:33: check] Error 1

As far as I can see, the issue is that libtree finds libc when it shouldn't. I'm using the following compiler and linker versions:

$ gcc --version
gcc (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ld --version
GNU ld (GNU Binutils) 2.37
Copyright (C) 2021 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

The tests ran on Ubuntu 20.04.4 LTS

Thanks, avp

haampie commented 2 years ago

Seems like you're using Guix, which probably has a compiler spec or wrapper to add rpaths to their glibc?