[buildd-tools-devel] Ubuntu patch for postgresql-debversion to build with --as-needed

Roger Leigh rleigh at codelibre.net
Wed Nov 17 23:43:24 UTC 2010


On Wed, Nov 17, 2010 at 07:22:36PM +0100, Michael Bienia wrote:
> On 2010-11-17 17:58:28 +0000, Roger Leigh wrote:
> > On Wed, Nov 17, 2010 at 06:28:22PM +0100, Michael Bienia wrote:
> > > the following patch was needed to get postgresql-debversion build again
> > > after --as-needed was added to the default linker flags in Ubuntu natty.
> > 
> > Seriously?  This is *not* a technically sensible default for your
> > toolchain.
> 
> Yes, see the announcement from Matthias Klose on ubuntu-devel-announce:
> https://lists.ubuntu.com/archives/ubuntu-devel-announce/2010-November/000783.html

Ye gods, I hope they have a rethink.  That's shockingly broken.

> > > ,----[ ld manpage; -l option ]-
> > > | The linker will search an archive only once, at the location where
> > > | it is specified on the command line.  If the archive defines a
> > > | symbol which was undefined in some object which appeared before the
> > > | archive on the command line, the linker will include the
> > > | appropriate file(s) from the archive.  However, an undefined symbol
> > > | in an object appearing later on the command line will not cause the
> > > | linker to search the archive again.
> > > `----
> > 
> > This is, as far as I understand, referring to "archives" only, that is
> > .a and .o files.  I don't think this rule applies to shared libraries,
> > but I may be wrong.
> > 
> > Given that this has only just become a problem--it's been working
> > happily using the wrong order since early 2009--there's some other
> > change in your toolchain as well.  Are you using gold as your linker?
> > This is stricter than the old ld, and may impose stricter ordering
> > requirements.
> 
> There was also changes regarding indirect linking, but I don't believe
> that this applies here as configure uses -lapt-pkg (but I've only a very
> limited knowledge about linking).
> 
> While trying to figure out why it doesn't work anymore, I tried the
> generated conftest.cpp (as found in the config.log) to link (inside my
> natty pbuilder):
> 
> - g++ -o conftest -g -O2  -Wl,-Bsymbolic-functions -lapt-pkg conftest.cpp
> => linking fails as it doesn't find "debVS"
> - g++ -o conftest -g -O2  -Wl,-Bsymbolic-functions,--no-as-needed -lapt-pkg conftest.cpp
> => linking works
> 
> Michael Vogt found out that using 
> g++ -o conftest -g -O2  -Wl,-Bsymbolic-functions conftest.cpp -lapt-pkg
> works too.
> 
> Perhaps you have a better explanation why this last one worked.

Ordinarily, specifying -lapt-pkg first makes no difference.  But when
combined with with --as-needed, it's dropped because there are no
symbols required from it /at that point/.  It later fails due to the
missing unresolved symbol.  Previous versions of the linker, I assume,
only consider symbols from shared objects after linking all archives
together, making the order of shared objects unimportant--they just
get added as DT_NEEDED as you would expect.

This could be considered to be a linker bug when using --as-needed,
though it is clearly a positional parameter, so could be intended.


You can get a fixed postgresql-debversion (1.0.4-1) from debian
unstable or the git repo (tag debian/postgresql-debversion-1.0.4-1).


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/buildd-tools-devel/attachments/20101117/8bb72274/attachment.pgp>


More information about the Buildd-tools-devel mailing list