The following build: USE="-readline -gdbm apache2 bcmath bzip2 exif gd ldap pic posix soap snmp xml cgi zip truetype mysql calendar cdb cjk concurrentmodphp ctype curl curlwrappers -db2 dbase discard-path doc fastbuild filter flatfile force-cgi-redirect ftp gmp hash imap inifile -interbase iodbc json kerberos ldap-sasl libedit mcve mhash -msql mssql mysqli odbc pcntl pdo postgres qdbm -recode -sapdb sharedext -sharedmem simplexml sockets spell sqlite suhosin sysvipc threads tidy tokenizer wddx xmlreader xmlrpc xmlwriter xpm xsl yaz" emerge -va php fails with: checking for sasl_version in -lldap... no configure: error: LDAP SASL check failed. Please check config.log for more information. It succeeds if I disable LDFLAGS=--as-needed Just for record: [ebuild R ] net-nds/openldap-2.3.39-r2 USE="berkdb crypt gdbm ipv6 perl ssl tcpd -debug -kerberos -minimal -odbc -overlays -samba -sasl (-selinux) -slp -smbkrb5passwd" 0 kB [ebuild R ] dev-libs/cyrus-sasl-2.1.22-r2 USE="berkdb crypt gdbm pam ssl -authdaemond -java -kerberos -ldap -mysql -ntlm_unsupported_patch -postgres -sample -srp -urandom" 0 kB I've tried to rebuild openldap with sasl but that didn't helped. Same error, same reason in config.log: configure:67667: x86_64-pc-linux-gnu-gcc -o conftest -I/usr/include -O2 -pipe -march=athlon64 -mtune=athlon64 -msse3 -fomit-frame-pointer -pthread -D_REENTRANT -I/usr/include -L/usr/lib64 -Wl,--as-needed -Wl,--version-script=/usr/portage/dev-lang/php/files/php5-ldvs -lldap -llber -lsasl2 conftest.c -lldap -lt1 -lfreetype -lX11 -lXpm -lpng -lz -ljpeg -lresolv -lm -ldl -lnsl -lxml2 -lz -lm -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -ldl -lxml2 -lz -lm -lldap -llber >&5 /var/tmp/portage/dev-lang/php-5.2.6_rc1-r1/temp/ccWGjULo.o: In function `main': conftest.c:(.text+0x7): undefined reference to `sasl_version' collect2: ld returned 1 exit status BTW, if I change the order of libs (put -lsasl2 to the end) conftest.c compiles without any problems.
Created attachment 145528 [details] emerge --info
Created attachment 145530 [details] config.log
I guess that's still reproducible with 5.2.6 (final; I just committed it)? Was this a regression, i.e. did it work before 5.2.6_rc1?
(In reply to comment #3) > I guess that's still reproducible with 5.2.6 (final; I just committed it)? Yes, it is. > Was this a regression, i.e. did it work before 5.2.6_rc1? Actually never tried...
Created attachment 151975 [details, diff] php-5.2.6-ldap-sasl--as-needed.patch Well, I've found the problem. The checks inside ext/ldap/config.m4 does not update LIBS variable with -lsasl (or whatever necessary) before ldap sasl checks, that's why PHP_CHECK_LIBRARY(ldap, sasl_version... check fails. Attached patch fixes the issue.
Thanks for the analysis and the fix, I'll commit it in -r1 to the tree tomorrow (I'm trusting you on this as I cannot test it -- the patch looks good to me nevertheless).
I would have forgotten to do it tomorrow, so I did it now. :p -r1 in the tree, have fun and thanks for the patch. =)
Well, though this bug is marked as RESOLVED FIXED, so I'm a bit late, I'll still add my 2c. The whole problem of this bug comes actually from the fact that PHP_CHECK_LIBRARY, which is built around AC_CHECK_LIB, updates LDFLAGS, instead of LIBS. In my own overlay, I had for quite a while now a fix for the --as-needed issue based on fixing that macro.
Created attachment 152021 [details, diff] my --as-needed patch Probably nobody is interested in it by now, but I will drop here the patch I'm applying. Maybe somebody will still care to review it.
I *am* still intersted. :) I'll keep the bug marked as FIXED though, as the reported problem is (hopefully) fixed, just not the best way it seems. I'll see about asking some guys about the preferred solution tomorrow, we can always replace the current patch by yours in a new revision/version.
I am interested too. :) Rafał, seems that your patch fixes some other things I have not experienced here too... And I like your patch more as it fixes the problem in the first place. Actually I was about to submit patch here to change LDFLAGS->LIBS inside PHP_CHECK_LIB, but this change, although better, affects to many things and IMO should go upstream. Some questions: 1. In sapi/apache/config.m4 and sapi/apache_hooks/config.m4: - APXS_LDFLAGS="@SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@" + APXS_LIBS="@SYBASE_LFLAGS@ @SYBASE_LIBS@ @SYBASE_CT_LFLAGS@ @SYBASE_CT_LIBS@" Why don't you leave *_LFLAGS in APXS_LDFLAGS? Seems it's better and should not do any harm as we AC_SUBST(APXS_LDFLAGS) too. 2. seems that $(EXTRA_LDFLAGS) could be dropped in the following line: + link_cmd='$(LIBTOOL) --mode=link ifelse($4,,[$(CC)],[$(CXX)]) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) -Wl,-G -o '$3'/$1.la -export-dynamic -avoid-version -prefer-pic -module -rpath $(phplibdir) $(EXTRA_LDFLAGS) $($2) $(translit($1,a-z_-,A-Z__)_SHARED_LIBADD) $(EXTRA_LIBS) && mv -f '$3'/.libs/$1.so '$3'/$1.so' Isn't it?
Well, the catch is that I wrote this patch so long ago, that I no longer remember the reason for most of the changes. Also, I wrote it when I understood libtool much less the I do now. This patch is simply something that had `worked for me` since then, when I build php with useflags: USE="apache2 bcmath berkdb bzip2 calendar cgi cjk cli crypt ctype curl curlwrappers doc exif fastbuild filter flatfile force-cgi-redirect ftp gd-external gdbm gmp hash iconv imap inifile ipv6 json kerberos ldap ldap-sasl mhash mysql mysqli ncurses nls odbc pcntl pcre pdo pic posix postgres readline reflection session sharedext simplexml snmp soap sockets spell spl sqlite ssl suhosin sysvipc threads tidy tokenizer truetype unicode xml xmlreader xmlrpc xmlwriter xsl zip-external zlib -adabas -birdstep -cdb -concurrentmodphp -db2 -dbase -dbmaker -debug -discard-path -empress -empress-bcs -esoob -fdftk -firebird -frontbase -gd -interbase -iodbc (-java-external) -kolab -libedit -mcve -msql -mssql -oci8 -oci8-instant-client -qdbm -recode -sapdb -sharedmem -solid -sybase -sybase-ct -wddx -xpm -yaz -zip" On 1 from c11: you're probably right. On 2: actually it looks like the whole second block for acinclude.m4 in not needed (as I said, this was written long ago)
Created attachment 153653 [details, diff] corrected patch Just for reference, patch with unneded section removed. It seems that the most important part is that change to PHP_CHECK_LIBRARY. Is that macro an upstream bug or was that actually needed in older autotools releases ?