Bug in apgcc when encountering dependencies on non-lib libraries

Scott Pakin <[email protected]> Mon, 09 Mar 2009 20:32:38 -0600
Newsgroups gmane.comp.autopackage.devel
Organization Los Alamos National Laboratory
Message-ID <[email protected]>
This drove me nuts trying to track down:

     $ env APBUILD_STATIC=uuid apgcc -o whatever whatever.c
     /usr/bin/ld: cannot find -l  NEEDED      ld-linux.so.2
     collect2: ld returned 1 exit status

It turns out that apgcc runs "objdump -p" on the shared versions of
static libraries and extractes LIBNAME from lines of the form "NEEDED
libLIBNAME.so":

     next unless (/^  NEEDED/);
     s/^  NEEDED\s+lib(.+?)\.so(.*)/$1/;

But look at libuuid.so's NEEDED lines:

     $ objdump -p /usr/lib/libuuid.so | grep NEEDED
       NEEDED      libc.so.6
       NEEDED      ld-linux.so.2

"NEEDED ld-linux.so.2" gets past the "next unless" line but fails to
make any substitutions in the subsequent line.  Consequently, apgcc
tries linking with "NEEDED ld-linux.so.2" and fails with the error
shown above.

I've attached a patch that fixes the problem.

Regards,
-- Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: autopackage-dev-unsubscribe-OfajU3CKLf1/[email protected]
For additional commands, e-mail: autopackage-dev-help-OfajU3CKLf1/[email protected]
apgcc-lib.patch (text/x-patch, 416 B)
--- apgcc.ORIG	2009-03-09 20:04:52.000000000 -0600
+++ apgcc	2009-03-09 20:22:34.000000000 -0600
@@ -801,7 +801,7 @@
 				my $pid = open2 ($r, $w, 'objdump', '-p', searchLib("lib$lib.so", \@searchPaths));
 				close ($w);
 				foreach (<$r>) {
-					next unless (/^  NEEDED/);
+					next unless (/^  NEEDED\s+lib(.+?)\.so/);
 					s/^  NEEDED\s+lib(.+?)\.so(.*)/$1/;
 					s/\n//;
 					push(@static_deps, "-l$_");