bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple definition of gnulib symbols


From: Simon Josefsson
Subject: Re: Multiple definition of gnulib symbols
Date: Thu, 26 Apr 2007 10:44:41 +0200

On 26 apr 2007, at 01.04, Bruno Haible wrote:

Simon Josefsson wrote:
It seems clear that the problem is that both libgnutls and libgsasl
contains the same gnulib symbols.

Uh, you are jumping to the conclusion rather quickly.

Oops. I don't understand the error, so jumping to conclusion isn't unlikely.

First of all, can the reporter reproduce the problem also when building
without the -ffunction-sections option?

Yes, I asked him to do that and there were no change.

Second, the error message is about gc-libgcrypt.o and gc-gnulib.o in
particular, not about gnulib in general. These two object files define
different, but partially overlapping sets of symbols:
  - gc-libgcrypt.o defines gc_hash_hmac_setkey, gc-gnulib.o doesn't.
  - both define gc_init.
Possibly there are also differences due to the version of gnulib used in
the two libraries /usr/lib/libgnutls.a and .libs/libgsasl.a . It would
help if your reporter could give you the output of "nm" on these two
libraries.

Bennett, could you try running 'nm' on the libraries?

But yes, gc-libgcrypt and gc-gnulib are intended to be two mutually exclusive modules, since they provide the same symbols, but I wouldn't have thought that could lead to problem between two projects that each use gc-libgcrypt and gc-gnulib. I would have thought that these symbols would not be externally visible, but I guess there is no such concept with static libraries.

Or is there some libtool/ld/etc setting that gnulib or my
projects should use, to avoid causing this situation?

Such errors when linking statically typically occur when you have object files defining more than one symbol. The rest of gnulib doesn't see this
kind of error because most .o files define one and only one function.

Oh! I had no idea that defining multiple symbols in a single object file could lead to trouble. Sigh.

How can you turn a module that defines 10 functions into a module that
defines just 1 symbol? Combine the 10 functions into a vtable (= struct
containing function pointers). See the 'list' module for an example:
- The header file defines inline functions or macros that access individual
    elements of this function pointer table,
  - Any .o file only defines a named function pointer table.
(This is not to say that here you won't have versioning problems: If at
some moment you add an 11th function pointer, two compiled versions of
this module will be binary incompatible.)

I see.  Seems somewhat complicated...

One solution might be for gnulib-tool to change the namespace of all
gnulib functions to 'gnutls_*' and 'gsasl_*' respectively, when
importing them into each project.

Yes. Ralf was the first one to realize the need for such a renaming. It can be done in a Makefile.am rule without special help from gnulib- tool. See
gettext/gettext-tools/libgettextpo/Makefile.am.

Aha! Ok, I think that approach may be simpler, if it already can be automated easily. I'll wait with implementing it until I can confirm and understand why it would be needed though, it seems I can learn something here.

Thanks,
Simon





reply via email to

[Prev in Thread] Current Thread [Next in Thread]