ID: 42374 Updated by: [EMAIL PROTECTED] -Summary: --as-needed bug - follow-up Reported By: galtgendo at o2 dot pl -Status: Open +Status: Assigned Bug Type: Compile Failure -Operating System: gentoo linux +Operating System: Gentoo -PHP Version: 5.2.3 +PHP Version: 5.2CVS-2007-08-23 -Assigned To: +Assigned To: jani New Comment:
After some investigation to this flag I'm leaning towards simply filtering it out totally if someone tries to use it. Reasons being: a) it seems to be experimental b) might cause problems in dynamic loading such as our shared extensions, f.e. php -> pdo -> pdo driver (haven't tested yet :) c) requires that pretty much everything in the system has to be compiled using it d) PHP build system does not link with anything else than what is actually needed anyway (AFAIK) Previous Comments: ------------------------------------------------------------------------ [2007-08-23 15:30:49] galtgendo at o2 dot pl For a simple test case: #include <glib.h> int main() { g_print("test done\n"); return 0; } gcc -o minitest -Wl,--as-needed `pkg-config glib-2.0 --cflags` minitest.c `pkg-config glib-2.0 --libs` - compiles fine gcc -o minitest -Wl,--as-needed `pkg-config glib-2.0 --cflags` `pkg-config glib-2.0 --libs` minitest.c - gives /tmp/ccKZrHDW.o: In function `main': minitest.c:(.text+0x19): undefined reference to `g_print' collect2: ld returned 1 exit status ------------------------------------------------------------------------ [2007-08-23 15:21:10] galtgendo at o2 dot pl Well, that's incorrect. PHP_CHECK_LIBRARY calls AC_CHECK_LIB. without -Wl,--as-needed it does not matter whether libs are in LDFLAGS or in LIBS, with that flag however all dependent libraries must appear after the objects. AC_CHECK_LIB does something like i686-pc-linux-gnu-gcc -o conftest ${CFLAGS} ${LDFLAGS} conftest.c ${LIBS} (more or less) that check fails with --as-needed flag if lib is added to LDFLAGS so it does not matter if it gets restored, cause the check already failed - those are the false negatives I'm talking about. All the other macros from the patch seem to do this, so that's why I changed them. I'm not sure if something got broken, however it was correct for the ext/ldap/config.m4 so there's at least a chance it will work for the rest. ------------------------------------------------------------------------ [2007-08-23 10:38:24] [EMAIL PROTECTED] PHP_CHECK_LIBRARY restores the LDFLAGS after doing the test so it shouldn't be any problem? And bug #41973 was about ext/ldap and that was fixed. I'd fix these case by case rather than blindly changing places unlikely to even cause any problems. ------------------------------------------------------------------------ [2007-08-22 15:40:41] galtgendo at o2 dot pl Well, I'm not 100%, if I was, I would mentioned it, not asked for futher testing. And AFAIK that commit from bug #41973 was only http://cvs.php.net/viewvc.cgi/php-src/ext/ldap/config.m4?r1=1.44&r2=1.45&diff_format=u so only about ext/ldap/config.m4 (as in my patch). What's more, although I can't recall if it made any difference you should consider changes in acinclude.m4, cause in PHP_CHECK_LIBRARY macro you were adding libraries to LDFLAGS instead of LIBS and that's most common source of --as-needed bugs. That's why I'm talking about false negatives - standard configure check would put those libraries in wrong place and check would fail even if the library was OK. ------------------------------------------------------------------------ [2007-08-22 14:46:27] [EMAIL PROTECTED] And have you even tested what was committed in our CVS? ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/42374 -- Edit this bug report at http://bugs.php.net/?id=42374&edit=1