| Summary: | ld ignores --as-needed? | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Jeroen Roovers (RETIRED) <jer> |
| Component: | Current packages | Assignee: | HPPA Porters <hppa> |
| Status: | RESOLVED TEST-REQUEST | ||
| Severity: | QA | CC: | matoro_gentoo, tove |
| Priority: | Normal | ||
| Version: | unspecified | ||
| Hardware: | HPPA | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Attachments: |
mail-filter:procmail-3.22-r10:20110520-163145.log
Remove -lnet, read my LIBS properly, put LDFLAGS before all objects and libs procmail-3.22-r10 original build log procmail-3.22 build log after the patch |
||
|
Description
Jeroen Roovers (RETIRED)
2011-05-20 16:44:55 UTC
elmer ~ # ldd /usr/bin/procmail
libm.so.6 => /lib/libm.so.6 (0x402d1000)
libnet.so.1 => /usr/lib/libnet.so.1 (0x40551000)
libc.so.6 => /lib/libc.so.6 (0x40965000)
/lib/ld.so.1 (0x4016e000)
elmer ~ # qfile /usr/lib/libnet.so.1
net-libs/libnet (/usr/lib/libnet.so.1)
Looks like it fails to respect LDFLAGS too, because if it doesn't need -lnet, then --as-needed should make sure the procmail binary isn't linked to libnet. Maybe the LDFLAGS should be moved to the front of the linker call, e.g. right after CFLAGS and before all the object files are mentioned. Created attachment 274347 [details, diff]
Remove -lnet, read my LIBS properly, put LDFLAGS before all objects and libs
I couldn't get procmail to link against libnet. But your patch looks good and reasonable. One question though before I apply it: sed [...] -e '/^LDFLAGS\t=/s:).*:):g' \ [...] -i Makefile || die "sed failed" what's that supposed to do? You are deleting everything after the parantheses. Fine but there is no ^LDFLAGS\t= in the Makefile. Am I missing something? (In reply to comment #4) > I couldn't get procmail to link against libnet. Is net-libs/libnet installed on your system? > But your patch looks good and > reasonable. One question though before I apply it: > > sed > [...] > -e '/^LDFLAGS\t=/s:).*:):g' \ > [...] > -i Makefile || die "sed failed" > > what's that supposed to do? You are deleting everything after the parantheses. > Fine but there is no ^LDFLAGS\t= in the Makefile. Am I missing something? May have been left over from testing. Since one Makefile is making another Makefile, I couldn't really track where the stuff after the ) was added - since they were the contents of $(LIBS), and since I was inserting $(LIBS) elsewhere already, I just removed the hard-coded linker flags as I found them. (In reply to comment #5) > Is net-libs/libnet installed on your system? Yes: # ls -l /usr/lib64/libnet* /usr/bin/procmail -rwsr-s--x 1 root root 88352 May 24 00:50 /usr/bin/procmail -rw-r--r-- 1 root root 203946 May 22 19:52 /usr/lib64/libnet.a -rw-r--r-- 1 root root 804 May 22 19:52 /usr/lib64/libnet.la lrwxrwxrwx 1 root root 15 May 22 19:52 /usr/lib64/libnet.so -> libnet.so.1.6.0 lrwxrwxrwx 1 root root 15 May 22 19:52 /usr/lib64/libnet.so.1 -> libnet.so.1.6.0 -rwxr-xr-x 1 root root 92568 May 22 19:52 /usr/lib64/libnet.so.1.6.0 -rw-r--r-- 1 root root 20766 Nov 26 17:49 /usr/lib64/libnetlink.a # ldd /usr/bin/procmail linux-vdso.so.1 => (0x00007fff731ff000) libm.so.6 => /lib64/libm.so.6 (0x00007f0e439fa000) libc.so.6 => /lib64/libc.so.6 (0x00007f0e43694000) /lib64/ld-linux-x86-64.so.2 (0x00007f0e43c7b000) > May have been left over from testing. Since one Makefile is making another > Makefile, I couldn't really track where the stuff after the ) was added - since > they were the contents of $(LIBS), and since I was inserting $(LIBS) elsewhere > already, I just removed the hard-coded linker flags as I found them. Well, here is one example command that is run on my laptop with procmail-3.22-r10: x86_64-pc-linux-gnu-gcc -O2 -pipe -march=core2 -fno-inline-functions lockfile.o exopen.o sublib.o acommon.o mcommon.o authenticate.o lastdirsep.o -o lockfile -Wl,-z,now -Wl,-O1 -Wl,--as-needed -lm -lnet -lnsl -ldl -lc And here is the same command after your patch: x86_64-pc-linux-gnu-gcc -O2 -pipe -march=core2 -fno-inline-functions -s -lm -lnsl -ldl -lc lockfile.o exopen.o sublib.o acommon.o mcommon.o authenticate.o lastdirsep.o -o lockfile Not good. I'll attach both build.logs in case you are interested. Created attachment 274539 [details]
procmail-3.22-r10 original build log
Created attachment 274541 [details]
procmail-3.22 build log after the patch
Comment on attachment 274347 [details, diff]
Remove -lnet, read my LIBS properly, put LDFLAGS before all objects and libs
Well, skip that last chunk and focus on the first one. We don't want to link against libnet in any case, not because it or something called the same name happens to be there.
I am nearly certain that net-libs/libnet has nothing to do with the -lnet in the Makefiles, but that some libnet library may have existed at some point on some obscure Unix-like OS.
OK, I noticed the original problem because on _one_ system, procmail could no longer find libnet.so, since it never needed it in the first place and should never have been linked to it. However, procmail was last emerged on that system (in 2009 when -r10 went stable) before --as-needed got added to the default LDFLAGS. To test I picked a seemingly random system with libnet installed, which happened to be a PA-RISC one, and tried to reproduce the problem, which succeeded. So I thought I had a case there. It turns out now that I cannot reproduce the problem on any other system than the PA-RISC, which gave us the build log I provided above and the `emerge --info' output in the Description. Apparently it ignores --as-needed for some reason. Let's say then that this is an HPPA problem. This no longer seems to be an issue. Installed net-libs/libnet, followed by mail-filter/procmail:
# ldd /usr/bin/procmail
linux-vdso32.so.1 (0xf7afe000)
libm.so.6 => /lib/libm.so.6 (0xf7654000)
libc.so.6 => /lib/libc.so.6 (0xf73c1000)
/lib/ld.so.1 (0xf77c1000)
Did not link to libnet. Retest please?
|