pkg-config doesn't deterministically list paths with --libs and --cflags. We want an ordered listing. Consider the following: $ PKG_CONFIG_PATH=/opt/TWWfsw/libpango18/lib/pkgconfig:\ /opt/TWWfsw/libglib26/lib/pkgconfig:\ /opt/TWWfsw/fcpackage22/lib/pkgconfig:\ /opt/TWWfsw/libttf21/lib/pkgconfig:/opt/TWWfsw/gettext014/lib/pkgconfig /opt/TWWfsw/pkgconfig/bin/pkg-config --cflags pangoxft -I/opt/TWWfsw/libpango18/include -I/opt/TWWfsw/libglib26/include -I/opt/TWWfsw/libglib26/lib/include -I/opt/TWWfsw/fcpackage22/include -I/opt/TWWfsw/libttf21/include/freetype2 -I/opt/TWWfsw/gettext014/include $ PKG_CONFIG_PATH=/opt/TWWfsw/libpango18/lib/pkgconfig:\ /opt/TWWfsw/libglib26/lib/pkgconfig:\ /opt/TWWfsw/fcpackage22/lib/pkgconfig:\ /opt/TWWfsw/libttf21/lib/pkgconfig:/opt/TWWfsw/gettext014/lib/pkgconfig /opt/TWWfsw/pkgconfig/bin/pkg-config --cflags pangox -I/opt/TWWfsw/libpango18/include -I/usr/X11R6/include -I/opt/TWWfsw/libglib26/include -I/opt/TWWfsw/libglib26/lib/include -I/opt/TWWfsw/gettext014/include $ PKG_CONFIG_PATH=/opt/TWWfsw/libpango18/lib/pkgconfig:\ /opt/TWWfsw/libglib26/lib/pkgconfig:\ /opt/TWWfsw/fcpackage22/lib/pkgconfig:\ /opt/TWWfsw/libttf21/lib/pkgconfig:/opt/TWWfsw/gettext014/lib/pkgconfig /opt/TWWfsw/pkgconfig/bin/pkg-config --cflags pangoxft pangox -I/opt/TWWfsw/libpango18/include -I/usr/X11R6/include -I/opt/TWWfsw/libglib26/include -I/opt/TWWfsw/libglib26/lib/include -I/opt/TWWfsw/fcpackage22/include -I/opt/TWWfsw/libttf21/include/freetype2 -I/opt/TWWfsw/gettext014/include Why isn't the output of the last command the --cflags of pangoxft followed by the --cflags of pangox with duplicates in pangox removed?
Created attachment 9598 [details] Patch to make pkg.c sort output in order packages were given The attached patch fixes the issue for us.
Created attachment 9614 [details] [review] new pkg.c patch that does not include unnecessary chunk
Created attachment 10814 [details] [review] a working patch It helps if the patch actually works :)
pangox specifies that the -I for X11R6 comes before the -I for libglib26 but pangoxft does not specify -I for X11R6 at all. Your proposed bahavior for "pkgconfig pangoxft pangox" sounds like -I for libglib26 would come first (since they are triggered by pangoxft, which is listed first), and then X11R6 would come later (since it's triggered by pangox, which is listed later, and is not a dup of an earlier flag). Is swapping flag ordering a good idea?
(In reply to comment #4) > pangox specifies that the -I for X11R6 comes before the -I for libglib26 but > pangoxft does not specify -I for X11R6 at all. Your proposed bahavior for > "pkgconfig pangoxft pangox" sounds like -I for libglib26 would come first > (since they are triggered by pangoxft, which is listed first), and then X11R6 > would come later (since it's triggered by pangox, which is listed later, and is > not a dup of an earlier flag). Is swapping flag ordering a good idea? The -I/usr/X11R6/include part of the issue here, it means that include files in that directory are being included in preference to the ones that are referenced by , for example, the fcpackage22 package. With the attached patch, the output is (we updated some packages): -I/opt/TWWfsw/libpango18/include -I/opt/TWWfsw/libglib26/include -I/opt/TWWfsw/libglib26/lib/include -I/opt/TWWfsw/fcpackage22/include -I/opt/TWWfsw/libttf23/include/freetype2 -I/opt/TWWfsw/libttf23/include -I/opt/TWWfsw/gettext014/include -I/usr/X11R6/include So, now the compiler will see the same files as it would if you had done: CFLAGS = `pkg-config --cflags pangoxft` CFLAGS += `pkg-config --cflags pangox` Which is what we want.
I just discussed this with Peter, and we are unable to agree on what the "correct" order of flags should be when multiple packages are specified to a single pkgconfig command. Here's our chatlog: <dmacks> pogma: /me if pangox wants X11R6 headers in preference to libglib26's, why should requesting flags for "pangoxft and pangox" discard that preference? <pogma> dmacks: if you want to do that change the order that you request them <dmacks> ? <dmacks> I don't think requester should have to know the preferences/precedences/etc of what he's requesting. <pogma> if you do pkg-config --cflags pangox pangoxft and pkg-config pangoxft pangox, you will get a different inclde order <dmacks> Do either of those results violate the ordering within either one's results? <dmacks> What the hell is the utility program that takes a list of ordered pairs and makes a single list that preserves all orderings? <pogma> dmacks: We simply want the same files to be found had you invoked pkg-config multiple times, once per package. pkg-config currently does some non-deterministic thing <dmacks> Well it's gotta be deterministic'ed by *something*. How does it choose? <dmacks> (seems like "pc foo bar" is requesting a coherent set of flags for the two of them, not simply stringing one after the other. <dmacks> Ahah! "tsort" <pogma> dmacks: So it is an argument about whether tsort is the better method for -I flags <dmacks> pogma: I think so. I don't actually have a clue what the existing logic is, but given the choice between "foo bar" listing all of foo followed by all of bar (with dups removed) vs tsorting, I'd say tsort.
Seems pointless to leave this open
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.