pkg-config2

Mike Hearn mike at navi.cx
Wed Feb 23 12:29:00 EET 2005


On Sat, 22 Jan 2005 18:49:40 -0500, Ian Reinhart Geiser wrote:
> Interested parties should kick it around and suggest patches.  We are still 
> working on Win32 support.  It build right now with mingw32, but the paths are 
> still not correct.  This is alpha and should be updated later this week.

Leaving aside the issue of whether it should exist, which I'm not getting
into, one thing I'd like to see is the ability to tweak the pkg-config
output based on things like what compiler/linker features are supported.

In particular, the --as-needed flag to ld. Right now we have this problem: 

[mike at littlegreen ~]$ pkg-config --libs libxslt
-lxslt -lxml2 -lpthread -lz -lm

As you can see it lists not only libxslt but also its dependencies.

Now you might say, but why is this a problem? It shows more -l switches
than you may expect but who cares, as everybody has libZ and libM and
libpthread.

Well here it doesn't matter so much. But for other libraries it does. This
sort of thing led to an inadvertent backwards compatibility break in GTK+
when an internal dependency (I forget which...) was dropped and no longer
shipped, but a bunch of apps out there were linked against it and broke
even though they didn't use it directly.

The reason pkg-config does this is (I think) for static linking. If you
want to statically link a library then you need to enumerate the
dependencies of that library explicitly because .a files don't contain
them. It may also be for compatibility with old-skool toolchains that
*require* you to enumerate every dependency like that.

But whatever the reason, the damage has been done and every .pc file looks
like this. Fortunately there is a new ld switch which will drop any -l
switches that aren't actually used by the program, so meaning these "bogus
dependencies" are no longer a problem. Unfortunately it's still quite new
(middle of last year?) and of course is GNU specific.

So what I'd love to see is pkg-config supporting this somehow, maybe it
already does, but ideally I'd like it to happen transparently without
having to patch all the bazillions of .pc files out there.

thanks -mike




More information about the xdg mailing list