Bug 29801

Summary: pkg.m4:_PKG_CONFIG doesn't check the return code of "pkg-config --libs|--cflags"
Product: pkg-config Reporter: Diab Jerius <djerius>
Component: srcAssignee: Tollef Fog Heen <tfheen>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: medium CC: ernstp
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: patch _PKG_CONFIG in pkg.m4

Description Diab Jerius 2010-08-25 08:40:36 UTC
Created attachment 38142 [details] [review]
patch _PKG_CONFIG in pkg.m4

_PKG_CONFIG doesn't check the return results of "pkg-config --libs|--cflags" and thus fails to notice when "pkg-config --exists" succeeds, but "pkg-config --libs|--cflags" doesn't.  This can happen when a package exists but one of its dependencies doesn't.

I've modified the code (see attachment) to check the results.  Unfortunately this turned up another feature, namely that 'pkg-config --print-errors' doesn't pick the error, so the error message that iss dumped doesn't say anything about why the check failed.  

I removed the redirect to /dev/null in the call to pkg-config in _PKG_CONFIG in order to display the failure.  A bit of a kludge...
Comment 1 Dan Williams 2010-11-07 13:30:00 UTC
Running into this too with jhbuild for GNOME.  jhbuild builds nspr 4.8.4 in private prefix, but does not build nss or nss-utils.  Instead, my local system has nss & nss-utils, which both require nspr >= 4.8.6.  So when building something inside jhbuild's prefix that wants NSS, the PKG_CHECK_MODULES(NSS, nss >= 3.11) succeeds but NSS_CFLAGS and NSS_LIBS is empty due to the dependency error:

[dcbw]$ pkg-config --exists --print-errors "nss >= 3.11"
[dcbw]$ echo $?
0
[dcbw]$ pkg-config --cflags --libs nss >= 3.11
Package 'NSS-UTIL' requires 'nspr >= 4.8.6' but version of NSPR is 4.8.4
[dcbw]$ echo $?
1

which makes me believe that the PKG_CHECK_MODULES should fail.
Comment 2 Ernst Sjöstrand 2010-12-28 17:16:44 UTC
I hit this too today, seems like a good thing to fix.
Comment 3 Tollef Fog Heen 2011-05-15 05:10:27 UTC
This has been fixed in git.

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.