After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 349548 - Compile error: --as-needed v. cygwin
Compile error: --as-needed v. cygwin
Status: RESOLVED FIXED
Product: libgda
Classification: Other
Component: general
1.9.x
Other All
: Normal normal
: ---
Assigned To: Rodrigo Moya
gnome-db Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-08-01 15:30 UTC by christopher taylor
Modified: 2007-03-19 07:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Compiler fix (768 bytes, patch)
2006-08-01 15:31 UTC, christopher taylor
none Details | Review
Patch (1.83 KB, patch)
2007-01-08 19:07 UTC, christopher taylor
none Details | Review
Patch (1.83 KB, patch)
2007-01-09 08:21 UTC, christopher taylor
none Details | Review
complete build log. (711.35 KB, text/plain)
2007-02-27 18:24 UTC, christopher taylor
  Details
build log (675.83 KB, text/plain)
2007-02-27 22:59 UTC, christopher taylor
  Details
libgda-merge-libs.patch (40.82 KB, patch)
2007-03-14 04:19 UTC, Yaakov Selkowitz
none Details | Review

Description christopher taylor 2006-08-01 15:30:36 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:
Comment 1 christopher taylor 2006-08-01 15:31:25 UTC
Created attachment 70032 [details] [review]
Compiler fix
Comment 2 Murray Cumming 2006-12-27 17:20:20 UTC
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.
Comment 3 Yaakov Selkowitz 2006-12-29 07:39:50 UTC
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?
Comment 4 christopher taylor 2007-01-08 19:07:01 UTC
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
Comment 5 christopher taylor 2007-01-09 08:21:42 UTC
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
Comment 6 Yaakov Selkowitz 2007-01-10 05:38:29 UTC
> 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.
Comment 7 Murray Cumming 2007-01-17 15:11:11 UTC
Cygwin (Mr Ports), could please check that this patch doesn't break your win32 build.
Comment 8 Yaakov Selkowitz 2007-01-18 05:51:18 UTC
> 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.)
Comment 9 Murray Cumming 2007-01-19 12:15:07 UTC
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?
Comment 10 Murray Cumming 2007-02-06 15:55:16 UTC
Does anyone have any ideas?
Comment 11 Yaakov Selkowitz 2007-02-26 03:00:15 UTC
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.
Comment 12 christopher taylor 2007-02-26 18:35:39 UTC
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.
Comment 13 Yaakov Selkowitz 2007-02-26 19:59:11 UTC
> 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?
Comment 14 christopher taylor 2007-02-27 18:24:13 UTC
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.
Comment 15 Yaakov Selkowitz 2007-02-27 20:00:07 UTC
This is with your patch or without?
Comment 16 christopher taylor 2007-02-27 22:49:27 UTC
This is with my patch, without a get what a posted above. I'll post another without the patch soon.
Comment 17 christopher taylor 2007-02-27 22:59:40 UTC
Created attachment 83503 [details]
build log

this time I did not patch.
Comment 18 Yaakov Selkowitz 2007-03-05 21:30:18 UTC
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?
Comment 19 christopher taylor 2007-03-06 10:38:16 UTC
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.
Comment 20 Yaakov Selkowitz 2007-03-13 02:20:36 UTC
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).
Comment 21 christopher taylor 2007-03-13 08:00:40 UTC
By the way, libgnomedb is suffering the same problem, there is an interdependency between libgnomedb-3 and libgnomedb-handlers-3.
Comment 22 Yaakov Selkowitz 2007-03-13 13:43:23 UTC
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?
Comment 23 Yaakov Selkowitz 2007-03-14 04:19:30 UTC
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.
Comment 24 malerba 2007-03-15 19:17:22 UTC
Patch applied, can I close the bug?
Comment 25 Yaakov Selkowitz 2007-03-15 21:45:32 UTC
Could OP verify first?
Comment 26 christopher taylor 2007-03-17 12:31:50 UTC
Looks good to me.