Bug 64674 - PKG_CHECK_MODULES assumes both --cflags and --libs succeed or fail
Summary: PKG_CHECK_MODULES assumes both --cflags and --libs succeed or fail
Status: RESOLVED DUPLICATE of bug 36039
Alias: None
Product: pkg-config
Classification: Unclassified
Component: src (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Dan Nicholson
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-16 15:36 UTC by Ross Burton
Modified: 2013-05-19 02:29 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
[PATCH] Error from PKG_CHECK_MODULES if either --cflags or --libs fails (1.15 KB, patch)
2013-05-18 02:31 UTC, Dan Nicholson
Details | Splinter Review

Description Ross Burton 2013-05-16 15:36:10 UTC
But this isn't the case depending on the .pc file.  It's possible that --cflags fails and --libs succeeds, but as the error value is only checked after --libs pkg.m4 believes that the calls succeeded.  This results in the _CFLAGS variable being empty, leading to confused looks and scratched heads.
Comment 1 Dan Nicholson 2013-05-17 12:07:20 UTC
PKG_CHECK_MODULES calls _PKG_CONFIG for both --cflags and --libs, which calls PKG_CHECK_EXISTS. What's supposed to happen is that --exists exits if package requirements for --cflags or --libs can't be met. Unfortunately, there was a bug where --exists was ignoring Requires completely. See bug 43149. What version of pkg-config are you using? That bug should be fixed in 0.28.

Still, whether it's that bug or something else, the right thing to do is have PKG_CHECK_MODULES check status after each call to _PKG_CONFIG.
Comment 2 Ross Burton 2013-05-17 13:49:58 UTC
Turns out we're running a relatively old pkgconfig 0.25.
Comment 3 Dan Nicholson 2013-05-18 02:31:48 UTC
Created attachment 79489 [details] [review]
[PATCH] Error from PKG_CHECK_MODULES if either --cflags or --libs fails


Older pkg-config (versions 0.24-0.26) had a bug where --exists failed to
honor Requires. See commit 3ead3dfb. This means that some versions can
fail --cflags but pass --libs. Ensure that PKG_CHECK_MODULES will return
an error if either fails.

Freedesktop #64674 (https://bugs.freedesktop.org/show_bug.cgi?id=64674)
---
 pkg.m4 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Comment 4 Dan Nicholson 2013-05-18 02:34:49 UTC
I think this patch should fix things. Can you check?

Unfortunately, it still leaves you in the position that you have to update pkg-config or autoreconf every package. By the way, the fix went into pkg-config-0.27, not 0.28. I've put a lot of effort into beefing up the test suite to make sure there are no regressions, so I think you'd be pretty safe if you want to upgrade.
Comment 5 Dan Nicholson 2013-05-19 02:29:40 UTC
Actually, I think this was already fixed some time ago and you're just being hit with old pkg.m4. Commit 4366f58 fixing bug 36039 is in pkg-config-0.26 and newer. This should make any failures in the --exists/--cflags/--libs chain error out. Maybe you can grab a newer pkg.m4 or just try to patch yours with this:

http://cgit.freedesktop.org/pkg-config/commit/?id=4366f58

I tried to reproduce this with pkg-config-0.25 and found that patch prevented it. I'm going to close this, but reopen if that doesn't fix things for you.

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


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.