tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: libstdc++ dependency mis-detection in gcc packages?
>> For many years I've used this patch which instead only records direct
>> dependencies via DT_NEEDED:
>>
>> https://github.com/TritonDataCenter/pkgsrc/commit/dff5fd726aa1d33966ab4557cc55026f38905f46
>>
>> It might be good to get consensus on this and figure out a portable way
>> to do it for all ELF platforms.
I think on NetBSD (at least from 8 forwards) you dump this info
with "readelf", and the output it produces is a little different
compared to the "elfdump" output. The attached proof-of-concept
shell script does basically the same operation as the diff using
readelf, it obviously needs to be re-formatted to fit in an .mk
file (and the SYSTEM_DEFAULT_RPATH pasted in instead of the
literal in the example) etc.
We would probably have to add some test to differentiate between
the different systems / tools to get at the direct dependency
information.
In my test case the attached script (which looks at cc1plus from
gcc10) produces the rather un-exciting
/lib/libz.so.1
/lib/libm.so.0
/lib/libc.so.12
output while pointing it at my /usr/pkg/lib/libgs.so produces a
bit more output:
/usr/X11R7/lib/libXt.so.7
/usr/X11R7/lib/libSM.so.7
/usr/X11R7/lib/libICE.so.7
/usr/X11R7/lib/libXext.so.7
/usr/X11R7/lib/libX11.so.7
/usr/pkg/lib/libtiff.so.5
/usr/pkg/lib/libcups.so.2
/usr/pkg/lib/libpng16.so.16
/usr/pkg/lib/libjbig2dec.so.0
/usr/pkg/lib/libjpeg.so.9
/lib/libz.so.1
/usr/pkg/lib/liblcms2.so.2
/lib/libm.so.0
/usr/pkg/lib/libidn.so.12
/usr/pkg/lib/libpaper.so.1
/usr/X11R7/lib/libfontconfig.so.2
/usr/X11R7/lib/libfreetype.so.19
/usr/lib/libbz2.so.1
/usr/pkg/lib/libopenjp2.so.7
/lib/libpthread.so.1
/lib/libc.so.12
while ldd on the latter produces no less than 52 lines of output.
However... While the above is probably a good idea, this doesn't
fully explain why libstdc++.so.7 is in the "required" list of the
gcc10 or gcc12 binary packages. gcc10 only depends on gsed, and
none of the binaries in the gcc10 package appear to depend on
libstdc++.so.7, judging by ldd output on the /bin/ and /libexec/
files in that package.
Regards,
- Håvard
#! /bin/sh
PKGSRC_SETENV=""
bins="/usr/pkg/gcc10/libexec/gcc/x86_64--netbsd/10.4.0/cc1plus"
libs=""
AWK=awk
SED=sed
DESTDIR=""
SORT=sort
SYSTEM_DEFAULT_RPATH="/lib:/usr/lib"
# requires=`
(${PKGSRC_SETENV} readelf -d $bins $libs 2>/dev/null || true) | ${AWK} '
/NEEDED/ {
l = gensub(/.*\[/, "", 0);
lib = gensub(/\]/, "", 0, l);
dsolibs = dsolibs (dsolibs ? ":" : "") lib;
}
/RPATH/ {
l = gensub(/.*\[/, "", 0);
path = gensub(/\]/, "", 0, l);
nrpath = split(path ":/lib:/usr/lib", rpath, ":");
nlibs = split(dsolibs, libs, ":");
for (l = 1; l <= nlibs; l++) {
for (r = 1; r <= nrpath; r++) {
sub(/\/$/, "", rpath[r]);
libfile = rpath[r] "/" libs[l];
if (!(libfile in libcache)) {
libcache[libfile] = system("test -f " libfile);
}
if (libcache[libfile] == 0) {
print libfile;
break;
}
}
}
}
'
# | ${SED} -e "s,${DESTDIR},," | ${SORT} -u`;
# echo $requires
Home |
Main Index |
Thread Index |
Old Index