Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 352265

Summary: mail-mta/exim: linking with USE="-*" fails due to as-needed
Product: Gentoo Linux Reporter: Christian Ruppert (idl0r) <idl0r>
Component: [OLD] ServerAssignee: Fabian Groffen <grobian>
Severity: normal CC: net-mail+disabled, xarthisius
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 129413    
Attachments: build.log

Description Christian Ruppert (idl0r) gentoo-dev 2011-01-20 18:55:19 UTC
mail-mta/exim-{4.72,4.73} USE="-*" fails due to missing -ldl

x86_64-pc-linux-gnu-gcc -o exim -rdynamic -ldl acl.o child.o crypt16.o daemon.o dbfn.o debug.o deliver.o directory.o dns.o drtables.o enq.o exim.o expand.o filter.o filtertest.o globals.o dkim.o header.o host.o ip.o log.o lss.o match.o moan.o os.o parse.o queue.o rda.o readconf.o receive.o retry.o rewrite.o rfc2047.o route.o search.o sieve.o smtp_in.o smtp_out.o spool_in.o spool_out.o store.o string.o tls.o tod.o transport.o tree.o verify.o local_scan.o  malware.o mime.o regex.o spam.o spool_mbox.o demime.o bmi_spam.o spf.o srs.o dcc.o version.o \
	  routers/routers.a transports/transports.a lookups/lookups.a \
	  auths/auths.a pdkim/pdkim.a \
	  -lresolv -lnsl -lcrypt -lm    \
	   -ldb   \
	    -lpcre -Wl,-O1 -Wl,--as-needed -Wl,-z,now -Wl,--sort-common
local_scan.o: In function `local_scan':
local_scan.c:(.text+0x5e): undefined reference to `dlopen'
local_scan.c:(.text+0x77): undefined reference to `dlsym'
local_scan.c:(.text+0x91): undefined reference to `dlsym'
local_scan.c:(.text+0xba): undefined reference to `dlclose'
local_scan.c:(.text+0xe7): undefined reference to `dlerror'
local_scan.c:(.text+0x19c): undefined reference to `dlclose'
local_scan.c:(.text+0x1d9): undefined reference to `dlsym'
local_scan.c:(.text+0x1f1): undefined reference to `dlclose'
local_scan.c:(.text+0x229): undefined reference to `dlclose'
local_scan.c:(.text+0x249): undefined reference to `dlclose'

It also looks like LDFLAGS are passed at the end which should be at the beginning usually.
Comment 1 Kacper Kowalik (Xarthisius) (RETIRED) gentoo-dev 2011-02-01 11:58:23 UTC
passing -ldl as EXTRALIBS in ebuild should fix it, it's suggested way by upstream in src/EDITME

what's left to be done is don't pass library via LDFLAGS and put it in correct order
Comment 2 Fabian Groffen gentoo-dev 2011-02-01 12:57:00 UTC
> x86_64-pc-linux-gnu-gcc -o exim -rdynamic -ldl

The -ldl is actually in there.  Doesn't fail for me, but --as-needed comes later in the pipe.

We can discuss the ordering here, but Exim's build system isn't all that standard.  Anyhow, I can't reproduce your issue here with 4.74-r1.
Comment 3 Fabian Groffen gentoo-dev 2011-05-12 10:45:51 UTC
per comment #2
Comment 4 Christian Ruppert (idl0r) gentoo-dev 2011-07-03 12:49:02 UTC
Still fails here, even with 4.76
Comment 5 Christian Ruppert (idl0r) gentoo-dev 2011-07-03 12:49:30 UTC
Created attachment 278921 [details]
Comment 6 Fabian Groffen gentoo-dev 2011-07-03 17:41:36 UTC
what is your /bin/sh?
Comment 7 Fabian Groffen gentoo-dev 2011-07-03 17:47:14 UTC
/bin/sh: line 66: export: `LFLAGS+': not a valid identifier

That line is from the localscan_dlopen patch, which sets -ldl for Linux, but fails because /bin/sh doesn't like it, apparently
Comment 8 Christian Ruppert (idl0r) gentoo-dev 2011-07-03 17:52:42 UTC
lrwxrwxrwx 1 root root 9 Jun 16 20:56 /bin/sh -> /bin/bash*

If it is really a shell script then it shouldn't use += anyway.
Comment 9 Fabian Groffen gentoo-dev 2011-07-03 17:57:27 UTC
it is a makefile, odd it works for me (on Linux).
Comment 10 Fabian Groffen gentoo-dev 2011-07-03 18:09:42 UTC
I updated the patch to include spaces around the = and in particular the +=, can you try if this helps you to get further?
Comment 11 Christian Ruppert (idl0r) gentoo-dev 2011-07-04 09:20:23 UTC
Created attachment 279023 [details]

The sh error has been fixed but not the main issue
Comment 12 Fabian Groffen gentoo-dev 2011-07-04 09:24:43 UTC
from your log:
> x86_64-pc-linux-gnu-gcc -o exim -rdynamic -ldl 

So -ldl is in there.  What's in your LDFLAGS?  I suspect the linker doesn't like -ldl given this early in the process (before the object that needs it or something).  It apparently is stripped out of the list of libs to take into consideration.
Comment 13 Christian Ruppert (idl0r) gentoo-dev 2011-07-04 09:37:08 UTC
Ah, right.. I didn't notice the -ldl there. Now it is a as-needed issue.
Comment 14 Fabian Groffen gentoo-dev 2011-07-04 09:43:17 UTC
yup, I just read up on it, and I think I've found a solution.
Comment 15 Fabian Groffen gentoo-dev 2011-07-04 10:30:18 UTC
I just committed a fix, which I really hope fixes this issue.  It remains odd that I cannot reproduce it.  The link line should be as suggested in [1] now (although that document mentions as-needed is experimental and shouldn't be used in production environments).
Comment 16 Christian Ruppert (idl0r) gentoo-dev 2011-07-04 10:41:24 UTC
as-needed is enabled by default in Gentoo for months. The only difference here is that I *force* as-needed. So you can only reproduce it if you force it as well, through the gcc rules/specs file. See code listing 1.4 from your link.

I'll test the patch later and let you know if it is fixed or not.
Comment 17 Fabian Groffen gentoo-dev 2011-07-04 12:01:27 UTC
I know it is enabled by default for months, but QA apparently considers it still a no-no.  Anyway, that's beside the point here.  I see now.  Forcing as-needed indeed will trigger the problem, which explains why only a few people see this.  Good!
Comment 18 Christian Ruppert (idl0r) gentoo-dev 2011-07-04 16:45:53 UTC
Works, thx :)