Bug 56699

Summary: pkg-config doesn't handle options that need to be stuck together semantically
Product: pkg-config Reporter: Zoltán Böszörményi <zboszor>
Component: srcAssignee: pkg-config
Status: RESOLVED DUPLICATE QA Contact:
Severity: major    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Patch against 0.27.1 to implement whole-archive library handling
Patch against current GIT to implement whole-archive library handling

Description Zoltán Böszörményi 2012-11-02 21:21:49 UTC
I found out that if I put these into a .pc file in this order:
  -L<directory> ...
  <list of regular shared libs>
  -Wl,--whole-archive
  <list of static libs linked as whole archive>
  -Wl,--no-whole-archive
then pkg-config completely messes up the output, so the result doesn't mean the same to GCC.

The output is:
  -Wl,--whole-archive
  -Wl,--no-whole-archive
  -L<directory> ...
  <list of shared and static libs together>

The result of linking using these options will be different.

As an example, xulrunner needs "-Wl,--whole-archive -lmozglue  -lmemory -Wl,--no-whole-archive" as is, otherwise calling NS_InitXPCOM2() ends in a segmentation fault.
Comment 1 Zoltán Böszörményi 2012-11-02 21:22:46 UTC
Created attachment 69468 [details] [review]
Patch against 0.27.1 to implement whole-archive library handling
Comment 2 Zoltán Böszörményi 2012-11-02 21:23:09 UTC
Created attachment 69469 [details] [review]
Patch against current GIT to implement whole-archive library handling
Comment 3 Dan Nicholson 2012-11-06 14:38:57 UTC
Thanks a lot for the patch. Unfortunately, I don't think this path can be taken because it would require pkg-config to have special case handling for every linker or compiler flags that's not -l/-L/-I. I think this has to be treated more generally, and I plan to attach something soon in our existing bug19950.

*** This bug has been marked as a duplicate of bug 19950 ***

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.