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

Roger Leigh rleigh at codelibre.net
Wed Nov 17 17:58:28 UTC 2010


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.

Please see the recent discussion on debian-ports and debian-gcc for
the detail.

It deliberately does the opposite of what the user requested, and it
means ELF initialisers are not run in the removed libraries.  Those
removed libraries may well have been needed--you can't tell!  Symbol
usage alone is *not sufficient* to make that determination.  In
short, it's broken, and not a sane *default*.  Using --as-needed on
a *per-package* basis may make sense, but to impose that level of
brokenness *globally* is *wrong*.

> Without this patch the configure failed at detecting libapt-pkg. The
> error was that the linking failed which made configure believe that
> libapt-pkg was missing:
> Exchanging the order of 'conftest.cpp' and '-lapt-pkg' fixes it as it
> matches then the described behaviour for ld:
> 
> ,----[ 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.

> The actual change is to use LIBS instead of LDFLAGS inside configure.ac.
> The patch was written by Michael Vogt.

Using LDFLAGS was wrong, and LIBS is the correct thing to use.
The patch looks correct, and I'll test it and apply it.


Thanks,
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/afb984f5/attachment.pgp>


More information about the Buildd-tools-devel mailing list