GNOME Bugzilla – Bug 349548
Compile error: --as-needed v. cygwin
Last modified: 2007-03-19 07:54:48 UTC
Please describe the problem: Compiling the package with binutils 2.17 and LDFLAGS="-Wl,--as-needed" leads to the following error: make[2]: Entering directory `/tmp/gnomebuild/spb-libgda-21387/libgda/report/testing' if gcc -DPACKAGE_NAME=\"GNU\ Data\ Access\" -DPACKAGE_TARNAME=\"libgda\" -DPACKAGE_VERSION=\"1.9.103\" -DPACKAGE_STRING=\"GNU\ Data\ Access\ 1.9.103\" -DPACKAGE_BUGREPORT=\"gnome-db-list@gnome.org\" -DBONOBO_EXPLICIT_TRANSLATION_DOMAIN=\"libgda-3\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DYYTEXT_POINTER=1 -DGETTEXT_PACKAGE=\"libgda-3\" -DHAVE_LOCALE_H=1 -DHAVE_LC_MESSAGES=1 -DHAVE_BIND_TEXTDOMAIN_CODESET=1 -DHAVE_GETTEXT=1 -DHAVE_DCGETTEXT=1 -DENABLE_NLS=1 -DHAVE_FAM= -DHAVE_MYSQL=1 -DHAVE_POSTGRES=1 -DHAVE_FIREBIRD=1 -DHAVE_LDAP=1 -DHAVE_POPT_H=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -I. -I. -I../.. -I../.. -I../../report -I../../report -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -I/usr/X11/include -march=athlon-xp -O -pipe -g -ggdb -MT gda-report-test.o -MD -MP -MF ".deps/gda-report-test.Tpo" -c -o gda-report-test.o gda-report-test.c; \ then mv -f ".deps/gda-report-test.Tpo" ".deps/gda-report-test.Po"; else rm -f ".deps/gda-report-test.Tpo"; exit 1; fi /bin/sh ../../libtool --tag=CC --mode=link gcc -I/usr/X11/include -march=athlon-xp -O -pipe -g -ggdb -Wl,--as-needed -o gda-report-test gda-report-test.o ../../libgda/libgda-3.la ../../libgda/graph/libgda_graph-3.la ../../libgda/handlers/libgda_handlers-3.la ../../libgda/sql-delimiter/libgda_sql_delimiter-3.la ../../report/libgda-report/libgda-report-3.la -pthread -Wl,--export-dynamic -lgobject-2.0 -lgthread-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lxslt -lxml2 -lz -lm mkdir .libs gcc -I/usr/X11/include -march=athlon-xp -O -pipe -g -ggdb -Wl,--as-needed -o .libs/gda-report-test gda-report-test.o -pthread -Wl,--export-dynamic ../../libgda/.libs/libgda-3.so -L/usr/lib ../../libgda/graph/.libs/libgda_graph-3.so ../../libgda/handlers/.libs/libgda_handlers-3.so ../../libgda/sql-delimiter/.libs/libgda_sql_delimiter-3.so ../../report/libgda-report/.libs/libgda-report-3.so /tmp/gnomebuild/spb-libgda-21387/libgda/libgda/.libs/libgda-3.so /usr/lib/libgamin-1.so /tmp/gnomebuild/spb-libgda-21387/libgda/libsql/.libs/libgdasql.so /usr/lib/libgobject-2.0.so /usr/lib/libgthread-2.0.so -lpthread /usr/lib/libgmodule-2.0.so /usr/lib/libglib-2.0.so /usr/lib/libxslt.so /usr/lib/libxml2.so -ldl -lz -lm ../../libgda/.libs/libgda-3.so: undefined reference to `gda_handler_string_new' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_delimiter_parse_copy_statement' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_handler_bin_new' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_graph_new' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_graph_query_new' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_handler_type_new' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_delimiter_parse_with_error' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_delimiter_destroy' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_handler_time_new_no_locale' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_graph_get_graph_type' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_delimiter_free_list' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_graph_get_type' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_delimiter_concat_list' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_handler_boolean_new' ../../libgda/.libs/libgda-3.so: undefined reference to `gda_handler_numerical_new' collect2: ld returned 1 exit status make[2]: *** [gda-report-test] Error 1 make[2]: Leaving directory `/tmp/gnomebuild/spb-libgda-21387/libgda/report/testing' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/tmp/gnomebuild/spb-libgda-21387/libgda/report' make: *** [all-recursive] Error 1 Thats because of some missing dependencies. I'll send a patch that fixed my issue hopefully it will be accepted Cheers Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Created attachment 70032 [details] [review] Compiler fix
Sorry for the delay. Could you update this for the latest code in cvs, if possible? It would also be nice if you could patch the ChangeLog.
This appears to be similar to the Cygwin build issues recently fixed in bug 314732. I don't understand how this patch will help because libgda-3.0 is interdependent with libgda_graph-3.0 and libgda_handlers-3.0; why doesn't this error occur when linking the latter?
Created attachment 79776 [details] [review] Patch This patch is applicable to svn trunk. It compiles fine, but I don't understand why somebody added: libgda_graph_3_0_la_LIBADD = ../libgda-3.0.la $(LIBGDA_LIBS) to libgda/graph/Makefile.am and libgda/handlers/Makefile.am That's useless as far as I see. Cheers
Created attachment 79829 [details] [review] Patch This patch is applicable to svn trunk. It compiles fine, but I don't understand why somebody added: libgda_graph_3_0_la_LIBADD = ../libgda-3.0.la $(LIBGDA_LIBS) to libgda/graph/Makefile.am and libgda/handlers/Makefile.am That's useless as far as I see. Cheers
> This patch is applicable to svn trunk. It compiles fine, but I don't understand > why somebody added: Because libgda-3.0 and libgda_graph-3.0 are *interdependent*; see bug 314732 for details.
Cygwin (Mr Ports), could please check that this patch doesn't break your win32 build.
> Cygwin (Mr Ports), could please check that this patch doesn't break your win32 > build. It does break it. I've already said that libgda-3.0 is INTERDEPENDENT with libgda_graph-3.0 and libgda_handlers-3.0, leaving the bootstrap as the only option for Win32. This patch just reverses the situation; libgda-3.0 will link, but libgda_graph and libgda_handlers will need to be boostrapped instead. (I still don't understand why this patch helps, as the latter two should have the same problem instead.)
OK, so: Do we need to choose between "cygwin build" and "Compiling the package with binutils 2.17 and LDFLAGS="-Wl,--as-needed""? Or is there some way to make both things work?
Does anyone have any ideas?
Don't have a linux box available, so it's hard for me to even verify this. I still don't understand why the proposed solution would help.
And I can't verify this on windows. Could you please post an error log? The patch I posted seems obvious to me, because libgda-3.so calls routines defined in libgda_handlers-3.so and libgda_graph-3.so.
> And I can't verify this on windows. Could you please post an error log? There is none. 2.99.5 builds on Cygwin with a minor patch, already in Bugzilla. > The patch I posted seems obvious to me, because libgda-3.so calls routines > defined in libgda_handlers-3.so and libgda_graph-3.so. But they are ***INTER***dependent; libgda_{graph,handlers}-3.0 also require libgda-3.0. Win32 (both Cygwin and MinGW) have two peculiarities: ld's default behaviour is like --as-needed, and libraries must have all symbols resolved at link time. This would make it impossible to build on Cygwin or MinGW, except for the bootstrapping which I introduced. But this doesn't generally affect other platforms. Now --as-needed seems to complicate things on Linux as well. I just don't understand why your patch would help; I would think that you would just get the opposite (libgda-{graph,handlers}-3.0 undefined symbols errors, which are found in libgda-3.0). Gentoo's guide on --as-needed is quite educational (see the paragraph "Failure in final linking, undefined symbols"): http://www.gentoo.org/proj/en/qa/asneeded.xml That makes me wonder how libgda could work at all with --as-needed. What version of binutils are you running, and on which distro? Could you attach a complete build log of 2.99.5 or SVN trunk?
Created attachment 83484 [details] complete build log. I'm using gcc v4.1.2, binutils v2.17.50.0.12 and libtool v1.5.23a on slackware. The attachment contains the output of "./configure && make", as you see it compiles just fine.
This is with your patch or without?
This is with my patch, without a get what a posted above. I'll post another without the patch soon.
Created attachment 83503 [details] build log this time I did not patch.
What happens if you just remove the '../libgda-3.0.la' from libgda_{graph,handlers}_3_0_la_LIBADD, without any changes to libgda_3_0_la_LIBADD?
See attachment on comment #17. Please note that I can compile libgda-3.0.so, but I can not use it because of missing references at runtime.
As was just pointed out on the list, the interdependency breaks -Wl,-z,defs as well. The accepted proposal to rework the libraries should resolve this as well (in addition to removing the need for Win32 bootstrapping).
By the way, libgnomedb is suffering the same problem, there is an interdependency between libgnomedb-3 and libgnomedb-handlers-3.
Yes, I know; I should have a patch for libgda trunk tonight, then I'll move to libgnomedb. There is one problem with this technique for libgnomedb: libgnomedb/data-entries/plugins/ would have to be moved up one or two levels so that libgnomedb-3.la will be compiled before libgnomedb_entry_builtin_plugins.la which depends on it. While I'm at it, should libgnomedb*-3 be renamed to -3.0 as was done with libgda?
Created attachment 84552 [details] [review] libgda-merge-libs.patch * Makefile.am * configure.in * doc/C/Makefile.am * libgda-3.0.pc.in * libgda/Makefile.am * libgda/graph/Makefile.am * libgda/handlers/Makefile.am * libgda/sql-delimiter/Makefile.am * libgda/sql-transaction/Makefile.am * providers/freetds/Makefile.am * providers/mdb/Makefile.am * providers/mysql/Makefile.am * providers/postgres/Makefile.am * providers/sqlite/Makefile.am * report/testing/Makefile.am * testing/Makefile.am * tests/Makefile.am * tools/Makefile.am: Change libgda sublibs to convenience libs and merge them into libgda-3.0.la. Fixes compilation with -Wl,--as-needed or -Wl,-z,defs and obsoletes the Win32 bootstrapping; see bug 349548 and others. * win32/Makefile.am * win32/dummy.la * win32/libgda_graph-3.0.def * win32/libgda_handlers-3.0.def: Removed.
Patch applied, can I close the bug?
Could OP verify first?
Looks good to me.