Bug 99770

Summary: Unknown keyword Libs.private detected in dbus-1.pc by pkg-config 0.28
Product: pkg-config Reporter: Ralf Habacker <ralf.habacker>
Component: srcAssignee: Dan Nicholson <nicholson>
Status: RESOLVED FIXED QA Contact:
Severity: trivial    
Priority: lowest CC: nicholson
Version: unspecified   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: parse: Don't emit unknown keyword warning for Libs.private

Description Ralf Habacker 2017-02-11 10:33:24 UTC
Testing dbus-1.pc pkg config file with

PKG_CONFIG_DEBUG_SPEW=1 pkg-config /home/xxx/src/dbus-2-cmake-build/tmp/usr/local/lib/pkgconfig/dbus-1.pc dbus-1 --libs

returns valid informations for example this:

  line>Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include 

but also an error
  line>Libs.private:  -lc -lpthread -l/usr/lib64/librt.so
Unknown keyword 'Libs.private' in '/home/xxx/src/dbus-2-cmake-build/tmp/usr/local/lib/pkgconfig/dbus-1.pc'
Comment 1 Simon McVittie 2017-02-13 12:26:14 UTC
Where did you get pkg-config 0.82? https://www.freedesktop.org/wiki/Software/pkg-config/ says the latest version is 0.29.1.

https://manpages.debian.org/jessie/pkg-config/pkg-config.1.en.html and https://manpages.debian.org/unstable/pkg-config/pkg-config.1.en.html (versions of different ages) both document Libs.private.
Comment 2 Simon McVittie 2017-04-07 11:41:22 UTC
This seems to be a (very minor) pkg-config bug: when run without --static (i.e. ignoring Libs.private), its debug output reports Libs.private as an unknown keyword.

This is on Debian's pkg-config/0.29-4, but I don't see any obvious candidates for a fix in upstream git history since 0.29.

Steps to reproduce: with this pkg-config data:

----8<----
$ cat /usr/lib/x86_64-linux-gnu/pkgconfig/dbus-1.pc
prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=/usr/lib/x86_64-linux-gnu
includedir=${prefix}/include
system_bus_default_address=unix:path=/var/run/dbus/system_bus_socket
datarootdir=${prefix}/share
datadir=${datarootdir}
sysconfdir=/etc
session_bus_services_dir=${datadir}/dbus-1/services
system_bus_services_dir=${datadir}/dbus-1/system-services
interfaces_dir=${datadir}/dbus-1/interfaces
daemondir=$bindir

Name: dbus
Description: Free desktop message bus
Version: 1.11.10
Libs: -L${libdir} -ldbus-1
Libs.private: -lpthread    -lsystemd  
Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include 
----8<----

I get this output, as expected: I have to link users of libdbus to -lpthread and -lsystemd but only if I am linking statically:

----8<----
$ pkg-config --static --libs dbus-1 
-ldbus-1 -lpthread -lsystemd
$ pkg-config --libs dbus-1 
-ldbus-1
----8<----

Enabling debug messages, I see an unexpected debug message in the non-static case only:

----8<----
$ PKG_CONFIG_DEBUG_SPEW=1 pkg-config --static --libs dbus-1 2>&1 | grep Unknown
$ PKG_CONFIG_DEBUG_SPEW=1 pkg-config --libs dbus-1 2>&1 | grep Unknown         
Unknown keyword 'Libs.private' in '/usr/lib/x86_64-linux-gnu/pkgconfig/dbus-1.pc'
----8<----

Expected result:

Libs.private is never reported to be an unknown keyword, because it has a valid meaning, even if we are currently in a mode where it is (correctly!) ignored

Actual result:

See output above
Comment 3 Dan Nicholson 2017-04-07 14:13:55 UTC
Ah, that is a silly bug in the conditional that makes it fall through to the unknown keyword warning. Requires.private handles it correctly, but Libs.private doesn't - https://cgit.freedesktop.org/pkg-config/tree/parse.c#n953. Patch coming.
Comment 4 Dan Nicholson 2017-04-07 14:23:48 UTC
The following fix has been pushed:
2dd2b19 parse: Don't emit unknown keyword warning for Libs.private
Comment 5 Dan Nicholson 2017-04-07 14:23:49 UTC
Created attachment 130747 [details] [review]
parse: Don't emit unknown keyword warning for Libs.private

Requires.private and Libs.private are skipped unless --static is in use.
However, the parser was checking for Libs.private and this option in a
single conditional unlike Requires.private. This was making the check
fall through to the else and emit an "Unknown keyword" debug message
when --static was not used. This was harmless but not true.

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.