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

Michael Bienia michael at bienia.de
Wed Nov 17 18:22:36 UTC 2010


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

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

Will do (even if it's just for my own knowledge).

> > ,----[ 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.

Michael



More information about the Buildd-tools-devel mailing list