Bug 9917

Summary: pkg-config does not support mixed static+shared library environment
Product: pkg-config Reporter: Stanislav Brabec <sbrabec>
Component: srcAssignee: Tollef Fog Heen <tfheen>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: medium CC: marcandre.lureau, pachoramos1
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Stanislav Brabec 2007-02-08 07:07:32 UTC
On many environments, some libraries cannot be built statically for good reasons (e. g. because it can load modules, which can use any symbol from the library).

If the upper level library can be built as static, it's impossible to create any pkg-config file, which will work correctly.

Example:
gtk+ is not build statically (statically linked binaries may fail on loading themes, input methods or so)
libgnome is built statically

To be able to build as-much-as-possible-static binary, you need (on Linux):

$(Libs from libgnome) $(Libs.private from libgnome)

Part of $(Libs from libgnome) has to expand to -Wl,-Bdynamic $(Libs from gtk+-2.0) -Wl,-Bstatic

But currently there is no way to specify any Ldflags inside .pc file and any items in Libs are sorted.


Proposed fix (backward compatible):

Implement "Libs.sharedonly:"

Proposed behavior for --static:

Collect all libs from "Libs:" and "Libs.private:".
Then collect all libs from "Libs.sharedonly:" and remove them from collected libs.

Then create command line:
all_libs_without_sharedonly -Wl,-Bdynamic all_sharedonly_libs -Wl,-Bstatic


Proposed fix (backward incompatible):

Support ${sharedonly} ${endsharedonly} variables in "Libs:".

Collect anything inside sharedonly into the separate list.
Comment 1 Dan Nicholson 2012-10-29 02:47:50 UTC
I see some merit in this proposal, but I don't see enough gain for an intrusive change that also requires new pc file syntax. I'm going to say that pkg-config will not support a mixed static and shared scenario. For this use case, I think you're on your own. Thanks for the suggestion.

For what it's worth, I'm working on the sorting bugs that hopefully can help this use case with the current pc file format.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.